+ {
+ logf (LOG_DEBUG, "Whole scan request (%d bytes)", p->slen);
+ }
+ return TCL_OK;
+}
+
+/*
+ * do_stepSize: Set/get replace Step Size
+ */
+static int do_stepSize (void *obj, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IrTcl_ScanObj *p = obj;
+ if (argc <= 0)
+ {
+ p->stepSize = 0;
+ return TCL_OK;
+ }
+ return get_set_int (&p->stepSize, interp, argc, argv);
+}
+
+/*
+ * do_numberOfTermsRequested: Set/get Number of Terms requested
+ */
+static int do_numberOfTermsRequested (void *obj, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IrTcl_ScanObj *p = obj;
+
+ if (argc <= 0)
+ {
+ p->numberOfTermsRequested = 20;
+ return TCL_OK;
+ }
+ return get_set_int (&p->numberOfTermsRequested, interp, argc, argv);
+}
+
+
+/*
+ * do_preferredPositionInResponse: Set/get preferred Position
+ */
+static int do_preferredPositionInResponse (void *obj, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IrTcl_ScanObj *p = obj;
+
+ if (argc <= 0)
+ {
+ p->preferredPositionInResponse = 1;
+ return TCL_OK;
+ }
+ return get_set_int (&p->preferredPositionInResponse, interp, argc, argv);
+}
+
+/*
+ * do_scanStatus: Get scan status
+ */
+static int do_scanStatus (void *obj, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IrTcl_ScanObj *p = obj;
+
+ if (argc <= 0)
+ return TCL_OK;
+ return get_set_int (&p->scanStatus, interp, argc, argv);
+}
+
+/*
+ * do_numberOfEntriesReturned: Get number of Entries returned
+ */
+static int do_numberOfEntriesReturned (void *obj, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IrTcl_ScanObj *p = obj;
+
+ if (argc <= 0)
+ return TCL_OK;
+ return get_set_int (&p->numberOfEntriesReturned, interp, argc, argv);
+}
+
+/*
+ * do_positionOfTerm: Get position of Term
+ */
+static int do_positionOfTerm (void *obj, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IrTcl_ScanObj *p = obj;
+
+ if (argc <= 0)
+ return TCL_OK;
+ return get_set_int (&p->positionOfTerm, interp, argc, argv);
+}
+
+/*
+ * do_scanLine: get Scan Line (surrogate or normal) after response
+ */
+static int do_scanLine (void *obj, Tcl_Interp *interp, int argc, char **argv)
+{
+ IrTcl_ScanObj *p = obj;
+ 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_ERROR;
+ }
+ if (Tcl_GetInt (interp, argv[2], &i) == TCL_ERROR)
+ return TCL_ERROR;
+ if (!p->entries_flag || p->which != Z_ListEntries_entries || !p->entries
+ || i >= p->num_entries || i < 0)
+ return TCL_OK;
+ switch (p->entries[i].which)
+ {
+ case Z_Entry_termInfo:
+ Tcl_AppendElement (interp, "T");
+ if (p->entries[i].u.term.buf)
+ Tcl_AppendElement (interp, p->entries[i].u.term.buf);
+ else
+ Tcl_AppendElement (interp, "");
+ sprintf (numstr, "%d", p->entries[i].u.term.globalOccurrences);
+ Tcl_AppendElement (interp, numstr);
+ break;
+ case Z_Entry_surrogateDiagnostic:
+ return
+ mk_nonSurrogateDiagnostics (interp, p->entries[i].u.diag.condition,
+ p->entries[i].u.diag.addinfo);
+ break;
+ }
+ return TCL_OK;
+}
+
+static IrTcl_Method ir_scan_method_tab[] = {
+ { 0, "scan", do_scan },
+ { 0, "stepSize", do_stepSize },
+ { 0, "numberOfTermsRequested", do_numberOfTermsRequested },
+ { 0, "preferredPositionInResponse", do_preferredPositionInResponse },
+ { 0, "scanStatus", do_scanStatus },
+ { 0, "numberOfEntriesReturned", do_numberOfEntriesReturned },
+ { 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)
+{
+ IrTcl_Methods tabs[2];
+
+ if (argc < 2)
+ {
+ interp->result = "wrong # args";
+ return TCL_ERROR;
+ }
+ tabs[0].tab = ir_scan_method_tab;
+ tabs[0].obj = clientData;
+ tabs[1].tab = NULL;
+
+ return ir_method (interp, argc, argv, tabs);
+}
+
+/*
+ * ir_scan_obj_delete: IR Scan Object disposal
+ */
+static void ir_scan_obj_delete (ClientData clientData)
+{
+ IrTcl_Methods tabs[2];
+ IrTcl_ScanObj *obj = clientData;
+
+ tabs[0].tab = ir_scan_method_tab;
+ tabs[0].obj = obj;
+ tabs[1].tab = NULL;
+
+ ir_method (NULL, -1, NULL, tabs);
+ free (obj);