/*
- * Copyright (C) 1994-1998, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recctrl.h,v $
- * Revision 1.26 1998-05-20 10:12:12 adam
+ * Revision 1.27 1998-10-16 08:14:28 adam
+ * Updated record control system.
+ *
+ * Revision 1.26 1998/05/20 10:12:12 adam
* Implemented automatic EXPLAIN database maintenance.
* Modified Zebra to work with ASN.1 compiled version of YAZ.
*
char *message;
};
-typedef struct recType
+typedef struct recType *RecType;
+
+struct recType
{
- 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;
+ char *name; /* Name of record type */
+ void (*init)(RecType recType); /* Init function - called once */
+ void (*destroy)(RecType recType); /* Destroy function */
+ int (*extract)(struct recExtractCtrl *ctrl); /* Extract proc */
+ int (*retrieve)(struct recRetrieveCtrl *ctrl); /* Retrieve proc */
+ void *clientData; /* data handle */
+};
+
+typedef struct recTypes *RecTypes;
+
+RecTypes recTypes_init (data1_handle dh);
+void recTypes_destroy (RecTypes recTypes);
+void recTypes_default_handlers (RecTypes recTypes);
-RecType recType_byName (const char *name, char *subType);
+RecType recType_byName (RecTypes rts, const char *name, char *subType);
int grs_extract_tree(struct recExtractCtrl *p, data1_node *n);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.87 1998-10-15 13:10:33 adam
+ * Revision 1.88 1998-10-16 08:14:29 adam
+ * Updated record control system.
+ *
+ * Revision 1.87 1998/10/15 13:10:33 adam
* Fixed bug in Zebra that caused it to stop indexing when empty
* record was read.
*
}
if (!*rGroup->recordType)
return 0;
- if (!(recType = recType_byName (rGroup->recordType, subType)))
+ if (!(recType =
+ recType_byName (rGroup->recTypes, rGroup->recordType, subType)))
{
logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
return 0;
/*
- * Copyright (C) 1995-1998, Index Data I/S
+ * Copyright (C) 1995-1998, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: index.h,v $
- * Revision 1.59 1998-06-08 14:43:11 adam
+ * Revision 1.60 1998-10-16 08:14:31 adam
+ * Updated record control system.
+ *
+ * Revision 1.59 1998/06/08 14:43:11 adam
* Added suport for EXPLAIN Proxy servers - added settings databasePath
* and explainDatabase to facilitate this. Increased maximum number
* of databases and attributes in one register.
#include <isam.h>
#include <isamc.h>
#include <data1.h>
+#include <recctrl.h>
#define IT_MAX_WORD 256
#define IT_KEY_HAVE_SEQNO 1
time_t mtime;
};
-
struct recordGroup {
char *groupName;
char *databaseName;
data1_handle dh;
BFiles bfs;
ZebraMaps zebra_maps;
+ RecTypes recTypes;
};
void getFnameTmp (char *fname, int no);
/*
- * Copyright (C) 1994-1998, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: main.c,v $
- * Revision 1.58 1998-06-08 14:43:13 adam
+ * Revision 1.59 1998-10-16 08:14:32 adam
+ * Updated record control system.
+ *
+ * Revision 1.58 1998/06/08 14:43:13 adam
* Added suport for EXPLAIN Proxy servers - added settings databasePath
* and explainDatabase to facilitate this. Increased maximum number
* of databases and attributes in one register.
rGroupDef.fileVerboseLimit = 100000;
rGroupDef.zebra_maps = NULL;
rGroupDef.dh = data1_create ();
+ rGroupDef.recTypes = recTypes_init (rGroupDef.dh);
+ recTypes_default_handlers (rGroupDef.recTypes);
prog = *argv;
if (argc < 2)
/*
- * Copyright (C) 1995-1998, Index Data I/S
+ * Copyright (C) 1995-1998, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: retrieve.c,v $
- * Revision 1.1 1998-03-05 08:45:13 adam
+ * Revision 1.2 1998-10-16 08:14:33 adam
+ * Updated record control system.
+ *
+ * Revision 1.1 1998/03/05 08:45:13 adam
* New result set model and modular ranking system. Moved towards
* descent server API. System information stored as "SGML" records.
*
*basenamep = odr_malloc (stream, strlen(basename)+1);
strcpy (*basenamep, basename);
- if (!(rt = recType_byName (file_type, subType)))
+ if (!(rt = recType_byName (zh->recTypes, file_type, subType)))
{
logf (LOG_WARN, "Retrieve: Cannot handle type %s", file_type);
return 14;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zebraapi.c,v $
- * Revision 1.10 1998-09-22 10:03:42 adam
+ * Revision 1.11 1998-10-16 08:14:34 adam
+ * Updated record control system.
+ *
+ * Revision 1.10 1998/09/22 10:03:42 adam
* Changed result sets to be persistent in the sense that they can
* be re-searched if needed.
* Fixed memory leak in rsm_or.
zh->sets = NULL;
zh->registerState = -1; /* trigger open of registers! */
zh->registerChange = 0;
-
+ zh->recTypes = recTypes_init (zh->dh);
+ recTypes_default_handlers (zh->recTypes);
+
zh->records = NULL;
zh->zebra_maps = zebra_maps_open (zh->res);
zh->rank_classes = NULL;
rec_close (&zh->records);
zebra_register_unlock (zh);
}
+ recTypes_destroy (zh->recTypes);
zebra_maps_close (zh->zebra_maps);
zebraRankDestroy (zh);
bfs_destroy (zh->bfs);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.h,v $
- * Revision 1.38 1998-09-22 10:03:44 adam
+ * Revision 1.39 1998-10-16 08:14:35 adam
+ * Updated record control system.
+ *
+ * Revision 1.38 1998/09/22 10:03:44 adam
* Changed result sets to be persistent in the sense that they can
* be re-searched if needed.
* Fixed memory leak in rsm_or.
#endif
ZebraMaps zebra_maps;
ZebraRankClass rank_classes;
+ RecTypes recTypes;
Passwd_db passwd_db;
};
/*
- * Copyright (C) 1994-1996, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recctrl.c,v $
- * Revision 1.2 1996-10-29 14:03:16 adam
+ * Revision 1.3 1998-10-16 08:14:36 adam
+ * Updated record control system.
+ *
+ * Revision 1.2 1996/10/29 14:03:16 adam
* Include zebrautl.h instead of alexutil.h.
*
* Revision 1.1 1996/10/11 10:57:24 adam
#include "rectext.h"
#include "recgrs.h"
-RecType recType_byName (const char *name, char *subType)
+struct recTypeEntry {
+ RecType recType;
+ struct recTypeEntry *next;
+ int init_flag;
+};
+
+struct recTypes {
+ data1_handle dh;
+ struct recTypeEntry *entries;
+};
+
+RecTypes recTypes_init (data1_handle dh)
+{
+ RecTypes p = (RecTypes) nmem_malloc (data1_nmem_get (dh), sizeof(*p));
+
+ p->dh = dh;
+ p->entries = 0;
+ return p;
+}
+
+void recTypes_destroy (RecTypes rts)
+{
+ struct recTypeEntry *rte;
+
+ for (rte = rts->entries; rte; rte = rte->next)
+ if (rte->init_flag)
+ (*(rte->recType)->destroy)(rte->recType);
+}
+
+void recTypes_add_handler (RecTypes rts, RecType rt)
{
+ struct recTypeEntry *rte;
+
+ rte = nmem_malloc (data1_nmem_get (rts->dh), sizeof(*rte));
+
+ rte->recType = rt;
+ rte->init_flag = 0;
+ rte->next = rts->entries;
+ rts->entries = rte;
+}
+
+RecType recType_byName (RecTypes rts, const char *name, char *subType)
+{
+ struct recTypeEntry *rte;
char *p;
char tmpname[256];
}
else
*subType = '\0';
- if (!strcmp (recTypeGrs->name, tmpname))
- return recTypeGrs;
- if (!strcmp (recTypeText->name, tmpname))
- return recTypeText;
- return NULL;
+ for (rte = rts->entries; rte; rte = rte->next)
+ if (!strcmp (rte->recType->name, tmpname))
+ {
+ if (!rte->init_flag)
+ {
+ rte->init_flag = 1;
+ (*(rte->recType)->init)(rte->recType);
+ }
+ return rte->recType;
+ }
+ return 0;
}
+void recTypes_default_handlers (RecTypes rts)
+{
+ recTypes_add_handler (rts, recTypeGrs);
+ recTypes_add_handler (rts, recTypeText);
+}
/*
- * Copyright (C) 1994-1998, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recgrs.c,v $
- * Revision 1.21 1998-07-01 09:16:10 adam
+ * Revision 1.22 1998-10-16 08:14:37 adam
+ * Updated record control system.
+ *
+ * Revision 1.21 1998/07/01 09:16:10 adam
* Element localno only added when it's greater than 0.
*
* Revision 1.20 1998/05/20 10:12:26 adam
return NULL;
}
-static void grs_init(void)
+static void grs_init(RecType recType)
+{
+}
+
+static void grs_destroy(RecType recType)
{
}
{
"grs",
grs_init,
+ grs_destroy,
grs_extract,
grs_retrieve
};
/*
- * Copyright (C) 1994-1998, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: rectext.c,v $
- * Revision 1.8 1998-05-20 10:12:27 adam
+ * Revision 1.9 1998-10-16 08:14:38 adam
+ * Updated record control system.
+ *
+ * Revision 1.8 1998/05/20 10:12:27 adam
* Implemented automatic EXPLAIN database maintenance.
* Modified Zebra to work with ASN.1 compiled version of YAZ.
*
#include <zebrautl.h>
#include "rectext.h"
-static void text_init (void)
+static void text_init (RecType recType)
+{
+}
+
+static void text_destroy (RecType recType)
{
}
static struct recType text_type = {
"text",
text_init,
+ text_destroy,
text_extract,
text_retrieve
};