Updated footer comment
[yaz-moved-to-github.git] / util / yaz-illclient.c
index f2734dc..cdaf416 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * Copyright (C) 1995-2006, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2009 Index Data
  * See the file LICENSE for details.
- *
- * $Id: yaz-illclient.c,v 1.7 2007-05-30 13:59:04 heikki 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;
-    char *version="$Id: yaz-illclient.c,v 1.7 2007-05-30 13:59:04 heikki Exp $"; /* from cvs */
+    char version[60];
     struct nameval *nv;
 
     /* default values */
@@ -222,8 +220,10 @@ void parseargs( int argc, char * argv[],  struct prog_args *args) {
             break;
         case 'l':
             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);
@@ -461,8 +461,9 @@ ILL_APDU *createrequest( struct prog_args *args, ODR odr) {
     if (args->oclc_auth) {
         req->num_iLL_request_extensions=2;
         req->iLL_request_extensions=
+            (ILL_Extension **)
             odr_malloc(odr, req->num_iLL_request_extensions*
-                            sizeof(*req->iLL_request_extensions));
+                       sizeof(*req->iLL_request_extensions));
         req->iLL_request_extensions[0]=makepromptextension(args,odr);
         req->iLL_request_extensions[1]=makeoclcextension(args,odr);
     }
@@ -502,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 */
@@ -687,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