Cosmetic.
authorSebastian Hammer <quinn@indexdata.com>
Tue, 6 Jun 1995 08:15:19 +0000 (08:15 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Tue, 6 Jun 1995 08:15:19 +0000 (08:15 +0000)
client/client.c
server/seshigh.c
server/statserv.c

index dafd7ef..612da41 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: client.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: client.c,v $
- * Revision 1.8  1995-06-05 10:52:22  quinn
+ * Revision 1.9  1995-06-06 08:15:19  quinn
+ * Cosmetic.
+ *
+ * Revision 1.8  1995/06/05  10:52:22  quinn
  * Added SCAN.
  *
  * Revision 1.7  1995/06/02  09:50:09  quinn
  * Added SCAN.
  *
  * Revision 1.7  1995/06/02  09:50:09  quinn
@@ -78,6 +81,8 @@ static int setno = 1;                   /* current set offset */
 static int protocol = PROTO_Z3950;      /* current app protocol */
 static ODR_MEM session_mem;                /* memory handle for init-response */
 static Z_InitResponse *session = 0;        /* session parameters */
 static int protocol = PROTO_Z3950;      /* current app protocol */
 static ODR_MEM session_mem;                /* memory handle for init-response */
 static Z_InitResponse *session = 0;        /* session parameters */
+static char last_scan[512] = "0";
+static char last_cmd[100] = "?";
 #ifdef RPN_QUERY
 #ifndef PREFIX_QUERY
 static CCL_bibset bibset;               /* CCL bibset handle */
 #ifdef RPN_QUERY
 #ifndef PREFIX_QUERY
 static CCL_bibset bibset;               /* CCL bibset handle */
@@ -127,7 +132,7 @@ static void send_initRequest()
 
 static int process_initResponse(Z_InitResponse *res)
 {
 
 static int process_initResponse(Z_InitResponse *res)
 {
-    /* save parameters for later use */
+    /* save session parameters for later use */
     session_mem = odr_extract_mem(in);
     session = res;
 
     session_mem = odr_extract_mem(in);
     session = res;
 
@@ -569,9 +574,6 @@ int send_scanrequest(char *string, int pp, int num)
     Z_ScanRequest *req = apdu->u.scanRequest;
     char *db = database;
     oident attset;
     Z_ScanRequest *req = apdu->u.scanRequest;
     char *db = database;
     oident attset;
-    Z_AttributesPlusTerm sp;
-    Z_Term term;
-    Odr_oct trm;
 
     req->num_databaseNames = 1;
     req->databaseNames = &db;
 
     req->num_databaseNames = 1;
     req->databaseNames = &db;
@@ -579,14 +581,7 @@ int send_scanrequest(char *string, int pp, int num)
     attset.class = CLASS_ATTSET;
     attset.value = VAL_BIB1;
     req->attributeSet = oid_getoidbyent(&attset);
     attset.class = CLASS_ATTSET;
     attset.value = VAL_BIB1;
     req->attributeSet = oid_getoidbyent(&attset);
-    req->termListAndStartPoint = &sp;
-    sp.num_attributes = 0;
-    sp.attributeList = ODR_NULLVAL;
-    sp.term = &term;
-    term.which = Z_Term_general;
-    term.u.general = &trm;
-    trm.buf = (unsigned char*) string;
-    trm.len = trm.size = strlen(string);
+    req->termListAndStartPoint = p_query_scan(out, string);
     req->numberOfTermsRequested = &num;
     req->preferredPositionInResponse = &pp;
     send_apdu(apdu);
     req->numberOfTermsRequested = &num;
     req->preferredPositionInResponse = &pp;
     send_apdu(apdu);
@@ -596,8 +591,12 @@ int send_scanrequest(char *string, int pp, int num)
 void display_term(Z_TermInfo *t)
 {
     if (t->term->which == Z_Term_general)
 void display_term(Z_TermInfo *t)
 {
     if (t->term->which == Z_Term_general)
+    {
        printf("%.*s (%d)\n", t->term->u.general->len, t->term->u.general->buf,
            t->globalOccurrences ? *t->globalOccurrences : -1);
        printf("%.*s (%d)\n", t->term->u.general->len, t->term->u.general->buf,
            t->globalOccurrences ? *t->globalOccurrences : -1);
+       sprintf(last_scan, "%.*s", t->term->u.general->len,
+           t->term->u.general->buf);
+    }
     else
        printf("Term type not general.\n");
 }
     else
        printf("Term type not general.\n");
 }
@@ -642,8 +641,13 @@ int cmd_scan(char *arg)
        return 0;
     }
     if (*arg)
        return 0;
     }
     if (*arg)
+    {
        if (send_scanrequest(arg, 5, 19) < 0)
            return 0;
        if (send_scanrequest(arg, 5, 19) < 0)
            return 0;
+    }
+    else
+       if (send_scanrequest(last_scan, 1, 19) < 0)
+           return 0;
     return 2;
 }
 
     return 2;
 }
 
