Check for socklen_t type for accept, getpeername
[yaz-moved-to-github.git] / client / client.c
index 58f03f4..66ee3e9 100644 (file)
@@ -1,8 +1,8 @@
-/*
+/* 
  * Copyright (c) 1995-2002, Index Data
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.164 2002-08-29 21:35:38 ja7 Exp $
+ * $Id: client.c,v 1.167 2002-09-10 10:20:27 ja7 Exp $
  */
 
 #include <stdio.h>
@@ -898,6 +898,7 @@ static int send_searchRequest(char *arg)
     char setstring[100];
     Z_RPNQuery *RPNquery;
     Odr_oct ccl_query;
+    YAZ_PQF_Parser pqf_parser;
 
     if (queryType == QueryType_CCL2RPN)
     {
@@ -951,12 +952,20 @@ static int send_searchRequest(char *arg)
     {
     case QueryType_Prefix:
         query.which = Z_Query_type_1;
-        RPNquery = p_query_rpn (out, protocol, arg);
+        pqf_parser = yaz_pqf_create ();
+        RPNquery = yaz_pqf_parse (pqf_parser, out, arg);
         if (!RPNquery)
         {
-            printf("Prefix query error\n");
+            const char *pqf_msg;
+            size_t off;
+            int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
+            printf("%*s^\n", off+4, "");
+            printf("Prefix query error: %s (code %d)\n", pqf_msg, code);
+            
+            yaz_pqf_destroy (pqf_parser);
             return 0;
         }
+        yaz_pqf_destroy (pqf_parser);
         query.u.type_1 = RPNquery;
         break;
     case QueryType_CCL:
@@ -1852,7 +1861,6 @@ int send_scanrequest(const char *query, int pp, int num, const char *term)
 {
     Z_APDU *apdu = zget_APDU(out, Z_APDU_scanRequest);
     Z_ScanRequest *req = apdu->u.scanRequest;
-    int use_rpn = 1;
     int oid[OID_SIZE];
     
     if (queryType == QueryType_CCL2RPN)
@@ -1867,7 +1875,6 @@ int send_scanrequest(const char *query, int pp, int num, const char *term)
             printf("CCL ERROR: %s\n", ccl_err_msg(error));
             return -1;
         }
-        use_rpn = 0;
         bib1.proto = PROTO_Z3950;
         bib1.oclass = CLASS_ATTSET;
         bib1.value = VAL_BIB1;
@@ -1879,11 +1886,22 @@ int send_scanrequest(const char *query, int pp, int num, const char *term)
         }
         ccl_rpn_delete (rpn);
     }
-    if (use_rpn && !(req->termListAndStartPoint =
-                     p_query_scan(out, protocol, &req->attributeSet, query)))
+    else
     {
-        printf("Prefix query error\n");
-        return -1;
+        YAZ_PQF_Parser pqf_parser = yaz_pqf_create ();
+
+        if (!(req->termListAndStartPoint =
+              yaz_pqf_scan(pqf_parser, out, &req->attributeSet, query)))
+        {
+            const char *pqf_msg;
+            size_t off;
+            int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
+            printf("%*s^\n", off+7, "");
+            printf("Prefix query error: %s (code %d)\n", pqf_msg, code);
+            yaz_pqf_destroy (pqf_parser);
+            return -1;
+        }
+        yaz_pqf_destroy (pqf_parser);
     }
     if (term && *term)
     {
@@ -2796,9 +2814,9 @@ int cmd_list_all(char* args) {
                printf("Connected to         : %s\n",last_open_command);
        } else {
                if(last_open_command) 
-                       printf("Not Connected to     : %s\n",last_open_command);
+                       printf("Not connected to     : %s\n",last_open_command);
                else 
-                       printf("Not Connected        : \n");
+                       printf("Not connected        : \n");
 
        };
        if(yazProxy) printf("using proxy          : %s\n",yazProxy);            
@@ -2806,14 +2824,14 @@ int cmd_list_all(char* args) {
        printf("auto_reconnect       : %s\n",auto_reconnect?"on":"off");
 
        if (!auth) {
-               printf("Authentication       : NONE\n");
+               printf("Authentication       : none\n");
        } else {
                switch(auth->which) {
                case Z_IdAuthentication_idPass:
                        printf("Authentication       : IdPass\n"); 
-                       printf("    Login            : %s\n",auth->u.idPass->userId?auth->u.idPass->userId:"");
-                       printf("    LoginGroup       : %s\n",auth->u.idPass->groupId?auth->u.idPass->groupId:"");
-                       printf("    PassWord         : %s\n",auth->u.idPass->password?auth->u.idPass->password:"");
+                       printf("    Login User       : %s\n",auth->u.idPass->userId?auth->u.idPass->userId:"");
+                       printf("    Login Group      : %s\n",auth->u.idPass->groupId?auth->u.idPass->groupId:"");
+                       printf("    Password         : %s\n",auth->u.idPass->password?auth->u.idPass->password:"");
                        break;
                case Z_IdAuthentication_open:
                        printf("Authentication       : psOpen\n");                      
@@ -2832,20 +2850,20 @@ int cmd_list_all(char* args) {
        
        /* Query options */
        printf("CCL file             : %s\n",ccl_fields);
-       printf("Qurry type           : %s\n",query_type_as_string(queryType));
+       printf("Query type           : %s\n",query_type_as_string(queryType));
        
-       printf("ElementSet numbering : %s\n",setnumber==-1?"off":"on");
+       printf("Named Result Sets    : %s\n",setnumber==-1?"off":"on");
 
        /* piggy back options */
        printf("ssub/lslb/mspn       : %d/%d/%d\n",smallSetUpperBound,largeSetLowerBound,mediumSetPresentNumber);
        
        /* print present related options */
-       printf("format               : %s\n",yaz_z3950_oid_value_to_str(recordsyntax,CLASS_RECSYN));
-       printf("schema               : %s\n",yaz_z3950_oid_value_to_str(schema,CLASS_SCHEMA));
-       printf("elements             : %s\n",elementSetNames?elementSetNames->u.generic:"");
+       printf("Format               : %s\n",yaz_z3950_oid_value_to_str(recordsyntax,CLASS_RECSYN));
+       printf("Schema               : %s\n",yaz_z3950_oid_value_to_str(schema,CLASS_SCHEMA));
+       printf("Elements             : %s\n",elementSetNames?elementSetNames->u.generic:"");
 
        /* loging options */
-       printf("Apdu log             : %s\n",apdu_file?"on":"off");
+       printf("APDU log             : %s\n",apdu_file?"on":"off");
        printf("Record log           : %s\n",marcdump?"on":"off");
        
        /* other infos */
@@ -3312,7 +3330,7 @@ int main(int argc, char **argv)
 
 /*
  * Local variables:
- * tab-width: 4
+ * tab-width: 8
  * c-basic-offset: 4
  * End:
  */