/*
* IR toolkit for tcl/tk
* (c) Index Data 1995
+ * See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ir-tcl.c,v $
- * Revision 1.31 1995-05-26 11:44:10 adam
+ * Revision 1.32 1995-05-29 08:44:16 adam
+ * Work on delete of objects.
+ *
+ * Revision 1.31 1995/05/26 11:44:10 adam
* Bugs fixed. More work on MARC utilities and queries. Test
* client is up-to-date again.
*
return NULL;
}
+static void delete_IR_records (IRSetObj *setobj)
+{
+ IRRecordList *rl, *rl1;
+
+ for (rl = setobj->record_list; rl; rl = rl1)
+ {
+ switch (rl->which)
+ {
+ case Z_NamePlusRecord_databaseRecord:
+ free (rl->u.dbrec.buf);
+ break;
+ case Z_NamePlusRecord_surrogateDiagnostic:
+ free (rl->u.diag.addinfo);
+ break;
+ }
+ rl1 = rl->next;
+ free (rl);
+ }
+ setobj->record_list = NULL;
+}
+
/*
* getsetint: Set/get integer value
*/
for (tab_i = tab; tab_i->tab; tab_i++)
for (t = tab_i->tab; t->name; t++)
- if (!strcmp (t->name, argv[1]))
- return (*t->method)(tab_i->obj, interp, argc, argv);
+ if (argc <= 0)
+ {
+ if ((*t->method)(tab_i->obj, interp, argc, argv) == TCL_ERROR)
+ return TCL_ERROR;
+ }
+ else
+ if (!strcmp (t->name, argv[1]))
+ return (*t->method)(tab_i->obj, interp, argc, argv);
+ if (argc <= 0)
+ return TCL_OK;
Tcl_AppendResult (interp, "Bad method. Possible methods:", NULL);
for (tab_i = tab; tab_i->tab; tab_i++)
for (t = tab_i->tab; t->name; t++)
Tcl_AppendResult (interp, " ", t->name, NULL);
return TCL_ERROR;
-
}
/*
}
/*
- * ir_asc2bitmask: Ascii to ODR bitmask conversion
- */
-int ir_asc2bitmask (const char *asc, Odr_bitmask *ob)
-{
- const char *cp = asc + strlen(asc);
- int bitno = 0;
-
- ODR_MASK_ZERO (ob);
- do
- {
- if (*--cp == '1')
- ODR_MASK_SET (ob, bitno);
- bitno++;
- } while (cp != asc);
- return bitno;
-}
-
-/*
* ir_named_bits: get/set named bits
*/
int ir_named_bits (struct ir_named_entry *tab, Odr_bitmask *ob,
- Tcl_Interp *interp,
- int argc, char **argv)
+ Tcl_Interp *interp, int argc, char **argv)
{
struct ir_named_entry *ti;
if (argc > 0)
}
/*
+ * ir_strdel: Delete string
+ */
+int ir_strdel (Tcl_Interp *interp, char **p)
+{
+ free (*p);
+ *p = NULL;
+ return TCL_OK;
+}
+
+/*
* ir_malloc: Malloc function
*/
void *ir_malloc (Tcl_Interp *interp, size_t size)
Z_InitRequest req;
int r;
+ if (argc <= 0)
+ return TCL_OK;
if (!p->cs_link)
{
interp->result = "not connected";
if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
{
interp->result = "cs_put failed in init";
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
return TCL_ERROR;
}
else if (r == 1)
};
IRObj *p = obj;
+ if (argc <= 0)
+ {
+ ODR_MASK_ZERO (&p->protocolVersion);
+ ODR_MASK_SET (&p->protocolVersion, 0);
+ ODR_MASK_SET (&p->protocolVersion, 1);
+ return TCL_OK;
+ }
return ir_named_bits (version_tab, &p->protocolVersion,
interp, argc-2, argv+2);
}
};
IRObj *p = obj;
+ if (argc <= 0)
+ {
+ ODR_MASK_ZERO (&p->options);
+ ODR_MASK_SET (&p->options, 0);
+ ODR_MASK_SET (&p->options, 1);
+ ODR_MASK_SET (&p->options, 7);
+ ODR_MASK_SET (&p->options, 14);
+ return TCL_OK;
+ }
return ir_named_bits (options_tab, &p->options, interp, argc-2, argv+2);
}
int argc, char **argv)
{
IRObj *p = obj;
+
+ if (argc <= 0)
+ {
+ p->preferredMessageSize = 4096;
+ return TCL_OK;
+ }
return get_set_int (&p->preferredMessageSize, interp, argc, argv);
}
int argc, char **argv)
{
IRObj *p = obj;
+
+ if (argc <= 0)
+ {
+ p->maximumRecordSize = 32768;
+ return TCL_OK;
+ }
return get_set_int (&p->maximumRecordSize, interp, argc, argv);
}
int argc, char **argv)
{
IRObj *p = obj;
-
+
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&p->initResult, interp, argc, argv);
}
{
IRObj *p = obj;
+ if (argc == 0)
+ return ir_strdup (interp, &p->implementationName, "TCL/TK on YAZ");
+ else if (argc == -1)
+ return ir_strdel (interp, &p->implementationName);
if (argc == 3)
{
- free (((IRObj*)obj)->implementationName);
+ free (p->implementationName);
if (ir_strdup (interp, &p->implementationName, argv[2])
== TCL_ERROR)
return TCL_ERROR;
static int do_implementationId (void *obj, Tcl_Interp *interp,
int argc, char **argv)
{
+ IRObj *p = obj;
+
+ if (argc == 0)
+ return ir_strdup (interp, &p->implementationId, "81");
+ else if (argc == -1)
+ return ir_strdel (interp, &p->implementationId);
if (argc == 3)
{
- free (((IRObj*)obj)->implementationId);
- if (ir_strdup (interp, &((IRObj*) obj)->implementationId, argv[2])
- == TCL_ERROR)
+ free (p->implementationId);
+ if (ir_strdup (interp, &p->implementationId, argv[2]) == TCL_ERROR)
return TCL_ERROR;
}
- Tcl_AppendResult (interp, ((IRObj*)obj)->implementationId,
- (char*) NULL);
+ Tcl_AppendResult (interp, p->implementationId, (char*) NULL);
return TCL_OK;
}
{
IRObj *p = obj;
+ if (argc == 0)
+ {
+ p->targetImplementationName = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_strdel (interp, &p->targetImplementationName);
Tcl_AppendResult (interp, p->targetImplementationName,
(char*) NULL);
return TCL_OK;
static int do_targetImplementationId (void *obj, Tcl_Interp *interp,
int argc, char **argv)
{
- Tcl_AppendResult (interp, ((IRObj*)obj)->targetImplementationId,
- (char*) NULL);
+ IRObj *p = obj;
+
+ if (argc == 0)
+ {
+ p->targetImplementationId = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_strdel (interp, &p->targetImplementationId);
+ Tcl_AppendResult (interp, p->targetImplementationId, (char*) NULL);
return TCL_OK;
}
static int do_targetImplementationVersion (void *obj, Tcl_Interp *interp,
int argc, char **argv)
{
- Tcl_AppendResult (interp, ((IRObj*)obj)->targetImplementationVersion,
- (char*) NULL);
+ IRObj *p = obj;
+
+ if (argc == 0)
+ {
+ p->targetImplementationVersion = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_strdel (interp, &p->targetImplementationVersion);
+ Tcl_AppendResult (interp, p->targetImplementationVersion, (char*) NULL);
return TCL_OK;
}
{
IRObj *p = obj;
- if (argc >= 3)
+ if (argc >= 3 || argc == -1)
{
free (p->idAuthenticationOpen);
free (p->idAuthenticationGroupId);
free (p->idAuthenticationUserId);
free (p->idAuthenticationPassword);
+ }
+ if (argc >= 3 || argc <= 0)
+ {
p->idAuthenticationOpen = NULL;
p->idAuthenticationGroupId = NULL;
p->idAuthenticationUserId = NULL;
p->idAuthenticationPassword = NULL;
-
+ }
+ if (argc <= 0)
+ return TCL_OK;
+ if (argc >= 3)
+ {
if (argc == 3)
{
if (ir_strdup (interp, &p->idAuthenticationOpen, argv[2])
}
if (p->idAuthenticationOpen)
Tcl_AppendElement (interp, p->idAuthenticationOpen);
- else
+ else if (p->idAuthenticationGroupId)
{
- Tcl_AppendElement (interp, p->idAuthenticationGroupId ?
- p->idAuthenticationGroupId : "");
- Tcl_AppendElement (interp, p->idAuthenticationUserId ?
- p->idAuthenticationUserId : "");
- Tcl_AppendElement (interp, p->idAuthenticationPassword ?
- p->idAuthenticationPassword : "");
+ Tcl_AppendElement (interp, p->idAuthenticationGroupId);
+ Tcl_AppendElement (interp, p->idAuthenticationUserId);
+ Tcl_AppendElement (interp, p->idAuthenticationPassword);
}
return TCL_OK;
}
int r;
int protocol_type = CS_Z3950;
+ if (argc <= 0)
+ return TCL_OK;
if (argc == 3)
{
if (p->hostname)
if ((r=cs_connect (p->cs_link, addr)) < 0)
{
interp->result = "cs_connect fail";
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
return TCL_ERROR;
}
ir_select_add (cs_fileno (p->cs_link), p);
{
IRObj *p = obj;
+ if (argc == 0)
+ {
+ p->connectFlag = 0;
+ p->hostname = NULL;
+ p->cs_link = NULL;
+ return TCL_OK;
+ }
if (p->hostname)
{
free (p->hostname);
{
IRObj *obj = o;
- if (argc == 3)
+ if (argc == 0)
+ return ir_strdup (interp, &obj->cs_type, "tcpip");
+ else if (argc == -1)
+ return ir_strdel (interp, &obj->cs_type);
+ else if (argc == 3)
{
free (obj->cs_type);
if (ir_strdup (interp, &obj->cs_type, argv[2]) == TCL_ERROR)
{
IRObj *obj = o;
- if (argc == 3)
+ if (argc == 0)
+ return ir_strdup (interp, &obj->protocol_type, "Z3950");
+ else if (argc == -1)
+ return ir_strdel (interp, &obj->protocol_type);
+ else if (argc == 3)
{
free (obj->protocol_type);
if (ir_strdup (interp, &obj->protocol_type, argv[2]) == TCL_ERROR)
{
IRObj *p = obj;
+ if (argc == 0)
+ {
+ p->callback = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_strdel (interp, &p->callback);
if (argc == 3)
{
free (p->callback);
- if (ir_strdup (interp, &p->callback, argv[2]) == TCL_ERROR)
- return TCL_ERROR;
+ if (argv[2][0])
+ {
+ if (ir_strdup (interp, &p->callback, argv[2]) == TCL_ERROR)
+ return TCL_ERROR;
+ }
+ else
+ p->callback = NULL;
p->interp = interp;
}
return TCL_OK;
{
IRObj *p = obj;
- if (argc == 3)
+ if (argc == 0)
+ {
+ p->failback = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_strdel (interp, &p->failback);
+ else if (argc == 3)
{
free (p->failback);
- if (ir_strdup (interp, &p->failback, argv[2]) == TCL_ERROR)
- return TCL_ERROR;
+ if (argv[2][0])
+ {
+ if (ir_strdup (interp, &p->failback, argv[2]) == TCL_ERROR)
+ return TCL_ERROR;
+ }
+ else
+ p->failback = NULL;
p->interp = interp;
}
return TCL_OK;
int i;
IRSetCObj *p = obj;
+ if (argc == -1)
+ {
+ for (i=0; i<p->num_databaseNames; i++)
+ free (p->databaseNames[i]);
+ free (p->databaseNames);
+ }
+ if (argc <= 0)
+ {
+ p->num_databaseNames = 0;
+ p->databaseNames = NULL;
+ return TCL_OK;
+ }
if (argc < 3)
{
for (i=0; i<p->num_databaseNames; i++)
{
IRSetCObj *p = obj;
+ if (argc <= 0)
+ {
+ p->replaceIndicator = 1;
+ return TCL_OK;
+ }
return get_set_int (&p->replaceIndicator, interp, argc, argv);
}
{
IRSetCObj *p = obj;
+ if (argc == 0)
+ return ir_strdup (interp, &p->queryType, "rpn");
+ else if (argc == -1)
+ return ir_strdel (interp, &p->queryType);
if (argc == 3)
{
free (p->queryType);
int argc, char **argv)
{
IRObj *p = obj;
-
+
+ if (argc == 0)
+ {
+ p->userInformationField = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_strdel (interp, &p->userInformationField);
Tcl_AppendResult (interp, p->userInformationField, NULL);
return TCL_OK;
}
static int do_smallSetUpperBound (void *o, Tcl_Interp *interp,
int argc, char **argv)
{
- IRSetCObj *obj = o;
+ IRSetCObj *p = o;
- return get_set_int (&obj->smallSetUpperBound, interp, argc, argv);
+ if (argc <= 0)
+ {
+ p->smallSetUpperBound = 0;
+ return TCL_OK;
+ }
+ return get_set_int (&p->smallSetUpperBound, interp, argc, argv);
}
/*
static int do_largeSetLowerBound (void *o, Tcl_Interp *interp,
int argc, char **argv)
{
- IRSetCObj *obj = o;
+ IRSetCObj *p = o;
- return get_set_int (&obj->largeSetLowerBound, interp, argc, argv);
+ if (argc <= 0)
+ {
+ p->largeSetLowerBound = 2;
+ return TCL_OK;
+ }
+ return get_set_int (&p->largeSetLowerBound, interp, argc, argv);
}
/*
static int do_mediumSetPresentNumber (void *o, Tcl_Interp *interp,
int argc, char **argv)
{
- IRSetCObj *obj = o;
-
- return get_set_int (&obj->mediumSetPresentNumber, interp, argc, argv);
+ IRSetCObj *p = o;
+
+ if (argc <= 0)
+ {
+ p->mediumSetPresentNumber = 0;
+ return TCL_OK;
+ }
+ return get_set_int (&p->mediumSetPresentNumber, interp, argc, argv);
}
*/
static void ir_obj_delete (ClientData clientData)
{
- free ( (void*) clientData);
-}
+ IRObj *obj = clientData;
+ IRMethods tab[3];
-static int ir_reset_inher (Tcl_Interp *interp, IRSetCObj *o)
-{
- o->smallSetUpperBound = 0;
- o->largeSetLowerBound = 2;
- o->mediumSetPresentNumber = 0;
- o->replaceIndicator = 1;
-#if 0
- obj->databaseNames = NULL;
- obj->num_databaseNames = 0;
-#else
- o->num_databaseNames = 1;
- if (!(o->databaseNames =
- ir_malloc (interp, sizeof(*o->databaseNames))))
- return TCL_ERROR;
- if (ir_strdup (interp, &o->databaseNames[0], "Default")
- == TCL_ERROR)
- return TCL_ERROR;
-#endif
- if (ir_strdup (interp, &o->queryType, "rpn") == TCL_ERROR)
- return TCL_ERROR;
- return TCL_OK;
+ --(obj->ref_count);
+ if (obj->ref_count > 0)
+ return;
+ assert (obj->ref_count == 0);
+
+ tab[0].tab = ir_method_tab;
+ tab[0].obj = obj;
+ tab[1].tab = ir_set_c_method_tab;
+ tab[1].obj = &obj->set_inher;
+ tab[2].tab = NULL;
+
+ ir_method (NULL, -1, NULL, tab);
+ odr_destroy (obj->odr_in);
+ odr_destroy (obj->odr_out);
+ odr_destroy (obj->odr_pr);
+ free (obj->buf_out);
+ free (obj->buf_in);
+ free (obj);
}
/*
static int ir_obj_mk (ClientData clientData, Tcl_Interp *interp,
int argc, char **argv)
{
+ IRMethods tab[3];
IRObj *obj;
#if CCL2RPN
FILE *inf;
}
if (!(obj = ir_malloc (interp, sizeof(*obj))))
return TCL_ERROR;
- if (ir_strdup (interp, &obj->cs_type, "tcpip") == TCL_ERROR)
- return TCL_ERROR;
- if (ir_strdup (interp, &obj->protocol_type, "Z3950") == TCL_ERROR)
- return TCL_ERROR;
- obj->cs_link = NULL;
- obj->bib1.proto = PROTO_Z3950;
- obj->bib1.class = CLASS_ATTSET;
- obj->bib1.value = VAL_BIB1;
-
- obj->maximumRecordSize = 32768;
- obj->preferredMessageSize = 4096;
- obj->connectFlag = 0;
-
- obj->idAuthenticationOpen = NULL;
- obj->idAuthenticationGroupId = NULL;
- obj->idAuthenticationUserId = NULL;
- obj->idAuthenticationPassword = NULL;
-
- if (ir_strdup (interp, &obj->implementationName, "TCL/TK on YAZ")
- == TCL_ERROR)
- return TCL_ERROR;
-
- if (ir_strdup (interp, &obj->implementationId, "TCL/TK/YAZ")
- == TCL_ERROR)
- return TCL_ERROR;
-
- obj->targetImplementationName = NULL;
- obj->targetImplementationId = NULL;
- obj->targetImplementationVersion = NULL;
- obj->userInformationField = NULL;
-
- obj->hostname = NULL;
+ obj->ref_count = 1;
#if CCL2RPN
obj->bibset = ccl_qual_mk ();
if ((inf = fopen ("default.bib", "r")))
fclose (inf);
}
#endif
- ODR_MASK_ZERO (&obj->protocolVersion);
- ODR_MASK_SET (&obj->protocolVersion, 0);
- ODR_MASK_SET (&obj->protocolVersion, 1);
-
- ODR_MASK_ZERO (&obj->options);
- ODR_MASK_SET (&obj->options, 0);
- ODR_MASK_SET (&obj->options, 1);
- ODR_MASK_SET (&obj->options, 7);
- ODR_MASK_SET (&obj->options, 14);
obj->odr_in = odr_createmem (ODR_DECODE);
obj->odr_out = odr_createmem (ODR_ENCODE);
obj->len_in = 0;
obj->buf_in = NULL;
- obj->callback = NULL;
- obj->failback = NULL;
+ tab[0].tab = ir_method_tab;
+ tab[0].obj = obj;
+ tab[1].tab = ir_set_c_method_tab;
+ tab[1].obj = &obj->set_inher;
+ tab[2].tab = NULL;
- if (ir_reset_inher (interp, &obj->set_inher) == TCL_ERROR)
+ if (ir_method (interp, 0, NULL, tab) == TCL_ERROR)
return TCL_ERROR;
Tcl_CreateCommand (interp, argv[1], ir_obj_method,
(ClientData) obj, ir_obj_delete);
IRSetObj *obj = o;
IRObj *p = obj->parent;
int r;
+ oident bib1;
+
+ if (argc <= 0)
+ return TCL_OK;
p->set_child = o;
if (argc != 3)
odr_reset (p->odr_out);
apdu.which = Z_APDU_searchRequest;
apdu.u.searchRequest = &req;
+
+ bib1.proto = PROTO_Z3950;
+ bib1.class = CLASS_ATTSET;
+ bib1.value = VAL_BIB1;
req.referenceId = 0;
req.smallSetUpperBound = &p->set_inher.smallSetUpperBound;
Tcl_AppendResult (interp, "Syntax error in query", NULL);
return TCL_ERROR;
}
- RPNquery->attributeSetId = oid_getoidbyent (&p->bib1);
+ RPNquery->attributeSetId = oid_getoidbyent (&bib1);
query.which = Z_Query_type_1;
query.u.type_1 = RPNquery;
logf (LOG_DEBUG, "RPN");
ccl_pr_tree (rpn, stderr);
fprintf (stderr, "\n");
assert((RPNquery = ccl_rpn_query(rpn)));
- RPNquery->attributeSetId = oid_getoidbyent (&p->bib1);
+ RPNquery->attributeSetId = oid_getoidbyent (&bib1);
query.which = Z_Query_type_1;
query.u.type_1 = RPNquery;
logf (LOG_DEBUG, "CCLRPN");
{
IRSetObj *obj = o;
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&obj->resultCount, interp, argc, argv);
}
{
IRSetObj *obj = o;
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&obj->searchStatus, interp, argc, argv);
}
{
IRSetObj *obj = o;
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&obj->presentStatus, interp, argc, argv);
}
{
IRSetObj *obj = o;
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&obj->nextResultSetPosition, interp, argc, argv);
}
{
IRSetObj *obj = o;
+ if (argc == 0)
+ return ir_strdup (interp, &obj->setName, "Default");
+ else if (argc == -1)
+ return ir_strdel (interp, &obj->setName);
if (argc == 3)
{
free (obj->setName);
{
IRSetObj *obj = o;
+ if (argc < 0)
+ return TCL_OK;
return get_set_int (&obj->numberOfRecordsReturned, interp, argc, argv);
}
int offset;
IRRecordList *rl;
+ if (argc == 0)
+ {
+ obj->record_list = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ {
+ delete_IR_records (obj);
+ return TCL_OK;
+ }
if (argc < 3)
{
sprintf (interp->result, "wrong # args");
IRRecordList *rl;
char buf[20];
+ if (argc <= 0)
+ return TCL_OK;
if (argc < 3)
{
sprintf (interp->result, "wrong # args");
int offset;
IRRecordList *rl;
- if (argc < 4)
+ if (argc <= 0)
+ return TCL_OK;
+ if (argc < 7)
{
sprintf (interp->result, "wrong # args");
return TCL_ERROR;
{
IRSetObj *obj = o;
+ if (argc == 0)
+ {
+ obj->recordFlag = 0;
+ obj->addinfo = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_strdel (interp, &obj->addinfo);
if (!obj->recordFlag)
{
Tcl_AppendElement (interp, "OK");
int number;
int r;
+ if (argc <= 0)
+ return TCL_OK;
if (argc >= 3)
{
if (Tcl_GetInt (interp, argv[2], &start) == TCL_ERROR)
int no = 1;
char *buf;
+ if (argc <= 0)
+ return TCL_OK;
if (argc < 3)
{
interp->result = "wrong # args";
return TCL_OK;
}
-/*
- * ir_set_obj_method: IR Set Object methods
- */
-static int ir_set_obj_method (ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv)
-{
- static IRMethod tab[] = {
+static IRMethod ir_set_method_tab[] = {
{ 0, "search", do_search },
{ 0, "searchStatus", do_searchStatus },
{ 0, "presentStatus", do_presentStatus },
{ 0, "responseStatus", do_responseStatus },
{ 0, "loadFile", do_loadFile },
{ 0, NULL, NULL}
- };
+};
+
+/*
+ * ir_set_obj_method: IR Set Object methods
+ */
+static int ir_set_obj_method (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
IRMethods tabs[3];
IRSetObj *p = clientData;
interp->result = "wrong # args";
return TCL_ERROR;
}
- tabs[0].tab = tab;
+ tabs[0].tab = ir_set_method_tab;
tabs[0].obj = p;
tabs[1].tab = ir_set_c_method_tab;
tabs[1].obj = &p->set_inher;
*/
static void ir_set_obj_delete (ClientData clientData)
{
- free ( (void*) clientData);
+ IRMethods tabs[3];
+ IRSetObj *p = clientData;
+
+ tabs[0].tab = ir_set_method_tab;
+ tabs[0].obj = p;
+ tabs[1].tab = ir_set_c_method_tab;
+ tabs[1].obj = &p->set_inher;
+ tabs[2].tab = NULL;
+
+ ir_method (NULL, -1, NULL, tabs);
+
+ free (p);
}
/*
static int ir_set_obj_mk (ClientData clientData, Tcl_Interp *interp,
int argc, char **argv)
{
+ IRMethods tabs[3];
IRSetObj *obj;
if (argc < 2 || argc > 3)
}
else
obj->parent = NULL;
- if (ir_strdup (interp, &obj->setName, argv[2]) == TCL_ERROR)
+
+ tabs[0].tab = ir_set_method_tab;
+ tabs[0].obj = obj;
+ tabs[1].tab = NULL;
+
+ if (ir_method (interp, 0, NULL, tabs) == TCL_ERROR)
return TCL_ERROR;
- obj->record_list = NULL;
- obj->addinfo = NULL;
+
Tcl_CreateCommand (interp, argv[1], ir_set_obj_method,
(ClientData) obj, ir_set_obj_delete);
return TCL_OK;
IRScanObj *obj = o;
IRObj *p = obj->parent;
int r;
+ oident bib1;
#if CCL2RPN
struct ccl_rpn_node *rpn;
int pos;
#endif
+ if (argc <= 0)
+ return TCL_OK;
p->scan_child = o;
if (argc != 3)
{
return TCL_ERROR;
}
odr_reset (p->odr_out);
+
+ bib1.proto = PROTO_Z3950;
+ bib1.class = CLASS_ATTSET;
+ bib1.value = VAL_BIB1;
+
apdu.which = Z_APDU_scanRequest;
apdu.u.scanRequest = &req;
req.referenceId = NULL;
req.num_databaseNames = p->set_inher.num_databaseNames;
req.databaseNames = p->set_inher.databaseNames;
- req.attributeSet = oid_getoidbyent (&p->bib1);
+ req.attributeSet = oid_getoidbyent (&bib1);
#if !CCL2RPN
if (!(req.termListAndStartPoint = p_query_scan (p->odr_out, argv[2])))
int argc, char **argv)
{
IRScanObj *p = obj;
+ if (argc <= 0)
+ {
+ p->stepSize = 0;
+ return TCL_OK;
+ }
return get_set_int (&p->stepSize, interp, argc, argv);
}
int argc, char **argv)
{
IRScanObj *p = obj;
+
+ if (argc <= 0)
+ {
+ p->numberOfTermsRequested = 20;
+ return TCL_OK;
+ }
return get_set_int (&p->numberOfTermsRequested, interp, argc, argv);
}
int argc, char **argv)
{
IRScanObj *p = obj;
+
+ if (argc <= 0)
+ {
+ p->preferredPositionInResponse = 1;
+ return TCL_OK;
+ }
return get_set_int (&p->preferredPositionInResponse, interp, argc, argv);
}
int argc, char **argv)
{
IRScanObj *p = obj;
+
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&p->scanStatus, interp, argc, argv);
}
int argc, char **argv)
{
IRScanObj *p = obj;
+
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&p->numberOfEntriesReturned, interp, argc, argv);
}
int argc, char **argv)
{
IRScanObj *p = obj;
+
+ if (argc <= 0)
+ return TCL_OK;
return get_set_int (&p->positionOfTerm, interp, argc, argv);
}
int i;
char numstr[20];
+ if (argc == 0)
+ {
+ p->entries_flag = 0;
+ p->entries = NULL;
+ p->nonSurrogateDiagnostics = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ {
+ p->entries_flag = 0;
+ /* release entries */
+ p->entries = NULL;
+ /* release non diagnostics */
+ p->nonSurrogateDiagnostics = NULL;
+ return TCL_OK;
+ }
if (argc != 3)
{
interp->result = "wrong # args";
return TCL_OK;
}
-/*
- * ir_scan_obj_method: IR Scan Object methods
- */
-static int ir_scan_obj_method (ClientData clientData, Tcl_Interp *interp,
- int argc, char **argv)
-{
- static IRMethod tab[] = {
+static IRMethod ir_scan_method_tab[] = {
{ 0, "scan", do_scan },
{ 0, "stepSize", do_stepSize },
{ 0, "numberOfTermsRequested", do_numberOfTermsRequested },
{ 0, "positionOfTerm", do_positionOfTerm },
{ 0, "scanLine", do_scanLine },
{ 0, NULL, NULL}
- };
+};
+
+/*
+ * ir_scan_obj_method: IR Scan Object methods
+ */
+static int ir_scan_obj_method (ClientData clientData, Tcl_Interp *interp,
+ int argc, char **argv)
+{
IRMethods tabs[3];
if (argc < 2)
interp->result = "wrong # args";
return TCL_ERROR;
}
-
- tabs[0].tab = tab;
+ tabs[0].tab = ir_scan_method_tab;
tabs[0].obj = clientData;
tabs[1].tab = NULL;
{
Tcl_CmdInfo parent_info;
IRScanObj *obj;
+ IRMethods tabs[3];
if (argc != 2)
{
if (!(obj = ir_malloc (interp, sizeof(*obj))))
return TCL_ERROR;
+ tabs[0].tab = ir_scan_method_tab;
+ tabs[0].obj = clientData;
+ tabs[1].tab = NULL;
+
+ if (ir_method (interp, 0, NULL, tabs) == TCL_ERROR)
+ return TCL_ERROR;
+#if 0
obj->stepSize = 0;
obj->numberOfTermsRequested = 20;
obj->preferredPositionInResponse = 1;
obj->entries = NULL;
obj->nonSurrogateDiagnostics = NULL;
+#endif
obj->parent = (IRObj *) parent_info.clientData;
Tcl_CreateCommand (interp, argv[1], ir_scan_obj_method,
logf (LOG_DEBUG, "cs_rcvconnect error");
if (p->failback)
Tcl_Eval (p->interp, p->failback);
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
return;
}
if (p->callback)
}
do
{
+ /* signal one more use of ir object - callbacks must not
+ release the ir memory (p pointer) */
+ ++(p->ref_count);
if ((r=cs_get (p->cs_link, &p->buf_in, &p->len_in)) <= 0)
{
logf (LOG_DEBUG, "cs_get failed, code %d", r);
ir_select_remove (cs_fileno (p->cs_link), p);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
+
+ /* relase ir object now if callback deleted it */
+ ir_obj_delete (p);
return;
}
if (r == 1)
logf (LOG_DEBUG, "%s", odr_errlist [odr_geterror (p->odr_in)]);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
+
+ /* relase ir object now if callback deleted it */
+ ir_obj_delete (p);
return;
}
switch(apdu->which)
logf (LOG_WARN, "Received unknown APDU type (%d)", apdu->which);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
}
odr_reset (p->odr_in);
if (p->callback)
Tcl_Eval (p->interp, p->callback);
+ if (p->ref_count == 1)
+ {
+ ir_obj_delete (p);
+ return;
+ }
+ --(p->ref_count);
} while (p->cs_link && cs_more (p->cs_link));
}
ir_select_remove_write (cs_fileno (p->cs_link), p);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
return;
}
ir_select_remove_write (cs_fileno (p->cs_link), p);
logf (LOG_DEBUG, "select write fail");
if (p->failback)
Tcl_Eval (p->interp, p->failback);
- do_disconnect (p, NULL, 0, NULL);
+ do_disconnect (p, NULL, 2, NULL);
}
else if (r == 0) /* remove select bit */
{