Extract/retrieve method seems to work for text records.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dir.c,v $
- * Revision 1.6 1995-09-08 14:52:26 adam
+ * Revision 1.7 1995-09-28 09:19:40 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.6 1995/09/08 14:52:26 adam
* Minor changes. Dictionary is lower case now.
*
* Revision 1.5 1995/09/06 16:11:16 adam
exit (1);
return NULL;
}
- if (!(entry = malloc (sizeof(*entry) * entry_max)))
- {
- logf (LOG_FATAL|LOG_ERRNO, "malloc");
- exit (1);
- }
+ entry = xmalloc (sizeof(*entry) * entry_max);
while ((dent = readdir (dir)))
{
if (strcmp (dent->d_name, ".") == 0 ||
{
struct dir_entry *entry_n;
- if (!(entry_n = malloc (sizeof(*entry) * (entry_max + 400))))
- {
- logf (LOG_FATAL|LOG_ERRNO, "malloc");
- exit (1);
- }
+ entry_n = xmalloc (sizeof(*entry) * (entry_max + 400));
memcpy (entry_n, entry, idx * sizeof(*entry));
- free (entry);
+ xfree (entry);
entry = entry_n;
entry_max += 100;
}
- if (!(entry[idx].name = malloc (strlen(dent->d_name)+1)))
- {
- logf (LOG_FATAL|LOG_ERRNO, "malloc");
- exit (1);
- }
+ entry[idx].name = xmalloc (strlen(dent->d_name)+1);
strcpy (entry[idx].name, dent->d_name);
idx++;
}
assert (e);
while (e[i].name)
- free (e[i++].name);
- free (e);
+ xfree (e[i++].name);
+ xfree (e);
*e_p = NULL;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.9 1995-09-27 12:22:28 adam
+ * Revision 1.10 1995-09-28 09:19:41 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.9 1995/09/27 12:22:28 adam
* More work on extract in record control.
* Field name is not in isam keys but in prefix in dictionary words.
*
sprintf (ext_res, "fileExtension.%s", ext);
if (!(file_type = res_get (common_resource, ext_res)))
return;
-
+ if (!(rt = recType_byName (file_type)))
+ return;
file_info = dict_lookup (file_idx, kname);
if (!file_info)
{
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);
}
else
logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
return;
}
- if (!(rt = recType_byName (file_type)))
- return;
extractCtrl.inf = inf;
extractCtrl.subType = "";
extractCtrl.init = wordInit;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: kcompare.c,v $
- * Revision 1.7 1995-09-27 12:22:28 adam
+ * Revision 1.8 1995-09-28 09:19:42 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.7 1995/09/27 12:22:28 adam
* More work on extract in record control.
* Field name is not in isam keys but in prefix in dictionary words.
*
int key_compare (const void *p1, const void *p2)
{
- struct it_key i1, i2;
- memcpy (&i1, p1, sizeof(i1));
- memcpy (&i2, p2, sizeof(i2));
- if (i1.sysno != i2.sysno)
+ const struct it_key *i1 = p1, *i2 = p2;
+ if (i1->sysno != i2->sysno)
{
- if (i1.sysno > i2.sysno)
+ if (i1->sysno > i2->sysno)
return 2;
else
return -2;
}
#if IT_KEY_HAVE_SEQNO
- if (i1.seqno != i2.seqno)
+ if (i1->seqno != i2->seqno)
{
- if (i1.seqno > i2.seqno)
+ if (i1->seqno > i2->seqno)
return 1;
else
return -1;
}
#else
- if (i1.freq != i2.freq)
+ if (i1->freq != i2->freq)
{
- if (i1.freq > i2.freq)
+ if (i1->freq > i2->freq)
return 1;
else
return -1;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: symtab.c,v $
- * Revision 1.1 1995-09-06 16:11:18 adam
+ * Revision 1.2 1995-09-28 09:19:44 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.1 1995/09/06 16:11:18 adam
* Option: only one word key per file.
*
*/
{
e1 = e->next;
(*func)(e->name, e->info, data);
- free (e->name);
- free (e);
+ xfree (e->name);
+ xfree (e);
}
- free (t);
+ xfree (t);
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: trav.c,v $
- * Revision 1.3 1995-09-06 16:11:18 adam
+ * Revision 1.4 1995-09-28 09:19:46 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.3 1995/09/06 16:11:18 adam
* Option: only one word key per file.
*
* Revision 1.2 1995/09/04 12:33:43 adam
logf (LOG_FATAL|LOG_ERRNO, "Cannot open %s", src);
exit (1);
}
- if (!(buf = malloc (4096)))
- {
- logf (LOG_FATAL|LOG_ERRNO, "malloc");
- exit (1);
- }
+ buf = xmalloc (4096);
while ((r=read (s_fd, buf, 4096))>0)
for (w = 0; w < r; w += i)
{
logf (LOG_FATAL|LOG_ERRNO, "read");
exit (1);
}
- free (buf);
+ xfree (buf);
close (d_fd);
close (s_fd);
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.7 1995-09-27 16:17:32 adam
+ * Revision 1.8 1995-09-28 09:19:47 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.7 1995/09/27 16:17:32 adam
* More work on retrieve.
*
* Revision 1.6 1995/09/08 08:53:22 adam
#include <unistd.h>
#include <fcntl.h>
-#include "zserver.h"
-
+#include <recctrl.h>
#include <backend.h>
#include <dmalloc.h>
+#include "zserver.h"
ZServerInfo server_info;
return &r;
}
+static int record_read (int fd, char *buf, size_t count)
+{
+ return read (fd, buf, count);
+}
+
+static int record_fetch (ZServerInfo *zi, int sysno, ODR stream,
+ oid_value input_format, oid_value *output_format,
+ char **rec_bufp, int *rec_lenp)
+{
+ char record_info[SYS_IDX_ENTRY_LEN];
+ char *fname, *file_type;
+ RecType rt;
+ struct recRetrieveCtrl retrieveCtrl;
+
+ if (lseek (zi->sys_idx_fd, sysno * SYS_IDX_ENTRY_LEN,
+ SEEK_SET) == -1)
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "Retrieve: lseek of sys_idx");
+ exit (1);
+ }
+ if (read (zi->sys_idx_fd, record_info, SYS_IDX_ENTRY_LEN) == -1)
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "Retrieve: read of sys_idx");
+ exit (1);
+ }
+ file_type = record_info;
+ fname = record_info + strlen(record_info) + 1;
+ if (!(rt = recType_byName (file_type)))
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "Retrieve: Cannot handle type %s",
+ file_type);
+ exit (1);
+ }
+ if ((retrieveCtrl.fd = open (fname, O_RDONLY)) == -1)
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "Retrieve: Open record file %s", fname);
+ exit (1);
+ }
+ retrieveCtrl.odr = stream;
+ retrieveCtrl.readf = record_read;
+ retrieveCtrl.input_format = input_format;
+ (*rt->retrieve)(&retrieveCtrl);
+ *output_format = retrieveCtrl.output_format;
+ *rec_bufp = retrieveCtrl.rec_buf;
+ *rec_lenp = retrieveCtrl.rec_len;
+ close (retrieveCtrl.fd);
+ return 0;
+}
+
bend_fetchresult *bend_fetch (void *handle, bend_fetchrequest *q, int *num)
{
static bend_fetchresult r;
logf (LOG_DEBUG, "Out of range. pos=%d", q->number);
return &r;
}
-#if 0
- r.len = records[0].size;
- server_info.recordBuf = r.record = xmalloc (r.len+1);
- strcpy (r.record, records[0].buf);
- resultSetRecordDel (&server_info, records, 1);
- r.format = VAL_SUTRS;
- r.errcode = 0;
-#endif
+ r.errcode = record_fetch (&server_info, records[0].sysno, q->stream,
+ q->format, &r.format, &r.record, &r.len);
return &r;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.h,v $
- * Revision 1.5 1995-09-27 16:17:32 adam
+ * Revision 1.6 1995-09-28 09:19:48 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.5 1995/09/27 16:17:32 adam
* More work on retrieve.
*
* Revision 1.4 1995/09/14 11:53:28 adam
ZServerSet *resultSetAdd (ZServerInfo *zi, const char *name,
int ov, RSET rset);
ZServerSet *resultSetGet (ZServerInfo *zi, const char *name);
-ZServerRecord *resultSetRecordGet (ZServerInfo *zi, const char *name,
- int num, int *positions);
+ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name,
+ int num, int *positions);
void resultSetRecordDel (ZServerInfo *zi, ZServerRecord *records, int num);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zsets.c,v $
- * Revision 1.5 1995-09-27 16:17:32 adam
+ * Revision 1.6 1995-09-28 09:19:49 adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.5 1995/09/27 16:17:32 adam
* More work on retrieve.
*
* Revision 1.4 1995/09/07 13:58:36 adam
int i;
for (i = 0; i<num; i++)
- free (records[i].buf);
- free (records);
+ xfree (records[i].buf);
+ xfree (records);
}