Need help understanding info in a header file

This is a discussion on Need help understanding info in a header file within the C Programming forums, part of the General Programming Boards category; i am trying to figure out what is the IFilePtr? (int, pointer, char?) Code: /* filesys - header information file ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    6

    Question Need help understanding info in a header file

    i am trying to figure out what is the IFilePtr? (int, pointer, char?)
    Code:
    /* filesys - header information file system interface */
    /*  $Id: filesys.h,v 1.97.4.4.2.3 2003/02/04 16:51:47 mark Exp $  */
    
    #ifndef	ACU_FSI_FILESYS_H
    #define	ACU_FSI_FILESYS_H
    
    /*
    ** LargeFileOff_t should be "long" or "off64_t" for UNIX systems, and
    ** "__int64" for Windows.
    */
    #ifndef LargeFileOff_t
    #ifdef  WIN32
    /* Win32 API */
    #define LargeFileOff_t  __int64
    #else   /* WIN32 */
    /* UNIX API */
    #ifdef	HAVE_LARGE_FILE_API
    #define LargeFileOff_t  off64_t
    #else	/* HAVE_LARGE_FILE_API */
    #define LargeFileOff_t  long
    #endif	/* HAVE_LARGE_FILE_API */
    #endif  /* WIN32 */
    #endif  /* LargeFileOff_t */
    
    /* Define PROTOTYPE if your compiler understands ANSI-style prototypes */
    #ifndef	P_
    #ifdef  PROTOTYPE
    #define P_(x)   x
    #else   /* PROTOTYPE */
    #define P_(x)   ()
    #endif  /* PROTOTYPE */
    #endif	/* P_ */
    
    /* Allow "region locks" (ie, record locks that are applied to the	*/
    /* entire record) by setting WANT_REGION_LOCKS to "1".  Region locks	*/
    /* improve performance in cases where very many locks are applied in a	*/
    /* file at once (because adjacent record locks will collapse into a	*/
    /* single lock region in the Unix lock manager).  */
    
    #define	WANT_REGION_LOCKS	0
    
    #if	WANT_REGION_LOCKS
    #ifdef	O_UNIX
    #ifndef	ENFORCED_LOCKS
    #define	REGION_LOCKS_OK
    #endif	/* ENFORCED_LOCKS */
    #endif	/* O_UNIX */
    #endif	/* WANT_REGION_LOCKS */
    
    typedef	struct _i_abilities {
    	unsigned	has_previous : 1;
    	unsigned	alternate_collate : 1;
    } I_ABILITIES;
    
    #ifdef	__cplusplus
    extern "C" {
    #endif	/* __cplusplus */
    
    #ifdef	INTERNAL_USE
    
    typedef	struct _i_file		*IFilePtr;
    typedef	struct _r_file		*RFilePtr;
    typedef	struct _s_file		*SFilePtr;
    
    #ifndef	ACU_GENERIC_PROC_DEFINED
    /* generic proc for registering functions */
    typedef int             (*GenericProc)();
    #define	ACU_GENERIC_PROC_DEFINED
    #endif	/* ACU_GENERIC_PROC_DEFINED */
    
    typedef	int		(*FSIInitProc) P_((int, int *));
    typedef	void		(*FSIExitProc) P_((void));
    typedef	int		(*FSIMakeProc) P_((char *, char *, char *, char *, char *, char *));
    typedef	IFilePtr	(*FSIOpenProc) P_((char *, int, char *));
    typedef	int		(*FSICloseProc) P_((IFilePtr));
    typedef	unsigned	(*FSIReadProc) P_((IFilePtr, char *, int));
    typedef	unsigned	(*FSINextProc) P_((IFilePtr, char *));
    typedef	unsigned	(*FSIPreviousProc) P_((IFilePtr, char *));
    typedef	int		(*FSIStartProc) P_((IFilePtr, char *, int, int, int));
    typedef	int		(*FSIWriteProc) P_((IFilePtr, char *, unsigned));
    typedef	int		(*FSIRewriteProc) P_((IFilePtr, char *, unsigned));
    typedef	int		(*FSIDeleteProc) P_((IFilePtr, char *));
    typedef	int		(*FSIUnlockProc) P_((IFilePtr));
    typedef	int		(*FSIInfoProc) P_((IFilePtr, int, char *));
    typedef	void		(*FSISyncProc) P_((int));
    typedef	int		(*FSIRemoveProc) P_((char *));
    typedef	int		(*FSIRenameProc) P_((char *, char *));
    typedef	int		(*FSIVersionProc) P_((char *, char *, char *, int, long *));
    typedef	void		(*FSIAbilitiesProc) P_((I_ABILITIES *));
    typedef	int		(*FSIExecuteProc) P_((char *, char *));
    typedef	int		(*FSICopyProc) P_((char *, char *));
    typedef	int		(*FSIBeginProc) P_((void));
    typedef	int		(*FSICommitProc) P_((int));
    typedef	int		(*FSIRollbackProc) P_((int));
    typedef	int		(*FSIRecoverProc) P_((void));
    typedef	GenericProc	(*FSIRegisterProc) P_((char *, GenericProc));
    typedef	void		(*FSIInitConfigProc) P_((void));
    
    typedef	int		(*FSI_RInitProc) P_((void));
    typedef	void		(*FSI_RExitProc) P_((void));
    typedef	int		(*FSI_RMakeProc) P_((char *, char *, long));
    typedef	RFilePtr	(*FSI_ROpenProc) P_((char *, int, unsigned,
    					     unsigned, long));
    typedef	int		(*FSI_RUnlockProc) P_((RFilePtr));
    typedef	int		(*FSI_RCloseProc) P_((RFilePtr));
    typedef	unsigned	(*FSI_RReadProc) P_((RFilePtr, char *, long));
    typedef	unsigned	(*FSI_RNextProc) P_((RFilePtr, char *));
    typedef	unsigned	(*FSI_RPreviousProc) P_((RFilePtr, char *));
    typedef	int		(*FSI_RStartProc) P_((RFilePtr, long, int));
    typedef	int		(*FSI_RWriteProc) P_((RFilePtr, char *, unsigned,
    					      long));
    typedef	int		(*FSI_RDeleteProc) P_((RFilePtr, long));
    typedef	int		(*FSI_RRewriteProc) P_((RFilePtr, char *, unsigned,
    						long));
    typedef	int		(*FSI_RRemoveProc) P_((char *));
    typedef	int		(*FSI_RRenameProc) P_((char *, char *));
    typedef	int		(*FSI_RCopyProc) P_((char *, char *));
    typedef	int		(*FSI_RInfoProc) P_((RFilePtr, int, char *));
    
    typedef	int		(*FSI_SMakeProc) P_((char *, char *));
    typedef	SFilePtr	(*FSI_SOpenProc) P_((char *, int, unsigned, int,
    					     unsigned, int, char *, int));
    typedef	int		(*FSI_SCloseProc) P_((SFilePtr, int));
    typedef	int		(*FSI_SReadProc) P_((SFilePtr, char *));
    typedef	int		(*FSI_SWriteProc) P_((SFilePtr, char *, unsigned, int));
    typedef	int		(*FSI_SRewriteProc) P_((SFilePtr, char *, unsigned));
    typedef	int		(*FSI_SRemoveProc) P_((char *));
    typedef	int		(*FSI_SRenameProc) P_((char *, char *));
    typedef	int		(*FSI_SCopyProc) P_((char *, char *));
    typedef	LargeFileOff_t	(*FSI_SSeekProc) P_((SFilePtr, LargeFileOff_t, int));
    typedef	int		(*FSI_SInfoProc) P_((SFilePtr, int, char *));
    
    typedef	struct _i_dispatch {
    	/*  Indexed file functions  */
    	FSIInitProc		p_init;
    	FSIExitProc		p_exit;
    	FSIMakeProc		p_make;
    	FSIOpenProc		p_open;
    	FSICloseProc		p_close;
    	FSIReadProc		p_read;
    	FSINextProc		p_next;
    	FSIPreviousProc		p_previous;
    	FSIStartProc		p_start;
    	FSIWriteProc		p_write;
    	FSIRewriteProc		p_rewrite;
    	FSIDeleteProc		p_delete;
    	FSIUnlockProc		p_unlock;
    	FSIInfoProc		p_info;
    	FSISyncProc		p_sync;
    	FSIRemoveProc		p_remove;
    	FSIRenameProc		p_rename;
    	FSIVersionProc		p_version;
    	FSIAbilitiesProc	p_abilities;
    	FSIExecuteProc		p_execute;
    	FSICopyProc		p_copy;
    	FSIBeginProc		p_begin;
    	FSICommitProc		p_commit;
    	FSIRollbackProc		p_rollback;
    	FSIRecoverProc		p_recover;
    
    	/*  Setup functions  */
    	FSIRegisterProc		p_register;
    	FSIInitConfigProc	p_init_cfg;
    
    	/*  Relative file functions  */
    	FSI_RInitProc		pr_init;
    	FSI_RExitProc		pr_exit;
    	FSI_RMakeProc		pr_make;
    	FSI_ROpenProc		pr_open;
    	FSI_RUnlockProc		pr_unlock;
    	FSI_RCloseProc		pr_close;
    	FSI_RReadProc		pr_read;
    	FSI_RNextProc		pr_next;
    	FSI_RPreviousProc	pr_previous;
    	FSI_RStartProc		pr_start;
    	FSI_RWriteProc		pr_write;
    	FSI_RDeleteProc		pr_delete;
    	FSI_RRewriteProc	pr_rewrite;
    	FSI_RRemoveProc		pr_remove;
    	FSI_RRenameProc		pr_rename;
    	FSI_RCopyProc		pr_copy;
    	FSI_RInfoProc		pr_info;
    
    	/*  Sequential file functions  */
    	FSI_SMakeProc		ps_make;
    	FSI_SOpenProc		ps_open;
    	FSI_SCloseProc		ps_close;
    	FSI_SReadProc		ps_read;
    	FSI_SWriteProc		ps_write;
    	FSI_SRewriteProc	ps_rewrite;
    	FSI_SRemoveProc		ps_remove;
    	FSI_SRenameProc		ps_rename;
    	FSI_SCopyProc		ps_copy;
    	FSI_SSeekProc		ps_seek;
    	FSI_SInfoProc		ps_info;
    } I_DISPATCH;
    
    typedef	int		(*FSI_IGetDispatchTableProc) P_((I_DISPATCH **));
    
    
    #else	/* INTERNAL_USE */
    
    struct _AcuFile_ {
    	long	notused;
    };
    
    typedef	struct _AcuFile_	*IFilePtr;
    typedef	struct _AcuFile_	*RFilePtr;
    typedef	struct _AcuFile_	*SFilePtr;
    
    #endif	/* INTERNAL_USE */

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Trimming some of the middle,
    Code:
    #ifdef	INTERNAL_USE
    typedef	struct _i_file		*IFilePtr;
    #else
    typedef	struct _AcuFile_	*IFilePtr;
    #endif
    So it's a pointer to a structure of one type or another.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    6

    then pray tell what is _i_file or _acufile_

    what are those? struct of what?

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Why are you trying to look up the skirt of your implementation?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    6

    I want to access the DLL outside of C/C++

    but i havent been able to determine what it is that i am trying to retreive from the actuall DLL involved.

    a function v5_open() returns an IFilePtr but i cant get it to work.

  6. #6
    Registered User
    Join Date
    Dec 2005
    Posts
    15
    Looks like some sort of COM-like wrapper on top of file IO to me.

    They may never define that structure (though you can try recursively greping for '_i_file' in the include tree). It's defined in this header as an anonymous structure.

    Part of the joy of making complicated DLL or SO files like this is that you can hide the details of whatever an '_i_file' is from the end user, so the DLL or SO file can be replaced without breaking the things that attempt to use it. Its contents probably aren't in your debug symbols, either.

    As long as only 'I_DISPATCH' struct, and 'FSI_IGetDispatchTableProc' remain the same, the library can be upgraded without breaking your application. If you start using hidden members from that data, your own app is almost guaranteed to stop working as soon as somebody upgrades that library.

  7. #7
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    a function v5_open() returns an IFilePtr but i cant get it to work.
    Can you show us exactly how you're trying to use it? How are you declaring your IFilePtr variable? And what's your statement look like where you make the call to v5_open()? And how exactly can't you get it to work? Is it giving a compile error or run-time error? What's the error say?
    If you understand what you're doing, you're not learning anything.

  8. #8
    Registered User
    Join Date
    Dec 2005
    Posts
    6

    what i am trying to do is implement the dll

    within a delphi program. with the help of the vendor. they sent me the .h, .lib, & .dll files as well as the .c sample file. after we talked for a little while they decided that v5_open returns a pointer IFilePtr. so supposedly i can assign v5_open to a IFilePtr.

    delphi implementation:
    function v5_open(pChar, int, pChar): IFilePtr; cdecl, external 'adll.dll';

    the problem is that it is always nil(null) when i try to load an IFilePtr.

  9. #9
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    I don't know the context of what you're doing, however if the call to v5_open() is returning nil (or NULL), there's probably something wrong with your call to v5_open() (the open is failing for some reason). You might want to try perror(), or at least looking at errno, since I'm guessing that v5_open() will set this on failure to indicate why it failed.

    You should not have to know anything about IFilePtr other than it's what's returned by v5_open() and expected by various other library functions (v5_write(), v5_read(), v5_close()?)
    Insert obnoxious but pithy remark here

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 04:25 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 05:14 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. Header File Understanding Help
    By hern in forum C Programming
    Replies: 1
    Last Post: 04-16-2004, 10:58 AM

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