Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm doing a research project on the random number theory, and I'm attempting to emulate srand. However, the file is encrypted. Does anyone have the source code, the writer of srand, or someone that may know the ins and outs of srand?
And if anyone tells me to look at the man page, I already have: no author is listed.
Last edited by Tux-O-Matic; 09-28-2006 at 03:59 PM.
Well, you'll always see garbage like that if you try to edit a binary file.
I wasn't aware of a commandline program named "srand" (it's a C library function) but the context of your description makes me think you found one. And then tried to edit it.
Thanks, but could someone please answer my original question please?
Unfortunately, I really can't tell what your original question was. I believe your inital assumption about an encrypted file is incorrect. I think you must be vi-ing some binary file and misinterpretting the non-ASCII characters as encryption. But I can't really tell that for sure, your description was not detailed enough. I'm just guessing. You need to give us more information.
If you're looking for the source code for the C library call srand(), I'd start off with something like the commands below to attempt to find it. I don't know if this will find the code for you, but at least it should give you some idea of where to look. You will need to have your kernel sources installed.
Code:
# cd /usr/include
# find . -type f -print | xargs fgrep srand
# cd /usr/src/linux
# find . -type f -name *.c -print | xargs fgrep srand
# find . -type f -name *.h -print | xargs fgrep srand
You can skip the -name parameter to find if you have just installed your kernel sources but not compiled. After a compile you'll have lots of object files in there and you certainly don't need to be grepping through those. Or, you can run a "make clean" to get rid of the object files before running the find.
I was trying to locate a sourcefile that contains the text "srand", not a file with srand in it's filename. Who knows what the actual sourcefile name is.
find -type f -name "*.[ch]" -exec grep srand {} \;
Gotcha! I typically use that "*.[ch]" type of specification myself, but didn't in my example, for some unexplained reason.
As far as -exec grep srand {} \;, my poor little brain recognizes | xargs grep srand much more readily. Habit and old age I guess! (Note: I still use -print with find too. Not really required these days, but it used to be. At least on older System V, SunOS, etc. Another archiac habit of mine.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.