@@ -728,11 +732,12 @@ static int client(void)
                break;
            if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0)
            {
                break;
            if ((res = sscanf(line, "%s %[^;]", word, arg)) <= 0)
            {
-               printf(C_PROMPT);
-               continue;
+               strcpy(word, last_cmd);
+               *arg = '\0';
            }
            }
-           if (res == 1)
+           else if (res == 1)
                *arg = 0;
                *arg = 0;
+           strcpy(last_cmd, word);
            for (i = 0; cmd[i].cmd; i++)
                if (!strncmp(cmd[i].cmd, word, strlen(word)))
                {
            for (i = 0; cmd[i].cmd; i++)
                if (!strncmp(cmd[i].cmd, word, strlen(word)))
                {
index 130716b..252caa5 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: seshigh.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: seshigh.c,v $
- * Revision 1.30  1995-06-05 10:53:32  quinn
+ * Revision 1.31  1995-06-06 08:15:37  quinn
+ * Cosmetic.
+ *
+ * Revision 1.30  1995/06/05  10:53:32  quinn
  * Added a better SCAN.
  *
  * Revision 1.29  1995/06/01  11:25:03  quinn
  * Added a better SCAN.
  *
  * Revision 1.29  1995/06/01  11:25:03  quinn
@@ -293,6 +296,7 @@ void ir_session(IOCHAN h, int event)
                iochan_setevent(h, EVENT_INPUT);
                
            /* we got a complete PDU. Let's decode it */
                iochan_setevent(h, EVENT_INPUT);
                
            /* we got a complete PDU. Let's decode it */
+           logf(LOG_DEBUG, "Got PDU, %d bytes", res);
            req = request_get(); /* get a new request structure */
            odr_reset(assoc->decode);
            odr_setbuf(assoc->decode, assoc->input_buffer, res, 0);
            req = request_get(); /* get a new request structure */
            odr_reset(assoc->decode);
            odr_setbuf(assoc->decode, assoc->input_buffer, res, 0);
@@ -340,6 +344,7 @@ void ir_session(IOCHAN h, int event)
                iochan_destroy(h);
                break;
            case 0: /* all sent - release the request structure */
                iochan_destroy(h);
                break;
            case 0: /* all sent - release the request structure */
+               logf(LOG_DEBUG, "Wrote PDU, %d bytes", req->len_response);
                odr_release_mem(req->request_mem);
                request_deq(&assoc->outgoing);
                request_release(req);
                odr_release_mem(req->request_mem);
                request_deq(&assoc->outgoing);
                request_release(req);
@@ -951,6 +956,10 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
        srq.term = req->termListAndStartPoint;
        srq.term_position = req->preferredPositionInResponse ?
            *req->preferredPositionInResponse : 1;
        srq.term = req->termListAndStartPoint;
        srq.term_position = req->preferredPositionInResponse ?
            *req->preferredPositionInResponse : 1;
+       if (req->termListAndStartPoint->term->which == Z_Term_general)
+           logf(LOG_DEBUG, "  term: %.*s",
+               req->termListAndStartPoint->term->u.general->len,
+               req->termListAndStartPoint->term->u.general->buf);
        if (!(srs = bend_scan(assoc->backend, &srq, 0)))
            ents.u.nonSurrogateDiagnostics = diagrecs(assoc->proto, 2, 0);
        else if (srs->errcode)
        if (!(srs = bend_scan(assoc->backend, &srq, 0)))
            ents.u.nonSurrogateDiagnostics = diagrecs(assoc->proto, 2, 0);
        else if (srs->errcode)
index b172941..c556df9 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: statserv.c,v $
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: statserv.c,v $
- * Revision 1.20  1995-05-29 08:12:09  quinn
+ * Revision 1.21  1995-06-06 08:15:40  quinn
+ * Cosmetic.
+ *
+ * Revision 1.20  1995/05/29  08:12:09  quinn
  * Moved oid to util
  *
  * Revision 1.19  1995/05/16  09:37:27  quinn
  * Moved oid to util
  *
  * Revision 1.19  1995/05/16  09:37:27  quinn
@@ -300,7 +303,8 @@ static void add_listener(char *where, int what)
 
 static void catchchld(int num)
 {
 
 static void catchchld(int num)
 {
-    while (waitpid(-1, 0, WNOHANG) > 0);
+    while (waitpid(-1, 0, WNOHANG) > 0)
+       ;
     signal(SIGCHLD, catchchld);
 }
 
     signal(SIGCHLD, catchchld);
 }