X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fextract.c;h=9207ab76518cfe7c1f09d8cee96b5f249d3771c6;hb=83762ea76e5af65ccb4407c6b38053bc6491a875;hp=fffe509489e6e46157eae204c390178c82e43785;hpb=6617321a09d4d5bf442feaea2d7f1347acd82e3c;p=idzebra-moved-to-github.git diff --git a/index/extract.c b/index/extract.c index fffe509..9207ab7 100644 --- a/index/extract.c +++ b/index/extract.c @@ -4,7 +4,16 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: extract.c,v $ - * Revision 1.23 1995-10-27 14:00:10 adam + * Revision 1.26 1995-11-20 11:56:24 adam + * Work on new traversal. + * + * Revision 1.25 1995/11/16 15:34:54 adam + * Uses new record management system in both indexer and server. + * + * Revision 1.24 1995/11/15 19:13:08 adam + * Work on record management. + * + * Revision 1.23 1995/10/27 14:00:10 adam * Implemented detection of database availability. * * Revision 1.22 1995/10/17 18:02:07 adam @@ -88,9 +97,19 @@ #include #include "index.h" +#if RECORD_BASE +#include "recindex.h" +#endif + static Dict file_idx; -static SYSNO sysno_next; + + +#if RECORD_BASE +static Records records = NULL; +#else static int sys_idx_fd = -1; +static SYSNO sysno_next; +#endif static int key_cmd; static int key_sysno; @@ -103,8 +122,9 @@ static int key_file_no; void key_open (int mem) { +#if !RECORD_BASE void *file_key; - +#endif if (mem < 50000) mem = 50000; key_buf = xmalloc (mem); @@ -118,6 +138,10 @@ void key_open (int mem) logf (LOG_FATAL, "dict_open fail of %s", "fileidx"); exit (1); } +#if RECORD_BASE + assert (!records); + records = rec_open (1); +#else file_key = dict_lookup (file_idx, "."); if (file_key) memcpy (&sysno_next, (char*)file_key+1, sizeof(sysno_next)); @@ -128,6 +152,7 @@ void key_open (int mem) logf (LOG_FATAL|LOG_ERRNO, "open %s", FNAME_SYS_IDX); exit (1); } +#endif } struct encode_info { @@ -241,8 +266,12 @@ int key_close (void) { key_flush (); xfree (key_buf); +#if RECORD_BASE + rec_close (&records); +#else close (sys_idx_fd); dict_insert (file_idx, ".", sizeof(sysno_next), &sysno_next); +#endif dict_close (file_idx); return key_file_no; } @@ -366,8 +395,8 @@ static int file_read (int fd, char *buf, size_t count) return read (fd, buf, count); } #endif -void file_extract (int cmd, const char *fname, const char *kname, - char *databaseName) +SYSNO file_extract (int cmd, const char *fname, const char *kname, + char *databaseName) { int i, r; char ext[128]; @@ -392,18 +421,29 @@ void file_extract (int cmd, const char *fname, const char *kname, } sprintf (ext_res, "fileExtension.%s", ext); if (!(file_type = res_get (common_resource, ext_res))) - return; + return 0; if (!(rt = recType_byName (file_type))) - return; + return 0; logf (LOG_DEBUG, "%c %s k=%s", cmd, fname, kname); file_info = dict_lookup (file_idx, kname); if (!file_info) { +#if RECORD_BASE + Record rec = rec_new (records); + + sysno = rec->sysno; + dict_insert (file_idx, kname, sizeof(sysno), &sysno); + rec->info[0] = rec_strdup (file_type); + rec->info[1] = rec_strdup (kname); + rec_put (records, rec); + rec_rm (rec); +#else sysno = sysno_next++; dict_insert (file_idx, kname, sizeof(sysno), &sysno); lseek (sys_idx_fd, sysno * SYS_IDX_ENTRY_LEN, SEEK_SET); write (sys_idx_fd, file_type, strlen (file_type)+1); write (sys_idx_fd, kname, strlen(kname)+1); +#endif } else memcpy (&sysno, (char*) file_info+1, sizeof(sysno)); @@ -411,7 +451,7 @@ void file_extract (int cmd, const char *fname, const char *kname, if ((extractCtrl.fd = open (fname, O_RDONLY)) == -1) { logf (LOG_WARN|LOG_ERRNO, "open %s", fname); - return; + return 0; } extractCtrl.subType = ""; extractCtrl.init = wordInit; @@ -429,4 +469,5 @@ void file_extract (int cmd, const char *fname, const char *kname, close (extractCtrl.fd); if (r) logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r); + return sysno; }