inc/fof.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 2000 Jim Kent.  This source code may be freely used         *
00003  * for personal, academic, and non-profit purposes.  Commercial use          *
00004  * permitted only by explicit agreement with Jim Kent (jim_kent@pacbell.net) *
00005  *****************************************************************************/
00006 /* fof.h - Manages a fof-type index file.  This index refers
00007  * to records in multiple external files. */
00008 
00009 struct fofPos
00010 /* This holds the result of a FOF search. */
00011     {
00012     FILE *f;              /* File. */
00013     bits32 offset;        /* Offset within file. */
00014     bits32 size;          /* Size within file. */
00015     int indexIx;          /* Position within index. */
00016     char *fileName;       /* File name. */
00017     };
00018 
00019 
00020 struct fof *fofOpen(char *fofName, char *fofDir);
00021 /* Open up the named fof. fofDir may be NULL.  It should include 
00022  * trailing '/' if non-null. */
00023 
00024 void fofClose(struct fof **pFof);
00025 /* Close down the named fof. */
00026 
00027 int fofElementCount(struct fof *fof);
00028 /* How many names are in fof file? */
00029 
00030 void fofMake(char *inFiles[], int inCount, char *outName, 
00031     boolean (*readHeader)(FILE *inFile, void *data),
00032     boolean (*nextRecord)(FILE *inFile, void *data, char **rName, int *rNameLen), 
00033     void *data, boolean dupeOk);
00034 /* Make an index file
00035  * Inputs:
00036  *     inFiles - List of files that you're indexing with header read and verified.
00037  *     inCount - Size of file list.
00038  *     outName - name of index file to create
00039  *     readHeader - function that sets up file to read first record.  May be NULL.
00040  *     nextRecord - function that reads next record in file you're indexing
00041  *                  and returns the name of that record.  Returns FALSE at
00042  *                  end of file.  Can set *rNameLen to zero you want indexer
00043  *                  to ignore the record. 
00044  *     data - void pointer passed through to nextRecord.
00045  *     dupeOk - set to TRUE if you want dupes to not cause squawking
00046  */
00047 
00048 boolean fofFindFirst(struct fof *fof, char *prefix, 
00049     int prefixSize, struct fofPos *retPos);
00050 /* Find first element with key starting with prefix. */
00051 
00052 boolean fofFind(struct fof *fof, char *name, struct fofPos *retPos);
00053 /* Find element corresponding with name.  Returns FALSE if no such name
00054  * in the index file. */
00055 
00056 void *fofFetch(struct fof *fof, char *name, int *retSize);
00057 /* Lookup element in index, allocate memory for it, and read
00058  * it.  Returns buffer with element in it, which should be
00059  * freeMem'd when done. Aborts if element isn't there. */
00060 
00061 char *fofFetchString(struct fof *fof, char *name, int *retSize);
00062 /* Lookup element in index, allocate memory for it, read it.
00063  * Returns zero terminated string with element in it, which 
00064  * should be freeMem'd when done. Aborts if element isn't there. */
00065 
00066 struct fofBatch
00067 /* A structure for doing batch FOF searches.  Client fills
00068  * in key and data members.  fofBatchSearch then fills in
00069  * file, offset, and size members.  The list on return is
00070  * sorted by file position for fast i/o. */
00071     {
00072     struct fofBatch *next;  /* Next in list. */
00073     char *key;              /* Lookup key - filled in by client. Not allocate here. */
00074     void *data;             /* Data associated with key - filled in by client. */
00075     FILE *f;                /* File - filled in by server. */
00076     bits32 offset;          /* Offset in file - filled in by server. */
00077     bits32 size;            /* Size in file - filled in by server. */
00078     };
00079  
00080 struct fofBatch *fofBatchFind(struct fof *fof, struct fofBatch *list);
00081 /* Look up all of members on list. */
00082 

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2