Code updates which makes things compile as C++. Mostly type casts were
[yaz-moved-to-github.git] / client / client.c
index d8edfe1..20697e3 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.334 2007-04-16 21:53:08 adam Exp $
+ * $Id: client.c,v 1.337 2007-05-06 20:12:19 adam Exp $
  */
 /** \file client.c
  *  \brief yaz-client program
@@ -173,7 +173,7 @@ int rl_attempted_completion_over = 0;
 #define AVOID_MARC_DECODE 1
 
 #define maxOtherInfosSupported 10
-struct {
+struct eoi {
     int oid[OID_SIZE];
     char* value;
 } extraOtherInfos[maxOtherInfosSupported];
@@ -349,7 +349,8 @@ static void send_initRequest(const char* type_and_host)
         
         yaz_oi_APDU(apdu, &p);
         
-        if ((p0=yaz_oi_update(p, out, NULL, 0, 0))) {
+        if ((p0=yaz_oi_update(p, out, NULL, 0, 0)))
+        {
             ODR_MASK_SET(req->options, Z_Options_negotiationModel);
             
             p0->which = Z_OtherInfo_externallyDefinedInfo;
@@ -360,7 +361,6 @@ static void send_initRequest(const char* type_and_host)
                                               negotiationCharsetRecords);
         }
     }
-    
     if (send_apdu(apdu))
         printf("Sent initrequest.\n");
 }
@@ -453,7 +453,7 @@ static int process_initResponse(Z_InitResponse *res)
     
         Z_CharSetandLanguageNegotiation *p =
                 yaz_get_charneg_record(res->otherInfo);
-        
+
         if (p) {
             
             char *charset=NULL, *lang=NULL;
@@ -462,18 +462,20 @@ static int process_initResponse(Z_InitResponse *res)
             yaz_get_response_charneg(session_mem, p, &charset, &lang,
                                      &selected);
 
+            printf("Accepted character set : %s\n", charset);
+            printf("Accepted code language : %s\n", lang ? lang : "none");
+            printf("Accepted records in ...: %d\n", selected );
+
             if (outputCharset && negotiationCharset) {
-                    odr_set_charset (out, charset, outputCharset);
-                    odr_set_charset (in, outputCharset, charset);
+                printf("Converting between %s and %s\n",
+                       outputCharset, negotiationCharset);
+                odr_set_charset (out, charset, outputCharset);
+                odr_set_charset (in, outputCharset, charset);
             }
             else {
-                    odr_set_charset (out, 0, 0);
-                    odr_set_charset (in, 0, 0);
+                odr_set_charset (out, 0, 0);
+                odr_set_charset (in, 0, 0);
             }
-            
-            printf("Accepted character set : %s\n", charset);
-            printf("Accepted code language : %s\n", lang ? lang : "none");
-            printf("Accepted records in ...: %d\n", selected );
         }
     }
     fflush (stdout);
@@ -622,7 +624,7 @@ static int parse_cmd_doc(const char **arg, ODR out, char **buf,
             return 0;
         }
         *len = fsize;
-        *buf = odr_malloc(out, fsize);
+        *buf = (char *) odr_malloc(out, fsize);
         if (fread(*buf, 1, fsize, inf) != fsize)
         {
             printf("Unable to read %s\n", fname);
@@ -1258,7 +1260,7 @@ static int send_srw(Z_SRW_PDU *sr)
     Z_GDU *gdu;
     char *path = 0;
 
-    path = odr_malloc(out, 2+strlen(databaseNames[0]));
+    path = (char *) odr_malloc(out, 2+strlen(databaseNames[0]));
     *path = '/';
     strcpy(path+1, databaseNames[0]);
 
@@ -2246,11 +2248,10 @@ static int cmd_update_Z3950(int version, int action_no, const char *recid,
         record_this = record_last;
     }
 
-    req->packageType =
-        yaz_string_to_oid_odr(yaz_oid_std(),
-                              CLASS_EXTSERV, 
-                              version == 0 ? "DB. Update (first version)" :
-                              "DB. Update", out);
+    req->packageType = odr_oiddup(out, (version == 0 ? 
+       yaz_oid_extserv_database_update_first_version :
+       yaz_oid_extserv_database_update));
+
     req->packageName = esPackageName;
     
     req->referenceId = set_refid (out);
@@ -3727,7 +3728,8 @@ static void initialize(void)
     /* If this fails, no problem: we detect cqltrans == 0 later */
 
 #if HAVE_READLINE_READLINE_H
-    rl_attempted_completion_function = (CPPFunction*)readline_completer;
+    rl_attempted_completion_function = 
+        (char **(*)(const char *, int, int)) readline_completer;
 #endif
     for(i = 0; i < maxOtherInfosSupported; ++i) {
         extraOtherInfos[i].oid[0] = -1;
@@ -3862,7 +3864,7 @@ static void http_response(Z_HTTP_Response *hres)
                            soap_handlers);
         if (!ret && soap_package->which == Z_SOAP_generic)
         {
-            Z_SRW_PDU *sr = soap_package->u.generic->p;
+            Z_SRW_PDU *sr = (Z_SRW_PDU *) soap_package->u.generic->p;
             if (sr->which == Z_SRW_searchRetrieve_response)
                 handle_srw_response(sr->u.response);
             else if (sr->which == Z_SRW_explain_response)
@@ -4765,6 +4767,7 @@ int main(int argc, char **argv)
     ODR_MASK_SET(&z3950_options, Z_Options_sort);
     ODR_MASK_SET(&z3950_options, Z_Options_extendedServices);
     ODR_MASK_SET(&z3950_options, Z_Options_delSet);
+    ODR_MASK_SET(&z3950_options, Z_Options_negotiationModel);
 
     while ((ret = options("k:c:q:a:b:m:v:p:u:t:Vxd:", argv, argc, &arg)) != -2)
     {