LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2006, 07:11 AM   #1
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Rep: Reputation: 15
Question c functions source code


hi,
I want to see the source code of c library functions and system calls such as fopen,fclose, and read,write,readdir,closedir,etc functions. So i have downloaded the glibc-2.4. But i am not able to see complete implementation of those functions. many functions implementation is not there. Can any body guide me in this direction.


Regards,
Rajesh
 
Old 06-22-2006, 08:03 AM   #2
Flesym
Member
 
Registered: Aug 2005
Location: Germany
Distribution: Ubuntu, Debian
Posts: 189

Rep: Reputation: 31
If you already downloaded the source of glibc go to the directory where you extracted it to. From here you can simply search the desired source file. In example of 'fopen' run:
Code:
find . -name "*fopen.c"
The most obvious file of the output will be your source-file.
 
Old 06-22-2006, 11:16 PM   #3
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Original Poster
Rep: Reputation: 15
hi Flesym,
Thanks for the reply.
Actually i have downloaded that version. But i am unable to find some functions implementations. For example,( i want to see opendir function):
1. find . -name "opendir.c"
The output of the command is
./sysdeps/mach/hurd/opendir.c
./sysdeps/unix/opendir.c
./sysdeps/unix/sysv/linux/opendir.c
./dirent/opendir.c

2. Then i opened dirent/opendir.c
This file has this implementation
#include <errno.h>
#include <stddef.h>
#include <dirent.h>
/* Open a directory stream on NAME. */
DIR * __opendir (const char *name)
{
__set_errno (ENOSYS);
return NULL;
}
weak_alias (__opendir, opendir)
stub_warning (opendir)
#include <stub-tag.h>

Its not doing any thing.
Give me any Suggestion.

Regards
Rajesh
 
Old 06-23-2006, 03:33 AM   #4
Flesym
Member
 
Registered: Aug 2005
Location: Germany
Distribution: Ubuntu, Debian
Posts: 189

Rep: Reputation: 31
In this case chose the sysdeps-file "./sysdeps/unix/opendir.c" (it was also in your output).

EDIT:
Oh, and in your find-command, you should lead the filename with a '*' (like in my example), because some files have prefixes; for example the 'fopen' function is defined in 'iofopen.c'

Last edited by Flesym; 06-23-2006 at 03:44 AM.
 
Old 06-23-2006, 08:01 AM   #5
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Original Poster
Rep: Reputation: 15
Thumbs up

hi Flesym,
Thanks for your help. I finally got the code for that.


Regards,
Rajesh.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is the actual code for C functions? like printf, scanf, etc purpleburple Programming 5 06-23-2006 04:49 AM
LXer: Open source promises more business functions LXer Syndicated Linux News 0 06-11-2006 08:54 AM
How to convert Assembly code to "C" source code ssg14j Programming 2 08-01-2005 12:48 PM
how can I get the source code!? linuxfaint Red Hat 1 06-10-2004 11:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration