NCBI C Toolkit Cross Reference

C/corelib/ncbifile.h


  1 #ifndef _NCBIFILE_
  2 #define _NCBIFILE_
  3 
  4 /*   ncbifile.h
  5 * ===========================================================================
  6 *
  7 *                            PUBLIC DOMAIN NOTICE
  8 *               National Center for Biotechnology Information
  9 *
 10 *  This software/database is a "United States Government Work" under the
 11 *  terms of the United States Copyright Act.  It was written as part of
 12 *  the author's official duties as a United States Government employee and
 13 *  thus cannot be copyrighted.  This software/database is freely available
 14 *  to the public for use. The National Library of Medicine and the U.S.
 15 *  Government have not placed any restriction on its use or reproduction.
 16 *
 17 *  Although all reasonable efforts have been taken to ensure the accuracy
 18 *  and reliability of the software and data, the NLM and the U.S.
 19 *  Government do not and cannot warrant the performance or results that
 20 *  may be obtained by using this software or data. The NLM and the U.S.
 21 *  Government disclaim all warranties, express or implied, including
 22 *  warranties of performance, merchantability or fitness for any particular
 23 *  purpose.
 24 *
 25 *  Please cite the author in any work or product based on this material.
 26 *
 27 * ===========================================================================
 28 *
 29 * File Name:  ncbifile.h
 30 *
 31 * Author:  Gish, Kans, Ostell, Schuler
 32 *
 33 * Version Creation Date:   1/1/91
 34 *
 35 * $Revision: 6.7 $
 36 *
 37 * File Description:
 38 *       prototypes for portable file routines
 39 *
 40 * Modifications:
 41 * --------------------------------------------------------------------------
 42 * $Log: ncbifile.h,v $
 43 * Revision 6.7  2007/08/16 17:09:22  kans
 44 * moved DirExplore from sqnutils
 45 *
 46 * Revision 6.6  2004/05/07 15:57:14  kans
 47 * added FileCache functions for buffered read, graceful handing of Unix, Mac, and DOS line endings
 48 *
 49 * Revision 6.5  2001/04/05 21:36:05  juran
 50 * EjectCd and MountCd #defined to FALSE.
 51 *
 52 * Revision 6.4  2000/03/08 17:55:48  vakatov
 53 * Use Int8 for the file size.
 54 * Also, get rid of the WIN16 code, do other cleanup.
 55 *
 56 * Revision 6.3  1998/06/26 20:39:43  vakatov
 57 * Added FilePathFind() -- complimentary to FileNameFind()
 58 *
 59 * Revision 6.2  1998/06/25 19:39:18  vakatov
 60 * Added "FileLengthEx()" -- it returns -1(not 0!) if the file does not exist
 61 *
 62 * Revision 6.1  1998/05/24 19:20:58  kans
 63 * added Nlm_DirCatalog (Mac implementation only so far)
 64 *
 65 * Revision 5.1  1996/12/03 21:48:33  vakatov
 66 * Adopted for 32-bit MS-Windows DLLs
 67 *
 68 * 04-15-93 Schuler     Changed _cdecl to LIBCALL
 69 * ==========================================================================
 70 */
 71 
 72 #undef NLM_EXTERN
 73 #ifdef NLM_IMPORT
 74 #define NLM_EXTERN NLM_IMPORT
 75 #else
 76 #define NLM_EXTERN extern
 77 #endif
 78 
 79 #ifdef __cplusplus
 80 extern "C" {
 81 #endif
 82 
 83 
 84 typedef FILE* (LIBCALLBACK *Nlm_FileOpenHook)
 85        (const char *filename, const char *mode);
 86 
 87 NLM_EXTERN FILE* LIBCALL Nlm_FileOpen(const char *filename, const char *mode);
 88 NLM_EXTERN void LIBCALL Nlm_FileClose(FILE *stream);
 89 NLM_EXTERN size_t LIBCALL Nlm_FileRead(void *ptr, size_t size, size_t n, FILE *stream);
 90 NLM_EXTERN size_t LIBCALL Nlm_FileWrite(const void *ptr, size_t size, size_t n, FILE *stream);
 91 NLM_EXTERN int LIBCALL Nlm_FilePuts(const char *ptr, FILE * fp);
 92 NLM_EXTERN char * LIBCALL Nlm_FileGets(char *ptr, size_t size, FILE * fp);
 93 NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_FileBuildPath(Nlm_CharPtr root, Nlm_CharPtr sub_path, Nlm_CharPtr filename);
 94 NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_FileNameFind(Nlm_CharPtr pathname);
 95 NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_FilePathFind(const Nlm_Char* fullname);
 96 NLM_EXTERN Nlm_Int8 LIBCALL Nlm_FileLength(Nlm_CharPtr fileName);
 97 /* Nlm_FileLengthEx() returns -1 if the file does not exist) */
 98 NLM_EXTERN Nlm_Int8 LIBCALL Nlm_FileLengthEx(const Nlm_Char* fileName);
 99 NLM_EXTERN Nlm_Boolean LIBCALL Nlm_FileRemove(Nlm_CharPtr fileName);
100 NLM_EXTERN Nlm_Boolean LIBCALL Nlm_FileRename(Nlm_CharPtr oldFileName, Nlm_CharPtr newFileName);
101 NLM_EXTERN void LIBCALL Nlm_FileCreate(Nlm_CharPtr fileName, Nlm_CharPtr type, Nlm_CharPtr creator);
102 NLM_EXTERN Nlm_Boolean LIBCALL Nlm_CreateDir(Nlm_CharPtr pathname);
103 NLM_EXTERN ValNodePtr LIBCALL Nlm_DirCatalog (Nlm_CharPtr pathname);
104 NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_TmpNam(Nlm_CharPtr s);
105 NLM_EXTERN void LIBCALL Nlm_SetFileOpenHook(Nlm_FileOpenHook hook);
106 
107 /* FileCache provides buffered text read for handling Unix, Mac, and DOS line endings gracefully */
108 
109 typedef struct nlm_filecachedata {
110   FILE      *fp;
111   Nlm_Char  buf [516];
112   Nlm_Int2  ctr;
113   Nlm_Int2  total;
114   Nlm_Int4  offset;
115 } Nlm_FileCache, PNTR Nlm_FileCachePtr;
116 
117 NLM_EXTERN Nlm_Boolean Nlm_FileCacheSetup (Nlm_FileCache PNTR fcp, FILE *fp);
118 NLM_EXTERN Nlm_CharPtr Nlm_FileCacheGetString (Nlm_FileCache PNTR fcp, Nlm_CharPtr str, size_t size);
119 NLM_EXTERN Nlm_CharPtr Nlm_FileCacheReadLine (Nlm_FileCache PNTR fcp, Nlm_CharPtr str, size_t size, Nlm_BoolPtr nonewline);
120 NLM_EXTERN void Nlm_FileCacheSeek (Nlm_FileCache PNTR fcp, Nlm_Int4 pos);
121 NLM_EXTERN Nlm_Int4 Nlm_FileCacheTell (Nlm_FileCache PNTR fcp);
122 NLM_EXTERN Nlm_Boolean Nlm_FileCacheFree (Nlm_FileCache PNTR fcp, Nlm_Boolean restoreFilePos);
123 
124 /* general file recursion function - directory must not be empty, proc callback function must not be NULL */
125 
126 typedef void (*Nlm_DirExpProc) (Nlm_CharPtr filename, Nlm_VoidPtr userdata);
127 
128 NLM_EXTERN Nlm_Int4 Nlm_DirExplore (
129   Nlm_CharPtr directory,
130   Nlm_CharPtr filter,
131   Nlm_CharPtr suffix,
132   Nlm_Boolean recurse,
133   Nlm_DirExpProc proc,
134   Nlm_VoidPtr userdata
135 );
136 
137 #define FileOpen Nlm_FileOpen
138 #define FileClose Nlm_FileClose
139 #define FileRead Nlm_FileRead
140 #define FileWrite Nlm_FileWrite
141 #define FilePuts Nlm_FilePuts
142 #define FileGets Nlm_FileGets
143 #define FileBuildPath Nlm_FileBuildPath
144 #define FileNameFind Nlm_FileNameFind
145 #define FilePathFind Nlm_FilePathFind
146 #define FileLength Nlm_FileLength
147 #define FileLengthEx Nlm_FileLengthEx
148 #define FileRemove Nlm_FileRemove
149 #define FileRename Nlm_FileRename
150 #define FileCreate Nlm_FileCreate
151 #define CreateDir Nlm_CreateDir
152 #define DirCatalog Nlm_DirCatalog
153 #define TmpNam Nlm_TmpNam
154 
155 #define FileCache Nlm_FileCache
156 #define FileCacheSetup Nlm_FileCacheSetup
157 #define FileCachePtr Nlm_FileCachePtr
158 
159 #define FileCacheSetup Nlm_FileCacheSetup
160 #define FileCacheGetString Nlm_FileCacheGetString
161 #define FileCacheReadLine Nlm_FileCacheReadLine
162 #define FileCacheSeek Nlm_FileCacheSeek
163 #define FileCacheTell Nlm_FileCacheTell
164 #define FileCacheFree Nlm_FileCacheFree
165 
166 #define DirExpProc Nlm_DirExpProc
167 #define DirExplore Nlm_DirExplore
168 
169 #define EjectCd(sVolume, deviceName, rawDeviceName, mountPoint, mountCmd)  FALSE
170 #define MountCd(sVolume, deviceName, mountPoint, mountCmd)                 FALSE
171 
172 
173 #ifdef __cplusplus
174 } /* extern "C" */
175 #endif
176 
177 #undef NLM_EXTERN
178 #ifdef NLM_EXPORT
179 #define NLM_EXTERN NLM_EXPORT
180 #else
181 #define NLM_EXTERN
182 #endif
183 
184 #endif /* _NCBIFILE_ */
185 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.