* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recctrl.h,v $
- * Revision 1.3 1995-09-27 12:21:25 adam
+ * Revision 1.4 1995-09-27 16:17:29 adam
+ * More work on retrieve.
+ *
+ * Revision 1.3 1995/09/27 12:21:25 adam
* New function: recType_byName.
*
* Revision 1.2 1995/09/15 14:45:03 adam
#include <oid.h>
#include <odr.h>
+/* single word entity */
typedef struct {
int attrSet;
int attrUse;
int seqno;
} RecWord;
+/* Extract record control */
struct recExtractCtrl {
- FILE *inf;
- char *subType;
- void (*init)(RecWord *p);
- void (*add)(const RecWord *p);
+ /* input parameters ... */
+ FILE *inf; /* Extract from this file */
+ char *subType; /* Sub type - may be NULL */
+ void (*init)(RecWord *p); /* Init of word spec */
+ void (*add)(const RecWord *p); /* Addition of a single word */
};
+/* Retrieve record control */
struct recRetrieveCtrl {
- ODR odr;
- int fd;
+ /* Input parameters ... */
+ ODR odr; /* ODR used to create response */
+ int fd; /* File descriptor and read function */
int (*readf)(int fd, char *buf, size_t count);
- oid_value input_format;
+ oid_value input_format; /* Preferred record syntax */
- /* response */
- oid_value output_format;
- void *rec_buf;
- size_t rec_len;
+ /* output parameters ... */
+ oid_value output_format; /* Record syntax of returned record */
+ void *rec_buf; /* Record buffer */
+ size_t rec_len; /* Length of record */
};
typedef struct recType
{
- char *name;
- void (*init)(void);
- int (*extract)(struct recExtractCtrl *ctrl);
- int (*retrieve)(struct recRetrieveCtrl *ctrl);
+ char *name; /* Name of record type */
+ void (*init)(void); /* Init function - called once */
+ int (*extract)(struct recExtractCtrl *ctrl); /* Extract proc */
+ int (*retrieve)(struct recRetrieveCtrl *ctrl); /* Retrieve proc */
} *RecType;
RecType recType_byName (const char *name);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.6 1995-09-08 08:53:22 adam
+ * Revision 1.7 1995-09-27 16:17:32 adam
+ * More work on retrieve.
+ *
+ * Revision 1.6 1995/09/08 08:53:22 adam
* Record buffer maintained in server_info.
*
* Revision 1.5 1995/09/06 16:11:18 adam
{
static bend_fetchresult r;
int positions[2];
- ZServerRecord *records;
+ ZServerSetSysno *records;
r.errstring = 0;
r.last_in_set = 0;
xfree (server_info.recordBuf);
server_info.recordBuf = NULL;
positions[0] = q->number;
- records = resultSetRecordGet (&server_info, q->setname, 1, positions);
+ records = resultSetSysnoGet (&server_info, q->setname, 1, positions);
if (!records)
{
logf (LOG_DEBUG, "resultSetRecordGet, error");
r.errcode = 13;
return &r;
}
- if (!records[0].buf)
+ if (!records[0].sysno)
{
r.errcode = 13;
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
return &r;
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.h,v $
- * Revision 1.4 1995-09-14 11:53:28 adam
+ * Revision 1.5 1995-09-27 16:17:32 adam
+ * More work on retrieve.
+ *
+ * Revision 1.4 1995/09/14 11:53:28 adam
* First work on regular expressions/truncations.
*
* Revision 1.3 1995/09/08 08:53:23 adam
char *buf;
} ZServerRecord;
+typedef struct {
+ int sysno;
+} ZServerSetSysno;
+
typedef struct ZServerSet_ {
char *name;
RSET rset;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zsets.c,v $
- * Revision 1.4 1995-09-07 13:58:36 adam
+ * Revision 1.5 1995-09-27 16:17:32 adam
+ * More work on retrieve.
+ *
+ * Revision 1.4 1995/09/07 13:58:36 adam
* New parameter: result-set file descriptor (RSFD) to support multiple
* positions within the same result-set.
* Boolean operators: and, or, not implemented.
return NULL;
}
-ZServerRecord *resultSetRecordGet (ZServerInfo *zi, const char *name,
- int num, int *positions)
+ZServerSetSysno *resultSetSysnoGet (ZServerInfo *zi, const char *name,
+ int num, int *positions)
+{
+ ZServerSet *sset;
+ ZServerSetSysno *sr;
+ RSET rset;
+ int num_i = 0;
+ int position = 0;
+ int psysno = 0;
+ struct it_key key;
+ RSFD rfd;
+
+ if (!(sset = resultSetGet (zi, name)))
+ return NULL;
+ if (!(rset = sset->rset))
+ return NULL;
+ logf (LOG_DEBUG, "resultSetRecordGet");
+ sr = xmalloc (sizeof(*sr) * num);
+ rfd = rset_open (rset, 0);
+ while (rset_read (rset, rfd, &key))
+ {
+ if (key.sysno != psysno)
+ {
+ psysno = key.sysno;
+ position++;
+ if (position == positions[num_i])
+ {
+ sr[num_i].sysno = psysno;
+ num_i++;
+ if (++num_i == num)
+ break;
+ }
+ }
+ }
+ rset_close (rset, rfd);
+ while (num_i < num)
+ {
+ sr[num_i].sysno = 0;
+ num_i++;
+ }
+ return sr;
+}
+
+void resultSetRecordDel (ZServerInfo *zi, ZServerRecord *records, int num)
+{
+ int i;
+
+ for (i = 0; i<num; i++)
+ free (records[i].buf);
+ free (records);
+}
+
+
+#if 0
+ZServerSetSysno *resultSetSysno (ZServerInfo *zi, const char *name,
+ int num, int *positions)
{
ZServerSet *sset;
ZServerRecord *sr;
}
return sr;
}
-
-void resultSetRecordDel (ZServerInfo *zi, ZServerRecord *records, int num)
-{
- int i;
-
- for (i = 0; i<num; i++)
- free (records[i].buf);
- free (records);
-}
+#endif