How do they do it???

This is a discussion on How do they do it??? within the C Programming forums, part of the General Programming Boards category; This is the code from Turbo C 2.01's DIR.H file. Code: #if __STDC__ #define _Cdecl #else #define _Cdecl cdecl #endif ...

  1. #1
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218

    How do they do it???

    This is the code from Turbo C 2.01's DIR.H file.
    Code:
    #if __STDC__
    #define _Cdecl
    #else
    #define _Cdecl	cdecl
    #endif
    
    #if     !defined(__DIR_DEF_)
    #define __DIR_DEF_
    
    struct	ffblk	{
    	char		ff_reserved[21];
    	char		ff_attrib;
    	unsigned	ff_ftime;
    	unsigned	ff_fdate;
    	long		ff_fsize;
    	char		ff_name[13];
    };
    
    #define WILDCARDS 0x01
    #define EXTENSION 0x02
    #define FILENAME  0x04
    #define DIRECTORY 0x08
    #define DRIVE	  0x10
    
    #define MAXPATH   80
    #define MAXDRIVE  3
    #define MAXDIR	  66
    #define MAXFILE   9
    #define MAXEXT	  5
    
    int	 _Cdecl chdir		(const char *path);
    int	 _Cdecl findfirst	(const char *path, struct ffblk *ffblk, 
    				 int attrib);
    int	 _Cdecl findnext	(struct ffblk *ffblk);
    void	 _Cdecl fnmerge		(char *path,const char *drive,const char *dir,
    				 const char *name, const char *ext);
    int	 _Cdecl fnsplit		(const char *path, char *drive, char *dir, 
    				 char *name, char *ext);
    int	 _Cdecl getcurdir	(int drive, char *directory);
    char	*_Cdecl getcwd		(char *buf, int buflen);
    int	 _Cdecl getdisk		(void);
    int	 _Cdecl mkdir		(const char *path);
    char	*_Cdecl mktemp		(char *template);
    int	 _Cdecl rmdir		(const char *path);
    char	*_Cdecl searchpath	(const char *file);
    int	 _Cdecl setdisk		(int drive);
    
    #endif
    How do they make all of the functions work Is there some secret that I don't know about?

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    60

    my stab

    I have no idea how much you know about programming, but do

    you realise that this header file is used to create a table of calls

    for the operating system to use to access a dll file with all the

    definitions?

    (I sorry if I am completly off target...)
    "It compiled, let's ship it!"

    Guitar Australia
    my site for some easy tutorials.

  3. #3
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218

    OK...

    then where does it tell the OS to make those calls? All that I see are definitions of dirves, etc. and definitions of funtions.

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    60

    when does it make calls.

    Hey, you sound like you know more than me. But in answer to the

    question about the calls, the os uses the defs to map to the

    address space of the dll module. In the source code that

    accompanies this header, the function calls are made.


    If that's not what you meant, I'm sorry, but that's all I know about

    that area.
    "It compiled, let's ship it!"

    Guitar Australia
    my site for some easy tutorials.

  5. #5
    Registered User kinghajj's Avatar
    Join Date
    Jun 2003
    Posts
    218

    DLLs?

    DLLs are in Windows, not DOS.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789

    Re: DLLs?

    Originally posted by kinghajj
    DLLs are in Windows, not DOS.
    The definitions in the header will be altered slightly (how so depends on if it's C or C++ and also the compiler) then they will map to a library file (usually with a .lib extension). It's the library that will probably house the code needed to perform these tasks

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21