Bump copyright year
[yaz-moved-to-github.git] / util / yaz-illclient.c
index b65c9e6..979400c 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * Copyright (C) 1995-2006, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
  * See the file LICENSE for details.
- *
- * $Id: yaz-illclient.c,v 1.9 2007-11-30 11:44:47 adam Exp $
  */
 
 /* WARNING - This is work in progress - not at all ready */
@@ -184,7 +182,7 @@ void parseargs( int argc, char * argv[],  struct prog_args *args) {
     int ret;
     char *arg;
     char *prog=*argv;
-    const char *version="$Id: yaz-illclient.c,v 1.9 2007-11-30 11:44:47 adam Exp $"; /* from cvs */
+    char version[60];
     struct nameval *nv;
 
     /* default values */
@@ -224,7 +222,8 @@ void parseargs( int argc, char * argv[],  struct prog_args *args) {
             yaz_log_init_file(arg);
             break;
         case 'V':
-            printf("%s %s",prog, version );
+            yaz_version(version, 0);
+            printf("%s %s\n",prog, version);
             break;
         case 'D':
             nv=parse_nameval(arg);
@@ -369,7 +368,7 @@ ILL_Extension *makepromptextension(struct prog_args *args, ODR odr) {
     odr_reset(odr_prt); /*!*/
 
     e->identifier = odr_intdup(odr,1);
-    e->critical = odr_intdup(odr,0);
+    e->critical = odr_booldup(odr,0);
     e->item = (Odr_any *) odr_malloc(odr,sizeof(*e->item));
     if ( ! z_External(odr_ext, &ext,0,0) ) {
         yaz_log(YLOG_FATAL,"Encoding of z_External failed ");
@@ -428,7 +427,7 @@ ILL_Extension *makeoclcextension(struct prog_args *args, ODR odr) {
     odr_reset(odr_prt); /*!*/
 
     e->identifier = odr_intdup(odr,1);
-    e->critical = odr_intdup(odr,0);
+    e->critical = odr_booldup(odr,0);
     e->item = (Odr_any *) odr_malloc(odr,sizeof(*e->item));
     if ( ! z_External(odr_ext, &ext,0,0) ) {
         yaz_log(YLOG_FATAL,"Encoding of z_External failed ");
@@ -504,8 +503,17 @@ void sendrequest(ILL_APDU *apdu, ODR odr, COMSTACK stack ) {
     }
     if (1) {
         FILE *F = fopen("req.apdu","w");
-        fwrite ( buf_out, 1, len_out, F);
-        fclose(F);
+        if (!F)
+        {
+            yaz_log(YLOG_FATAL|YLOG_ERRNO, "open req.apdu failed");
+        }
+        else
+        {
+            if (fwrite ( buf_out, 1, len_out, F) != len_out)
+                yaz_log(YLOG_FATAL|YLOG_ERRNO, "write req.apdu failed");
+            if (fclose(F))
+                yaz_log(YLOG_FATAL|YLOG_ERRNO, "write req.apdu failed");
+        }
     }
     
 } /* sendrequest */
@@ -600,7 +608,7 @@ void checkerr( ILL_Status_Or_Error_Report *staterr ) {
                     printf("Already forwarded: \n");
                     break;
                 case ILL_User_Error_Report_intermediary_problem:
-                    printf("Intermediary problem: %d\n", 
+                    printf("Intermediary problem: " ODR_INT_PRINTF "\n", 
                         *uerr->u.intermediary_problem);
                     break;
                 case ILL_User_Error_Report_security_problem:
@@ -608,7 +616,7 @@ void checkerr( ILL_Status_Or_Error_Report *staterr ) {
                         getillstring(uerr->u.security_problem));
                     break;
                 case ILL_User_Error_Report_unable_to_perform:
-                    printf("Unable to perform: %d\n", 
+                    printf("Unable to perform: " ODR_INT_PRINTF "\n", 
                           *uerr->u.unable_to_perform);
                     break;
                 default:
@@ -620,11 +628,11 @@ void checkerr( ILL_Status_Or_Error_Report *staterr ) {
             ILL_Provider_Error_Report *perr= err->provider_error_report;
             switch( perr->which ) {
                 case ILL_Provider_Error_Report_general_problem:
-                    printf("General Problem: %d:", 
+                    printf("General Problem: " ODR_INT_PRINTF ":", 
                           *perr->u.general_problem);
                     break;
                 case ILL_Provider_Error_Report_transaction_id_problem:
-                    printf("Transaction Id Problem: %d:", 
+                    printf("Transaction Id Problem: " ODR_INT_PRINTF ":", 
                           *perr->u.general_problem);
                     break;
                 case ILL_Provider_Error_Report_state_transition_prohibited:
@@ -689,6 +697,7 @@ int main (int argc, char * argv[]) {
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab