Expanded tabs in all source files. Added vim/emacs local variables
authorAdam Dickmeiss <adam@indexdata.dk>
Sat, 25 Jun 2005 15:46:01 +0000 (15:46 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Sat, 25 Jun 2005 15:46:01 +0000 (15:46 +0000)
trailer.

161 files changed:
client/admin.c
client/admin.h
client/bertorture.c
client/client.c
client/tabcomplete.c
client/tabcomplete.h
header.c
include/yaz/backend.h
include/yaz/ccl.h
include/yaz/charneg.h
include/yaz/comstack.h
include/yaz/cql.h
include/yaz/ill.h
include/yaz/log.h
include/yaz/logrpn.h
include/yaz/marcdisp.h
include/yaz/nmem.h
include/yaz/odr.h
include/yaz/oid.h
include/yaz/options.h
include/yaz/otherinfo.h
include/yaz/pquery.h
include/yaz/proto.h
include/yaz/prt-ext.h
include/yaz/readconf.h
include/yaz/soap.h
include/yaz/sortspec.h
include/yaz/srw.h
include/yaz/statserv.h
include/yaz/tcpip.h
include/yaz/tpath.h
include/yaz/unix.h
include/yaz/wrbuf.h
include/yaz/xmalloc.h
include/yaz/yaz-ccl.h
include/yaz/yaz-iconv.h
include/yaz/yaz-util.h
include/yaz/yaz-version.h
include/yaz/yconfig.h
include/yaz/zgdu.h
include/yaz/zoom.h
rfc1006/makensap.c
rfc1006/rfct.c
src/atoin.c
src/ber_any.c
src/ber_bit.c
src/ber_bool.c
src/ber_int.c
src/ber_len.c
src/ber_null.c
src/ber_oct.c
src/ber_oid.c
src/ber_tag.c
src/cclerrms.c
src/cclfind.c
src/cclptree.c
src/cclqfile.c
src/cclqual.c
src/cclstr.c
src/ccltoken.c
src/charneg.c
src/comstack.c
src/cqlstdio.c
src/cqlstrer.c
src/cqlstring.c
src/cqltransform.c
src/cqlutil.c
src/diag-entry.c
src/diag-entry.h
src/dumpber.c
src/eventl.c
src/eventl.h
src/grs1disp.c
src/ill-get.c
src/initopt.c
src/log.c
src/logrpn.c
src/marcdisp.c
src/matchstr.c
src/nmem.c
src/nmemsdup.c
src/odr-priv.h
src/odr.c
src/odr_any.c
src/odr_bit.c
src/odr_bool.c
src/odr_choice.c
src/odr_cons.c
src/odr_enum.c
src/odr_int.c
src/odr_mem.c
src/odr_null.c
src/odr_oct.c
src/odr_oid.c
src/odr_seq.c
src/odr_tag.c
src/odr_use.c
src/odr_util.c
src/oid.c
src/opacdisp.c
src/options.c
src/otherinfo.c
src/pquery.c
src/prt-ext.c
src/readconf.c
src/requestq.c
src/service.c
src/service.h
src/seshigh.c
src/session.h
src/siconv.c
src/soap.c
src/sortspec.c
src/srw.c
src/srwutil.c
src/statserv.c
src/tcpdchk.c
src/tcpip.c
src/tpath.c
src/unix.c
src/version.c
src/waislen.c
src/wrbuf.c
src/xcqlutil.c
src/xmalloc.c
src/yaz-ccl.c
src/z3950oid.c
src/zgdu.c
src/zget.c
src/zoom-c.c
src/zoom-opt.c
src/zoom-p.h
test/tstccl.c
test/tsticonv.c
test/tstlog.c
test/tstmatchstr.c
test/tstnmem.c
test/tstodr.c
test/tstsoap1.c
test/tstsoap2.c
test/tstwrbuf.c
util/benchmark.c
util/cclsh.c
util/cql2pqf.c
util/cql2xcql.c
util/marcdump.c
util/srwtst.c
util/yaziconv.c
win/resource.h
zoom/zoomsh.c
zoom/zoomtst1.c
zoom/zoomtst2.c
zoom/zoomtst3.c
zoom/zoomtst4.c
zoom/zoomtst5.c
zoom/zoomtst6.c
zoom/zoomtst7.c
zoom/zoomtst8.c
ztest/read-grs.c
ztest/read-marc.c
ztest/ztest.c

index 84674be..9dddf0d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: admin.c,v 1.20 2005-06-24 19:56:52 adam Exp $
+ * $Id: admin.c,v 1.21 2005-06-25 15:46:01 adam Exp $
  */
 
 #include <stdio.h>
@@ -85,44 +85,44 @@ int sendAdminES(int type, char* param1)
     switch ( type )
     {
     case Z_ESAdminOriginPartToKeep_reIndex:
-       toKeep->u.reIndex=odr_nullval();
-       break;
-       
+        toKeep->u.reIndex=odr_nullval();
+        break;
+        
     case Z_ESAdminOriginPartToKeep_truncate:
-       toKeep->u.truncate=odr_nullval();
-       break;
+        toKeep->u.truncate=odr_nullval();
+        break;
     case Z_ESAdminOriginPartToKeep_drop:
-       toKeep->u.drop=odr_nullval();
-       break;
+        toKeep->u.drop=odr_nullval();
+        break;
     case Z_ESAdminOriginPartToKeep_create:
-       toKeep->u.create=odr_nullval();
-       break;
+        toKeep->u.create=odr_nullval();
+        break;
     case Z_ESAdminOriginPartToKeep_import:
-       toKeep->u.import = (Z_ImportParameters*)
+        toKeep->u.import = (Z_ImportParameters*)
             odr_malloc(out, sizeof(*toKeep->u.import));
-       toKeep->u.import->recordType=param1;
-       /* Need to add additional setup of records here */
-       break;
+        toKeep->u.import->recordType=param1;
+        /* Need to add additional setup of records here */
+        break;
     case Z_ESAdminOriginPartToKeep_refresh:
-       toKeep->u.refresh=odr_nullval();
-       break;
+        toKeep->u.refresh=odr_nullval();
+        break;
     case Z_ESAdminOriginPartToKeep_commit:
-       toKeep->u.commit=odr_nullval();
-       break;
+        toKeep->u.commit=odr_nullval();
+        break;
     case Z_ESAdminOriginPartToKeep_shutdown:
-       toKeep->u.commit=odr_nullval();
-       break;
+        toKeep->u.commit=odr_nullval();
+        break;
     case Z_ESAdminOriginPartToKeep_start:
-       toKeep->u.commit=odr_nullval();
-       break;
+        toKeep->u.commit=odr_nullval();
+        break;
     default:
-       /* Unknown admin service */
-       break;
+        /* Unknown admin service */
+        break;
     }
     
     notToKeep = r->u.adminService->u.esRequest->notToKeep =
-       (Z_ESAdminOriginPartNotToKeep *)
-       odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->notToKeep));
+        (Z_ESAdminOriginPartNotToKeep *)
+        odr_malloc(out, sizeof(*r->u.adminService->u.esRequest->notToKeep));
     notToKeep->which=Z_ESAdminOriginPartNotToKeep_recordsWillFollow;
     notToKeep->u.recordsWillFollow=odr_nullval();
     
@@ -147,7 +147,7 @@ int cmd_adm_truncate(const char *arg)
     if ( arg )
     {
         sendAdminES(Z_ESAdminOriginPartToKeep_truncate, NULL);
-       return 2;
+        return 2;
     }
     return 0;
 }
@@ -159,7 +159,7 @@ int cmd_adm_create(const char *arg)
     if ( arg )
     {
         sendAdminES(Z_ESAdminOriginPartToKeep_create, NULL);
-       return 2;
+        return 2;
     }
     return 0;
 }
@@ -171,7 +171,7 @@ int cmd_adm_drop(const char *arg)
     if ( arg )
     {
         sendAdminES(Z_ESAdminOriginPartToKeep_drop, NULL);
-       return 2;
+        return 2;
     }
     return 0;
 }
@@ -195,69 +195,69 @@ int cmd_adm_import(const char *arg)
     ODR out = getODROutputStream();
 
     if (arg && sscanf (arg, "%19s %1023s %1023s", type_str,
-                      dir_str, pattern_str) != 3)
-       return 0;
+                       dir_str, pattern_str) != 3)
+        return 0;
     if (num_databaseNames != 1)
-       return 0;
+        return 0;
     dir = opendir(dir_str);
     if (!dir)
-       return 0;
+        return 0;
     
     sendAdminES(Z_ESAdminOriginPartToKeep_import, type_str);
     
     printf ("sent es request\n");
     if ((cp=strrchr(dir_str, '/')) && cp[1] == 0)
-       sep="";
-       
+        sep="";
+        
     while ((ent = readdir(dir)))
     {
-       if (fnmatch (pattern_str, ent->d_name, 0) == 0)
-       {
-           char fname[1024];
-           struct stat status;
-           FILE *inf;
-               
-           sprintf (fname, "%s%s%s", dir_str, sep, ent->d_name);
-           stat (fname, &status);
+        if (fnmatch (pattern_str, ent->d_name, 0) == 0)
+        {
+            char fname[1024];
+            struct stat status;
+            FILE *inf;
+                
+            sprintf (fname, "%s%s%s", dir_str, sep, ent->d_name);
+            stat (fname, &status);
 
-           if (S_ISREG(status.st_mode) && (inf = fopen(fname, "r")))
-           {
-               Z_NamePlusRecord *rec;
-               Odr_oct *oct = (Odr_oct *) odr_malloc (out, sizeof(*oct));
+            if (S_ISREG(status.st_mode) && (inf = fopen(fname, "r")))
+            {
+                Z_NamePlusRecord *rec;
+                Odr_oct *oct = (Odr_oct *) odr_malloc (out, sizeof(*oct));
 
-               if (!apdu)
-               {
-                   apdu = zget_APDU(out, Z_APDU_segmentRequest);
-                   segment = apdu->u.segmentRequest;
-                   segment->segmentRecords = (Z_NamePlusRecord **)
-                       odr_malloc (out, chunk * sizeof(*segment->segmentRecords));
-               }
-               rec = (Z_NamePlusRecord *) odr_malloc (out, sizeof(*rec));
-               rec->databaseName = 0;
-               rec->which = Z_NamePlusRecord_intermediateFragment;
-               rec->u.intermediateFragment = (Z_FragmentSyntax *)
-                   odr_malloc (out, sizeof(*rec->u.intermediateFragment));
-               rec->u.intermediateFragment->which =
-                   Z_FragmentSyntax_notExternallyTagged;
-               rec->u.intermediateFragment->u.notExternallyTagged = oct;
-               
-               oct->len = oct->size = status.st_size;
-               oct->buf = (unsigned char *) odr_malloc (out, oct->size);
-               fread (oct->buf, 1, oct->size, inf);
-               fclose (inf);
-               
-               segment->segmentRecords[segment->num_segmentRecords++] = rec;
+                if (!apdu)
+                {
+                    apdu = zget_APDU(out, Z_APDU_segmentRequest);
+                    segment = apdu->u.segmentRequest;
+                    segment->segmentRecords = (Z_NamePlusRecord **)
+                        odr_malloc (out, chunk * sizeof(*segment->segmentRecords));
+                }
+                rec = (Z_NamePlusRecord *) odr_malloc (out, sizeof(*rec));
+                rec->databaseName = 0;
+                rec->which = Z_NamePlusRecord_intermediateFragment;
+                rec->u.intermediateFragment = (Z_FragmentSyntax *)
+                    odr_malloc (out, sizeof(*rec->u.intermediateFragment));
+                rec->u.intermediateFragment->which =
+                    Z_FragmentSyntax_notExternallyTagged;
+                rec->u.intermediateFragment->u.notExternallyTagged = oct;
+                
+                oct->len = oct->size = status.st_size;
+                oct->buf = (unsigned char *) odr_malloc (out, oct->size);
+                fread (oct->buf, 1, oct->size, inf);
+                fclose (inf);
+                
+                segment->segmentRecords[segment->num_segmentRecords++] = rec;
 
-               if (segment->num_segmentRecords == chunk)
-               {
-                   send_apdu (apdu);
-                   apdu = 0;
-               }
-           }   
-       }
+                if (segment->num_segmentRecords == chunk)
+                {
+                    send_apdu (apdu);
+                    apdu = 0;
+                }
+            }   
+        }
     }
     if (apdu)
-       send_apdu(apdu);
+        send_apdu(apdu);
     apdu = zget_APDU(out, Z_APDU_segmentRequest);
     send_apdu (apdu);
     closedir(dir);
@@ -279,7 +279,7 @@ int cmd_adm_refresh(const char *arg)
     if ( arg )
     {
         sendAdminES(Z_ESAdminOriginPartToKeep_refresh, NULL);
-       return 2;
+        return 2;
     }
     return 0;
 }
@@ -303,3 +303,11 @@ int cmd_adm_startup(const char *arg)
     sendAdminES(Z_ESAdminOriginPartToKeep_start, NULL);
     return 2;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index ce862f0..0a87a11 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: admin.h,v 1.8 2005-01-15 19:47:08 adam Exp $
+ * $Id: admin.h,v 1.9 2005-06-25 15:46:01 adam Exp $
  */
 
 int cmd_adm_reindex(const char* arg);
@@ -18,9 +18,9 @@ int cmd_adm_startup(const char* arg);
 int send_apdu(Z_APDU *a);
 /*
  * Local variables:
- * tab-width: 8
  * c-basic-offset: 4
+ * indent-tabs-mode: nil
  * End:
- * vim600: sw=4 ts=8 fdm=marker
- * vim<600: sw=4 ts=8
+ * vim: shiftwidth=4 tabstop=8 expandtab
  */
+
index 79db2d2..d2a4b2f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: bertorture.c,v 1.3 2005-01-16 21:51:49 adam Exp $
+ * $Id: bertorture.c,v 1.4 2005-06-25 15:46:01 adam Exp $
  */
 
 #include <signal.h>
@@ -221,3 +221,11 @@ int main(int argc, char **argv)
             printf ("%3d %9d\n", i, estat[i]);
     exit(0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 14aa737..f85f0e1 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.291 2005-06-24 19:56:52 adam Exp $
+ * $Id: client.c,v 1.292 2005-06-25 15:46:01 adam Exp $
  */
 
 #include <stdio.h>
@@ -145,7 +145,7 @@ typedef enum {
 static QueryType queryType = QueryType_Prefix;
 
 static CCL_bibset bibset;               /* CCL bibset handle */
-static cql_transform_t cqltrans;       /* CQL context-set handle */
+static cql_transform_t cqltrans;        /* CQL context-set handle */
 
 #if HAVE_READLINE_COMPLETION_OVER
 
@@ -162,7 +162,7 @@ struct {
     int oidval;
     char* value;
 } extraOtherInfos[maxOtherInfosSupported];
-       
+        
 
 void process_cmd_line(char* line);
 char ** readline_completer(char *text, int start, int end);
@@ -194,31 +194,31 @@ static void do_hex_dump(const char* buf, int len)
 {
     if (hex_dump)
     {
-       int i,x;
-       for( i=0; i<len ; i=i+16 ) 
-       {                       
-           printf(" %4.4d ",i);
-           for(x=0 ; i+x<len && x<16; ++x) 
-           {
-               printf("%2.2X ",(unsigned int)((unsigned char)buf[i+x]));
-           }
-           printf("\n");
-       }
+        int i,x;
+        for( i=0; i<len ; i=i+16 ) 
+        {                       
+            printf(" %4.4d ",i);
+            for(x=0 ; i+x<len && x<16; ++x) 
+            {
+                printf("%2.2X ",(unsigned int)((unsigned char)buf[i+x]));
+            }
+            printf("\n");
+        }
     }
     if (dump_file_prefix)
     {
-       static int no = 0;
-       if (++no < 1000 && strlen(dump_file_prefix) < 500)
-       {
-           char fname[1024];
-           FILE *of;
-           sprintf (fname, "%s.%03d.raw", dump_file_prefix, no);
-           of = fopen(fname, "wb");
-           
-           fwrite (buf, 1, len, of);
-           
-           fclose(of);
-       }
+        static int no = 0;
+        if (++no < 1000 && strlen(dump_file_prefix) < 500)
+        {
+            char fname[1024];
+            FILE *of;
+            sprintf (fname, "%s.%03d.raw", dump_file_prefix, no);
+            of = fopen(fname, "wb");
+            
+            fwrite (buf, 1, len, of);
+            
+            fclose(of);
+        }
     }
 }
 
@@ -226,7 +226,7 @@ void add_otherInfos(Z_APDU *a)
 {
     Z_OtherInformation **oi;
     int i;
-               
+                
     yaz_oi_APDU(a, &oi);
     for(i=0; i<maxOtherInfosSupported; ++i) 
     {
@@ -313,7 +313,7 @@ static void send_initRequest(const char* type_and_host)
 
     ODR_MASK_ZERO(req->protocolVersion);
     for (i = 0; i<z3950_version; i++)
-       ODR_MASK_SET(req->protocolVersion, i);
+        ODR_MASK_SET(req->protocolVersion, i);
 
     *req->maximumRecordSize = 1024*kilobytes;
     *req->preferredMessageSize = 1024*kilobytes;
@@ -327,23 +327,23 @@ static void send_initRequest(const char* type_and_host)
         1, type_and_host);
     
     if (negotiationCharset || yazLang) {
-       Z_OtherInformation **p;
-       Z_OtherInformationUnit *p0;
-       
-       yaz_oi_APDU(apdu, &p);
-       
-       if ((p0=yaz_oi_update(p, out, NULL, 0, 0))) {
-           ODR_MASK_SET(req->options, Z_Options_negotiationModel);
-           
-           p0->which = Z_OtherInfo_externallyDefinedInfo;
-           p0->information.externallyDefinedInfo =
-               yaz_set_proposal_charneg(
-                   out,
-                   (const char**)&negotiationCharset, 
-                   negotiationCharset ? 1 : 0,
-                   (const char**)&yazLang, yazLang ? 1 : 0, 
-                   negotiationCharsetRecords);
-       }
+        Z_OtherInformation **p;
+        Z_OtherInformationUnit *p0;
+        
+        yaz_oi_APDU(apdu, &p);
+        
+        if ((p0=yaz_oi_update(p, out, NULL, 0, 0))) {
+            ODR_MASK_SET(req->options, Z_Options_negotiationModel);
+            
+            p0->which = Z_OtherInfo_externallyDefinedInfo;
+            p0->information.externallyDefinedInfo =
+                yaz_set_proposal_charneg(
+                    out,
+                    (const char**)&negotiationCharset, 
+                    negotiationCharset ? 1 : 0,
+                    (const char**)&yazLang, yazLang ? 1 : 0, 
+                    negotiationCharsetRecords);
+        }
     }
     
     if (send_apdu(apdu))
@@ -383,46 +383,46 @@ static int process_initResponse(Z_InitResponse *res)
         printf("Version: %s\n", res->implementationVersion);
     if (res->userInformationField)
     {
-       Z_External *uif = res->userInformationField;
-       if (uif->which == Z_External_userInfo1) {
-           render_initUserInfo(uif->u.userInfo1);
-       } else {
-           printf("UserInformationfield:\n");
-           if (!z_External(print, (Z_External**)&uif, 0, 0))
-           {
-               odr_perror(print, "Printing userinfo\n");
-               odr_reset(print);
-           }
-           if (uif->which == Z_External_octet) {
-               printf("Guessing visiblestring:\n");
-               printf("'%.*s'\n", uif->u.octet_aligned->len,
-                      uif->u.octet_aligned->buf);
-           }
-           else if (uif->which == Z_External_single) 
-           {
-               Odr_any *sat = uif->u.single_ASN1_type;
-               oident *oid = oid_getentbyoid(uif->direct_reference);
-               if (oid->value == VAL_OCLCUI) {
-                   Z_OCLC_UserInformation *oclc_ui;
-                   ODR decode = odr_createmem(ODR_DECODE);
-                   odr_setbuf(decode, sat->buf, sat->len, 0);
-                   if (!z_OCLC_UserInformation(decode, &oclc_ui, 0, 0))
-                       printf ("Bad OCLC UserInformation:\n");
-                   else
-                       printf ("OCLC UserInformation:\n");
-                   if (!z_OCLC_UserInformation(print, &oclc_ui, 0, 0))
-                       printf ("Bad OCLC UserInformation spec\n");
-                   odr_destroy(decode);
-               }
-               else
-               {
-                   /* Peek at any private Init-diagnostic APDUs */
-                   printf("### NAUGHTY: External is '%.*s'\n",
-                          sat->len, sat->buf);
-               }
-           }
-           odr_reset (print);
-       }
+        Z_External *uif = res->userInformationField;
+        if (uif->which == Z_External_userInfo1) {
+            render_initUserInfo(uif->u.userInfo1);
+        } else {
+            printf("UserInformationfield:\n");
+            if (!z_External(print, (Z_External**)&uif, 0, 0))
+            {
+                odr_perror(print, "Printing userinfo\n");
+                odr_reset(print);
+            }
+            if (uif->which == Z_External_octet) {
+                printf("Guessing visiblestring:\n");
+                printf("'%.*s'\n", uif->u.octet_aligned->len,
+                       uif->u.octet_aligned->buf);
+            }
+            else if (uif->which == Z_External_single) 
+            {
+                Odr_any *sat = uif->u.single_ASN1_type;
+                oident *oid = oid_getentbyoid(uif->direct_reference);
+                if (oid->value == VAL_OCLCUI) {
+                    Z_OCLC_UserInformation *oclc_ui;
+                    ODR decode = odr_createmem(ODR_DECODE);
+                    odr_setbuf(decode, sat->buf, sat->len, 0);
+                    if (!z_OCLC_UserInformation(decode, &oclc_ui, 0, 0))
+                        printf ("Bad OCLC UserInformation:\n");
+                    else
+                        printf ("OCLC UserInformation:\n");
+                    if (!z_OCLC_UserInformation(print, &oclc_ui, 0, 0))
+                        printf ("Bad OCLC UserInformation spec\n");
+                    odr_destroy(decode);
+                }
+                else
+                {
+                    /* Peek at any private Init-diagnostic APDUs */
+                    printf("### NAUGHTY: External is '%.*s'\n",
+                           sat->len, sat->buf);
+                }
+            }
+            odr_reset (print);
+        }
     }
     printf ("Options:");
     yaz_init_opt_decode(res->options, pr_opt, 0);
@@ -433,10 +433,10 @@ static int process_initResponse(Z_InitResponse *res)
     
     if (ODR_MASK_GET(res->options, Z_Options_negotiationModel)) {
     
-       Z_CharSetandLanguageNegotiation *p =
-               yaz_get_charneg_record(res->otherInfo);
-       
-       if (p) {
+        Z_CharSetandLanguageNegotiation *p =
+                yaz_get_charneg_record(res->otherInfo);
+        
+        if (p) {
             
             char *charset=NULL, *lang=NULL;
             int selected;
@@ -444,19 +444,19 @@ static int process_initResponse(Z_InitResponse *res)
             yaz_get_response_charneg(session_mem, p, &charset, &lang,
                                      &selected);
 
-           if (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);
-           }
+            if (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);
+            }
             
             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);
     return 0;
@@ -466,27 +466,27 @@ static int process_initResponse(Z_InitResponse *res)
 static void render_initUserInfo(Z_OtherInformation *ui1) {
     int i;
     printf("Init response contains %d otherInfo unit%s:\n",
-          ui1->num_elements, ui1->num_elements == 1 ? "" : "s");
+           ui1->num_elements, ui1->num_elements == 1 ? "" : "s");
 
     for (i = 0; i < ui1->num_elements; i++) {
-       Z_OtherInformationUnit *unit = ui1->list[i];
-       printf("  %d: otherInfo unit contains ", i+1);
-       if (unit->which == Z_OtherInfo_externallyDefinedInfo &&
-           unit->information.externallyDefinedInfo &&
-           unit->information.externallyDefinedInfo->which ==
-           Z_External_diag1) {
-           render_diag(unit->information.externallyDefinedInfo->u.diag1);
-       } 
-       else if (unit->which != Z_OtherInfo_externallyDefinedInfo)
-       {
-           printf("unsupported otherInfo unit->which = %d\n", unit->which);
-       }
-       else 
-       {
-           printf("unsupported otherInfo unit external %d\n",
-                  unit->information.externallyDefinedInfo ? 
-                  unit->information.externallyDefinedInfo->which : -2);
-       }
+        Z_OtherInformationUnit *unit = ui1->list[i];
+        printf("  %d: otherInfo unit contains ", i+1);
+        if (unit->which == Z_OtherInfo_externallyDefinedInfo &&
+            unit->information.externallyDefinedInfo &&
+            unit->information.externallyDefinedInfo->which ==
+            Z_External_diag1) {
+            render_diag(unit->information.externallyDefinedInfo->u.diag1);
+        } 
+        else if (unit->which != Z_OtherInfo_externallyDefinedInfo)
+        {
+            printf("unsupported otherInfo unit->which = %d\n", unit->which);
+        }
+        else 
+        {
+            printf("unsupported otherInfo unit external %d\n",
+                   unit->information.externallyDefinedInfo ? 
+                   unit->information.externallyDefinedInfo->which : -2);
+        }
     }
 }
 
@@ -497,30 +497,30 @@ static void render_diag(Z_DiagnosticFormat *diag) {
 
     printf("%d diagnostic%s:\n", diag->num, diag->num == 1 ? "" : "s");
     for (i = 0; i < diag->num; i++) {
-       Z_DiagnosticFormat_s *ds = diag->elements[i];
-       printf("    %d: ", i+1);
-       switch (ds->which) {
-       case Z_DiagnosticFormat_s_defaultDiagRec: {
-           Z_DefaultDiagFormat *dd = ds->u.defaultDiagRec;
-           /* ### should check `dd->diagnosticSetId' */
-           printf("code=%d (%s)", *dd->condition,
-                  diagbib1_str(*dd->condition));
-           /* Both types of addinfo are the same, so use type-pun */
-           if (dd->u.v2Addinfo != 0)
-               printf(",\n\taddinfo='%s'", dd->u.v2Addinfo);
-           break;
-       }
-       case Z_DiagnosticFormat_s_explicitDiagnostic:
-           printf("Explicit diagnostic (not supported)");
-           break;
-       default:
-           printf("Unrecognised diagnostic type %d", ds->which);
-           break;
-       }
-
-       if (ds->message != 0)
-           printf(", message='%s'", ds->message);
-       printf("\n");
+        Z_DiagnosticFormat_s *ds = diag->elements[i];
+        printf("    %d: ", i+1);
+        switch (ds->which) {
+        case Z_DiagnosticFormat_s_defaultDiagRec: {
+            Z_DefaultDiagFormat *dd = ds->u.defaultDiagRec;
+            /* ### should check `dd->diagnosticSetId' */
+            printf("code=%d (%s)", *dd->condition,
+                   diagbib1_str(*dd->condition));
+            /* Both types of addinfo are the same, so use type-pun */
+            if (dd->u.v2Addinfo != 0)
+                printf(",\n\taddinfo='%s'", dd->u.v2Addinfo);
+            break;
+        }
+        case Z_DiagnosticFormat_s_explicitDiagnostic:
+            printf("Explicit diagnostic (not supported)");
+            break;
+        default:
+            printf("Unrecognised diagnostic type %d", ds->which);
+            break;
+        }
+
+        if (ds->message != 0)
+            printf(", message='%s'", ds->message);
+        printf("\n");
     }
 }
 
@@ -562,70 +562,70 @@ static int set_base(const char *arg)
 }
 
 static int parse_cmd_doc(const char **arg, ODR out, char **buf,
-                        int *len, int opt)
+                         int *len, int opt)
 {
     const char *sep;
     while (**arg && strchr(" \t\n\r\f", **arg))
-       (*arg)++;
+        (*arg)++;
     if ((*arg)[0] == '\"' && (sep=strchr(*arg+1, '"')))
     {
-       (*arg)++;
-       *len = sep - *arg;
-       *buf = odr_strdupn(out, *arg, *len);
-       (*arg) = sep+1;
-       return 1;
+        (*arg)++;
+        *len = sep - *arg;
+        *buf = odr_strdupn(out, *arg, *len);
+        (*arg) = sep+1;
+        return 1;
     }
     else if ((*arg)[0] && (*arg)[0] != '\"')
     {
-       long fsize;
-       FILE *inf;
-       const char *fname = *arg;
-       
-       while (**arg != '\0' && **arg != ' ')
-           (*arg)++;
-           
-       inf = fopen(fname, "rb");
-       if (!inf)
-       {
-           printf("Couldn't open %s\n", fname);
-           return 0;
-       }
-       if (fseek(inf, 0L, SEEK_END) == -1)
-       {
-           printf("Couldn't seek in %s\n", fname);
-           fclose(inf);
-           return 0;
-       }
-       fsize = ftell(inf);
-       if (fseek(inf, 0L, SEEK_SET) == -1)
-       {
-           printf("Couldn't seek in %s\n", fname);
-           fclose(inf);
-           return 0;
-       }
-       *len = fsize;
-       *buf = odr_malloc(out, fsize);
-       if (fread(*buf, 1, fsize, inf) != fsize)
-       {
-           printf("Unable to read %s\n", fname);
-           fclose(inf);
-           return 0;
-       }
-       fclose(inf);
-       return 1;
+        long fsize;
+        FILE *inf;
+        const char *fname = *arg;
+        
+        while (**arg != '\0' && **arg != ' ')
+            (*arg)++;
+            
+        inf = fopen(fname, "rb");
+        if (!inf)
+        {
+            printf("Couldn't open %s\n", fname);
+            return 0;
+        }
+        if (fseek(inf, 0L, SEEK_END) == -1)
+        {
+            printf("Couldn't seek in %s\n", fname);
+            fclose(inf);
+            return 0;
+        }
+        fsize = ftell(inf);
+        if (fseek(inf, 0L, SEEK_SET) == -1)
+        {
+            printf("Couldn't seek in %s\n", fname);
+            fclose(inf);
+            return 0;
+        }
+        *len = fsize;
+        *buf = odr_malloc(out, fsize);
+        if (fread(*buf, 1, fsize, inf) != fsize)
+        {
+            printf("Unable to read %s\n", fname);
+            fclose(inf);
+            return 0;
+        }
+        fclose(inf);
+        return 1;
     }
     else if (**arg == '\0')
     {
-       if (opt)
-       {
-           *len = 0;
-           *buf = 0;
-           return 1;
-       }
-       printf("Missing doc argument\n");
+        if (opt)
+        {
+            *len = 0;
+            *buf = 0;
+            return 1;
+        }
+        printf("Missing doc argument\n");
     }
     else
-       printf("Bad doc argument %s\n", *arg);
+        printf("Bad doc argument %s\n", *arg);
     return 0;
 }
 
@@ -663,9 +663,9 @@ int session_connect(const char *arg)
     }   
     if (session_mem)
     {
-       nmem_destroy (session_mem);
-       session_mem = NULL;
-       session_initResponse = 0;
+        nmem_destroy (session_mem);
+        session_mem = NULL;
+        session_initResponse = 0;
     }
     cs_get_host_args(arg, &basep);
 
@@ -685,7 +685,7 @@ int session_connect(const char *arg)
     }
 #if HAVE_XML2
     if (conn->protocol == PROTO_HTTP)
-       queryType = QueryType_CQL;
+        queryType = QueryType_CQL;
 #else
     if (conn->protocol == PROTO_HTTP)
     {
@@ -706,11 +706,11 @@ int session_connect(const char *arg)
     {
         printf ("error = %s\n", cs_strerror(conn));
         if (conn->cerrno == CSYSERR)
-       {
-           char msg[256];
-           yaz_strerror(msg, sizeof(msg));
-           printf ("%s\n", msg);
-       }
+        {
+            char msg[256];
+            yaz_strerror(msg, sizeof(msg));
+            printf ("%s\n", msg);
+        }
         cs_close(conn);
         conn = 0;
         return 0;
@@ -719,25 +719,25 @@ int session_connect(const char *arg)
 #if HAVE_OPENSSL_SSL_H
     if ((ssl = (SSL *) cs_get_ssl(conn)))
     {
-       X509 *server_cert = SSL_get_peer_certificate (ssl);
-
-       if (server_cert)
-       {
-           char *pem_buf;
-           int pem_len;
-           BIO *bio = BIO_new(BIO_s_mem());
+        X509 *server_cert = SSL_get_peer_certificate (ssl);
 
-           /* get PEM buffer in memory */
-           PEM_write_bio_X509(bio, server_cert);
-           pem_len = BIO_get_mem_data(bio, &pem_buf);
-           fwrite(pem_buf, pem_len, 1, stdout);
-       
-           /* print all info on screen .. */
-           X509_print_fp(stdout, server_cert);
-           BIO_free(bio);
+        if (server_cert)
+        {
+            char *pem_buf;
+            int pem_len;
+            BIO *bio = BIO_new(BIO_s_mem());
+
+            /* get PEM buffer in memory */
+            PEM_write_bio_X509(bio, server_cert);
+            pem_len = BIO_get_mem_data(bio, &pem_buf);
+            fwrite(pem_buf, pem_len, 1, stdout);
+        
+            /* print all info on screen .. */
+            X509_print_fp(stdout, server_cert);
+            BIO_free(bio);
 
-           X509_free (server_cert);
-       }
+            X509_free (server_cert);
+        }
     }
 #endif
     if (basep && *basep)
@@ -763,17 +763,17 @@ int cmd_open(const char *arg)
 void try_reconnect() 
 {
     char* open_command;
-       
+        
     if(!( auto_reconnect && last_open_command) ) return ;
 
     open_command = (char *) xmalloc (strlen(last_open_command)+6);
     strcpy (open_command, "open ");
-       
+        
     strcat (open_command, last_open_command);
 
     process_cmd_line(open_command);
-       
-    xfree(open_command);                               
+        
+    xfree(open_command);                                
 }
 
 int cmd_authentication(const char *arg)
@@ -798,14 +798,14 @@ int cmd_authentication(const char *arg)
     if (r == 1)
     {
         auth = &au;
-       if (!strcmp(user, "-")) {
-           au.which = Z_IdAuthentication_anonymous;
-           printf("Authentication set to Anonymous\n");
-       } else {
-           au.which = Z_IdAuthentication_open;
-           au.u.open = user;
-           printf("Authentication set to Open (%s)\n", user);
-       }
+        if (!strcmp(user, "-")) {
+            au.which = Z_IdAuthentication_anonymous;
+            printf("Authentication set to Anonymous\n");
+        } else {
+            au.which = Z_IdAuthentication_open;
+            au.u.open = user;
+            printf("Authentication set to Open (%s)\n", user);
+        }
     }
     if (r == 2)
     {
@@ -815,7 +815,7 @@ int cmd_authentication(const char *arg)
         idPass.groupId = NULL;
         idPass.userId = user;
         idPass.password = group;
-       printf("Authentication set to User (%s), Pass (%s)\n", user, group);
+        printf("Authentication set to User (%s), Pass (%s)\n", user, group);
     }
     if (r == 3)
     {
@@ -825,8 +825,8 @@ int cmd_authentication(const char *arg)
         idPass.groupId = group;
         idPass.userId = user;
         idPass.password = pass;
-       printf("Authentication set to User (%s), Group (%s), Pass (%s)\n",
-              user, group, pass);
+        printf("Authentication set to User (%s), Group (%s), Pass (%s)\n",
+               user, group, pass);
     }
     return 1;
 }
@@ -884,7 +884,7 @@ static void display_record(Z_External *r)
                             r->u.octet_aligned->len);
                 fprintf(stdout, "---------\n");
                 
-               /* note just ignores the error ant print the bytes form the octet_aligned later */
+                /* note just ignores the error ant print the bytes form the octet_aligned later */
             } else {
                 /*
                  * Note: we throw away the original, BER-encoded record here.
@@ -906,9 +906,9 @@ static void display_record(Z_External *r)
     {
         const char *octet_buf = (char*)r->u.octet_aligned->buf;
         if (ent->oclass == CLASS_RECSYN && 
-               (ent->value == VAL_TEXT_XML || 
-                ent->value == VAL_APPLICATION_XML ||
-                ent->value == VAL_HTML))
+                (ent->value == VAL_TEXT_XML || 
+                 ent->value == VAL_APPLICATION_XML ||
+                 ent->value == VAL_HTML))
         {
             print_record((const unsigned char *) octet_buf,
                          r->u.octet_aligned->len);
@@ -953,17 +953,17 @@ static void display_record(Z_External *r)
                         else
                             from = "ISO-8859-1";
                     }
-                   else if (marcCharset)
-                       from = marcCharset;
+                    else if (marcCharset)
+                        from = marcCharset;
                     if (outputCharset && from)
                     {   
                         cd = yaz_iconv_open(outputCharset, from);
                         printf ("convert from %s to %s", from, 
                                 outputCharset);
-                       if (!cd)
-                           printf (" unsupported\n");
-                       else
-                           printf ("\n");
+                        if (!cd)
+                            printf (" unsupported\n");
+                        else
+                            printf ("\n");
                     }
                     if (!cd)
                         fwrite (result, 1, rlen, stdout);
@@ -977,11 +977,11 @@ static void display_record(Z_External *r)
                         {
                             size_t outbytesleft = sizeof(outbuf);
                             char *outp = outbuf;
-                           size_t r;
+                            size_t r;
 
                             r = yaz_iconv (cd, (char**) &inp,
-                                          &inbytesleft, 
-                                          &outp, &outbytesleft);
+                                           &inbytesleft, 
+                                           &outp, &outbytesleft);
                             if (r == (size_t) (-1))
                             {
                                 int e = yaz_iconv_error(cd);
@@ -992,12 +992,12 @@ static void display_record(Z_External *r)
                         }
                     }
                 }
-               else
+                else
                 {
                     printf ("bad MARC. Dumping as it is:\n");
                     print_record((const unsigned char*) octet_buf,
                                   r->u.octet_aligned->len);
-               }       
+                }       
                 yaz_marc_destroy(mt);
                 if (cd)
                     yaz_iconv_close(cd);
@@ -1037,105 +1037,105 @@ static void display_record(Z_External *r)
     }
     else if (ent && ent->value == VAL_OPAC)
     {
-       int i;
-       if (r->u.opac->bibliographicRecord)
-           display_record(r->u.opac->bibliographicRecord);
-       for (i = 0; i<r->u.opac->num_holdingsData; i++)
-       {
-           Z_HoldingsRecord *h = r->u.opac->holdingsData[i];
-           if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
-           {
-               printf ("MARC holdings %d\n", i);
-               display_record(h->u.marcHoldingsRecord);
-           }
-           else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
-           {
-               int j;
-
-               Z_HoldingsAndCircData *data = h->u.holdingsAndCirc;
-
-               printf ("Data holdings %d\n", i);
-               if (data->typeOfRecord)
-                   printf ("typeOfRecord: %s\n", data->typeOfRecord);
-               if (data->encodingLevel)
-                   printf ("encodingLevel: %s\n", data->encodingLevel);
-               if (data->receiptAcqStatus)
-                   printf ("receiptAcqStatus: %s\n", data->receiptAcqStatus);
-               if (data->generalRetention)
-                   printf ("generalRetention: %s\n", data->generalRetention);
-               if (data->completeness)
-                   printf ("completeness: %s\n", data->completeness);
-               if (data->dateOfReport)
-                   printf ("dateOfReport: %s\n", data->dateOfReport);
-               if (data->nucCode)
-                   printf ("nucCode: %s\n", data->nucCode);
-               if (data->localLocation)
-                   printf ("localLocation: %s\n", data->localLocation);
-               if (data->shelvingLocation)
-                   printf ("shelvingLocation: %s\n", data->shelvingLocation);
-               if (data->callNumber)
-                   printf ("callNumber: %s\n", data->callNumber);
-               if (data->shelvingData)
-                   printf ("shelvingData: %s\n", data->shelvingData);
-               if (data->copyNumber)
-                   printf ("copyNumber: %s\n", data->copyNumber);
-               if (data->publicNote)
-                   printf ("publicNote: %s\n", data->publicNote);
-               if (data->reproductionNote)
-                   printf ("reproductionNote: %s\n", data->reproductionNote);
-               if (data->termsUseRepro)
-                   printf ("termsUseRepro: %s\n", data->termsUseRepro);
-               if (data->enumAndChron)
-                   printf ("enumAndChron: %s\n", data->enumAndChron);
-               for (j = 0; j<data->num_volumes; j++)
-               {
-                   printf ("volume %d\n", j);
-                   if (data->volumes[j]->enumeration)
-                       printf (" enumeration: %s\n",
-                               data->volumes[j]->enumeration);
-                   if (data->volumes[j]->chronology)
-                       printf (" chronology: %s\n",
-                               data->volumes[j]->chronology);
-                   if (data->volumes[j]->enumAndChron)
-                       printf (" enumAndChron: %s\n",
-                               data->volumes[j]->enumAndChron);
-               }
-               for (j = 0; j<data->num_circulationData; j++)
-               {
-                   printf ("circulation %d\n", j);
-                   if (data->circulationData[j]->availableNow)
-                       printf (" availableNow: %d\n",
-                               *data->circulationData[j]->availableNow);
-                   if (data->circulationData[j]->availablityDate)
-                       printf (" availabiltyDate: %s\n",
-                               data->circulationData[j]->availablityDate);
-                   if (data->circulationData[j]->availableThru)
-                       printf (" availableThru: %s\n",
-                               data->circulationData[j]->availableThru);
-                   if (data->circulationData[j]->restrictions)
-                       printf (" restrictions: %s\n",
-                               data->circulationData[j]->restrictions);
-                   if (data->circulationData[j]->itemId)
-                       printf (" itemId: %s\n",
-                               data->circulationData[j]->itemId);
-                   if (data->circulationData[j]->renewable)
-                       printf (" renewable: %d\n",
-                               *data->circulationData[j]->renewable);
-                   if (data->circulationData[j]->onHold)
-                       printf (" onHold: %d\n",
-                               *data->circulationData[j]->onHold);
-                   if (data->circulationData[j]->enumAndChron)
-                       printf (" enumAndChron: %s\n",
-                               data->circulationData[j]->enumAndChron);
-                   if (data->circulationData[j]->midspine)
-                       printf (" midspine: %s\n",
-                               data->circulationData[j]->midspine);
-                   if (data->circulationData[j]->temporaryLocation)
-                       printf (" temporaryLocation: %s\n",
-                               data->circulationData[j]->temporaryLocation);
-               }
-           }
-       }
+        int i;
+        if (r->u.opac->bibliographicRecord)
+            display_record(r->u.opac->bibliographicRecord);
+        for (i = 0; i<r->u.opac->num_holdingsData; i++)
+        {
+            Z_HoldingsRecord *h = r->u.opac->holdingsData[i];
+            if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
+            {
+                printf ("MARC holdings %d\n", i);
+                display_record(h->u.marcHoldingsRecord);
+            }
+            else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
+            {
+                int j;
+
+                Z_HoldingsAndCircData *data = h->u.holdingsAndCirc;
+
+                printf ("Data holdings %d\n", i);
+                if (data->typeOfRecord)
+                    printf ("typeOfRecord: %s\n", data->typeOfRecord);
+                if (data->encodingLevel)
+                    printf ("encodingLevel: %s\n", data->encodingLevel);
+                if (data->receiptAcqStatus)
+                    printf ("receiptAcqStatus: %s\n", data->receiptAcqStatus);
+                if (data->generalRetention)
+                    printf ("generalRetention: %s\n", data->generalRetention);
+                if (data->completeness)
+                    printf ("completeness: %s\n", data->completeness);
+                if (data->dateOfReport)
+                    printf ("dateOfReport: %s\n", data->dateOfReport);
+                if (data->nucCode)
+                    printf ("nucCode: %s\n", data->nucCode);
+                if (data->localLocation)
+                    printf ("localLocation: %s\n", data->localLocation);
+                if (data->shelvingLocation)
+                    printf ("shelvingLocation: %s\n", data->shelvingLocation);
+                if (data->callNumber)
+                    printf ("callNumber: %s\n", data->callNumber);
+                if (data->shelvingData)
+                    printf ("shelvingData: %s\n", data->shelvingData);
+                if (data->copyNumber)
+                    printf ("copyNumber: %s\n", data->copyNumber);
+                if (data->publicNote)
+                    printf ("publicNote: %s\n", data->publicNote);
+                if (data->reproductionNote)
+                    printf ("reproductionNote: %s\n", data->reproductionNote);
+                if (data->termsUseRepro)
+                    printf ("termsUseRepro: %s\n", data->termsUseRepro);
+                if (data->enumAndChron)
+                    printf ("enumAndChron: %s\n", data->enumAndChron);
+                for (j = 0; j<data->num_volumes; j++)
+                {
+                    printf ("volume %d\n", j);
+                    if (data->volumes[j]->enumeration)
+                        printf (" enumeration: %s\n",
+                                data->volumes[j]->enumeration);
+                    if (data->volumes[j]->chronology)
+                        printf (" chronology: %s\n",
+                                data->volumes[j]->chronology);
+                    if (data->volumes[j]->enumAndChron)
+                        printf (" enumAndChron: %s\n",
+                                data->volumes[j]->enumAndChron);
+                }
+                for (j = 0; j<data->num_circulationData; j++)
+                {
+                    printf ("circulation %d\n", j);
+                    if (data->circulationData[j]->availableNow)
+                        printf (" availableNow: %d\n",
+                                *data->circulationData[j]->availableNow);
+                    if (data->circulationData[j]->availablityDate)
+                        printf (" availabiltyDate: %s\n",
+                                data->circulationData[j]->availablityDate);
+                    if (data->circulationData[j]->availableThru)
+                        printf (" availableThru: %s\n",
+                                data->circulationData[j]->availableThru);
+                    if (data->circulationData[j]->restrictions)
+                        printf (" restrictions: %s\n",
+                                data->circulationData[j]->restrictions);
+                    if (data->circulationData[j]->itemId)
+                        printf (" itemId: %s\n",
+                                data->circulationData[j]->itemId);
+                    if (data->circulationData[j]->renewable)
+                        printf (" renewable: %d\n",
+                                *data->circulationData[j]->renewable);
+                    if (data->circulationData[j]->onHold)
+                        printf (" onHold: %d\n",
+                                *data->circulationData[j]->onHold);
+                    if (data->circulationData[j]->enumAndChron)
+                        printf (" enumAndChron: %s\n",
+                                data->circulationData[j]->enumAndChron);
+                    if (data->circulationData[j]->midspine)
+                        printf (" midspine: %s\n",
+                                data->circulationData[j]->midspine);
+                    if (data->circulationData[j]->temporaryLocation)
+                        printf (" temporaryLocation: %s\n",
+                                data->circulationData[j]->temporaryLocation);
+                }
+            }
+        }
     }
     else 
     {
@@ -1326,17 +1326,17 @@ static int send_srw(Z_SRW_PDU *sr)
         char *buf_out;
         int len_out;
         int r;
-       if (apdu_file)
-       {
-           if (!z_GDU(print, &gdu, 0, 0))
-               printf ("Failed to print outgoing APDU\n");
-           odr_reset(print);
-       }
+        if (apdu_file)
+        {
+            if (!z_GDU(print, &gdu, 0, 0))
+                printf ("Failed to print outgoing APDU\n");
+            odr_reset(print);
+        }
         buf_out = odr_getbuf(out, &len_out, 0);
         
         /* we don't odr_reset(out), since we may need the buffer again */
 
-       do_hex_dump(buf_out, len_out);
+        do_hex_dump(buf_out, len_out);
 
         r = cs_put(conn, buf_out, len_out);
 
@@ -1357,21 +1357,21 @@ static char *encode_SRW_term(ODR o, const char *q)
     yaz_iconv_t cd;
     char *res;
     if (outputCharset)
-       in_charset = outputCharset;
+        in_charset = outputCharset;
     cd = yaz_iconv_open("UTF-8", in_charset);
     if (!cd)
     {
-       wrbuf_free(w, 1);
-       return odr_strdup(o, q);
+        wrbuf_free(w, 1);
+        return odr_strdup(o, q);
     }
     wrbuf_iconv_write(w, cd, q, strlen(q));
     if (wrbuf_len(w))
     {
-       int len = wrbuf_len(w);
-       res = odr_strdupn(o, wrbuf_buf(w), len);
+        int len = wrbuf_len(w);
+        res = odr_strdupn(o, wrbuf_buf(w), len);
     }
     else
-       res = odr_strdup(o, q);    
+        res = odr_strdup(o, q);    
     yaz_iconv_close(cd);
     wrbuf_free(w, 1);
     return res;
@@ -1388,16 +1388,16 @@ static int send_SRW_scanRequest(const char *arg, int pos, int num)
     switch(queryType)
     {
     case QueryType_CQL:
-       sr->u.scan_request->query_type = Z_SRW_query_type_cql;
-       sr->u.scan_request->scanClause.cql = encode_SRW_term(out, arg);
-       break;
+        sr->u.scan_request->query_type = Z_SRW_query_type_cql;
+        sr->u.scan_request->scanClause.cql = encode_SRW_term(out, arg);
+        break;
     case QueryType_Prefix:
-       sr->u.scan_request->query_type = Z_SRW_query_type_pqf;
-       sr->u.scan_request->scanClause.pqf = encode_SRW_term(out, arg);
-       break;
+        sr->u.scan_request->query_type = Z_SRW_query_type_pqf;
+        sr->u.scan_request->scanClause.pqf = encode_SRW_term(out, arg);
+        break;
     default:
-       printf ("Only CQL and PQF supported in SRW\n");
-       return 0;
+        printf ("Only CQL and PQF supported in SRW\n");
+        return 0;
     }
     sr->u.scan_request->responsePosition = odr_intdup(out, pos);
     sr->u.scan_request->maximumTerms = odr_intdup(out, num);
@@ -1426,22 +1426,22 @@ static int send_SRW_searchRequest(const char *arg)
     switch(queryType)
     {
     case QueryType_CQL:
-       srw_sr->u.request->query_type = Z_SRW_query_type_cql;
-       srw_sr->u.request->query.cql = encode_SRW_term(srw_sr_odr_out, arg);
+        srw_sr->u.request->query_type = Z_SRW_query_type_cql;
+        srw_sr->u.request->query.cql = encode_SRW_term(srw_sr_odr_out, arg);
 
-       sr->u.request->query_type = Z_SRW_query_type_cql;
-       sr->u.request->query.cql = encode_SRW_term(srw_sr_odr_out, arg);
-       break;
+        sr->u.request->query_type = Z_SRW_query_type_cql;
+        sr->u.request->query.cql = encode_SRW_term(srw_sr_odr_out, arg);
+        break;
     case QueryType_Prefix:
-       srw_sr->u.request->query_type = Z_SRW_query_type_pqf;
-       srw_sr->u.request->query.pqf = encode_SRW_term(srw_sr_odr_out, arg);
+        srw_sr->u.request->query_type = Z_SRW_query_type_pqf;
+        srw_sr->u.request->query.pqf = encode_SRW_term(srw_sr_odr_out, arg);
 
-       sr->u.request->query_type = Z_SRW_query_type_pqf;
-       sr->u.request->query.pqf = encode_SRW_term(srw_sr_odr_out, arg);
-       break;
+        sr->u.request->query_type = Z_SRW_query_type_pqf;
+        sr->u.request->query.pqf = encode_SRW_term(srw_sr_odr_out, arg);
+        break;
     default:
-       printf ("Only CQL and PQF supported in SRW\n");
-       return 0;
+        printf ("Only CQL and PQF supported in SRW\n");
+        return 0;
     }
     sr->u.request->maximumRecords = odr_intdup(out, 0);
 
@@ -1477,29 +1477,29 @@ static int send_searchRequest(const char *arg)
             return 0;
         }
     } else if (myQueryType == QueryType_CQL2RPN) {
-       /* ### All this code should be wrapped in a utility function */
-       CQL_parser parser;
-       struct cql_node *node;
-       const char *addinfo;
-       if (cqltrans == 0) {
+        /* ### All this code should be wrapped in a utility function */
+        CQL_parser parser;
+        struct cql_node *node;
+        const char *addinfo;
+        if (cqltrans == 0) {
             printf("Can't use CQL: no translation file.  Try set_cqlfile\n");
-           return 0;
-       }
-       parser = cql_parser_create();
-       if ((error = cql_parser_string(parser, arg)) != 0) {
+            return 0;
+        }
+        parser = cql_parser_create();
+        if ((error = cql_parser_string(parser, arg)) != 0) {
             printf("Can't parse CQL: must be a syntax error\n");
             return 0;
-       }
-       node = cql_parser_result(parser);
-       if ((error = cql_transform_buf(cqltrans, node, pqfbuf,
-                                      sizeof pqfbuf)) != 0) {
-           error = cql_transform_error(cqltrans, &addinfo);
-           printf ("Can't convert CQL to PQF: %s (addinfo=%s)\n",
-                   cql_strerror(error), addinfo);
+        }
+        node = cql_parser_result(parser);
+        if ((error = cql_transform_buf(cqltrans, node, pqfbuf,
+                                       sizeof pqfbuf)) != 0) {
+            error = cql_transform_error(cqltrans, &addinfo);
+            printf ("Can't convert CQL to PQF: %s (addinfo=%s)\n",
+                    cql_strerror(error), addinfo);
             return 0;
         }
-       arg = pqfbuf;
-       myQueryType = QueryType_Prefix;
+        arg = pqfbuf;
+        myQueryType = QueryType_Prefix;
     }
 
     req->referenceId = set_refid (out);
@@ -1912,8 +1912,8 @@ void process_ESResponse(Z_ExtendedServicesResponse *res)
     }
     if (res->taskPackage && res->taskPackage->which == Z_External_octet)
     {
-       Odr_oct *doc = res->taskPackage->u.octet_aligned;
-       printf("%.*s\n", doc->len, doc->buf);
+        Odr_oct *doc = res->taskPackage->u.octet_aligned;
+        printf("%.*s\n", doc->len, doc->buf);
     }
 }
 
@@ -2032,8 +2032,8 @@ static Z_External *create_external_ILL_APDU(int which)
         r->u.single_ASN1_type->size = ill_request_size;
         memcpy (r->u.single_ASN1_type->buf, ill_request_buf, ill_request_size);
 /*         printf ("len = %d\n", ill_request_size); */
-/*             do_hex_dump(ill_request_buf,ill_request_size); */
-/*             printf("--- end of extenal\n"); */
+/*              do_hex_dump(ill_request_buf,ill_request_size); */
+/*              printf("--- end of extenal\n"); */
 
     }
     return r;
@@ -2134,8 +2134,8 @@ static int only_z3950()
 {
     if (protocol == PROTO_HTTP)
     {
-       printf ("Not supported by SRW\n");
-       return 1;
+        printf ("Not supported by SRW\n");
+        return 1;
     }
     return 0;
 }
@@ -2165,16 +2165,16 @@ static int cmd_update_common(const char *arg, int version)
     Z_External *record_this = 0;
 
     if (only_z3950())
-       return 0;
+        return 0;
     *action = 0;
     *recid = 0;
     sscanf (arg, "%19s %19s%n", action, recid, &noread);
     if (noread == 0)
     {
-       printf("Update must be followed by action and recid\n");
-       printf(" where action is one of insert,replace,delete.update\n");
-       printf(" recid is some record ID (any string)\n");
-       return 0;
+        printf("Update must be followed by action and recid\n");
+        printf(" where action is one of insert,replace,delete.update\n");
+        printf(" recid is some record ID (any string)\n");
+        return 0;
     }
 
     if (!strcmp (action, "insert"))
@@ -2194,10 +2194,10 @@ static int cmd_update_common(const char *arg, int version)
 
     arg += noread;
     if (parse_cmd_doc(&arg, out, &rec_buf, &rec_len, 1) == 0)
-       return 0;
+        return 0;
 
     if (rec_buf)
-       record_this = z_ext_record (out, VAL_TEXT_XML, rec_buf, rec_len);
+        record_this = z_ext_record (out, VAL_TEXT_XML, rec_buf, rec_len);
     else
     {
         if (!record_last)
@@ -2209,8 +2209,8 @@ static int cmd_update_common(const char *arg, int version)
     }
 
     req->packageType =
-       yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
-                              version == 0 ? VAL_DBUPDATE0 : VAL_DBUPDATE);
+        yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
+                               version == 0 ? VAL_DBUPDATE0 : VAL_DBUPDATE);
 
     req->packageName = esPackageName;
     
@@ -2223,87 +2223,87 @@ static int cmd_update_common(const char *arg, int version)
     r->descriptor = 0;
     if (version == 0)
     {
-       Z_IU0OriginPartToKeep *toKeep;
-       Z_IU0SuppliedRecords *notToKeep;
-
-       r->which = Z_External_update0;
-       r->u.update0 = (Z_IU0Update *) odr_malloc(out, sizeof(*r->u.update0));
-       r->u.update0->which = Z_IUUpdate_esRequest;
-       r->u.update0->u.esRequest = (Z_IU0UpdateEsRequest *)
-           odr_malloc(out, sizeof(*r->u.update0->u.esRequest));
-       toKeep = r->u.update0->u.esRequest->toKeep = (Z_IU0OriginPartToKeep *)
-           odr_malloc(out, sizeof(*r->u.update0->u.esRequest->toKeep));
-       
-       toKeep->databaseName = databaseNames[0];
-       toKeep->schema = 0;
-       toKeep->elementSetName = 0;
-
-       toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
-       *toKeep->action = action_no;
-       
-       notToKeep = r->u.update0->u.esRequest->notToKeep = (Z_IU0SuppliedRecords *)
-           odr_malloc(out, sizeof(*r->u.update0->u.esRequest->notToKeep));
-       notToKeep->num = 1;
-       notToKeep->elements = (Z_IU0SuppliedRecords_elem **)
-           odr_malloc(out, sizeof(*notToKeep->elements));
-       notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *)
-           odr_malloc(out, sizeof(**notToKeep->elements));
-       notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
-       if (*recid)
-       {
-           notToKeep->elements[0]->u.opaque = (Odr_oct *)
-               odr_malloc (out, sizeof(Odr_oct));
-           notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
-           notToKeep->elements[0]->u.opaque->size = strlen(recid);
-           notToKeep->elements[0]->u.opaque->len = strlen(recid);
-       }
-       else
-           notToKeep->elements[0]->u.opaque = 0;
-       notToKeep->elements[0]->supplementalId = 0;
-       notToKeep->elements[0]->correlationInfo = 0;
-       notToKeep->elements[0]->record = record_this;
+        Z_IU0OriginPartToKeep *toKeep;
+        Z_IU0SuppliedRecords *notToKeep;
+
+        r->which = Z_External_update0;
+        r->u.update0 = (Z_IU0Update *) odr_malloc(out, sizeof(*r->u.update0));
+        r->u.update0->which = Z_IUUpdate_esRequest;
+        r->u.update0->u.esRequest = (Z_IU0UpdateEsRequest *)
+            odr_malloc(out, sizeof(*r->u.update0->u.esRequest));
+        toKeep = r->u.update0->u.esRequest->toKeep = (Z_IU0OriginPartToKeep *)
+            odr_malloc(out, sizeof(*r->u.update0->u.esRequest->toKeep));
+        
+        toKeep->databaseName = databaseNames[0];
+        toKeep->schema = 0;
+        toKeep->elementSetName = 0;
+
+        toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
+        *toKeep->action = action_no;
+        
+        notToKeep = r->u.update0->u.esRequest->notToKeep = (Z_IU0SuppliedRecords *)
+            odr_malloc(out, sizeof(*r->u.update0->u.esRequest->notToKeep));
+        notToKeep->num = 1;
+        notToKeep->elements = (Z_IU0SuppliedRecords_elem **)
+            odr_malloc(out, sizeof(*notToKeep->elements));
+        notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *)
+            odr_malloc(out, sizeof(**notToKeep->elements));
+        notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
+        if (*recid)
+        {
+            notToKeep->elements[0]->u.opaque = (Odr_oct *)
+                odr_malloc (out, sizeof(Odr_oct));
+            notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+            notToKeep->elements[0]->u.opaque->size = strlen(recid);
+            notToKeep->elements[0]->u.opaque->len = strlen(recid);
+        }
+        else
+            notToKeep->elements[0]->u.opaque = 0;
+        notToKeep->elements[0]->supplementalId = 0;
+        notToKeep->elements[0]->correlationInfo = 0;
+        notToKeep->elements[0]->record = record_this;
     }
     else
     {
-       Z_IUOriginPartToKeep *toKeep;
-       Z_IUSuppliedRecords *notToKeep;
-
-       r->which = Z_External_update;
-       r->u.update = (Z_IUUpdate *) odr_malloc(out, sizeof(*r->u.update));
-       r->u.update->which = Z_IUUpdate_esRequest;
-       r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
-           odr_malloc(out, sizeof(*r->u.update->u.esRequest));
-       toKeep = r->u.update->u.esRequest->toKeep = (Z_IUOriginPartToKeep *)
-           odr_malloc(out, sizeof(*r->u.update->u.esRequest->toKeep));
-       
-       toKeep->databaseName = databaseNames[0];
-       toKeep->schema = 0;
-       toKeep->elementSetName = 0;
-       toKeep->actionQualifier = 0;
-       toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
-       *toKeep->action = action_no;
-
-       notToKeep = r->u.update->u.esRequest->notToKeep = (Z_IUSuppliedRecords *)
-           odr_malloc(out, sizeof(*r->u.update->u.esRequest->notToKeep));
-       notToKeep->num = 1;
-       notToKeep->elements = (Z_IUSuppliedRecords_elem **)
-           odr_malloc(out, sizeof(*notToKeep->elements));
-       notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
-           odr_malloc(out, sizeof(**notToKeep->elements));
-       notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
-       if (*recid)
-       {
-           notToKeep->elements[0]->u.opaque = (Odr_oct *)
-               odr_malloc (out, sizeof(Odr_oct));
-           notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
-           notToKeep->elements[0]->u.opaque->size = strlen(recid);
-           notToKeep->elements[0]->u.opaque->len = strlen(recid);
-       }
-       else
-           notToKeep->elements[0]->u.opaque = 0;
-       notToKeep->elements[0]->supplementalId = 0;
-       notToKeep->elements[0]->correlationInfo = 0;
-       notToKeep->elements[0]->record = record_this;
+        Z_IUOriginPartToKeep *toKeep;
+        Z_IUSuppliedRecords *notToKeep;
+
+        r->which = Z_External_update;
+        r->u.update = (Z_IUUpdate *) odr_malloc(out, sizeof(*r->u.update));
+        r->u.update->which = Z_IUUpdate_esRequest;
+        r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
+            odr_malloc(out, sizeof(*r->u.update->u.esRequest));
+        toKeep = r->u.update->u.esRequest->toKeep = (Z_IUOriginPartToKeep *)
+            odr_malloc(out, sizeof(*r->u.update->u.esRequest->toKeep));
+        
+        toKeep->databaseName = databaseNames[0];
+        toKeep->schema = 0;
+        toKeep->elementSetName = 0;
+        toKeep->actionQualifier = 0;
+        toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
+        *toKeep->action = action_no;
+
+        notToKeep = r->u.update->u.esRequest->notToKeep = (Z_IUSuppliedRecords *)
+            odr_malloc(out, sizeof(*r->u.update->u.esRequest->notToKeep));
+        notToKeep->num = 1;
+        notToKeep->elements = (Z_IUSuppliedRecords_elem **)
+            odr_malloc(out, sizeof(*notToKeep->elements));
+        notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
+            odr_malloc(out, sizeof(**notToKeep->elements));
+        notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
+        if (*recid)
+        {
+            notToKeep->elements[0]->u.opaque = (Odr_oct *)
+                odr_malloc (out, sizeof(Odr_oct));
+            notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+            notToKeep->elements[0]->u.opaque->size = strlen(recid);
+            notToKeep->elements[0]->u.opaque->len = strlen(recid);
+        }
+        else
+            notToKeep->elements[0]->u.opaque = 0;
+        notToKeep->elements[0]->supplementalId = 0;
+        notToKeep->elements[0]->correlationInfo = 0;
+        notToKeep->elements[0]->record = record_this;
     }
     
     send_apdu(apdu);
@@ -2328,25 +2328,25 @@ static int cmd_xmles(const char *arg)
     sscanf(arg, "%50s%n", oid_str, &noread);
     if (noread == 0)
     {
-       printf("Missing OID for xmles\n");
-       return 0;
+        printf("Missing OID for xmles\n");
+        return 0;
     }
     arg += noread;
     oid_value_xmles  = oid_getvalbyname(oid_str);
     if (oid_value_xmles == VAL_NONE)
     {
-       printf("Bad OID: %s\n", oid_str);
-       return 0;
+        printf("Bad OID: %s\n", oid_str);
+        return 0;
     }
 
     if (parse_cmd_doc(&arg, out, (char **) &ext->u.single_ASN1_type->buf,
-                     &ext->u.single_ASN1_type->len, 0) == 0)
-       return 0;
+                      &ext->u.single_ASN1_type->len, 0) == 0)
+        return 0;
     req->packageType = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
-                                             oid_value_xmles);
+                                              oid_value_xmles);
 
     ext->direct_reference = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
-                                                  oid_value_xmles);
+                                                   oid_value_xmles);
     send_apdu(apdu);
 
     return 2;
@@ -2358,7 +2358,7 @@ static int cmd_itemorder(const char *arg)
     int itemno;
    
     if (only_z3950())
-       return 0;
+        return 0;
     if (sscanf (arg, "%10s %d", type, &itemno) != 2)
         return 0;
 
@@ -2376,9 +2376,9 @@ static void show_opt(const char *arg, void *clientData)
 static int cmd_zversion(const char *arg)
 {
     if (*arg && arg)
-       z3950_version = atoi(arg);
+        z3950_version = atoi(arg);
     else
-       printf ("version is %d\n", z3950_version);
+        printf ("version is %d\n", z3950_version);
     return 0;
 }
 
@@ -2386,16 +2386,16 @@ static int cmd_options(const char *arg)
 {
     if (*arg)
     {
-       int r;
-       int pos;
-       r = yaz_init_opt_encode(&z3950_options, arg, &pos);
-       if (r == -1)
-           printf("Unknown option(s) near %s\n", arg+pos);
+        int r;
+        int pos;
+        r = yaz_init_opt_encode(&z3950_options, arg, &pos);
+        if (r == -1)
+            printf("Unknown option(s) near %s\n", arg+pos);
     }
     else
     {
-       yaz_init_opt_decode(&z3950_options, show_opt, 0);
-       printf ("\n");
+        yaz_init_opt_decode(&z3950_options, show_opt, 0);
+        printf ("\n");
     }
     return 0;
 }
@@ -2403,22 +2403,22 @@ static int cmd_options(const char *arg)
 static int cmd_explain(const char *arg)
 {
     if (protocol != PROTO_HTTP)
-       return 0;
+        return 0;
 #if HAVE_XML2
     if (!conn)
-       cmd_open(0);
+        cmd_open(0);
     if (conn)
     {
-       Z_SRW_PDU *sr = 0;
-       
-       setno = 1;
-       
-       /* save this for later .. when fetching individual records */
-       sr = yaz_srw_get(out, Z_SRW_explain_request);
-       if (recordsyntax == VAL_TEXT_XML)
+        Z_SRW_PDU *sr = 0;
+        
+        setno = 1;
+        
+        /* save this for later .. when fetching individual records */
+        sr = yaz_srw_get(out, Z_SRW_explain_request);
+        if (recordsyntax == VAL_TEXT_XML)
             sr->u.explain_request->recordPacking = "xml";
-       send_srw(sr);
-       return 2;
+        send_srw(sr);
+        return 2;
     }
 #endif
     return 0;
@@ -2449,8 +2449,8 @@ static int cmd_find(const char *arg)
 #if HAVE_XML2
         if (!conn)
             cmd_open(0);
-       if (!conn)
-           return 0;
+        if (!conn)
+            return 0;
         if (!send_SRW_searchRequest(arg))
             return 0;
 #else
@@ -2463,7 +2463,7 @@ static int cmd_find(const char *arg)
         {
             try_reconnect(); 
             
-            if (!conn) {                                       
+            if (!conn) {                                        
                 printf("Not connected yet\n");
                 return 0;
             }
@@ -2482,7 +2482,7 @@ static int cmd_delete(const char *arg)
         return 0;
     }
     if (only_z3950())
-       return 0;
+        return 0;
     if (!send_deleteResultSetRequest(arg))
         return 0;
     return 2;
@@ -2498,7 +2498,7 @@ static int cmd_ssub(const char *arg)
 static int cmd_lslb(const char *arg)
 {
     if (only_z3950())
-       return 0;
+        return 0;
     if (!(largeSetLowerBound = atoi(arg)))
         return 0;
     return 1;
@@ -2507,7 +2507,7 @@ static int cmd_lslb(const char *arg)
 static int cmd_mspn(const char *arg)
 {
     if (only_z3950())
-       return 0;
+        return 0;
     if (!(mediumSetPresentNumber = atoi(arg)))
         return 0;
     return 1;
@@ -2600,13 +2600,13 @@ static int send_presentRequest(const char *arg)
         compo.u.complex->generic->which = Z_Schema_oid;
 
         compo.u.complex->generic->schema.oid =
-           yaz_str_to_z3950oid(out, CLASS_SCHEMA, record_schema);
+            yaz_str_to_z3950oid(out, CLASS_SCHEMA, record_schema);
 
         if (!compo.u.complex->generic->schema.oid)
         {
             /* OID wasn't a schema! Try record syntax instead. */
             compo.u.complex->generic->schema.oid = (Odr_oid *)
-               yaz_str_to_z3950oid(out, CLASS_RECSYN, record_schema);
+                yaz_str_to_z3950oid(out, CLASS_RECSYN, record_schema);
         }
         if (!elementSetNames)
             compo.u.complex->generic->elementSpec = 0;
@@ -2705,8 +2705,8 @@ static int cmd_show(const char *arg)
 #if HAVE_XML2
         if (!conn)
             cmd_open(0);
-       if (!conn)
-           return 0;
+        if (!conn)
+            return 0;
         if (!send_SRW_presentRequest(arg))
             return 0;
 #else
@@ -2747,10 +2747,10 @@ int cmd_cancel(const char *arg)
         return 0;
     }
     if (only_z3950())
-       return 0;
+        return 0;
     if (session_initResponse &&
-       !ODR_MASK_GET(session_initResponse->options,
-                     Z_Options_triggerResourceCtrl))
+        !ODR_MASK_GET(session_initResponse->options,
+                      Z_Options_triggerResourceCtrl))
     {
         printf("Target doesn't support cancel (trigger resource ctrl)\n");
         return 0;
@@ -2769,7 +2769,7 @@ int cmd_cancel_find(const char *arg) {
     int fres;
     fres=cmd_find(arg);
     if( fres > 0 ) {
-       return cmd_cancel("");
+        return cmd_cancel("");
     };
     return fres;
 }
@@ -2780,7 +2780,7 @@ int send_scanrequest(const char *query, int pp, int num, const char *term)
     Z_ScanRequest *req = apdu->u.scanRequest;
     
     if (only_z3950())
-       return 0;
+        return 0;
     if (queryType == QueryType_CCL2RPN)
     {
         int error, pos;
@@ -2793,7 +2793,7 @@ int send_scanrequest(const char *query, int pp, int num, const char *term)
             return -1;
         }
         req->attributeSet =
-           yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1);
+            yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1);
         if (!(req->termListAndStartPoint = ccl_scan_query (out, rpn)))
         {
             printf("Couldn't convert CCL to Scan term\n");
@@ -2850,7 +2850,7 @@ int send_sortrequest(const char *arg, int newset)
     char setstring[32];
 
     if (only_z3950())
-       return 0;
+        return 0;
     if (setnumber >= 0)
         sprintf (setstring, "%d", setnumber);
     else
@@ -2974,9 +2974,9 @@ int cmd_sort_generic(const char *arg, int newset)
         return 0;
     }
     if (only_z3950())
-       return 0;
+        return 0;
     if (session_initResponse && 
-       !ODR_MASK_GET(session_initResponse->options, Z_Options_sort))
+        !ODR_MASK_GET(session_initResponse->options, Z_Options_sort))
     {
         printf("Target doesn't support sort\n");
         return 0;
@@ -3029,52 +3029,52 @@ int cmd_scan(const char *arg)
 #if HAVE_XML2
         if (!conn)
             cmd_open(0);
-       if (!conn)
-           return 0;
-       if (*arg)
-       {
-           if (send_SRW_scanRequest(arg, scan_position, scan_size) < 0)
-               return 0;
-       }
-       else
-       {
-           if (send_SRW_scanRequest(last_scan_line, 1, scan_size) < 0)
-               return 0;
-       }
-       return 2;
+        if (!conn)
+            return 0;
+        if (*arg)
+        {
+            if (send_SRW_scanRequest(arg, scan_position, scan_size) < 0)
+                return 0;
+        }
+        else
+        {
+            if (send_SRW_scanRequest(last_scan_line, 1, scan_size) < 0)
+                return 0;
+        }
+        return 2;
 #else
         return 0;
 #endif
     }
     else
     {
-       if (!conn)
-       {
-           try_reconnect();
-           
-           if (!conn) {                                                                
-               printf("Session not initialized yet\n");
-               return 0;
-           }
-       }
-       if (session_initResponse && 
-           !ODR_MASK_GET(session_initResponse->options, Z_Options_scan))
-       {
-           printf("Target doesn't support scan\n");
-           return 0;
-       }
-       if (*arg)
-       {
-           strcpy (last_scan_query, arg);
-           if (send_scanrequest(arg, scan_position, scan_size, 0) < 0)
-               return 0;
-       }
-       else
-       {
-           if (send_scanrequest(last_scan_query, 1, scan_size, last_scan_line) < 0)
-               return 0;
-       }
-       return 2;
+        if (!conn)
+        {
+            try_reconnect();
+            
+            if (!conn) {                                                                
+                printf("Session not initialized yet\n");
+                return 0;
+            }
+        }
+        if (session_initResponse && 
+            !ODR_MASK_GET(session_initResponse->options, Z_Options_scan))
+        {
+            printf("Target doesn't support scan\n");
+            return 0;
+        }
+        if (*arg)
+        {
+            strcpy (last_scan_query, arg);
+            if (send_scanrequest(arg, scan_position, scan_size, 0) < 0)
+                return 0;
+        }
+        else
+        {
+            if (send_scanrequest(last_scan_query, 1, scan_size, last_scan_line) < 0)
+                return 0;
+        }
+        return 2;
     }
 }
 
@@ -3181,7 +3181,7 @@ int cmd_close(const char *arg)
     if (!conn)
         return 0;
     if (only_z3950())
-       return 0;
+        return 0;
 
     apdu = zget_APDU(out, Z_APDU_close);
     req = apdu->u.close;
@@ -3217,7 +3217,7 @@ int cmd_marccharset(const char *arg)
     *l1 = 0;
     if (sscanf(arg, "%29s", l1) < 1)
     {
-       printf("MARC character set is `%s'\n", 
+        printf("MARC character set is `%s'\n", 
                marcCharset ? marcCharset: "none");
         return 1;
     }
@@ -3235,7 +3235,7 @@ int cmd_displaycharset(const char *arg)
     *l1 = 0;
     if (sscanf(arg, "%29s", l1) < 1)
     {
-       printf("Display character set is `%s'\n", 
+        printf("Display character set is `%s'\n", 
                outputCharset ? outputCharset: "none");
     }
     else
@@ -3264,23 +3264,23 @@ int cmd_negcharset(const char *arg)
 
     *l1 = 0;
     if (sscanf(arg, "%29s %d %d", l1, &negotiationCharsetRecords,
-              &negotiationCharsetVersion) < 1)
+               &negotiationCharsetVersion) < 1)
     {
-       printf("Current negotiation character set is `%s'\n", 
+        printf("Current negotiation character set is `%s'\n", 
                negotiationCharset ? negotiationCharset: "none");  
-       printf("Records in charset %s\n", negotiationCharsetRecords ? 
-              "yes" : "no");
-       printf("Charneg version %d\n", negotiationCharsetVersion);
+        printf("Records in charset %s\n", negotiationCharsetRecords ? 
+               "yes" : "no");
+        printf("Charneg version %d\n", negotiationCharsetVersion);
     }
     else
     {
-       xfree (negotiationCharset);
-       negotiationCharset = NULL;
-       if (*l1 && strcmp(l1, "-") && strcmp(l1, "none"))
-       {
-           negotiationCharset = xstrdup(l1);
-           printf ("Character set negotiation : %s\n", negotiationCharset);
-       }
+        xfree (negotiationCharset);
+        negotiationCharset = NULL;
+        if (*l1 && strcmp(l1, "-") && strcmp(l1, "none"))
+        {
+            negotiationCharset = xstrdup(l1);
+            printf ("Character set negotiation : %s\n", negotiationCharset);
+        }
     }
     return 1;
 }
@@ -3292,17 +3292,17 @@ int cmd_charset(const char* arg)
     *l1 = *l2 = *l3 = 0;
     if (sscanf(arg, "%29s %29s %29s", l1, l2, l3) < 1)
     {
-       cmd_negcharset("");
-       cmd_displaycharset("");
-       cmd_marccharset("");
+        cmd_negcharset("");
+        cmd_displaycharset("");
+        cmd_marccharset("");
     }
     else
     {
-       cmd_negcharset(l1);
-       if (*l2)
-           cmd_displaycharset(l2);
-       if (*l3)
-           cmd_marccharset(l3);
+        cmd_negcharset(l1);
+        if (*l2)
+            cmd_displaycharset(l2);
+        if (*l3)
+            cmd_marccharset(l3);
     }
     return 1;
 }
@@ -3310,8 +3310,8 @@ int cmd_charset(const char* arg)
 int cmd_lang(const char* arg)
 {
     if (*arg == '\0') {
-       printf("Current language is `%s'\n", (yazLang)?yazLang:NULL);
-       return 1;
+        printf("Current language is `%s'\n", (yazLang)?yazLang:NULL);
+        return 1;
     }
     xfree (yazLang);
     yazLang = NULL;
@@ -3347,10 +3347,10 @@ int cmd_source(const char* arg, int echo )
         
         if ((cp = strrchr (line, '\n')))
             *cp = '\0';
-       
-       if( echo ) {
-           printf( "processing line: %s\n",line );
-       };
+        
+        if( echo ) {
+            printf( "processing line: %s\n",line );
+        };
         process_cmd_line(line);
     }
     
@@ -3440,10 +3440,10 @@ int cmd_set_cqlfile(const char* arg)
 
     if ((newcqltrans = cql_transform_open_fname(arg)) == 0) {
         perror("unable to open CQL file");
-       return 0;
+        return 0;
     }
     if (cqltrans != 0)
-       cql_transform_close(cqltrans);
+        cql_transform_close(cqltrans);
 
     cqltrans = newcqltrans;
     strcpy(cql_fields, arg);
@@ -3457,7 +3457,7 @@ int cmd_set_auto_reconnect(const char* arg)
     } else if(strcmp(arg,"on")==0) {
         auto_reconnect = 1;
     } else if(strcmp(arg,"off")==0) {
-        auto_reconnect = 0;            
+        auto_reconnect = 0;             
     } else {
         printf("Error use on or off\n");
         return 1;
@@ -3479,7 +3479,7 @@ int cmd_set_auto_wait(const char* arg)
     } else if(strcmp(arg,"on")==0) {
         auto_wait = 1;
     } else if(strcmp(arg,"off")==0) {
-        auto_wait = 0;         
+        auto_wait = 0;          
     } else {
         printf("Error use on or off\n");
         return 1;
@@ -3583,7 +3583,7 @@ int cmd_register_oid(const char* args) {
     oid[i+1] = -1;
     
     new_oident = oid_addent (oid, PROTO_GENERAL, oidclass, oname_str,
-                            VAL_DYNAMIC);  
+                             VAL_DYNAMIC);  
     if(strcmp(new_oident->desc,oname_str))
     {
         fprintf(stderr,"oid is already named as %s, registration failed\n",
@@ -3611,13 +3611,13 @@ void source_rcfile()
     char* homedir=getenv("HOME");
 
     if( homedir ) {
-       
-       sprintf(buffer,"%s/.yazclientrc",homedir);
+        
+        sprintf(buffer,"%s/.yazclientrc",homedir);
 
-       if(stat(buffer,&statbuf)==0) {
-           cmd_source(buffer, 0 );
-       }
-       
+        if(stat(buffer,&statbuf)==0) {
+            cmd_source(buffer, 0 );
+        }
+        
     };
     
     if(stat(".yazclientrc",&statbuf)==0) {
@@ -3677,20 +3677,20 @@ static void handle_srw_record(Z_SRW_record *rec)
 {
     if (rec->recordPosition)
     {
-       printf ("pos=%d", *rec->recordPosition);
-       setno = *rec->recordPosition + 1;
+        printf ("pos=%d", *rec->recordPosition);
+        setno = *rec->recordPosition + 1;
     }
     if (rec->recordSchema)
-       printf (" schema=%s", rec->recordSchema);
+        printf (" schema=%s", rec->recordSchema);
     printf ("\n");
     if (rec->recordData_buf && rec->recordData_len)
     {
-       fwrite(rec->recordData_buf, 1, rec->recordData_len, stdout);
-       if (marc_file)
-           fwrite (rec->recordData_buf, 1, rec->recordData_len, marc_file);
+        fwrite(rec->recordData_buf, 1, rec->recordData_len, stdout);
+        if (marc_file)
+            fwrite (rec->recordData_buf, 1, rec->recordData_len, marc_file);
     }
     else
-       printf ("No data!");
+        printf ("No data!");
     printf("\n");
 }
 
@@ -3707,36 +3707,36 @@ static void handle_srw_response(Z_SRW_searchRetrieveResponse *res)
     
     for (i = 0; i<res->num_diagnostics; i++)
     {
-       if (res->diagnostics[i].uri)
-           printf ("SRW diagnostic %s\n",
-                   res->diagnostics[i].uri);
-       else
-           printf ("SRW diagnostic missing or could not be decoded\n");
-       if (res->diagnostics[i].message)
+        if (res->diagnostics[i].uri)
+            printf ("SRW diagnostic %s\n",
+                    res->diagnostics[i].uri);
+        else
+            printf ("SRW diagnostic missing or could not be decoded\n");
+        if (res->diagnostics[i].message)
             printf ("Message: %s\n", res->diagnostics[i].message);
-       if (res->diagnostics[i].details)
+        if (res->diagnostics[i].details)
             printf ("Details: %s\n", res->diagnostics[i].details);
     }
     if (res->numberOfRecords)
         printf ("Number of hits: %d\n", *res->numberOfRecords);
     for (i = 0; i<res->num_records; i++)
-       handle_srw_record(res->records + i);
+        handle_srw_record(res->records + i);
 }
 
 static void handle_srw_scan_term(Z_SRW_scanTerm *term)
 {
     if (term->displayTerm)
-       printf("%s:", term->displayTerm);
+        printf("%s:", term->displayTerm);
     else if (term->value)
-       printf("%s:", term->value);
+        printf("%s:", term->value);
     else
-       printf("No value:");
+        printf("No value:");
     if (term->numberOfRecords)
-       printf(" %d", *term->numberOfRecords);
+        printf(" %d", *term->numberOfRecords);
     if (term->whereInList)
-       printf(" %s", term->whereInList);
+        printf(" %s", term->whereInList);
     if (term->value && term->displayTerm)
-       printf(" %s", term->value);
+        printf(" %s", term->value);
 
     strcpy(last_scan_line, term->value);
     printf("\n");
@@ -3750,19 +3750,19 @@ static void handle_srw_scan_response(Z_SRW_scanResponse *res)
     
     for (i = 0; i<res->num_diagnostics; i++)
     {
-       if (res->diagnostics[i].uri)
-           printf ("SRW diagnostic %s\n",
-                   res->diagnostics[i].uri);
-       else
-           printf ("SRW diagnostic missing or could not be decoded\n");
-       if (res->diagnostics[i].message)
+        if (res->diagnostics[i].uri)
+            printf ("SRW diagnostic %s\n",
+                    res->diagnostics[i].uri);
+        else
+            printf ("SRW diagnostic missing or could not be decoded\n");
+        if (res->diagnostics[i].message)
             printf ("Message: %s\n", res->diagnostics[i].message);
-       if (res->diagnostics[i].details)
+        if (res->diagnostics[i].details)
             printf ("Details: %s\n", res->diagnostics[i].details);
     }
     if (res->terms)
-       for (i = 0; i<res->num_terms; i++)
-           handle_srw_scan_term(res->terms + i);
+        for (i = 0; i<res->num_terms; i++)
+            handle_srw_scan_term(res->terms + i);
 }
 
 static void http_response(Z_HTTP_Response *hres)
@@ -3805,9 +3805,9 @@ static void http_response(Z_HTTP_Response *hres)
                     soap_package->u.fault->fault_code);
             printf ("SOAP Fault string %s\n", 
                     soap_package->u.fault->fault_string);
-           if (soap_package->u.fault->details)
-               printf ("SOAP Details %s\n", 
-                       soap_package->u.fault->details);
+            if (soap_package->u.fault->details)
+                printf ("SOAP Details %s\n", 
+                        soap_package->u.fault->details);
         }
         else
             ret = -1;
@@ -3817,7 +3817,7 @@ static void http_response(Z_HTTP_Response *hres)
     {
         if (hres->code != 200)
         {
-           printf ("HTTP Error Status=%d\n", hres->code);
+            printf ("HTTP Error Status=%d\n", hres->code);
         }
         else
         {
@@ -3827,18 +3827,18 @@ static void http_response(Z_HTTP_Response *hres)
     }
     else
     {
-       if (!strcmp(hres->version, "1.0"))
-       {
-           /* HTTP 1.0: only if Keep-Alive we stay alive.. */
-           if (!connection_head || strcmp(connection_head, "Keep-Alive"))
-               close_session();
-       }
-       else 
-       {
-           /* HTTP 1.1: only if no close we stay alive .. */
-           if (connection_head && !strcmp(connection_head, "close"))
-               close_session();
-       }
+        if (!strcmp(hres->version, "1.0"))
+        {
+            /* HTTP 1.0: only if Keep-Alive we stay alive.. */
+            if (!connection_head || strcmp(connection_head, "Keep-Alive"))
+                close_session();
+        }
+        else 
+        {
+            /* HTTP 1.1: only if no close we stay alive .. */
+            if (connection_head && !strcmp(connection_head, "close"))
+                close_session();
+        }
     }
 }
 #endif
@@ -3871,7 +3871,7 @@ void wait_and_handle_response(int one_response_only)
                 
                 buf_out = odr_getbuf(out, &len_out, 0);
                 
-               do_hex_dump(buf_out, len_out);
+                do_hex_dump(buf_out, len_out);
 
                 cs_put(conn, buf_out, len_out);
                 
@@ -3886,9 +3886,9 @@ void wait_and_handle_response(int one_response_only)
             break;
         }
 #if HAVE_GETTIMEOFDAY
-       if (got_tv_end == 0)
-           gettimeofday (&tv_end, 0); /* count first one only */
-       got_tv_end++;
+        if (got_tv_end == 0)
+            gettimeofday (&tv_end, 0); /* count first one only */
+        got_tv_end++;
 #endif
         odr_reset(out);
         odr_reset(in); /* release APDU from last round */
@@ -3905,13 +3905,13 @@ void wait_and_handle_response(int one_response_only)
             odr_dumpBER(f, netbuffer, res);
             fprintf(f, "---------\n");
             if (apdu_file)
-           {
+            {
                 z_GDU(print, &gdu, 0, 0);
-               odr_reset(print);
-           }
+                odr_reset(print);
+            }
             if (conn && cs_more(conn))
                 continue;
-           break;
+            break;
         }
         if (ber_file)
             odr_dumpBER(ber_file, netbuffer, res);
@@ -3977,8 +3977,8 @@ void wait_and_handle_response(int one_response_only)
             http_response(gdu->u.HTTP_Response);
         }
 #endif
-       if (one_response_only)
-           break;
+        if (one_response_only)
+            break;
         if (conn && !cs_more(conn))
             break;
     }
@@ -4016,7 +4016,7 @@ int cmd_cclparse(const char* arg)
     else
     {
         if (rpn)
-        {      
+        {       
             ccl_pr_tree(rpn, stdout); 
         }
     }
@@ -4041,11 +4041,11 @@ int cmd_set_otherinfo(const char* args)
         /* reset this otherinfo */
         if(otherinfoNo>=maxOtherInfosSupported) {
             printf("Error otherinfo index to large (%d>%d)\n",
-                  otherinfoNo,maxOtherInfosSupported);
+                   otherinfoNo,maxOtherInfosSupported);
         }
         extraOtherInfos[otherinfoNo].oidval = -1;
         if (extraOtherInfos[otherinfoNo].value)
-           free(extraOtherInfos[otherinfoNo].value);                   
+            free(extraOtherInfos[otherinfoNo].value);                   
         return 0;
     }
     if (sscan_res<3) {
@@ -4055,7 +4055,7 @@ int cmd_set_otherinfo(const char* args)
     
     if (otherinfoNo>=maxOtherInfosSupported) {
         printf("Error otherinfo index to large (%d>%d)\n",
-              otherinfoNo,maxOtherInfosSupported);
+               otherinfoNo,maxOtherInfosSupported);
     }
     
     oidval = oid_getvalbyname (oidstr);
@@ -4075,18 +4075,18 @@ int cmd_sleep(const char* args )
     int sec=atoi(args);
     if( sec > 0 ) {
 #ifdef WIN32
-       Sleep(sec*1000);
+        Sleep(sec*1000);
 #else
-       sleep(sec);
+        sleep(sec);
 #endif
-       printf("Done sleeping %d seconds\n", sec);      
+        printf("Done sleeping %d seconds\n", sec);      
     }
     return 1;    
 }
 
 int cmd_list_otherinfo(const char* args)
 {
-    int i;        
+    int i;         
     
     if(strlen(args)>0) {
         i = atoi(args);
@@ -4103,7 +4103,7 @@ int cmd_list_otherinfo(const char* args)
                        CLASS_RECSYN),
                    extraOtherInfos[i].value);
         
-    } else {           
+    } else {            
         for(i=0; i<maxOtherInfosSupported; ++i) {
             if(extraOtherInfos[i].oidval != -1) 
                 printf("  otherinfo %d %s %s\n",
@@ -4132,7 +4132,7 @@ int cmd_list_all(const char* args) {
             printf("Not connected        : \n");
         
     }
-    if(yazProxy) printf("using proxy          : %s\n",yazProxy);               
+    if(yazProxy) printf("using proxy          : %s\n",yazProxy);                
     
     printf("auto_reconnect       : %s\n",auto_reconnect?"on":"off");
     printf("auto_wait            : %s\n",auto_wait?"on":"off");
@@ -4148,8 +4148,8 @@ int cmd_list_all(const char* args) {
             printf("    Password         : %s\n",auth->u.idPass->password?auth->u.idPass->password:"");
             break;
         case Z_IdAuthentication_open:
-            printf("Authentication       : psOpen\n");                 
-            printf("    Open string      : %s\n",auth->u.open);        
+            printf("Authentication       : psOpen\n");                  
+            printf("    Open string      : %s\n",auth->u.open); 
             break;
         default:
             printf("Authentication       : Unknown\n");
@@ -4199,16 +4199,16 @@ int cmd_clear_otherinfo(const char* args)
             return 0;
         }
         
-        if(extraOtherInfos[otherinfoNo].oidval != -1) {                        
+        if(extraOtherInfos[otherinfoNo].oidval != -1) {                 
             /* only clear if set. */
             extraOtherInfos[otherinfoNo].oidval=-1;
             free(extraOtherInfos[otherinfoNo].value);
         }
     } else {
         int i;
-       
+        
         for(i=0; i<maxOtherInfosSupported; ++i) {
-            if (extraOtherInfos[i].oidval!=-1 ) {                              
+            if (extraOtherInfos[i].oidval!=-1 ) {                               
                 extraOtherInfos[i].oidval=-1;
                 free(extraOtherInfos[i].value);
             }
@@ -4222,11 +4222,11 @@ int cmd_wait_response(const char *arg)
     int wait_for = atoi(arg);
     int i=0;
     if( wait_for < 1 ) {
-       wait_for = 1;
+        wait_for = 1;
     };
     
     for( i=0 ; i < wait_for ; ++i ) {
-       wait_and_handle_response(1);
+        wait_and_handle_response(1);
     };
     return 0;
 }
@@ -4239,7 +4239,7 @@ static struct {
     char *cmd;
     int (*fun)(const char *arg);
     char *ad;
-       completerFunctionType rl_completerfunction;
+        completerFunctionType rl_completerfunction;
     int complete_filenames;
     char **local_tabcompletes;
 } cmd_array[] = {
@@ -4340,7 +4340,7 @@ static int cmd_help (const char *line)
         printf(" @or opl opr                   Or\n");
         printf(" @not opl opr                  And-Not\n");
         printf(" @set set                      Result set\n");
-       printf(" @prox exl dist ord rel uc ut  Proximity. Use help prox\n");
+        printf(" @prox exl dist ord rel uc ut  Proximity. Use help prox\n");
         printf("\n");
         printf("Bib-1 attribute types\n");
         printf("1=Use:         ");
@@ -4358,27 +4358,27 @@ static int cmd_help (const char *line)
     }
     if (!strcmp(topic, "prox"))
     {
-       printf("Proximity:\n");
-       printf(" @prox exl dist ord rel uc ut\n");
-       printf(" exl:  exclude flag . 0=include, 1=exclude.\n");
-       printf(" dist: distance integer.\n");
-       printf(" ord:  order flag. 0=unordered, 1=ordered.\n");
-       printf(" rel:  relation integer. 1<  2<=  3= 4>=  5>  6!= .\n");
-       printf(" uc:   unit class. k=known, p=private.\n");
-       printf(" ut:   unit type. 1=character, 2=word, 3=sentence,\n");
-       printf("        4=paragraph, 5=section, 6=chapter, 7=document,\n");
-       printf("        8=element, 9=subelement, 10=elementType, 11=byte.\n");
-       printf("\nExamples:\n");
-       printf(" Search for a and b in-order at most 3 words apart:\n");
-       printf("  @prox 0 3 1 2 k 2 a b\n");
-       printf(" Search for any order of a and b next to each other:\n");
-       printf("  @prox 0 1 0 3 k 2 a b\n");
+        printf("Proximity:\n");
+        printf(" @prox exl dist ord rel uc ut\n");
+        printf(" exl:  exclude flag . 0=include, 1=exclude.\n");
+        printf(" dist: distance integer.\n");
+        printf(" ord:  order flag. 0=unordered, 1=ordered.\n");
+        printf(" rel:  relation integer. 1<  2<=  3= 4>=  5>  6!= .\n");
+        printf(" uc:   unit class. k=known, p=private.\n");
+        printf(" ut:   unit type. 1=character, 2=word, 3=sentence,\n");
+        printf("        4=paragraph, 5=section, 6=chapter, 7=document,\n");
+        printf("        8=element, 9=subelement, 10=elementType, 11=byte.\n");
+        printf("\nExamples:\n");
+        printf(" Search for a and b in-order at most 3 words apart:\n");
+        printf("  @prox 0 3 1 2 k 2 a b\n");
+        printf(" Search for any order of a and b next to each other:\n");
+        printf("  @prox 0 1 0 3 k 2 a b\n");
     }
     return 1;
 }
 
 int cmd_register_tab(const char* arg) {
-       
+        
     char command[101], tabargument[101];
     int i;
     int num_of_tabs;
@@ -4404,7 +4404,7 @@ int cmd_register_tab(const char* arg) {
     if(!cmd_array[i].local_tabcompletes)
         cmd_array[i].local_tabcompletes = (char **) calloc(1,sizeof(char**));
     
-    num_of_tabs=0;             
+    num_of_tabs=0;              
     
     tabslist = cmd_array[i].local_tabcompletes;
     for(;tabslist && *tabslist;tabslist++) {
@@ -4500,8 +4500,8 @@ char *command_generator(const char *text, int state)
 char ** readline_completer(char *text, int start, int end) {
 #if HAVE_READLINE_READLINE_H
 
-       completerFunctionType completerToUse;
-       
+        completerFunctionType completerToUse;
+        
     if(start == 0) {
 #if HAVE_READLINE_RL_COMPLETION_MATCHES
         char** res=rl_completion_matches(text,
@@ -4607,7 +4607,7 @@ static void show_version(void)
     yaz_version(vstr, 0);
     printf ("YAZ version: %s\n", YAZ_VERSION);
     if (strcmp(vstr, YAZ_VERSION))
-       printf ("YAZ DLL/SO: %s\n", vstr);
+        printf ("YAZ DLL/SO: %s\n", vstr);
     exit(0);
 }
 
@@ -4629,7 +4629,7 @@ int main(int argc, char **argv)
 #endif
 #endif
     if (codeset)
-       outputCharset = xstrdup(codeset);
+        outputCharset = xstrdup(codeset);
     
     ODR_MASK_SET(&z3950_options, Z_Options_search);
     ODR_MASK_SET(&z3950_options, Z_Options_present);
@@ -4651,16 +4651,16 @@ int main(int argc, char **argv)
                 strcpy (open_command, "open ");
                 strcat (open_command, arg);
             }
-           else
-           {
-               fprintf(stderr, "%s: Specify at most one server address\n",
-                       prog);
-               exit(1);
-           }
+            else
+            {
+                fprintf(stderr, "%s: Specify at most one server address\n",
+                        prog);
+                exit(1);
+            }
+            break;
+        case 'd':
+            dump_file_prefix = arg;
             break;
-       case 'd':
-           dump_file_prefix = arg;
-           break;
         case 'k':
             kilobytes = atoi(arg);
             break;
@@ -4694,9 +4694,9 @@ int main(int argc, char **argv)
             else
                 apdu_file=fopen(arg, "a");
             break;
-       case 'x':
-           hex_dump = 1;
-           break;
+        case 'x':
+            hex_dump = 1;
+            break;
         case 'p':
             yazProxy=strdup(arg);
             break;
@@ -4712,21 +4712,21 @@ int main(int argc, char **argv)
             yaz_log_init(yaz_log_mask_str(arg), "", 0);
             break;
         case 'V':
-           show_version();
+            show_version();
             break;
         default:
             fprintf (stderr, "Usage: %s "
-                    " [-a <apdulog>]"
+                     " [-a <apdulog>]"
                      " [-b berdump]"
-                    " [-d dump]\n"
-                    " [-c cclfields]"
+                     " [-d dump]\n"
+                     " [-c cclfields]"
                      " [-k size]"
-                    " [-m <marclog>]\n" 
-                    " [-p <proxy-addr>]"
-                    " [-q cqlfields]"
-                    " [-u <auth>]"
-                    " [-V]"
-                    " [<server-addr>]\n",
+                     " [-m <marclog>]\n" 
+                     " [-p <proxy-addr>]"
+                     " [-q cqlfields]"
+                     " [-u <auth>]"
+                     " [-V]"
+                     " [<server-addr>]\n",
                      prog);
             exit (1);
         }      
@@ -4757,3 +4757,11 @@ int main(int argc, char **argv)
     client ();
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 01bb0e0..b748c10 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tabcomplete.c,v 1.11 2005-06-24 19:56:52 adam Exp $
+ * $Id: tabcomplete.c,v 1.12 2005-06-25 15:46:01 adam Exp $
  */
 
 #include <string.h>
@@ -21,7 +21,7 @@ extern char** curret_global_list;
  * ***************************************************************************/
 
 char* complete_from_list(char* completions[], const char *text, int state)
-{      
+{       
     static int idx;
     
     if(!completions) return NULL;
@@ -34,7 +34,7 @@ char* complete_from_list(char* completions[], const char *text, int state)
            _strnicmp
 #else
            strncasecmp
-#endif             
+#endif              
            (completions[idx],text,strlen(text))) {
             ++idx; /* skip this entry on the next run */ 
             return (char*)strdup(completions[idx-1]);
@@ -70,16 +70,16 @@ void oid_loader(struct oident* oid, void* data_)
     
     if((oid->oclass == CLASS_GENERAL) || (oid->oclass == data->oclass)) {
         if(data->index==data->max) {
-                       data->values=(char**)realloc(data->values,((data->max+1)*2)*sizeof(char*));
-                       data->max=(data->max+1)*2 - 1;
+                        data->values=(char**)realloc(data->values,((data->max+1)*2)*sizeof(char*));
+                        data->max=(data->max+1)*2 - 1;
         };
         data->values[data->index]=oid->desc;
-        ++data->index;         
+        ++data->index;          
     }
 }
 
-char** build_list_for_oclass(oid_class oclass) {       
-    oid_callback_t data;       
+char** build_list_for_oclass(oid_class oclass) {        
+    oid_callback_t data;        
     data.values = (char **) calloc(10,sizeof(char*));
     data.index = 0;
     data.max = 9;
@@ -88,7 +88,7 @@ char** build_list_for_oclass(oid_class oclass) {
     oid_trav(oid_loader, &data);
     
     data.values[data.index]=0;
-    return data.values;           
+    return data.values;    
 }
 
 /* ***************************************************************************
@@ -115,7 +115,7 @@ char* complete_format(const char* text, int state)
     char** list=build_list_for_oclass(CLASS_RECSYN);
     char* res=complete_from_list(list,text,state);  
     
-    free(list);        
+    free(list); 
     return res;
 }
 
@@ -124,7 +124,7 @@ char* complete_schema(const char* text, int state)
     char** list=build_list_for_oclass(CLASS_SCHEMA);
     char* res=complete_from_list(list,text,state);  
     
-    free(list);        
+    free(list); 
     return res;
 }
 
@@ -134,7 +134,7 @@ char* complete_attributeset(const char* text, int state)
     char** list=build_list_for_oclass(CLASS_ATTSET);
     char* res=complete_from_list(list,text,state);  
     
-    free(list);        
+    free(list); 
     return res;
 }
 
@@ -144,3 +144,11 @@ char* default_completer(const char* text, int state)
     return complete_from_list(curret_global_list,text,state);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e8e4841..aff7707 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tabcomplete.h,v 1.5 2005-01-15 19:47:08 adam Exp $
+ * $Id: tabcomplete.h,v 1.6 2005-06-25 15:46:01 adam Exp $
  */
 
 /* 
@@ -15,10 +15,11 @@ char* complete_schema(const char* text, int state);
 char* complete_attributeset(const char* text, int state);
 char* default_completer(const char* text, int state);
 char* complete_auto_reconnect(const char *text, int state);
 /*
  * Local variables:
- * tab-width: 4
  * c-basic-offset: 4
+ * indent-tabs-mode: nil
  * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
  */
+
index c417ad1..b506bc0 100644 (file)
--- a/header.c
+++ b/header.c
@@ -2,7 +2,15 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: header.c,v 1.9 2005-01-15 19:47:08 adam Exp $
+ * $Id: header.c,v 1.10 2005-06-25 15:46:01 adam Exp $
  *
  */
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 1d56e06..ef78d7a 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: backend.h,v 1.31 2005-05-20 19:29:18 adam Exp $
+ * $Id: backend.h,v 1.32 2005-06-25 15:46:01 adam Exp $
  */
 
 /** 
@@ -241,7 +241,7 @@ typedef struct bend_initresult
 } bend_initresult;
 
 YAZ_EXPORT void bend_request_send (bend_association a, bend_request req,
-                                  Z_APDU *res);
+                                   Z_APDU *res);
 
 YAZ_EXPORT bend_request bend_request_mk (bend_association a);
 
@@ -305,3 +305,11 @@ YAZ_EXPORT int check_ip_tcpd(void *cd, const char *addr, int len, int type);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d0a2b09..6296864 100644 (file)
@@ -49,7 +49,7 @@
 /*
  * CCL - header file
  *
- * $Id: ccl.h,v 1.22 2005-04-15 21:47:55 adam Exp $
+ * $Id: ccl.h,v 1.23 2005-06-25 15:46:01 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -124,10 +124,10 @@ struct ccl_rpn_attr {
 #define CCL_RPN_ATTR_NUMERIC 1
 #define CCL_RPN_ATTR_STRING 2
     union {
-       /** numeric attribute value */
-       int numeric;
-       /** string attribute value */
-       char *str;
+        /** numeric attribute value */
+        int numeric;
+        /** string attribute value */
+        char *str;
     } value;
 };
 
@@ -143,15 +143,15 @@ struct ccl_rpn_node {
     /** RPN tree node type */
     int kind;
     union {
-       /** Boolean including proximity 0=left, 2=right, 3=prox parms */
-       struct ccl_rpn_node *p[3];
-       /** Attributes + Term */
-       struct {
-           char *term;
-           struct ccl_rpn_attr *attr_list;
-       } t;
-       /** Result set */
-       char *setname;
+        /** Boolean including proximity 0=left, 2=right, 3=prox parms */
+        struct ccl_rpn_node *p[3];
+        /** Attributes + Term */
+        struct {
+            char *term;
+            struct ccl_rpn_attr *attr_list;
+        } t;
+        /** Result set */
+        char *setname;
     } u;
 };
 
@@ -298,7 +298,7 @@ struct ccl_token *ccl_token_add (struct ccl_token *at);
  */
 YAZ_EXPORT
 struct ccl_rpn_node *ccl_find_str (CCL_bibset bibset,
-                                  const char *str, int *error, int *pos);
+                                   const char *str, int *error, int *pos);
 
 /**
  * Parses CCL Find command from a list of CCL tokens. Otherwise similar to
@@ -354,7 +354,7 @@ void ccl_qual_add (CCL_bibset b, const char *name, int no, int *attr);
 /** Add qualifier and supply attributes pairs+attribute set for it */
 YAZ_EXPORT
 void ccl_qual_add_set (CCL_bibset b, const char *name, int no,
-                      int *type, int *value, char **svalue, char **attsets);
+                       int *type, int *value, char **svalue, char **attsets);
 
 /** Add special qualifier */
 YAZ_EXPORT
@@ -383,7 +383,7 @@ void ccl_qual_line(CCL_bibset bibset, char *line);
 /* Add CCL qualifier by using qual_name + value pair */
 YAZ_EXPORT
 void ccl_qual_fitem (CCL_bibset bibset, const char *value,
-                    const char *qual_name);
+                     const char *qual_name);
 
 /** Make CCL qualifier set */
 YAZ_EXPORT
@@ -407,7 +407,7 @@ int ccl_memicmp (const char *s1, const char *s2, size_t n);
 /** Search for qualifier 'name' in set 'b'. */
 YAZ_EXPORT
 struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp, const char *name,
-                                     size_t len, int seq);
+                                      size_t len, int seq);
 
 /** Create CCL parser */
 YAZ_EXPORT
@@ -424,7 +424,7 @@ char *ccl_strdup (const char *str);
 /** Search for special qualifier */
 YAZ_EXPORT
 const char *ccl_qual_search_special (CCL_bibset b,
-                                               const char *name);
+                                                const char *name);
 /** Pretty-print CCL RPN node tree to WRBUF */
 YAZ_EXPORT
 void ccl_pquery (WRBUF w, struct ccl_rpn_node *p);
@@ -437,3 +437,11 @@ YAZ_END_CDECL
 
 #endif
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index f8815af..8b21d33 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: charneg.h,v 1.6 2005-05-18 12:38:40 adam Exp $
+ * $Id: charneg.h,v 1.7 2005-06-25 15:46:01 adam Exp $
  */
 /** 
  * \file charneg.h
@@ -64,15 +64,15 @@ int yaz_del_charneg_record(Z_OtherInformation **p);
  */
 YAZ_EXPORT
 Z_External *yaz_set_proposal_charneg(ODR odr,
-                                    const char **charsets, int num_charsets,
-                                    const char **langs,
-                                    int num_langs, int selected);
+                                     const char **charsets, int num_charsets,
+                                     const char **langs,
+                                     int num_langs, int selected);
 
 YAZ_EXPORT
 void yaz_get_response_charneg(NMEM mem,
-                             Z_CharSetandLanguageNegotiation *p,
-                             char **charset, char **lang,
-                             int *selected);
+                              Z_CharSetandLanguageNegotiation *p,
+                              char **charset, char **lang,
+                              int *selected);
 
 /*
  * Server's part
@@ -80,16 +80,24 @@ void yaz_get_response_charneg(NMEM mem,
  
 YAZ_EXPORT
 Z_External *yaz_set_response_charneg(ODR odr,
-                                    const char *charset, const char *lang,
-                                    int selected);
+                                     const char *charset, const char *lang,
+                                     int selected);
 
 
 YAZ_EXPORT
 void yaz_get_proposal_charneg(NMEM mem,
-                             Z_CharSetandLanguageNegotiation *p,
-                             char ***charsets, int *num_charsets,
-                             char ***langs, int *num_langs,
-                             int *selected);
+                              Z_CharSetandLanguageNegotiation *p,
+                              char ***charsets, int *num_charsets,
+                              char ***langs, int *num_langs,
+                              int *selected);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e830c39..b335c86 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: comstack.h,v 1.20 2005-02-01 14:37:47 adam Exp $
+ * $Id: comstack.h,v 1.21 2005-06-25 15:46:01 adam Exp $
  */
 
 /** 
@@ -82,8 +82,8 @@ struct comstack
 #define CS_CLIENT 0
 #define CS_SERVER 1
     int (*f_listen)(COMSTACK h, char *raddr, int *addrlen,
-                  int (*check_ip)(void *cd, const char *a, int len, int type),
-                  void *cd);
+                   int (*check_ip)(void *cd, const char *a, int len, int type),
+                   void *cd);
     COMSTACK (*f_accept)(COMSTACK handle);
     int (*f_close)(COMSTACK handle);
     char *(*f_addrstr)(COMSTACK handle);
@@ -104,7 +104,7 @@ struct comstack
 #define cs_close(handle) ((*(handle)->f_close)(handle))
 #define cs_create(type, blocking, proto) ((*type)(-1, blocking, proto, 0))
 #define cs_createbysocket(sock, type, blocking, proto) \
-       ((*type)(sock, blocking, proto, 0))
+        ((*type)(sock, blocking, proto, 0))
 #define cs_type(handle) ((handle)->type)
 #define cs_fileno(handle) ((handle)->iofile)
 #define cs_stackerr(handle) ((handle)->stackerr)
@@ -116,7 +116,7 @@ struct comstack
 #define cs_want_read(handle) ((handle)->io_pending & CS_WANT_READ)
 #define cs_want_write(handle) ((handle)->io_pending & CS_WANT_WRITE)
 #define cs_set_blocking(handle,blocking) ((handle)->f_set_blocking(handle, blocking))
-                                         
+                                          
 #define CS_WANT_READ 1
 #define CS_WANT_WRITE 2
 
@@ -135,7 +135,7 @@ YAZ_EXPORT int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len);
 /*
  * error management.
  */
-                                         
+                                          
 #define CSNONE     0
 #define CSYSERR    1
 #define CSOUTSTATE 2
@@ -143,7 +143,7 @@ YAZ_EXPORT int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len);
 #define CSWRONGBUF 4
 #define CSDENY     5
 #define CSERRORSSL 6
-#define CSLASTERROR CSERRORSSL /* must be the value of last CS error */
+#define CSLASTERROR CSERRORSSL  /* must be the value of last CS error */
 
 /* backwards compatibility */
 #define CS_SR     PROTO_SR
@@ -152,3 +152,11 @@ YAZ_EXPORT int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 33c7295..3a6215a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cql.h,v 1.11 2005-01-15 19:47:09 adam Exp $
+/* $Id: cql.h,v 1.12 2005-06-25 15:46:02 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -81,30 +81,30 @@ struct cql_node {
     /** node type */
     int which;
     union {
-       /** which == CQL_NODE_ST */
+        /** which == CQL_NODE_ST */
         struct {
-           /** CQL index */
+            /** CQL index */
             char *index;
-           /** CQL index URI or NULL if no URI */
-           char *index_uri;
-           /** Search term */
+            /** CQL index URI or NULL if no URI */
+            char *index_uri;
+            /** Search term */
             char *term;
-           /** relation */
+            /** relation */
             char *relation;
-           /** relation URL or NULL if no relation URI) */
-           char *relation_uri;
-           /** relation modifiers */
+            /** relation URL or NULL if no relation URI) */
+            char *relation_uri;
+            /** relation modifiers */
             struct cql_node *modifiers;
         } st;
-       /** which == CQL_NODE_BOOL */
+        /** which == CQL_NODE_BOOL */
         struct {
             /** operator name "and", "or", ... */
             char *value;
-           /** left operand */
+            /** left operand */
             struct cql_node *left;
-           /** right operand */ 
+            /** right operand */ 
             struct cql_node *right;
-           /** modifiers (NULL for no list) */
+            /** modifiers (NULL for no list) */
             struct cql_node *modifiers;
         } boolean;
     } u;
@@ -153,7 +153,7 @@ struct cql_node *cql_node_mk_sc(NMEM nmem, const char *index,
  */
 YAZ_EXPORT
 struct cql_node *cql_apply_prefix(NMEM nmem, struct cql_node *cn,
-                                 const char *prefix, const char *uri);
+                                  const char *prefix, const char *uri);
 
 /**
  * This function creates a boolean node.
@@ -285,3 +285,11 @@ YAZ_END_CDECL
 
 #endif
 /* CQL_H_INCLUDED */
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 7c0b62b..a2577b5 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ill.h,v 1.7 2005-01-15 19:47:09 adam Exp $
+ * $Id: ill.h,v 1.8 2005-06-25 15:46:02 adam Exp $
  */
 #ifndef ILL_H
 #define ILL_H
@@ -33,3 +33,11 @@ YAZ_EXPORT ILL_APDU *ill_get_APDU (
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index afd68e2..418aef3 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: log.h,v 1.33 2005-05-18 12:30:00 adam Exp $
+ * $Id: log.h,v 1.34 2005-06-25 15:46:02 adam Exp $
  */
 
 /**
@@ -104,9 +104,9 @@ YAZ_EXPORT void yaz_log_init_max_size(int mx);
  * yaz_log_init_level, optionally defined via yaz_log_mask_str. */
 YAZ_EXPORT void yaz_log(int level, const char *fmt, ...)
 #ifdef __GNUC__
-       __attribute__ ((format (printf, 2, 3)))
+        __attribute__ ((format (printf, 2, 3)))
 #endif
-       ;
+        ;
 
 /** 
  * yaz_log_mask_str converts a comma-separated list of log levels to a bit 
@@ -132,9 +132,9 @@ YAZ_EXPORT int yaz_log_module_level(const char *name);
 YAZ_EXPORT FILE *yaz_log_file(void);
 
 YAZ_EXPORT void log_event_start(void (*func)(int level, const char *msg, void *info),
-       void *info);
+        void *info);
 YAZ_EXPORT void log_event_end(void (*func)(int level, const char *msg, void *info),
-       void *info);
+        void *info);
 
 YAZ_EXPORT void yaz_log_reopen(void);
 
@@ -174,3 +174,11 @@ YAZ_EXPORT void yaz_log_reopen(void);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 0d80685..7b1ea55 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: logrpn.h,v 1.7 2005-01-15 19:47:09 adam Exp $
+ * $Id: logrpn.h,v 1.8 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -37,3 +37,11 @@ YAZ_EXPORT void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index f027be3..4c425f3 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: marcdisp.h,v 1.13 2005-02-08 13:51:30 adam Exp $
+ * $Id: marcdisp.h,v 1.14 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -78,7 +78,7 @@ YAZ_EXPORT int marc_display_ex (const char *buf, FILE *outf, int debug);
 YAZ_EXPORT int marc_display_exl (const char *buf, FILE *outf, int debug,
                                  int length);
 YAZ_EXPORT int marc_display_wrbuf (const char *buf, WRBUF wr, int debug,
-                                  int bsize);
+                                   int bsize);
 YAZ_EXPORT int yaz_marc_decode(const char *buf, WRBUF wr,
                                int debug, int bsize, int xml);
 
@@ -96,3 +96,11 @@ YAZ_EXPORT int atoi_n (const char *buf, int len);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b424be0..bd4ff09 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: nmem.h,v 1.16 2005-06-03 20:30:30 adam Exp $
+ * $Id: nmem.h,v 1.17 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -64,10 +64,10 @@ YAZ_EXPORT int nmem_total(NMEM n);
 YAZ_EXPORT char *nmem_strdup (NMEM mem, const char *src);
 YAZ_EXPORT char *nmem_strdupn (NMEM mem, const char *src, size_t n);
 YAZ_EXPORT void nmem_strsplit_blank(NMEM nmem, const char *dstr,
-                                   char ***darray, int *num);
+                                    char ***darray, int *num);
 YAZ_EXPORT void nmem_strsplit(NMEM nmem, const char *delim,
-                             const char *dstr,
-                             char ***darray, int *num);
+                              const char *dstr,
+                              char ***darray, int *num);
 
 YAZ_EXPORT int *nmem_intdup (NMEM mem, int v);
 YAZ_EXPORT void nmem_transfer (NMEM dst, NMEM src);
@@ -106,3 +106,11 @@ YAZ_EXPORT void yaz_strerror(char *buf, int max);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 43f352c..421f44a 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: odr.h,v 1.20 2005-05-26 21:47:16 adam Exp $
+ * $Id: odr.h,v 1.21 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -230,10 +230,10 @@ YAZ_EXPORT Odr_null *odr_nullval(void);
 
 YAZ_EXPORT int ber_boolean(ODR o, int *val);
 YAZ_EXPORT int ber_tag(ODR o, void *p, int zclass, int tag,
-                      int *constructed, int opt, const char *name);
+                       int *constructed, int opt, const char *name);
 YAZ_EXPORT int ber_enctag(ODR o, int zclass, int tag, int constructed);
 YAZ_EXPORT int ber_dectag(const unsigned char *buf, int *zclass,
-                         int *tag, int *constructed, int max);
+                          int *tag, int *constructed, int max);
 YAZ_EXPORT int odr_bool(ODR o, int **p, int opt, const char *name);
 YAZ_EXPORT int odr_integer(ODR o, int **p, int opt, const char *name);
 YAZ_EXPORT int odr_enum(ODR o, int **p, int opt, const char *name);
@@ -245,7 +245,7 @@ YAZ_EXPORT int ber_null(ODR o);
 YAZ_EXPORT int odr_null(ODR o, Odr_null **p, int opt, const char *name);
 YAZ_EXPORT int ber_integer(ODR o, int *val);
 YAZ_EXPORT int odr_constructed_begin(ODR o, void *p, int zclass, int tag,
-                                    const char *name);
+                                     const char *name);
 YAZ_EXPORT int odr_constructed_end(ODR o);
 YAZ_EXPORT int odr_sequence_begin(ODR o, void *p, int size, const char *name);
 YAZ_EXPORT int odr_set_begin(ODR o, void *p, int size, const char *name);
@@ -256,19 +256,19 @@ YAZ_EXPORT int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name);
 YAZ_EXPORT int odp_more_chunks(ODR o, const unsigned char *base, int len);
 YAZ_EXPORT int odr_constructed_more(ODR o);
 YAZ_EXPORT int odr_bitstring(ODR o, Odr_bitmask **p, int opt,
-                            const char *name);
+                             const char *name);
 YAZ_EXPORT int ber_bitstring(ODR o, Odr_bitmask *p, int cons);
 YAZ_EXPORT int odr_generalstring(ODR o, char **p, int opt, const char *name);
 YAZ_EXPORT int ber_oidc(ODR o, Odr_oid *p, int max_oid_size);
 YAZ_EXPORT int odr_oid(ODR o, Odr_oid **p, int opt, const char *name);
 YAZ_EXPORT int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
-                         const char *name);
+                          const char *name);
 YAZ_EXPORT int odr_cstring(ODR o, char **p, int opt, const char *name);
 YAZ_EXPORT int odr_iconv_string(ODR o, char **p, int opt, const char *name);
 YAZ_EXPORT int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num,
-                              const char *name);
+                               const char *name);
 YAZ_EXPORT int odr_set_of(ODR o, Odr_fun type, void *p, int *num,
-                         const char *name);
+                          const char *name);
 YAZ_EXPORT int odr_any(ODR o, Odr_any **p, int opt, const char *name);
 YAZ_EXPORT int ber_any(ODR o, Odr_any **p);
 YAZ_EXPORT int completeBER(const unsigned char *buf, int len);
@@ -304,30 +304,30 @@ typedef struct Odr_external
 #define ODR_EXTERNAL_arbitrary 2
     union
     {
-       Odr_any  *single_ASN1_type;
-       Odr_oct  *octet_aligned; 
-       Odr_bitmask *arbitrary;      /* we aren't really equipped for this*/
+        Odr_any  *single_ASN1_type;
+        Odr_oct  *octet_aligned; 
+        Odr_bitmask *arbitrary;      /* we aren't really equipped for this*/
     } u;
 } Odr_external;
 
 YAZ_EXPORT int odr_external(ODR o, Odr_external **p, int opt,
-                           const char *name);
+                            const char *name);
 YAZ_EXPORT int odr_visiblestring(ODR o, char **p, int opt,
-                                const char *name);
+                                 const char *name);
 YAZ_EXPORT int odr_graphicstring(ODR o, char **p, int opt,
-                                const char *name);
+                                 const char *name);
 YAZ_EXPORT int odr_generalizedtime(ODR o, char **p, int opt,
-                                  const char *name);
+                                   const char *name);
 
 YAZ_EXPORT int odr_set_charset(ODR o, const char *to, const char *from);
 
 YAZ_EXPORT void odr_set_stream(ODR o,  void *handle,
-                              void (*stream_write)(ODR o, 
-                                                   void *handle,
-                                                   int type,
-                                                   const char *buf,
-                                                   int len),
-                              void (*stream_close)(void *handle));
+                               void (*stream_write)(ODR o, 
+                                                    void *handle,
+                                                    int type,
+                                                    const char *buf,
+                                                    int len),
+                               void (*stream_close)(void *handle));
 
 YAZ_EXPORT void odr_printf(ODR o, const char *fmt, ...);
 
@@ -338,3 +338,11 @@ YAZ_END_CDECL
 #include <yaz/xmalloc.h>
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 19fb305..05849fe 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: oid.h,v 1.26 2005-06-21 07:33:08 adam Exp $
+ * $Id: oid.h,v 1.27 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -256,8 +256,8 @@ YAZ_EXPORT int oid_oidlen(int *o);
 YAZ_EXPORT oid_value oid_getvalbyname(const char *name);
 YAZ_EXPORT void oid_setprivateoids(oident *list);
 YAZ_EXPORT struct oident *oid_addent (int *oid, enum oid_proto proto,
-                                     enum oid_class oclass,
-                                     const char *desc, int value);
+                                      enum oid_class oclass,
+                                      const char *desc, int value);
 
 YAZ_EXPORT void oid_trav (void (*func)(struct oident *oidinfo, void *vp),
                           void *vp);
@@ -267,8 +267,16 @@ YAZ_EXPORT void oid_exit(void);
 YAZ_EXPORT int *oid_name_to_oid(oid_class oclass, const char *name, int *oid);
 YAZ_EXPORT char *oid_to_dotstring(const int *oid, char *oidbuf);
 YAZ_EXPORT char *oid_name_to_dotstring(oid_class oclass, const char *name,
-                                      char *oidbuf);
+                                       char *oidbuf);
 
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a285f2b..2a71410 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: options.h,v 1.5 2005-01-15 19:47:09 adam Exp $
+ * $Id: options.h,v 1.6 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -42,4 +42,12 @@ YAZ_EXPORT int options (const char *desc, char **argv, int argc, char **arg);
 YAZ_END_CDECL
 
 #endif
-       
+        
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index af86a17..cb429cb 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: otherinfo.h,v 1.4 2005-01-15 19:47:09 adam Exp $
+ * $Id: otherinfo.h,v 1.5 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file otherinfo.h
@@ -37,3 +37,11 @@ YAZ_EXPORT char *yaz_oi_get_string_oidval(
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e50c913..183201e 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: pquery.h,v 1.6 2005-01-15 19:47:09 adam Exp $
+ * $Id: pquery.h,v 1.7 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file pquery.h
@@ -81,3 +81,11 @@ YAZ_EXPORT int yaz_pqf_error (YAZ_PQF_Parser p, const char **msg, size_t *off);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2ba1770..1d796ba 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: proto.h,v 1.20 2005-02-25 17:05:09 adam Exp $
+ * $Id: proto.h,v 1.21 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file proto.h
@@ -109,9 +109,9 @@ typedef struct Z_IOItemOrder Z_ItemOrder;
 YAZ_EXPORT Z_APDU *zget_APDU(ODR o, int which);
 YAZ_EXPORT Z_Close *zget_Close (ODR o);
 YAZ_EXPORT Odr_oid *yaz_oidval_to_z3950oid (ODR o, int oid_class,
-                                           int oid_value);
+                                            int oid_value);
 YAZ_EXPORT Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class,
-                                        const char *str);
+                                         const char *str);
 YAZ_EXPORT const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class);
 
 YAZ_EXPORT const char* yaz_z3950_oid_value_to_str(oid_value ov, oid_class oc);
@@ -127,22 +127,22 @@ void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf);
 
 /** \brief Encodes Z39.50 Init OPtions based on string mnemonics */
 YAZ_EXPORT int yaz_init_opt_encode(Z_Options *opt, const char *opt_str,
-                                  int *error_pos);
+                                   int *error_pos);
 
 /** \brief Decodes Z39.50 Init Options - for printing */
 YAZ_EXPORT void yaz_init_opt_decode(Z_Options *opt,
-                                   void (*pr)(const char *name,
-                                              void *clientData),
-                                   void *clientData);
+                                    void (*pr)(const char *name,
+                                               void *clientData),
+                                    void *clientData);
 /** \brief Creates Default Diag Format Diagnostic */
 YAZ_EXPORT
 Z_DefaultDiagFormat *zget_DefaultDiagFormat(ODR o, int error,
-                                           const char *addinfo);
+                                            const char *addinfo);
 
 /** \brief Creates Surrogate Diagnostic Records */
 YAZ_EXPORT
 Z_NamePlusRecord *zget_surrogateDiagRec(ODR o, const char *dbname,
-                                       int error, const char *addinfo);
+                                        int error, const char *addinfo);
 
 /** \brief Creates Initialize Response diagnostics */
 YAZ_EXPORT
@@ -165,3 +165,11 @@ YAZ_END_CDECL
 #include <yaz/prt-ext.h>
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 659a9e3..ed29603 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: prt-ext.h,v 1.12 2005-01-27 09:08:42 adam Exp $
+ * $Id: prt-ext.h,v 1.13 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -95,34 +95,34 @@ struct Z_External
 #define Z_External_OCLCUserInfo 28
     union
     {
-       /* Generic types */
-       Odr_any *single_ASN1_type;
-       Odr_oct *octet_aligned;
-       Odr_bitmask *arbitrary;
-
-       /* Specific types */
-       Z_SUTRS *sutrs;
-       Z_ExplainRecord *explainRecord;
-
-       Z_ResourceReport1 *resourceReport1;
-       Z_ResourceReport2 *resourceReport2;
-       Z_PromptObject1 *promptObject1;
-       Z_GenericRecord *grs1;
-       Z_TaskPackage *extendedService;
-
-       Z_ItemOrder *itemOrder;
-       Z_DiagnosticFormat *diag1;
-       Z_Espec1 *espec1;
-       Z_BriefBib *summary;
+        /* Generic types */
+        Odr_any *single_ASN1_type;
+        Odr_oct *octet_aligned;
+        Odr_bitmask *arbitrary;
+
+        /* Specific types */
+        Z_SUTRS *sutrs;
+        Z_ExplainRecord *explainRecord;
+
+        Z_ResourceReport1 *resourceReport1;
+        Z_ResourceReport2 *resourceReport2;
+        Z_PromptObject1 *promptObject1;
+        Z_GenericRecord *grs1;
+        Z_TaskPackage *extendedService;
+
+        Z_ItemOrder *itemOrder;
+        Z_DiagnosticFormat *diag1;
+        Z_Espec1 *espec1;
+        Z_BriefBib *summary;
         Z_OPACRecord *opac;
 
-       Z_SearchInfoReport *searchResult1;
-       Z_IUUpdate *update;
-       Z_DateTime *dateTime;
+        Z_SearchInfoReport *searchResult1;
+        Z_IUUpdate *update;
+        Z_DateTime *dateTime;
         Z_UniverseReport *universeReport;
         Z_Admin *adminService;
 
-       Z_IU0Update *update0;
+        Z_IU0Update *update0;
         Z_OtherInformation *userInfo1;
         Z_CharSetandLanguageNegotiation *charNeg3;
         Z_PromptObject1 *acfPrompt1;
@@ -131,7 +131,7 @@ struct Z_External
         Z_KRBObject *acfKrb1;
         Z_MultipleSearchTerms_2 *multipleSearchTerms_2;
         Z_InternationalString *cql;
-       Z_OCLC_UserInformation *oclc;
+        Z_OCLC_UserInformation *oclc;
     } u;
 };
 
@@ -142,8 +142,16 @@ YAZ_EXPORT int z_External(ODR o, Z_External **p, int opt, const char *name);
 YAZ_EXPORT Z_ext_typeent *z_ext_getentbyref(oid_value val);
 /** \brief encodes EXTERNAL record based on OID (NULL if knot known) */
 YAZ_EXPORT Z_External *z_ext_record(ODR o, int format, const char *buf,
-                                   int len);
+                                    int len);
 
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 7eeaf07..522cdd7 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: readconf.h,v 1.4 2005-01-15 19:47:10 adam Exp $
+ * $Id: readconf.h,v 1.5 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file readconf.h
@@ -40,11 +40,19 @@ YAZ_BEGIN_CDECL
     
 YAZ_EXPORT int readconf(char *name, void *rprivate,
                         int (*fun)(char *name, void *rprivate,
-                                  int argc, char *argv[]));
+                                   int argc, char *argv[]));
 
 YAZ_EXPORT int readconf_line(FILE *f, int *lineno,
-                            char *line, int len, char *argv[], int num);
+                             char *line, int len, char *argv[], int num);
     
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2211c4b..c920874 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: soap.h,v 1.9 2005-01-15 19:47:10 adam Exp $
+ * $Id: soap.h,v 1.10 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file soap.h
@@ -42,7 +42,7 @@ typedef struct {
 } Z_SOAP;
 
 typedef int (*Z_SOAP_fun)(ODR o, void * ptr, void **handler_data,
-                        void *client_data, const char *ns);
+                         void *client_data, const char *ns);
 typedef struct {
     char *ns;
     void *client_data;
@@ -53,14 +53,14 @@ YAZ_EXPORT int z_soap_codec(ODR o, Z_SOAP **pp,
                             char **content_buf, int *content_len,
                             Z_SOAP_Handler *handlers);
 YAZ_EXPORT int z_soap_codec_enc(ODR o, Z_SOAP **pp, 
-                               char **content_buf, int *content_len,
-                               Z_SOAP_Handler *handlers,
-                               const char *encoding);
+                                char **content_buf, int *content_len,
+                                Z_SOAP_Handler *handlers,
+                                const char *encoding);
 YAZ_EXPORT int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, 
-                                   char **content_buf, int *content_len,
-                                   Z_SOAP_Handler *handlers,
-                                   const char *encoding,
-                                   const char *stylesheet);
+                                    char **content_buf, int *content_len,
+                                    Z_SOAP_Handler *handlers,
+                                    const char *encoding,
+                                    const char *stylesheet);
 
 YAZ_EXPORT int z_soap_error(ODR o, Z_SOAP *p,
                             const char *fault_code, const char *fault_string,
@@ -68,3 +68,11 @@ YAZ_EXPORT int z_soap_error(ODR o, Z_SOAP *p,
 
 YAZ_END_CDECL
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index de395aa..a01cb62 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: sortspec.h,v 1.3 2005-01-15 19:47:10 adam Exp $
+ * $Id: sortspec.h,v 1.4 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file sortspec.h
@@ -43,3 +43,11 @@ YAZ_END_CDECL
 
 #endif
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2f6b505..24fd5d6 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: srw.h,v 1.21 2005-04-22 08:27:57 adam Exp $
+ * $Id: srw.h,v 1.22 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file srw.h
@@ -148,20 +148,28 @@ YAZ_EXPORT int yaz_diag_srw_to_bib1(int srw_code);
 
 YAZ_EXPORT char *yaz_uri_val(const char *path, const char *name, ODR o);
 YAZ_EXPORT void yaz_uri_val_int(const char *path, const char *name,
-                               ODR o, int **intp);
+                                ODR o, int **intp);
 YAZ_EXPORT int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                             Z_SOAP **soap_package, ODR decode, char **charset);
+                              Z_SOAP **soap_package, ODR decode, char **charset);
 YAZ_EXPORT int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                             Z_SOAP **soap_package, ODR decode, 
-                             char **charset,
-                             Z_SRW_diagnostic **, int *num_diagnostic);
+                              Z_SOAP **soap_package, ODR decode, 
+                              char **charset,
+                              Z_SRW_diagnostic **, int *num_diagnostic);
 
 YAZ_EXPORT void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
-                                      int *num, int code,
-                                      const char *addinfo);
+                                       int *num, int code,
+                                       const char *addinfo);
     
 YAZ_EXPORT void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d, 
-                                     int code, const char *details);
+                                      int code, const char *details);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 0b99731..8e19f0a 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: statserv.h,v 1.8 2005-01-15 19:47:10 adam Exp $
+ * $Id: statserv.h,v 1.9 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
 #include <yaz/backend.h>
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 43d4618..16aaf99 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: tcpip.h,v 1.6 2005-01-15 19:47:10 adam Exp $
+ * $Id: tcpip.h,v 1.7 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file tcpip.h
@@ -46,3 +46,11 @@ YAZ_EXPORT COMSTACK ssl_type(int s, int blocking, int protocol, void *vp);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b660e7e..726f3eb 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: tpath.h,v 1.7 2005-01-15 19:47:10 adam Exp $
+ * $Id: tpath.h,v 1.8 2005-06-25 15:46:03 adam Exp $
  *
  */
 /**
@@ -50,3 +50,11 @@ YAZ_EXPORT int yaz_is_abspath (const char *p);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c66625c..fc6da6e 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: unix.h,v 1.4 2005-01-15 19:47:10 adam Exp $
+ * $Id: unix.h,v 1.5 2005-06-25 15:46:03 adam Exp $
  * UNIX socket COMSTACK. By Morten Bøgeskov.
  */
 /**
@@ -50,3 +50,11 @@ YAZ_END_CDECL
 #endif
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2b76be9..8241d1d 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: wrbuf.h,v 1.14 2005-01-15 19:47:10 adam Exp $
+ * $Id: wrbuf.h,v 1.15 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file wrbuf.h
@@ -55,9 +55,9 @@ YAZ_EXPORT int wrbuf_puts(WRBUF b, const char *buf);
 YAZ_EXPORT int wrbuf_xmlputs(WRBUF b, const char *cp);
 YAZ_EXPORT void wrbuf_printf(WRBUF b, const char *fmt, ...);
 YAZ_EXPORT int wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf,
-                                int size);
+                                 int size);
 YAZ_EXPORT int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd,
-                                      const char *buf, int size);
+                                       const char *buf, int size);
 
 #define wrbuf_len(b) ((b)->pos)
 #define wrbuf_buf(b) ((b)->buf)
@@ -69,3 +69,11 @@ YAZ_EXPORT int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd,
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 7a8bd6e..60ef839 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: xmalloc.h,v 1.6 2005-01-16 21:51:49 adam Exp $
+ * $Id: xmalloc.h,v 1.7 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file xmalloc.h
@@ -49,7 +49,7 @@ YAZ_BEGIN_CDECL
 YAZ_EXPORT void *xrealloc_f (void *o, size_t size, const char *file, int line);
 YAZ_EXPORT void *xmalloc_f (size_t size, const char *file, int line);
 YAZ_EXPORT void *xcalloc_f (size_t nmemb, size_t size,
-                           const char *file, int line);
+                            const char *file, int line);
 YAZ_EXPORT char *xstrdup_f (const char *p, const char *file, int line);
 YAZ_EXPORT void xfree_f (void *p, const char *file, int line);
 YAZ_EXPORT void xmalloc_trav_f(const char *s, const char *file, int line);
@@ -57,3 +57,11 @@ YAZ_EXPORT void xmalloc_trav_f(const char *s, const char *file, int line);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 68cfc99..5f510f2 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: yaz-ccl.h,v 1.8 2005-01-15 19:47:10 adam Exp $
+ * $Id: yaz-ccl.h,v 1.9 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file yaz-ccl.h
@@ -45,3 +45,11 @@ YAZ_EXPORT Z_AttributesPlusTerm *ccl_scan_query (ODR o, struct ccl_rpn_node *p);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 5eacbd7..4e62904 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: yaz-iconv.h,v 1.7 2005-01-15 19:47:10 adam Exp $
+ * $Id: yaz-iconv.h,v 1.8 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file yaz-iconv.h
@@ -61,3 +61,11 @@ YAZ_EXPORT int yaz_strcmp_del(const char *a, const char *b, const char *b_del);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e5261e4..16b25fb 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: yaz-util.h,v 1.15 2005-01-15 19:47:10 adam Exp $
+ * $Id: yaz-util.h,v 1.16 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file yaz-util.h
 #include <yaz/yaz-iconv.h>
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index fa9839c..401f4a8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: yaz-version.h,v 1.71 2005-06-08 09:11:17 adam Exp $
+ * $Id: yaz-version.h,v 1.72 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -34,3 +34,11 @@ YAZ_END_CDECL
 
 #endif
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a615eb2..939203a 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: yconfig.h,v 1.8 2005-01-15 19:47:10 adam Exp $
+ * $Id: yconfig.h,v 1.9 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file yconfig.h
 #endif
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 4579e00..e7a97c0 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zgdu.h,v 1.4 2005-01-15 19:47:10 adam Exp $
+ * $Id: zgdu.h,v 1.5 2005-06-25 15:46:03 adam Exp $
  */
 
 /**
@@ -66,3 +66,11 @@ YAZ_EXPORT Z_GDU *z_get_HTTP_Request(ODR o);
 YAZ_END_CDECL
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 748b82d..09383a8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom.h,v 1.25 2005-01-15 19:47:10 adam Exp $
+ * $Id: zoom.h,v 1.26 2005-06-25 15:46:03 adam Exp $
  */
 /**
  * \file zoom.h
@@ -29,7 +29,7 @@ ZOOM_BEGIN_CDECL
 typedef struct ZOOM_options_p *ZOOM_options;
 typedef struct ZOOM_query_p *ZOOM_query;
 typedef struct ZOOM_connection_p *ZOOM_connection;
-typedef        struct ZOOM_resultset_p *ZOOM_resultset;
+typedef struct ZOOM_resultset_p *ZOOM_resultset;
 typedef struct ZOOM_task_p *ZOOM_task;
 typedef struct ZOOM_record_p *ZOOM_record;
 typedef struct ZOOM_scanset_p *ZOOM_scanset;
@@ -52,7 +52,7 @@ ZOOM_connection_create (ZOOM_options options);
 /* connect given existing connection */
 ZOOM_API(void)
 ZOOM_connection_connect(ZOOM_connection c, const char *host,
-                             int portnum);
+                              int portnum);
 
 /* destroy connection (close connection also) */
 ZOOM_API(void)
@@ -68,14 +68,14 @@ ZOOM_connection_option_set (ZOOM_connection c, const char *key,
 
 ZOOM_API(void)
 ZOOM_connection_option_setl (ZOOM_connection c, const char *key,
-                            const char *val, int len);
+                             const char *val, int len);
 
 /* return error code (0 == success, failure otherwise). cp
    holds error string on failure, addinfo holds addititional info (if any)
 */
 ZOOM_API(int)
 ZOOM_connection_error (ZOOM_connection c, const char **cp,
-                           const char **addinfo);
+                            const char **addinfo);
 
 ZOOM_API(int)
 ZOOM_connection_error_x (ZOOM_connection c, const char **cp,
@@ -207,7 +207,7 @@ ZOOM_scanset_term(ZOOM_scanset scan, size_t pos,
 
 ZOOM_API(const char *)
 ZOOM_scanset_display_term(ZOOM_scanset scan, size_t pos,
-                         int *occ, int *len);
+                          int *occ, int *len);
 
 ZOOM_API(size_t)
 ZOOM_scanset_size(ZOOM_scanset scan);
@@ -244,7 +244,7 @@ ZOOM_API(void)
 /* Sort */
 ZOOM_API(void)
     ZOOM_resultset_sort(ZOOM_resultset r,
-                       const char *sort_type, const char *sort_spec);
+                        const char *sort_type, const char *sort_spec);
 
 /* ----------------------------------------------------------- */
 /* options */
@@ -295,3 +295,11 @@ ZOOM_API(int)
 ZOOM_event (int no, ZOOM_connection *cs);
 
 ZOOM_END_CDECL
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d802c42..ca1bd7d 100644 (file)
@@ -26,8 +26,8 @@ int makensap(char *text, unsigned char *binary)
     fprintf(stderr, "Mapping textform NSAP '%s'\n", text);
     if (!(addr = tcpip_strtoaddr(text)))
     {
-       fprintf(stderr, "Failed to resolve '%s'\n", text);
-       return -1;
+        fprintf(stderr, "Failed to resolve '%s'\n", text);
+        return -1;
     }
     memcpy(binary, addr, sizeof(struct sockaddr_in));
     return sizeof(struct sockaddr_in);
@@ -48,15 +48,23 @@ static struct sockaddr_in *tcpip_strtoaddr(const char *str)
     strcpy(buf, str);
     if ((p = strchr(buf, ':')))
     {
-       *p = 0;
-       port = atoi(p + 1);
+        *p = 0;
+        port = atoi(p + 1);
     }
     add.sin_port = htons(port);
     if ((hp = gethostbyname(buf)))
-       memcpy(&add.sin_addr.s_addr, *hp->h_addr_list, sizeof(struct in_addr));
+        memcpy(&add.sin_addr.s_addr, *hp->h_addr_list, sizeof(struct in_addr));
     else if ((tmpadd = inet_addr(buf)) != 0)
-       memcpy(&add.sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
+        memcpy(&add.sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
     else
-       return 0;
+        return 0;
     return &add;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b79e6a2..1fd469d 100644 (file)
@@ -4,7 +4,11 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: rfct.c,v $
- * Revision 1.9  1996-02-23 10:01:00  quinn
+ * Revision 1.10  2005-06-25 15:46:03  adam
+ * Expanded tabs in all source files. Added vim/emacs local variables
+ * trailer.
+ *
+ * Revision 1.9  1996/02/23 10:01:00  quinn
  * Smallish
  *
  * Revision 1.8  1995/11/01  13:54:52  quinn
@@ -220,7 +224,7 @@ static void init_rfc(void)
     int i;
 
     for (i = 0; i < NOFILE; i++)
-       control[i] = 0;
+        control[i] = 0;
     rfc_running = 1;
 }
 
@@ -233,24 +237,24 @@ int t_open(char *name, int oflag, struct t_info *info)
     TRC(fprintf(stderr, "T_OPEN\n"));
 
     if (!rfc_running)
-       init_rfc();
+        init_rfc();
 
     if (!(proto = getprotobyname("tcp")))
-       return 0;
+        return 0;
     if ((s = socket(AF_INET, SOCK_STREAM, proto->p_proto)) < 0)
-       return 0;
+        return 0;
 #ifdef NONBLOCKING_OSI
     if ((oflag & O_NONBLOCK) && fcntl(s, F_SETFL, O_NONBLOCK) < 0)
     {
-       t_errno = TSYSERR;
-       return -1;
+        t_errno = TSYSERR;
+        return -1;
     }
 #endif
     if (!(cnt = control[s] = malloc(sizeof(struct rfct_control))))
     {
-       TRC(perror("malloc()"));
-       t_errno = TSYSERR;
-       return -1;
+        TRC(perror("malloc()"));
+        t_errno = TSYSERR;
+        return -1;
     }
 
     cnt->togo = 0;
@@ -263,7 +267,7 @@ int t_open(char *name, int oflag, struct t_info *info)
     cnt->tmpfd = -1;
     cnt->ltsel_len = 0;
     for (i = 0; i < MAX_QLEN; i++)
-       cnt->oci[i] = -1;
+        cnt->oci[i] = -1;
 
     /*
      * RFC1006 sets a higher than standard (TP) default max TPDU size, but the
@@ -275,14 +279,14 @@ int t_open(char *name, int oflag, struct t_info *info)
 
     if (info)
     {
-       info->addr = TSEL_MAXLEN + sizeof(struct sockaddr_in) + 1;
-       info->options = 1024;
-       info->tsdu = -1; /* is this right? */
-       info->etsdu = 0;
-       info->connect = -2;
-       info->discon = -2;
-       info->servtype = T_COTS_ORD;  /* lets hope our user doesn't
-                                       try something funny. */
+        info->addr = TSEL_MAXLEN + sizeof(struct sockaddr_in) + 1;
+        info->options = 1024;
+        info->tsdu = -1; /* is this right? */
+        info->etsdu = 0;
+        info->connect = -2;
+        info->discon = -2;
+        info->servtype = T_COTS_ORD;  /* lets hope our user doesn't
+                                        try something funny. */
     }
     return s;
 }
@@ -301,33 +305,33 @@ int t_connect(int fd, struct t_call *sndcall, struct t_call *rcvcall)
     TRC(fprintf(stderr, "T_CONNECT\n"));
     if (!cnt || cnt->state != T_IDLE)
     {
-       TRC(fprintf(stderr, "TOUTSTATE\n"));
-       t_errno = TOUTSTATE;
-       return -1;
+        TRC(fprintf(stderr, "TOUTSTATE\n"));
+        t_errno = TOUTSTATE;
+        return -1;
     }
     /* take the address apart */
     p = sndcall->addr.buf;
     if (*p) /* transport selector */
     {
-       TRC(fprintf(stderr, "Tsel length is %d.\n", *p));
-       pbuf[0] = TPDU_PARM_CLDID;
-       pbuf[1] = *p;
-       memcpy(pbuf + 2, p + 1, *p);
-       plen = *p + 2;
+        TRC(fprintf(stderr, "Tsel length is %d.\n", *p));
+        pbuf[0] = TPDU_PARM_CLDID;
+        pbuf[1] = *p;
+        memcpy(pbuf + 2, p + 1, *p);
+        plen = *p + 2;
     }
     p += *p + 1; /* skip tsel */
     if (*p != sizeof(addr))
     {
-       TRC(fprintf(stderr, "Expected  sockaddr here.\n"));
-       t_errno = TBADADDR;
-       return -1;
+        TRC(fprintf(stderr, "Expected  sockaddr here.\n"));
+        t_errno = TBADADDR;
+        return -1;
     }
     p++;
     memcpy(&addr, p, sizeof(addr));
     if (connect(fd, (struct sockaddr*) &addr, sizeof(addr)) < 0)
     {
-       t_errno = TSYSERR;
-       return -1;
+        t_errno = TSYSERR;
+        return -1;
     }
 
     /*
@@ -340,9 +344,9 @@ int t_connect(int fd, struct t_call *sndcall, struct t_call *rcvcall)
      */
     if (cnt->tsize <= 2048)
     {
-       pbuf[plen++] = TPDU_PARM_TSIZE;
-       pbuf[plen++] = 1;
-       pbuf[plen++] = 0x0b; /* request max PDU size (2048 octets) */
+        pbuf[plen++] = TPDU_PARM_TSIZE;
+        pbuf[plen++] = 1;
+        pbuf[plen++] = 0x0b; /* request max PDU size (2048 octets) */
     }
 
     rfc.version = RFC_VERSION;
@@ -368,9 +372,9 @@ int t_connect(int fd, struct t_call *sndcall, struct t_call *rcvcall)
      */
     if (writev(fd, vec, 3) < 4 + 7 + plen)
     {
-       TRC(fprintf(stderr, "writev came up short. Aborting connect\n"));
-       t_errno = TSYSERR;
-       return -1;
+        TRC(fprintf(stderr, "writev came up short. Aborting connect\n"));
+        t_errno = TSYSERR;
+        return -1;
     }
     cnt->state = T_OUTCON;
     cnt->event = 0;
@@ -387,26 +391,26 @@ static int read_n(int fd, char *buf, int toget)
 
     do
     {
-       if ((res = read(fd, buf, toget - got)) < 0)
-       {
-           if (errno == EAGAIN)
-               t_errno = TNODATA;
-           else
-           {
-               TRC(fprintf(stderr, "Error on read.\n"));
-               t_errno = TSYSERR;
-           }
-           return -1;
-       }
-       if (!res) /* peer closed network connection */
-       {
-           t_errno = TLOOK;
-           cnt->event = T_DISCONNECT;  /* is this correct ? ## */
-           cnt->hlen = cnt->pending = 0;
-           cnt->state = T_IDLE; /* this can't be correct ## */
-           return 0;
-       }
-       buf += res;
+        if ((res = read(fd, buf, toget - got)) < 0)
+        {
+            if (errno == EAGAIN)
+                t_errno = TNODATA;
+            else
+            {
+                TRC(fprintf(stderr, "Error on read.\n"));
+                t_errno = TSYSERR;
+            }
+            return -1;
+        }
+        if (!res) /* peer closed network connection */
+        {
+            t_errno = TLOOK;
+            cnt->event = T_DISCONNECT;  /* is this correct ? ## */
+            cnt->hlen = cnt->pending = 0;
+            cnt->state = T_IDLE; /* this can't be correct ## */
+            return 0;
+        }
+        buf += res;
     }
     while ((got += res) < toget);
     return toget;
@@ -423,75 +427,75 @@ int t_rcvconnect(int fd, struct t_call *call)
     TRC(fprintf(stderr, "T_RCVCONNECT\n"));
     if (!cnt || cnt->state != T_OUTCON)
     {
-       TRC(fprintf(stderr, "TOUTSTATE\n"));
-       t_errno = TOUTSTATE;
-       return -1;
+        TRC(fprintf(stderr, "TOUTSTATE\n"));
+        t_errno = TOUTSTATE;
+        return -1;
     }
     if (!cnt->event)
-       if (t_look_wait(fd, 1) <= 0)
-           return -1;
+        if (t_look_wait(fd, 1) <= 0)
+            return -1;
     if (cnt->event != T_CONNECT)
     {
-       t_errno = TLOOK;
-       return -1;
+        t_errno = TLOOK;
+        return -1;
     }
     /* read the rest of the CC TPDU */
     if (read_n(fd, buf, cnt->hlen) <= 0)
-       return -1;
+        return -1;
     memcpy(&chead, buf, 5);
     if (chead.class != 0)
     {
-       TRC(fprintf(stderr, "Expected TP0, got %d\n", (int)chead.class));
-       t_errno = TSYSERR;
-       return -1;
+        TRC(fprintf(stderr, "Expected TP0, got %d\n", (int)chead.class));
+        t_errno = TSYSERR;
+        return -1;
     }
     if (call)
-       *(addrp = call->addr.buf) = 0;
+        *(addrp = call->addr.buf) = 0;
     cnt->hlen -= 5;
     for (p = buf + 5; cnt->hlen > 0;)
     {
-       switch ((unsigned char)*p)
-       {
-           case TPDU_PARM_TSIZE:
-               cnt->tsize = 1 << *(p + 2);
-               break;
-           case TPDU_PARM_CLDID:
-               if (call)
-               {
-                   if (*(p + 1) > TSEL_MAXLEN)
-                   {
-                       TRC(fprintf(stderr, "Called TSEL too long.\n"));
-                       t_errno = TSYSERR; /* Wrong.. ## */
-                       return -1;
-                   }
-                   *addrp = *(p + 1); /* length */
-                   memcpy(addrp + 1, p + 2, *(p + 1)); /* remote TSEL */
-                   addrp += *(p + 1); /* move past TSEL */
-               }
-               break;
-           case TPDU_PARM_CLGID: break; /* ignoring this for now */
-           default:
-               TRC(fprintf(stderr, "Inoring CR parameter: %d\n",
-                   (unsigned char)*p));
-           /* we silently ignore anything else */
-       }
-       p++;
-       cnt->hlen -= (unsigned char) *p + 2;
-       p += (unsigned char) *p + 1;
+        switch ((unsigned char)*p)
+        {
+            case TPDU_PARM_TSIZE:
+                cnt->tsize = 1 << *(p + 2);
+                break;
+            case TPDU_PARM_CLDID:
+                if (call)
+                {
+                    if (*(p + 1) > TSEL_MAXLEN)
+                    {
+                        TRC(fprintf(stderr, "Called TSEL too long.\n"));
+                        t_errno = TSYSERR; /* Wrong.. ## */
+                        return -1;
+                    }
+                    *addrp = *(p + 1); /* length */
+                    memcpy(addrp + 1, p + 2, *(p + 1)); /* remote TSEL */
+                    addrp += *(p + 1); /* move past TSEL */
+                }
+                break;
+            case TPDU_PARM_CLGID: break; /* ignoring this for now */
+            default:
+                TRC(fprintf(stderr, "Inoring CR parameter: %d\n",
+                    (unsigned char)*p));
+            /* we silently ignore anything else */
+        }
+        p++;
+        cnt->hlen -= (unsigned char) *p + 2;
+        p += (unsigned char) *p + 1;
     }
     addrp++; /* skip to end of addr + 1 */
     if (call)
     {
-       if (getpeername(fd, (struct sockaddr*) &peer, &len) < 0)
-       {
-           TRC(perror("getpeername()"));
-           t_errno = TSYSERR;
-           return -1;
-       }
-       *(addrp++) = sizeof(struct sockaddr_in);
-       memcpy(addrp, &peer, sizeof(struct sockaddr_in));
-       addrp += sizeof(struct sockaddr_in);
-       call->addr.len = addrp - call->addr.buf + 1;
+        if (getpeername(fd, (struct sockaddr*) &peer, &len) < 0)
+        {
+            TRC(perror("getpeername()"));
+            t_errno = TSYSERR;
+            return -1;
+        }
+        *(addrp++) = sizeof(struct sockaddr_in);
+        memcpy(addrp, &peer, sizeof(struct sockaddr_in));
+        addrp += sizeof(struct sockaddr_in);
+        call->addr.len = addrp - call->addr.buf + 1;
     }
     cnt->state = T_DATAXFER;
     cnt->event = 0;
@@ -509,107 +513,107 @@ int t_snd(int fd, char *buf, unsigned nbytes, int flags)
     TRC(fprintf(stderr, "T_SND [%d bytes, flags %d]\n", nbytes, flags));
     if (!cnt || cnt->state != T_DATAXFER)
     {
-       TRC(fprintf(stderr, "Trying to write in the wrong state on fd %d.\n",
-           fd));
-       t_errno = TOUTSTATE;
-       return -1;
+        TRC(fprintf(stderr, "Trying to write in the wrong state on fd %d.\n",
+            fd));
+        t_errno = TOUTSTATE;
+        return -1;
     }
     if (!nbytes)
     {
-       t_errno = TBADDATA;
-       return -1;
+        t_errno = TBADDATA;
+        return -1;
     }
     do /* write the TSDU (segment) in chunks depending on the TPDU max size */
     {
-       if (cnt->togo > 0) /* we have a partial TPDU on the wire */
-       {
-           TRC(fprintf(stderr, "  writing continuation block (%d)\n",
-               cnt->togo));
-           if ((res = write(fd, buf, cnt->togo)) < 0)
-           {
-               if (errno == EAGAIN)
-               {
-                   t_errno = TFLOW;
-                   return -1;
-               }
-               cnt->togo -= res;
-               return res;
-           }
-           writ += res;
-           cnt->togo = 0;
-           TRC(fprintf(stderr, "  wrote %d, total %d\n", res, writ));
-       }
-       else /* prepare and send (possibly partial) header */
-       {
-           towrite = nbytes - writ;
-           if (towrite + 3 + 4 > cnt->tsize)
-               towrite = cnt->tsize - (3 + 4); /* space for DATA header */
-           rfc.version = RFC_VERSION;
-           rfc.reserved = 0;
-           rfc.len = htons(towrite + 4 + 3); /* RFC1006 length */
-           rfc.hlen = 2;
-           rfc.code = TPDU_CODE_DATA;
-           if (flags & T_MORE || towrite + writ < nbytes)
-               eot = 0;
-           else
-               eot = 1;
-           rfc.suffix[0] = eot << 7; /* DATA EOT marker */
-           if (cnt->togo < 0)
-               head_offset = 7 + cnt->togo;
-           else
-               head_offset = 0;
-           vec[0].iov_base = (caddr_t) (char*)&rfc + head_offset;
-           vec[0].iov_len = 7 - head_offset;
-           vec[1].iov_base = (caddr_t) buf + writ;
-           vec[1].iov_len = towrite;
-           TRC(fprintf(stderr, "  sending beg of block (%d+%d)\n",
-               7 - head_offset, towrite));
-           if ((res = writev(fd, vec, 2)) < 0)
-           {
-               TRC(fprintf(stderr, "  write returned -1\n"));
-               /* thwarted by flow control */
-               if (errno == EAGAIN)
-               {
-                   if (writ)
-                       return writ;
-                   else
-                   {
-                       t_errno = TFLOW;
-                       return -1;
-                   }
-               }
-               else
-                   t_errno = TSYSERR;
-               return -1;
-           }
-           /* somewhat thwarted */
-           else if (res < towrite + 7 - head_offset)
-           {
-               /*
-                * Write came up short. We assume that this is a flow-
-                * control thing, and return immediately. Maybe it'd
-                * be better to take another loop, and generate an
-                * actual EAGAIN from write?
-                */
-               TRC(fprintf(stderr, "  write returned %d\n", res));
-               if (res < 7 - head_offset) /* we didn't send a full header */
-               {
-                   cnt->togo = -(7 - head_offset - res);
-                   t_errno = TFLOW;
-                   return -1;
-               }
-               else if ((res -= 7 - head_offset) < towrite) /* not all data */
-               {
-                   cnt->togo = towrite - res;
-                   return nbytes - (writ + res);
-               }
-           }
-           else /* whew... nonblocking I/O is hard work */
-           {
-               cnt->togo = 0;
-               writ += res - (7 - head_offset);
-           }
-       }
+        if (cnt->togo > 0) /* we have a partial TPDU on the wire */
+        {
+            TRC(fprintf(stderr, "  writing continuation block (%d)\n",
+                cnt->togo));
+            if ((res = write(fd, buf, cnt->togo)) < 0)
+            {
+                if (errno == EAGAIN)
+                {
+                    t_errno = TFLOW;
+                    return -1;
+                }
+                cnt->togo -= res;
+                return res;
+            }
+            writ += res;
+            cnt->togo = 0;
+            TRC(fprintf(stderr, "  wrote %d, total %d\n", res, writ));
+        }
+        else /* prepare and send (possibly partial) header */
+        {
+            towrite = nbytes - writ;
+            if (towrite + 3 + 4 > cnt->tsize)
+                towrite = cnt->tsize - (3 + 4); /* space for DATA header */
+            rfc.version = RFC_VERSION;
+            rfc.reserved = 0;
+            rfc.len = htons(towrite + 4 + 3); /* RFC1006 length */
+            rfc.hlen = 2;
+            rfc.code = TPDU_CODE_DATA;
+            if (flags & T_MORE || towrite + writ < nbytes)
+                eot = 0;
+            else
+                eot = 1;
+            rfc.suffix[0] = eot << 7; /* DATA EOT marker */
+            if (cnt->togo < 0)
+                head_offset = 7 + cnt->togo;
+            else
+                head_offset = 0;
+            vec[0].iov_base = (caddr_t) (char*)&rfc + head_offset;
+            vec[0].iov_len = 7 - head_offset;
+            vec[1].iov_base = (caddr_t) buf + writ;
+            vec[1].iov_len = towrite;
+            TRC(fprintf(stderr, "  sending beg of block (%d+%d)\n",
+                7 - head_offset, towrite));
+            if ((res = writev(fd, vec, 2)) < 0)
+            {
+                TRC(fprintf(stderr, "  write returned -1\n"));
+                /* thwarted by flow control */
+                if (errno == EAGAIN)
+                {
+                    if (writ)
+                        return writ;
+                    else
+                    {
+                        t_errno = TFLOW;
+                        return -1;
+                    }
+                }
+                else
+                    t_errno = TSYSERR;
+                return -1;
+            }
+            /* somewhat thwarted */
+            else if (res < towrite + 7 - head_offset)
+            {
+                /*
+                 * Write came up short. We assume that this is a flow-
+                 * control thing, and return immediately. Maybe it'd
+                 * be better to take another loop, and generate an
+                 * actual EAGAIN from write?
+                 */
+                TRC(fprintf(stderr, "  write returned %d\n", res));
+                if (res < 7 - head_offset) /* we didn't send a full header */
+                {
+                    cnt->togo = -(7 - head_offset - res);
+                    t_errno = TFLOW;
+                    return -1;
+                }
+                else if ((res -= 7 - head_offset) < towrite) /* not all data */
+                {
+                    cnt->togo = towrite - res;
+                    return nbytes - (writ + res);
+                }
+            }
+            else /* whew... nonblocking I/O is hard work */
+            {
+                cnt->togo = 0;
+                writ += res - (7 - head_offset);
+            }
+        }
     }
     while (writ < nbytes);
     TRC(fprintf(stderr, "  finishing with %d written\n", nbytes));
@@ -627,104 +631,104 @@ int _t_rcv(int fd, char *buf, unsigned nbytes, int *flags)
     TRC(fprintf(stderr, "T_RCV [nbytes=%d, flags=0x%x]\n", nbytes, *flags));
     if (!cnt || cnt->state != T_DATAXFER)
     {
-       t_errno = TOUTSTATE;
-       return -1;
+        t_errno = TOUTSTATE;
+        return -1;
     }
     *flags = 0;
     do /* loop until we have a full TSDU or an error */
     {
-       if (!cnt->event)
-           if (t_look_wait(fd, 0) <= 0)
-               return -1;
-       if (cnt->event != T_DATA)
-       {
-           t_errno = TLOOK;
-           return -1;
-       }
-       if (cnt->hlen)  /* beginning of block */
-       {
-           TRC(fprintf(stderr, "  Beginning of TPDU\n"));
-           if (cnt->hlen > 2)
-           {
-               TRC(fprintf(stderr, "We can't handle parameters to DATA\n"));
-               t_errno = TSYSERR;
-               return -1;
-           }
-           toget = cnt->pending;
-           if (toget > nbytes - got)
-               toget = nbytes - got;
-           TRC(fprintf(stderr, "  toget=%d\n", toget));
-           vec[0].iov_base = (caddr_t) &dhead;
-           vec[0].iov_len = 1;
-           vec[1].iov_base = (caddr_t) buf + got;
-           vec[1].iov_len = toget;
-           if ((res = readv(fd, vec, 2)) < 0)
-           {
-               TRC(perror("readv()"));
-               if (errno == EAGAIN)
-               {
-                   if (got)  /* we got some data in previous cycle */
-                       break;
-                   t_errno = TNODATA; /* no data */
-                   return -1;
-               }
-               t_errno = TSYSERR;
-               return -1;
-           }
-           TRC(fprintf(stderr, "  readv() returned %d\n", res));
-           if (res == 0)
-           {
-               t_errno = TLOOK;
-               cnt->event = T_DISCONNECT;
-               return -1;
-           }
-           got += res - 1;
-           cnt->eot_flag = (dhead.nr & DATA_EOT) >> 7;
-           cnt->hlen = 0;
-           cnt->pending -= got;
-           TRC(fprintf(stderr, "  Got total of %d octets, %d pending\n",
-               got, cnt->pending));
-       }
-       else /* continuation */
-       {
-           TRC(fprintf(stderr, "  Reading middle of TPDU\n"));
-           toget = cnt->pending;
-           if (toget > nbytes - got)
-               toget = nbytes - got;
-           TRC(fprintf(stderr, "  toget=%d\n", toget));
-           if ((res = read(fd, buf + got, toget)) < 0)
-           {
-               TRC(perror("read()"));
-               if (errno == EAGAIN)
-               {
-                   if (got)  /* we got some data in previous cycle */
-                       break;
-                   t_errno = TNODATA; /* no data */
-                   return -1;
-               }
-               t_errno = TSYSERR;
-               return -1;
-           }
-           TRC(fprintf(stderr, "  read() returned %d\n", res));
-           if (res == 0)
-           {
-               t_errno = TLOOK;
-               cnt->event = T_DISCONNECT;
-               return -1;
-           }
-           got += res;
-           cnt->pending -= res;
-           TRC(fprintf(stderr, "  Got total of %d octets, %d pending\n",
-               got, cnt->pending));
-       }
-       TRC(fprintf(stderr, "  bottom of loop: pending=%d, got=%d\n",
-           cnt->pending, got));
+        if (!cnt->event)
+            if (t_look_wait(fd, 0) <= 0)
+                return -1;
+        if (cnt->event != T_DATA)
+        {
+            t_errno = TLOOK;
+            return -1;
+        }
+        if (cnt->hlen)  /* beginning of block */
+        {
+            TRC(fprintf(stderr, "  Beginning of TPDU\n"));
+            if (cnt->hlen > 2)
+            {
+                TRC(fprintf(stderr, "We can't handle parameters to DATA\n"));
+                t_errno = TSYSERR;
+                return -1;
+            }
+            toget = cnt->pending;
+            if (toget > nbytes - got)
+                toget = nbytes - got;
+            TRC(fprintf(stderr, "  toget=%d\n", toget));
+            vec[0].iov_base = (caddr_t) &dhead;
+            vec[0].iov_len = 1;
+            vec[1].iov_base = (caddr_t) buf + got;
+            vec[1].iov_len = toget;
+            if ((res = readv(fd, vec, 2)) < 0)
+            {
+                TRC(perror("readv()"));
+                if (errno == EAGAIN)
+                {
+                    if (got)  /* we got some data in previous cycle */
+                        break;
+                    t_errno = TNODATA; /* no data */
+                    return -1;
+                }
+                t_errno = TSYSERR;
+                return -1;
+            }
+            TRC(fprintf(stderr, "  readv() returned %d\n", res));
+            if (res == 0)
+            {
+                t_errno = TLOOK;
+                cnt->event = T_DISCONNECT;
+                return -1;
+            }
+            got += res - 1;
+            cnt->eot_flag = (dhead.nr & DATA_EOT) >> 7;
+            cnt->hlen = 0;
+            cnt->pending -= got;
+            TRC(fprintf(stderr, "  Got total of %d octets, %d pending\n",
+                got, cnt->pending));
+        }
+        else /* continuation */
+        {
+            TRC(fprintf(stderr, "  Reading middle of TPDU\n"));
+            toget = cnt->pending;
+            if (toget > nbytes - got)
+                toget = nbytes - got;
+            TRC(fprintf(stderr, "  toget=%d\n", toget));
+            if ((res = read(fd, buf + got, toget)) < 0)
+            {
+                TRC(perror("read()"));
+                if (errno == EAGAIN)
+                {
+                    if (got)  /* we got some data in previous cycle */
+                        break;
+                    t_errno = TNODATA; /* no data */
+                    return -1;
+                }
+                t_errno = TSYSERR;
+                return -1;
+            }
+            TRC(fprintf(stderr, "  read() returned %d\n", res));
+            if (res == 0)
+            {
+                t_errno = TLOOK;
+                cnt->event = T_DISCONNECT;
+                return -1;
+            }
+            got += res;
+            cnt->pending -= res;
+            TRC(fprintf(stderr, "  Got total of %d octets, %d pending\n",
+                got, cnt->pending));
+        }
+        TRC(fprintf(stderr, "  bottom of loop: pending=%d, got=%d\n",
+            cnt->pending, got));
     }
     while (cnt->pending && got < nbytes);
     *flags = cnt->pending || !cnt->eot_flag ? T_MORE : 0;
     TRC(fprintf(stderr, "  flags=0x%x\n", *flags));
     if (!cnt->pending)
-       cnt->event = 0;
+        cnt->event = 0;
     TRC(fprintf(stderr, "  Return value: %d\n", got));
     memset(buf + got, 0, 10);
     return got;
@@ -739,11 +743,11 @@ int t_rcv(int fd, char *buf, unsigned nbytes, int *flags)
 
     do
     {
-       if ((res = _t_rcv(fd, buf, nbytes, flags)) <= 0)
-           return res;
-       buf += res;
-       nbytes -= res;
-       total += res;
+        if ((res = _t_rcv(fd, buf, nbytes, flags)) <= 0)
+            return res;
+        buf += res;
+        nbytes -= res;
+        total += res;
     }
     while (*flags & T_MORE && nbytes > 0);
     return total;
@@ -758,9 +762,9 @@ int t_close(int fd)
     TRC(fprintf(stderr, "T_CLOSE\n"));
     if (!cnt || cnt->state == T_UNINIT)
     {
-       TRC(fprintf(stderr, "Trying to close a bad fd.\n"));
-       t_errno = TBADF;
-       return -1;
+        TRC(fprintf(stderr, "Trying to close a bad fd.\n"));
+        t_errno = TBADF;
+        return -1;
     }
     free(cnt);
     return close(fd);
@@ -789,43 +793,43 @@ static int t_look_wait(int fd, int wait)
     TRC(fprintf(stderr, "T_LOOK\n"));
     if (!cnt || cnt->state == T_UNINIT)
     {
-       t_errno = TBADF;
-       return -1;
+        t_errno = TBADF;
+        return -1;
     }
     if (cnt->event)
-       return cnt->event;
+        return cnt->event;
     if (cnt->state == T_IDLE && cnt->tmpfd < 0)
-       return T_LISTEN; /* the only possible type of event */
+        return T_LISTEN; /* the only possible type of event */
     if ((res = read_n(fd, (char*) &head, 6)) < 0)
-       return -1;
+        return -1;
     if (res == 0)
     {
-       TRC(fprintf(stderr, "Network disconnect\n"));
-       return cnt->event = T_DISCONNECT;
+        TRC(fprintf(stderr, "Network disconnect\n"));
+        return cnt->event = T_DISCONNECT;
     }
     TRC(fprintf(stderr, "t_look got %d bytes\n", res));
     if (head.version != RFC_VERSION)
     {
-       TRC(fprintf(stderr, "Got bad RFC1006 version in t_look: %d.\n",
-           head.version));
-       t_errno = TSYSERR; /* should signal protocol error, somehow ## */
-       return -1;
+        TRC(fprintf(stderr, "Got bad RFC1006 version in t_look: %d.\n",
+            head.version));
+        t_errno = TSYSERR; /* should signal protocol error, somehow ## */
+        return -1;
     }
     cnt->curcode = head.code;
     cnt->hlen = head.hlen - 1; /* length of header suffix */
     cnt->pending = ntohs(head.len) - 6 - cnt->hlen;
     TRC(fprintf(stderr, "t_look: len=%d, code=0x%2.2x, hlen=%d.\n",
-       cnt->pending + 6, cnt->curcode, cnt->hlen));
+        cnt->pending + 6, cnt->curcode, cnt->hlen));
     switch (cnt->curcode)
     {
-       case TPDU_CODE_CREQ: cnt->event = T_LISTEN; break;
-       case TPDU_CODE_CCON: cnt->event = T_CONNECT; break;
-       case TPDU_CODE_DATA: cnt->event = T_DATA; break;
-       case TPDU_CODE_DREQ: cnt->event = T_DISCONNECT; break; 
-       default:
-           TRC(fprintf(stderr, "t_look: Bad package: 0x%2.2x.\n", cnt->curcode));
-           t_errno = TSYSERR;  /* protocol error */
-           return -1;
+        case TPDU_CODE_CREQ: cnt->event = T_LISTEN; break;
+        case TPDU_CODE_CCON: cnt->event = T_CONNECT; break;
+        case TPDU_CODE_DATA: cnt->event = T_DATA; break;
+        case TPDU_CODE_DREQ: cnt->event = T_DISCONNECT; break; 
+        default:
+            TRC(fprintf(stderr, "t_look: Bad package: 0x%2.2x.\n", cnt->curcode));
+            t_errno = TSYSERR;  /* protocol error */
+            return -1;
     }
     return cnt->event;
 }    
@@ -850,86 +854,86 @@ int t_bind(int fd, struct t_bind *req, struct t_bind *ret)
     TRC(fprintf(stderr, "T_BIND\n"));
     if (!cnt || cnt->state != T_UNBND)
     {
-       TRC(fprintf(stderr, "Bad state\n"));
-       t_errno = TOUTSTATE;
-       return -1;
+        TRC(fprintf(stderr, "Bad state\n"));
+        t_errno = TOUTSTATE;
+        return -1;
     }
     cnt->ltsel_len = 0;
     if (req)
     {
-       cnt->qlen = req->qlen < MAX_QLEN ? req->qlen : MAX_QLEN;
-       if (req->addr.len)
-       {
-           p = req->addr.buf;
-           if (*p > TSEL_MAXLEN)
-           {
-               TRC(fprintf(stderr, "Tsel too large.\n"));
-               t_errno = TBADADDR;
-               return -1;
-           }
-           cnt->ltsel_len = *p;
-           if (cnt->ltsel_len)
-               memcpy(cnt->ltsel, p + 1, cnt->ltsel_len);
-           p += cnt->ltsel_len + 1;
-           if (*p < sizeof(addr))
-           {
-               TRC(fprintf(stderr, "W: No NSAP provided for local bind\n"));
-           }
-           else
-           {
-               memcpy(&addr, p + 1, sizeof(addr));
-               got_addr = 1;
-           }
-       }
+        cnt->qlen = req->qlen < MAX_QLEN ? req->qlen : MAX_QLEN;
+        if (req->addr.len)
+        {
+            p = req->addr.buf;
+            if (*p > TSEL_MAXLEN)
+            {
+                TRC(fprintf(stderr, "Tsel too large.\n"));
+                t_errno = TBADADDR;
+                return -1;
+            }
+            cnt->ltsel_len = *p;
+            if (cnt->ltsel_len)
+                memcpy(cnt->ltsel, p + 1, cnt->ltsel_len);
+            p += cnt->ltsel_len + 1;
+            if (*p < sizeof(addr))
+            {
+                TRC(fprintf(stderr, "W: No NSAP provided for local bind\n"));
+            }
+            else
+            {
+                memcpy(&addr, p + 1, sizeof(addr));
+                got_addr = 1;
+            }
+        }
     }
     else
-       cnt->qlen = 0;
+        cnt->qlen = 0;
     if (!got_addr) /* user didn't give an address - local bind */
     {
-       addr.sin_family = AF_INET;
-       addr.sin_addr.s_addr = INADDR_ANY;
-       if (cnt->qlen)
-           addr.sin_port = htons(RFC_DEFAULT_PORT);
-       else /* we'll leave binding to connect - just set dummy */
-           addr.sin_port = 0; /* dummy for ret */
+        addr.sin_family = AF_INET;
+        addr.sin_addr.s_addr = INADDR_ANY;
+        if (cnt->qlen)
+            addr.sin_port = htons(RFC_DEFAULT_PORT);
+        else /* we'll leave binding to connect - just set dummy */
+            addr.sin_port = 0; /* dummy for ret */
     }
     if (cnt->qlen && bind(fd, (struct sockaddr *) &addr,
-        sizeof(addr)) < 0 )
+         sizeof(addr)) < 0 )
     {
-       TRC(perror("bind()"));
-       t_errno = TSYSERR; /* this should be refined */
-       return -1;
+        TRC(perror("bind()"));
+        t_errno = TSYSERR; /* this should be refined */
+        return -1;
     }
     if (cnt->qlen)
     {
-       if (listen(fd, cnt->qlen) < 0)
-       {
-           t_errno = TSYSERR;
-           return -1;
-       }
-       cnt->listen = 1;
-       TRC(fprintf(stderr, "  listen OK\n"));
+        if (listen(fd, cnt->qlen) < 0)
+        {
+            t_errno = TSYSERR;
+            return -1;
+        }
+        cnt->listen = 1;
+        TRC(fprintf(stderr, "  listen OK\n"));
     }
     cnt->state = T_IDLE;
     /* All right! Now let's give something back, if our user wants it */
     if (ret)
     {
-       ret->qlen = cnt->qlen;
-       if (ret->addr.maxlen < (ret->addr.len = cnt->ltsel_len + 2 +
-           sizeof(addr)))
-       {
-           /* No space - but we're still bound */
-           t_errno = TBUFOVFLW;
-           ret->addr.len = 0;
-           return -1;
-       }
-       p = ret->addr.buf;
-       *(p++) = cnt->ltsel_len;
-       if (cnt->ltsel_len)
-           memcpy(p, cnt->ltsel, cnt->ltsel_len);
-       p += cnt->ltsel_len;
-       *(p++) = sizeof(addr);
-       memcpy(p, &addr, sizeof(addr));
+        ret->qlen = cnt->qlen;
+        if (ret->addr.maxlen < (ret->addr.len = cnt->ltsel_len + 2 +
+            sizeof(addr)))
+        {
+            /* No space - but we're still bound */
+            t_errno = TBUFOVFLW;
+            ret->addr.len = 0;
+            return -1;
+        }
+        p = ret->addr.buf;
+        *(p++) = cnt->ltsel_len;
+        if (cnt->ltsel_len)
+            memcpy(p, cnt->ltsel, cnt->ltsel_len);
+        p += cnt->ltsel_len;
+        *(p++) = sizeof(addr);
+        memcpy(p, &addr, sizeof(addr));
     }
     return 0;
 }    
@@ -952,64 +956,64 @@ int t_rcvdis(int fd, struct t_discon *discon)
     TRC(fprintf(stderr, "T_RCVDIS\n"));
     if (!cnt) 
     {
-       TRC(fprintf(stderr, "TOUTSTATE\n"));
-       t_errno = TOUTSTATE;
-       return -1;
+        TRC(fprintf(stderr, "TOUTSTATE\n"));
+        t_errno = TOUTSTATE;
+        return -1;
     }
     if (!cnt->event)
-       if (t_look_wait(fd, 1) <= 0)
-           return -1;
+        if (t_look_wait(fd, 1) <= 0)
+            return -1;
     if (cnt->event != T_DISCONNECT)
     {
-       t_errno = TLOOK;
-       return -1;
+        t_errno = TLOOK;
+        return -1;
     }
     /* read the rest of the DR TPDU */
     if (read_n(fd, buf, cnt->hlen) <= 0)
-       return -1;
+        return -1;
     memcpy(&chead, buf, 5);
     cnt->hlen -= 5;
     for (p = buf + 5; cnt->hlen > 0;)
     {
-       switch ((unsigned char)*p)
-       {
-           default:
-               TRC(fprintf(stderr, "Inoring RD parameter: %d\n",
-                   (unsigned char)*p));
-           /* we silently ignore anything else */
-       }
-       p++;
-       cnt->hlen -= (unsigned char) *p + 2;
-       p += (unsigned char) *p + 1;
+        switch ((unsigned char)*p)
+        {
+            default:
+                TRC(fprintf(stderr, "Inoring RD parameter: %d\n",
+                    (unsigned char)*p));
+            /* we silently ignore anything else */
+        }
+        p++;
+        cnt->hlen -= (unsigned char) *p + 2;
+        p += (unsigned char) *p + 1;
     }
     if (cnt->pending)
     {
-       if (read_n(fd, udata, cnt->pending) < cnt->pending)
-       {
-           TRC(fprintf(stderr, "Unable to read user data\n"));
-           t_errno = TSYSERR;
-           return -1;
-       }
+        if (read_n(fd, udata, cnt->pending) < cnt->pending)
+        {
+            TRC(fprintf(stderr, "Unable to read user data\n"));
+            t_errno = TSYSERR;
+            return -1;
+        }
     }
     cnt->state = T_IDLE;  /* should we close transport? */
     cnt->event = 0;
     if (discon)
     {
-       discon->sequence = -1; /* TOFIX */
-       discon->reason = chead.reason;
-       TRC(fprintf(stderr, "Diconnect reason %d\n", chead.reason));
-       if (cnt->pending > discon->udata.maxlen)
-       {
-           t_errno = TBUFOVFLW;
-           return -1;
-       }
-       if (cnt->pending)
-       {
-           memcpy(discon->udata.buf, udata, cnt->pending);
-           udata[cnt->pending] = '\0';
-           TRC(fprintf(stderr, "Discon udata: '%s'\n", udata));
-       }
-       discon->udata.len = cnt->pending;
+        discon->sequence = -1; /* TOFIX */
+        discon->reason = chead.reason;
+        TRC(fprintf(stderr, "Diconnect reason %d\n", chead.reason));
+        if (cnt->pending > discon->udata.maxlen)
+        {
+            t_errno = TBUFOVFLW;
+            return -1;
+        }
+        if (cnt->pending)
+        {
+            memcpy(discon->udata.buf, udata, cnt->pending);
+            udata[cnt->pending] = '\0';
+            TRC(fprintf(stderr, "Discon udata: '%s'\n", udata));
+        }
+        discon->udata.len = cnt->pending;
     }
     return 0;
 }    
@@ -1028,7 +1032,7 @@ char *t_alloc(int fd, int struct_type, int fields)
 {
     char *r = malloc(1024);
     if (!r)
-       return 0;
+        return 0;
     TRC(fprintf(stderr, "T_ALLOC\n"));
     memset(r, 0, 1024);
     return r;
@@ -1045,10 +1049,10 @@ static int switch_fds(int fd1, int fd2)
     
     TRC(fprintf(stderr, "Switching fds %d <--> %d\n", fd1, fd2));
     if ((tmp = dup(fd1)) < 0 ||
-       dup2(fd2, fd1) < 0 ||
-       dup2(tmp, fd2) < 0 ||
-       close(tmp) < 0)
-           return -1;
+        dup2(fd2, fd1) < 0 ||
+        dup2(tmp, fd2) < 0 ||
+        close(tmp) < 0)
+            return -1;
     tmpc = control[fd1];
     control[fd1] = control[fd2];
     control[fd2] = tmpc;
@@ -1069,70 +1073,70 @@ static int rcvconreq(int fd, struct t_call *call)
     TRC(fprintf(stderr, "RCVCONRES\n"));
     if (!call)
     {
-       t_errno = TSYSERR;
-       return -1;
+        t_errno = TSYSERR;
+        return -1;
     }
     for (qslot = 0; qslot < cnt->qlen; qslot++)
-       if (cnt->oci[qslot] < 0)
-           break;
+        if (cnt->oci[qslot] < 0)
+            break;
     if (qslot == cnt->qlen) /* no free slots - shouldn't happen here */
     {
-       t_errno = TBADF;
-       return -1;
+        t_errno = TBADF;
+        return -1;
     }
     /* read the rest of the CREQ TPDU */
     if (read_n(cnt->tmpfd, buf, new->hlen) <= 0)
-       return -1;
+        return -1;
     memcpy(&chead, buf, 5);
     if (chead.class != 0)
     {
-       TRC(fprintf(stderr, "Expected TP0, got %d\n", (int)chead.class));
-       t_errno = TSYSERR;
-       return -1;
+        TRC(fprintf(stderr, "Expected TP0, got %d\n", (int)chead.class));
+        t_errno = TSYSERR;
+        return -1;
     }
     memcpy(new->rref, chead.src_ref, 2); /* we'll echo this back at her */
     new->hlen -= 5;
     if (call && call->addr.maxlen)
-       *(addrp = call->addr.buf) = 0;
+        *(addrp = call->addr.buf) = 0;
     for (p = buf + 5; new->hlen > 0;)
     {
-       switch ((unsigned char)*p)
-       {
-           case TPDU_PARM_TSIZE:
-               new->tsize = 1 << *(p + 2); /* we go with their max */
-               break;
-           case TPDU_PARM_CLDID: break; /* ignore */
-           case TPDU_PARM_CLGID:
-               if (addrp)
-               {
-                   if (*(p + 1) > TSEL_MAXLEN)
-                   {
-                       TRC(fprintf(stderr, "Called TSEL too long.\n"));
-                       t_errno = TSYSERR; /* Wrong.. ## */
-                       return -1;
-                   }
-                   *addrp = *(p + 1); /* length */
-                   memcpy(addrp + 1, p + 2, *(p + 1)); /* remote TSEL */
-                   addrp += *(p + 1); /* move past TSEL */
-               }
-               break;
-           /* we silently ignore preferred TPDU size and others */
-       }
-       p++;
-       new->hlen -= (unsigned char) *p + 2;
-       p += (unsigned char) *p + 1;
+        switch ((unsigned char)*p)
+        {
+            case TPDU_PARM_TSIZE:
+                new->tsize = 1 << *(p + 2); /* we go with their max */
+                break;
+            case TPDU_PARM_CLDID: break; /* ignore */
+            case TPDU_PARM_CLGID:
+                if (addrp)
+                {
+                    if (*(p + 1) > TSEL_MAXLEN)
+                    {
+                        TRC(fprintf(stderr, "Called TSEL too long.\n"));
+                        t_errno = TSYSERR; /* Wrong.. ## */
+                        return -1;
+                    }
+                    *addrp = *(p + 1); /* length */
+                    memcpy(addrp + 1, p + 2, *(p + 1)); /* remote TSEL */
+                    addrp += *(p + 1); /* move past TSEL */
+                }
+                break;
+            /* we silently ignore preferred TPDU size and others */
+        }
+        p++;
+        new->hlen -= (unsigned char) *p + 2;
+        p += (unsigned char) *p + 1;
     }
     if (addrp)
     {
-       addrp++;
-       if (getpeername(cnt->tmpfd, (struct sockaddr*) &addr, &len) < 0)
-       {
-           TRC(perror("getpeername()"));
-           t_errno = TSYSERR;
-           return -1;
-       }
-       *(addrp++) = sizeof(struct sockaddr_in);
-       memcpy(addrp, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
+        addrp++;
+        if (getpeername(cnt->tmpfd, (struct sockaddr*) &addr, &len) < 0)
+        {
+            TRC(perror("getpeername()"));
+            t_errno = TSYSERR;
+            return -1;
+        }
+        *(addrp++) = sizeof(struct sockaddr_in);
+        memcpy(addrp, (struct sockaddr *) &addr, sizeof(struct sockaddr_in));
     }
     new->event = 0;
     cnt->event = 0;
@@ -1174,118 +1178,118 @@ int t_listen(int fd, struct t_call *call)
     TRC(fprintf(stderr, "T_LISTEN\n"));
     if (!cnt || cnt->state != T_IDLE)
     {
-       TRC(fprintf(stderr, "T_listen expects state==T_IDLE (wrong?)\n"));
-       t_errno = TOUTSTATE;
-       return -1;
+        TRC(fprintf(stderr, "T_listen expects state==T_IDLE (wrong?)\n"));
+        t_errno = TOUTSTATE;
+        return -1;
     }
     if (!cnt->qlen)
     {
-       t_errno = TBADQLEN;
-       return -1;
+        t_errno = TBADQLEN;
+        return -1;
     }
     for (i = 0; i < cnt->qlen; i++)
-       if (cnt->oci[i] < 0)
-           break;
+        if (cnt->oci[i] < 0)
+            break;
     if (i == cnt->qlen) /* no slots in queue */
     {
-       TRC(fprintf(stderr, "No more space in queue\n"));
-       t_errno = TBADF; /* what would be more correct? */
-       return -1;
+        TRC(fprintf(stderr, "No more space in queue\n"));
+        t_errno = TBADF; /* what would be more correct? */
+        return -1;
     }
     if (cnt->tmpfd < 0)
     {
-       TRC(fprintf(stderr, "Accept..."));
-       if ((cnt->tmpfd = accept(fd, (struct sockaddr*) &addr, &addrlen)) < 0)
-       {
-           if (errno == EWOULDBLOCK)
-           {
-               t_errno = TNODATA;
-               TRC(fprintf(stderr, "Accept returned WOULDBLOCK\n"));
-           }
-           else
-           {
-               TRC(fprintf(stderr, "accept failed\n"));
-               t_errno = TSYSERR;
-           }
-           return -1;
-       }
+        TRC(fprintf(stderr, "Accept..."));
+        if ((cnt->tmpfd = accept(fd, (struct sockaddr*) &addr, &addrlen)) < 0)
+        {
+            if (errno == EWOULDBLOCK)
+            {
+                t_errno = TNODATA;
+                TRC(fprintf(stderr, "Accept returned WOULDBLOCK\n"));
+            }
+            else
+            {
+                TRC(fprintf(stderr, "accept failed\n"));
+                t_errno = TSYSERR;
+            }
+            return -1;
+        }
 #ifdef NONBLOCKING_OSI
-       if ((cnt->flags & O_NONBLOCK) && fcntl(cnt->tmpfd, F_SETFL,
-           O_NONBLOCK) < 0)
-       {
-           t_errno = TSYSERR;
-           return -1;
-       }
+        if ((cnt->flags & O_NONBLOCK) && fcntl(cnt->tmpfd, F_SETFL,
+            O_NONBLOCK) < 0)
+        {
+            t_errno = TSYSERR;
+            return -1;
+        }
 #endif
-       tmpfd_is_new = 1;
-       TRC(fprintf(stderr, "Accept OK\n"));
-       if (!(new = control[cnt->tmpfd] = malloc(sizeof(*new))))
-       {
-           TRC(perror("malloc()"));
-           t_errno = TSYSERR;
-           return -1;
-       }
-       new->togo = 0;
-       new->pending = 0;
-       new->state = T_IDLE;
-       new->event = 0;
-       new->listen = 0;
-       new->qlen = cnt->qlen;
-       new->flags = cnt->flags;
-       new->tmpfd = cnt->tmpfd;
-       new->ltsel_len = 0;
-       for (i = 0; i < MAX_QLEN; i++)
-           new->oci[i] = -1;
+        tmpfd_is_new = 1;
+        TRC(fprintf(stderr, "Accept OK\n"));
+        if (!(new = control[cnt->tmpfd] = malloc(sizeof(*new))))
+        {
+            TRC(perror("malloc()"));
+            t_errno = TSYSERR;
+            return -1;
+        }
+        new->togo = 0;
+        new->pending = 0;
+        new->state = T_IDLE;
+        new->event = 0;
+        new->listen = 0;
+        new->qlen = cnt->qlen;
+        new->flags = cnt->flags;
+        new->tmpfd = cnt->tmpfd;
+        new->ltsel_len = 0;
+        for (i = 0; i < MAX_QLEN; i++)
+            new->oci[i] = -1;
     }
     /* we got a network connection. Now try to read transport CREQ TPDU */
     if ((event = t_look_wait(tmpfd_is_new ? cnt->tmpfd : fd, 1)) < 0)
     {
-       if (t_errno == TNODATA)
-       {
-           if (tmpfd_is_new)
-           {
-               /*
-                * We give the user something to select on for the incoming
-                * CR. Switch the new association with the listener socket.
-                */
-               TRC(fprintf(stderr, "Switching FDs\n"));
-               if (switch_fds(cnt->tmpfd, fd) < 0)
-               {
-                   t_errno = TSYSERR;
-                   return -1;
-               }
-           }
-           return -1;
-       }
-       else
-       {
-           t_close(cnt->tmpfd);
-           cnt->tmpfd = -1;
-       }
-       return -1; /* t_look & t_read hopefully set up the right errcodes */
+        if (t_errno == TNODATA)
+        {
+            if (tmpfd_is_new)
+            {
+                /*
+                 * We give the user something to select on for the incoming
+                 * CR. Switch the new association with the listener socket.
+                 */
+                TRC(fprintf(stderr, "Switching FDs\n"));
+                if (switch_fds(cnt->tmpfd, fd) < 0)
+                {
+                    t_errno = TSYSERR;
+                    return -1;
+                }
+            }
+            return -1;
+        }
+        else
+        {
+            t_close(cnt->tmpfd);
+            cnt->tmpfd = -1;
+        }
+        return -1; /* t_look & t_read hopefully set up the right errcodes */
     }
     else
     {
-       /* We got something! */
-       if (event != T_LISTEN)
-       {
-           TRC(fprintf(stderr, "Expected T_LISTEN\n"));
-           t_errno = TLOOK;
-           return -1;
-       }
-       /*
-        * switch back the fds, if necessary */
-       if (!tmpfd_is_new && switch_fds(fd, cnt->tmpfd) < 0)
-       {
-           t_errno = TSYSERR;
-           return -1;
-       }
-       if (rcvconreq(fd, call) < 0)
-       {
-           t_close(cnt->tmpfd);
-           cnt->tmpfd = -1;
-       }
-       return 0;
+        /* We got something! */
+        if (event != T_LISTEN)
+        {
+            TRC(fprintf(stderr, "Expected T_LISTEN\n"));
+            t_errno = TLOOK;
+            return -1;
+        }
+        /*
+         * switch back the fds, if necessary */
+        if (!tmpfd_is_new && switch_fds(fd, cnt->tmpfd) < 0)
+        {
+            t_errno = TSYSERR;
+            return -1;
+        }
+        if (rcvconreq(fd, call) < 0)
+        {
+            t_close(cnt->tmpfd);
+            cnt->tmpfd = -1;
+        }
+        return 0;
     }
 }    
 
@@ -1298,7 +1302,7 @@ int t_listen(int fd, struct t_call *call)
 int t_unbind(int fd)
 {
     TRC(fprintf(stderr,
-       "T_UNBIND [not supported by transport implementation]\n"));
+        "T_UNBIND [not supported by transport implementation]\n"));
     t_errno = TNOTSUPPORT;
     return -1;
 }    
@@ -1317,64 +1321,64 @@ int t_accept(int fd, int resfd, struct t_call *call)
     TRC(fprintf(stderr, "T_ACCEPT\n"));
     if (!listener || listener->state != T_INCON)
     {
-       TRC(fprintf(stderr, "TOUTSTATE\n"));
-       t_errno = TOUTSTATE;
-       return -1;
+        TRC(fprintf(stderr, "TOUTSTATE\n"));
+        t_errno = TOUTSTATE;
+        return -1;
     }
     /* Get the semi-connection */
     if (call->sequence >= listener->qlen || listener->oci[call->sequence] < 0)
     {
-       TRC(fprintf(stderr, "TBADSEQ\n"));
-       t_errno = TBADSEQ;
-       return -1;
+        TRC(fprintf(stderr, "TBADSEQ\n"));
+        t_errno = TBADSEQ;
+        return -1;
     }
     new = control[(newfd = listener->oci[call->sequence])];
     listener->oci[call->sequence] = -1;
     res = control[resfd];
     if (!res)
     {
-       t_errno = TBADF;
-       return -1;
+        t_errno = TBADF;
+        return -1;
     }
     if (res != listener) /* move the new connection */
     {
-       TRC(fprintf(stderr, "  Moving to new fd (%d)\n", resfd));
-       if (res->state != T_IDLE || res->qlen)
-       {
-           TRC(fprintf(stderr, "Trying to move new assc. to bad fd.\n"));
-           t_errno = TBADF;
-           return -1;
-       }
-       dup2(newfd, resfd); /* closes resfd */
-       close(newfd);
-       control[resfd] = new;
-       /* transfer local bindings from res */
-       if (res->ltsel_len)
-           memcpy(control[resfd]->ltsel, res->ltsel, res->ltsel_len);
-       control[resfd]->ltsel_len = res->ltsel_len;
-       free(res);
-       res = control[resfd];
-       listener->event = 0;
-       listener->state = T_IDLE;
+        TRC(fprintf(stderr, "  Moving to new fd (%d)\n", resfd));
+        if (res->state != T_IDLE || res->qlen)
+        {
+            TRC(fprintf(stderr, "Trying to move new assc. to bad fd.\n"));
+            t_errno = TBADF;
+            return -1;
+        }
+        dup2(newfd, resfd); /* closes resfd */
+        close(newfd);
+        control[resfd] = new;
+        /* transfer local bindings from res */
+        if (res->ltsel_len)
+            memcpy(control[resfd]->ltsel, res->ltsel, res->ltsel_len);
+        control[resfd]->ltsel_len = res->ltsel_len;
+        free(res);
+        res = control[resfd];
+        listener->event = 0;
+        listener->state = T_IDLE;
     }
     else /* lose our listener */
     {
-       TRC(fprintf(stderr, "  Moving to listener fd\n"));
-       for (i = 0; i < listener->qlen; i++)
-           if (listener->oci[i] >= 0)
-           {
-               TRC(fprintf(stderr, "Still conn indications on listener\n"));
-               t_errno = TBADF;
-               return -1;
-           }
-       dup2(newfd, fd);
-       close(newfd);
-       control[fd] = new;
-       if (listener->ltsel_len)
-           memcpy(control[resfd]->ltsel, listener->ltsel, listener->ltsel_len);
-       control[resfd]->ltsel_len = listener->ltsel_len;
-       free(listener);
-       res = control[resfd];
+        TRC(fprintf(stderr, "  Moving to listener fd\n"));
+        for (i = 0; i < listener->qlen; i++)
+            if (listener->oci[i] >= 0)
+            {
+                TRC(fprintf(stderr, "Still conn indications on listener\n"));
+                t_errno = TBADF;
+                return -1;
+            }
+        dup2(newfd, fd);
+        close(newfd);
+        control[fd] = new;
+        if (listener->ltsel_len)
+            memcpy(control[resfd]->ltsel, listener->ltsel, listener->ltsel_len);
+        control[resfd]->ltsel_len = listener->ltsel_len;
+        free(listener);
+        res = control[resfd];
     }
     rfc.version = RFC_VERSION;
     rfc.reserved = 0;
@@ -1394,7 +1398,7 @@ int t_accept(int fd, int resfd, struct t_call *call)
     parm[3] = TPDU_PARM_CLDID;
     parm[4] = res->ltsel_len; 
     if (res->ltsel_len)
-       memcpy(parm + 5, res->ltsel, res->ltsel_len);
+        memcpy(parm + 5, res->ltsel, res->ltsel_len);
 
     rfc.len =  htons(4 + 7 + 3 + 2 + res->ltsel_len);
     rfc.hlen = 6 + 3 + 2 + res->ltsel_len;
@@ -1406,9 +1410,9 @@ int t_accept(int fd, int resfd, struct t_call *call)
     vec[2].iov_len = 3 + 2 + res->ltsel_len;
     if (writev(resfd, vec, 3) < 4 + 7 + 3 + (2 + res->ltsel_len))
     {
-       TRC(fprintf(stderr, "writev came up short. Aborting connect\n"));
-       t_errno = TSYSERR;
-       return -1;
+        TRC(fprintf(stderr, "writev came up short. Aborting connect\n"));
+        t_errno = TSYSERR;
+        return -1;
     }
     res->state = T_DATAXFER;
     res->event = 0;
@@ -1420,3 +1424,11 @@ int t_getstate(int fd)
     TRC(fprintf(stderr, "T_GETSTATE\n"));
     return control[fd] ? control[fd]->state : T_UNINIT;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 908188e..0239f82 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: atoin.c,v 1.6 2005-01-15 19:47:10 adam Exp $
+ * $Id: atoin.c,v 1.7 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -29,8 +29,16 @@ int atoi_n (const char *buf, int len)
     {
         if (isdigit (*(const unsigned char *) buf))
             val = val*10 + (*buf - '0');
-       buf++;
+        buf++;
     }
     return val;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b300315..8899dde 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_any.c,v 1.3 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_any.c,v 1.4 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -58,23 +58,23 @@ int completeBER_n(const unsigned char *buf, int len, int level)
     
     if (len > 5000000 || level > 1000)
     {
-       bad = 1;
+        bad = 1;
 #if BER_ANY_DEBUG
-       yaz_log(LOG_LOG, "completeBER lev=%d len=%d", level, len);
+        yaz_log(LOG_LOG, "completeBER lev=%d len=%d", level, len);
 #endif
-       if (level > 1000)
-           return -2;
+        if (level > 1000)
+            return -2;
     }
     if (len < 2)
-       return 0;
+        return 0;
     if (!buf[0] && !buf[1])
-       return -2;
+        return -2;
     if ((res = ber_dectag(b, &zclass, &tag, &cons, len)) <= 0)
-       return 0;
+        return 0;
 #if 0
 /* removed, since ber_dectag never reads that far .. */
     if (res > len)
-       return 0;
+        return 0;
 #endif
     b += res;
     len -= res;
@@ -83,36 +83,36 @@ int completeBER_n(const unsigned char *buf, int len, int level)
     if (res == -2)
     {
 #if BER_ANY_DEBUG
-       if (bad)
-           yaz_log(LOG_LOG, "<<<<<<<<< return1 lev=%d res=%d", level, res);
+        if (bad)
+            yaz_log(LOG_LOG, "<<<<<<<<< return1 lev=%d res=%d", level, res);
 #endif
-       return -1;  /* error */
+        return -1;  /* error */
     }
     if (res == -1)  
     {
 #if BER_ANY_DEBUG
-       if (bad)
-           yaz_log(LOG_LOG, "<<<<<<<<< return3 lev=%d res=-1", level);
+        if (bad)
+            yaz_log(LOG_LOG, "<<<<<<<<< return3 lev=%d res=-1", level);
 #endif
-       return 0;    /* incomplete length */
+        return 0;    /* incomplete length */
     }
     if (ll > 5000000)
     {
 #if BER_ANY_DEBUG
-       if (bad)
-           yaz_log(LOG_LOG, "<<<<<<<<< return2 lev=%d len=%d res=%d ll=%d",
-                   level, len, res, ll);
+        if (bad)
+            yaz_log(LOG_LOG, "<<<<<<<<< return2 lev=%d len=%d res=%d ll=%d",
+                    level, len, res, ll);
 #endif
-       return -1;  /* error */
+        return -1;  /* error */
     }
 #if 0
 /* no longer necessary, since ber_declen never reads that far (returns -1) */
     if (res > len)
     {
-       if (bad)
-           yaz_log(LOG_LOG, "<<<<<<<<< return4 lev=%d res=%d len=%d",
-                   level, res, len);
-       return 0;
+        if (bad)
+            yaz_log(LOG_LOG, "<<<<<<<<< return4 lev=%d res=%d len=%d",
+                    level, res, len);
+        return 0;
     }
 #endif
     b += res;
@@ -120,35 +120,35 @@ int completeBER_n(const unsigned char *buf, int len, int level)
     if (ll >= 0)
     {   /* definite length */
 #if BER_ANY_DEBUG
-       if (bad && len < ll)
-           yaz_log(LOG_LOG, "<<<<<<<<< return5 lev=%d len=%d ll=%d",
-                   level, len, ll);
+        if (bad && len < ll)
+            yaz_log(LOG_LOG, "<<<<<<<<< return5 lev=%d len=%d ll=%d",
+                    level, len, ll);
 #endif
-       return (len >= ll ? ll + (b-buf) : 0);
+        return (len >= ll ? ll + (b-buf) : 0);
     }
     /* indefinite length */
     if (!cons)
     {   /* if primitive, it's an error */
 #if BER_ANY_DEBUG
-       yaz_log(LOG_LOG, "<<<<<<<<< return6 lev=%d ll=%d len=%d res=%d",
-               level, ll, len, res);
+        yaz_log(LOG_LOG, "<<<<<<<<< return6 lev=%d ll=%d len=%d res=%d",
+                level, ll, len, res);
 #endif
-       return -1;   /* error */
+        return -1;   /* error */
     }
     /* constructed - cycle through children */
     while (len >= 2)
     {
-       if (b[0] == 0 && b[1] == 0)
-           break;
-       if (!(res = completeBER_n(b, len, level+1)))
-           return 0;
-       if (res == -1)
-           return -1;
-       b += res;
-       len -= res;
+        if (b[0] == 0 && b[1] == 0)
+            break;
+        if (!(res = completeBER_n(b, len, level+1)))
+            return 0;
+        if (res == -1)
+            return -1;
+        b += res;
+        len -= res;
     }
     if (len < 2)
-       return 0;
+        return 0;
     return (b - buf) + 2;
 }
 
@@ -156,6 +156,14 @@ int completeBER(const unsigned char *buf, int len)
 {
     int res = completeBER_n(buf, len, 0);
     if (res < 0)
-       return len;
+        return len;
     return res;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 39bf989..7fbaed1 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_bit.c,v 1.3 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_bit.c,v 1.4 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -82,3 +82,11 @@ int ber_bitstring(ODR o, Odr_bitmask *p, int cons)
         return 0;
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e2cbeda..8d74df9 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_bool.c,v 1.3 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_bool.c,v 1.4 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -58,3 +58,11 @@ int ber_boolean(ODR o, int *val)
     default: odr_seterror(o, OOTHER, 11); return 0;
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index fc89b0d..84e560b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_int.c,v 1.4 2005-01-16 21:51:50 adam Exp $
+ * $Id: ber_int.c,v 1.5 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -41,21 +41,21 @@ int ber_integer(ODR o, int *val)
     switch (o->direction)
     {
     case ODR_DECODE:
-       if ((res = ber_decinteger(o->bp, val, odr_max(o))) <= 0)
-       {
-           odr_seterror(o, OPROTO, 50);
-           return 0;
-       }
-       o->bp += res;
-       return 1;
+        if ((res = ber_decinteger(o->bp, val, odr_max(o))) <= 0)
+        {
+            odr_seterror(o, OPROTO, 50);
+            return 0;
+        }
+        o->bp += res;
+        return 1;
     case ODR_ENCODE:
-       if ((res = ber_encinteger(o, *val)) < 0)
-           return 0;
-       return 1;
+        if ((res = ber_encinteger(o, *val)) < 0)
+            return 0;
+        return 1;
     case ODR_PRINT:
-       return 1;
+        return 1;
     default:
-       odr_seterror(o, OOTHER, 51);  return 0;
+        odr_seterror(o, OOTHER, 51);  return 0;
     }
 }
 
@@ -116,3 +116,11 @@ int ber_decinteger(const unsigned char *buf, int *val, int max)
 #endif
     return b - buf;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 4075ea6..1a02fde 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_len.c,v 1.3 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_len.c,v 1.4 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -40,49 +40,49 @@ int ber_enclen(ODR o, int len, int lenlen, int exact)
 #endif
     if (len < 0)      /* Indefinite */
     {
-       if (odr_putc(o, 0x80) < 0)
-           return 0;
+        if (odr_putc(o, 0x80) < 0)
+            return 0;
 #ifdef ODR_DEBUG
-       fprintf(stderr, "[indefinite]");
+        fprintf(stderr, "[indefinite]");
 #endif
-       return 0;
+        return 0;
     }
     if (len <= 127 && (lenlen == 1 || !exact)) /* definite short form */
     {
-       if (odr_putc(o, (unsigned char) len) < 0)
-           return 0;
-       return 1;
+        if (odr_putc(o, (unsigned char) len) < 0)
+            return 0;
+        return 1;
     }
     if (lenlen == 1)
     {
-       if (odr_putc(o, 0x80) < 0)
-           return 0;
-       return 0;
+        if (odr_putc(o, 0x80) < 0)
+            return 0;
+        return 0;
     }
     /* definite long form */
     do
     {
-       octs[n++] = len;
-       len >>= 8;
+        octs[n++] = len;
+        len >>= 8;
     }
     while (len);
     if (n >= lenlen)
-       return -1;
+        return -1;
     lenpos = odr_tell(o); /* remember length-of-length position */
     if (odr_putc(o, 0) < 0)  /* dummy */
-       return 0;
+        return 0;
     if (exact)
-       while (n < --lenlen)        /* pad length octets */
-           if (odr_putc(o, 0) < 0)
-               return 0;
+        while (n < --lenlen)        /* pad length octets */
+            if (odr_putc(o, 0) < 0)
+                return 0;
     while (n--)
-       if (odr_putc(o, octs[n]) < 0)
-           return 0;
+        if (odr_putc(o, octs[n]) < 0)
+            return 0;
     /* set length of length */
     end = odr_tell(o);
     odr_seek(o, ODR_S_SET, lenpos);
     if (odr_putc(o, (end - lenpos - 1) | 0X80) < 0)
-       return 0;
+        return 0;
     odr_seek(o, ODR_S_END, 0);
     return odr_tell(o) - lenpos;
 }
@@ -107,22 +107,22 @@ int ber_declen(const unsigned char *buf, int *len, int max)
         return -1;
     if (*b == 0X80)     /* Indefinite */
     {
-       *len = -1;
+        *len = -1;
 #ifdef ODR_DEBUG
-       fprintf(stderr, "[len=%d]", *len);
+        fprintf(stderr, "[len=%d]", *len);
 #endif
-       return 1;
+        return 1;
     }
     if (!(*b & 0X80))   /* Definite short form */
     {
-       *len = (int) *b;
+        *len = (int) *b;
 #ifdef ODR_DEBUG
-       fprintf(stderr, "[len=%d]", *len);
+        fprintf(stderr, "[len=%d]", *len);
 #endif
-       return 1;
+        return 1;
     }
     if (*b == 0XFF)     /* reserved value */
-       return -2;
+        return -2;
     /* indefinite long form */ 
     n = *b & 0X7F;
     if (n >= max)
@@ -131,8 +131,8 @@ int ber_declen(const unsigned char *buf, int *len, int max)
     b++;
     while (--n >= 0)
     {
-       *len <<= 8;
-       *len |= *(b++);
+        *len <<= 8;
+        *len |= *(b++);
     }
     if (*len < 0)
         return -2;
@@ -141,3 +141,11 @@ int ber_declen(const unsigned char *buf, int *len, int max)
 #endif
     return (b - buf);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 526e491..7797e13 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_null.c,v 1.3 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_null.c,v 1.4 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -48,9 +48,17 @@ int ber_null(ODR o)
 #endif
         return 1;
     case ODR_PRINT:
-       return 1;
+        return 1;
     default:
-       odr_seterror(o, OOTHER, 13);
-       return 0;
+        odr_seterror(o, OOTHER, 13);
+        return 0;
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a69219d..593cc11 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_oct.c,v 1.3 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_oct.c,v 1.4 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -28,59 +28,67 @@ int ber_octetstring(ODR o, Odr_oct *p, int cons)
     switch (o->direction)
     {
     case ODR_DECODE:
-       if ((res = ber_declen(o->bp, &len, odr_max(o))) < 0)
-       {
-           odr_seterror(o, OPROTO, 14);
-           return 0;
-       }
-       o->bp += res;
-       if (cons)       /* fetch component strings */
-       {
-           base = o->bp;
-           while (odp_more_chunks(o, base, len))
-               if (!odr_octetstring(o, &p, 0, 0))
-                   return 0;
-           return 1;
-       }
-       /* primitive octetstring */
-       if (len < 0)
-       {
-           odr_seterror(o, OOTHER, 15);
-           return 0;
-       }
-       if (len > odr_max(o))
-       {
-           odr_seterror(o, OOTHER, 16);
-           return 0;
-       }
-       if (len + 1 > p->size - p->len)
-       {
-           c = (unsigned char *)odr_malloc(o, p->size += len + 1);
-           if (p->len)
-               memcpy(c, p->buf, p->len);
-           p->buf = c;
-       }
-       if (len)
-           memcpy(p->buf + p->len, o->bp, len);
-       p->len += len;
-       o->bp += len;
-       /* the final null is really not part of the buffer, but */
-       /* it helps somes applications that assumes C strings */
-       if (len)
-           p->buf[p->len] = '\0';
-       return 1;
+        if ((res = ber_declen(o->bp, &len, odr_max(o))) < 0)
+        {
+            odr_seterror(o, OPROTO, 14);
+            return 0;
+        }
+        o->bp += res;
+        if (cons)       /* fetch component strings */
+        {
+            base = o->bp;
+            while (odp_more_chunks(o, base, len))
+                if (!odr_octetstring(o, &p, 0, 0))
+                    return 0;
+            return 1;
+        }
+        /* primitive octetstring */
+        if (len < 0)
+        {
+            odr_seterror(o, OOTHER, 15);
+            return 0;
+        }
+        if (len > odr_max(o))
+        {
+            odr_seterror(o, OOTHER, 16);
+            return 0;
+        }
+        if (len + 1 > p->size - p->len)
+        {
+            c = (unsigned char *)odr_malloc(o, p->size += len + 1);
+            if (p->len)
+                memcpy(c, p->buf, p->len);
+            p->buf = c;
+        }
+        if (len)
+            memcpy(p->buf + p->len, o->bp, len);
+        p->len += len;
+        o->bp += len;
+        /* the final null is really not part of the buffer, but */
+        /* it helps somes applications that assumes C strings */
+        if (len)
+            p->buf[p->len] = '\0';
+        return 1;
     case ODR_ENCODE:
-       if ((res = ber_enclen(o, p->len, 5, 0)) < 0)
-           return 0;
-       if (p->len == 0)
-           return 1;
-       if (odr_write(o, p->buf, p->len) < 0)
-           return 0;
-       return 1;
+        if ((res = ber_enclen(o, p->len, 5, 0)) < 0)
+            return 0;
+        if (p->len == 0)
+            return 1;
+        if (odr_write(o, p->buf, p->len) < 0)
+            return 0;
+        return 1;
     case ODR_PRINT:
-       return 1;
+        return 1;
     default:
-       odr_seterror(o, OOTHER, 17);
-       return 0;
+        odr_seterror(o, OOTHER, 17);
+        return 0;
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e1947d6..6a0541e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_oid.c,v 1.6 2005-05-26 21:46:40 adam Exp $
+ * $Id: ber_oid.c,v 1.7 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -44,8 +44,8 @@ int ber_oidc(ODR o, Odr_oid *p, int max_oid_size)
             return 0;
         }
         pos = 0;
-       while (len)
-       {
+        while (len)
+        {
             int id = 0;
             do
             {
@@ -61,20 +61,20 @@ int ber_oidc(ODR o, Odr_oid *p, int max_oid_size)
             while (*(o->bp++) & 0X80);
             if (pos > 0)
                 p[pos++] = id;
-           else
+            else
             {
                 p[0] = id / 40;
-               if (p[0] > 2)
+                if (p[0] > 2)
                     p[0] = 2;
-               p[1] = id - p[0] * 40;
-               pos = 2;
+                p[1] = id - p[0] * 40;
+                pos = 2;
+            }
+            if (pos >= max_oid_size)
+            {
+                odr_seterror(o, OPROTO, 55);
+                return 0;
             }
-           if (pos >= max_oid_size)
-           {
-               odr_seterror(o, OPROTO, 55);
-               return 0;
-           }
-       }
+        }
         p[pos] = -1;
         return 1;
     case ODR_ENCODE:
@@ -93,7 +93,7 @@ int ber_oidc(ODR o, Odr_oid *p, int max_oid_size)
             n = 0;
             if (pos == 1)
                 id = p[0]*40 + p[1];
-           else 
+            else 
                 id = p[pos];
             do
             {
@@ -124,3 +124,11 @@ int ber_oidc(ODR o, Odr_oid *p, int max_oid_size)
         return 0;
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b6f7644..64908d7 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_tag.c,v 1.4 2005-01-15 19:47:11 adam Exp $
+ * $Id: ber_tag.c,v 1.5 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -21,8 +21,8 @@
 
 /* ber_tag
  * On encoding:
- *     if  p: write tag. return 1 (success) or -1 (error).
- *     if !p: return 0.
+ *      if  p: write tag. return 1 (success) or -1 (error).
+ *      if !p: return 0.
  * On decoding:
  *      if tag && zclass match up, advance pointer and return 1. set cons.
  *      else leave pointer unchanged. Return 0.
@@ -37,13 +37,13 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt,
     char **pp = (char **)p;
 
     if (o->direction == ODR_DECODE)
-       *pp = 0;
+        *pp = 0;
     o->t_class = -1;
     if (o->op->stackp < 0)
     {
-       odr_seek(o, ODR_S_SET, 0);
+        odr_seek(o, ODR_S_SET, 0);
         o->top = 0;
-       o->bp = o->buf;
+        o->bp = o->buf;
         odr_ber_tag->lclass = -1;
     }
     switch (o->direction)
@@ -137,31 +137,31 @@ int ber_enctag(ODR o, int zclass, int tag, int constructed)
     b |= (cons << 5) & 0X20;
     if (tag <= 30)
     {
-       b |= tag & 0X1F;
-       if (odr_putc(o, b) < 0)
-           return -1;
-       return 1;
+        b |= tag & 0X1F;
+        if (odr_putc(o, b) < 0)
+            return -1;
+        return 1;
     }
     else
     {
-       b |= 0X1F;
-       if (odr_putc(o, b) < 0)
-           return -1;
-       do
-       {
-           octs[n++] = tag & 0X7F;
-           tag >>= 7;
-       }
-       while (tag);
-       while (n--)
-       {
-           unsigned char oo;
+        b |= 0X1F;
+        if (odr_putc(o, b) < 0)
+            return -1;
+        do
+        {
+            octs[n++] = tag & 0X7F;
+            tag >>= 7;
+        }
+        while (tag);
+        while (n--)
+        {
+            unsigned char oo;
 
-           oo = octs[n] | ((n > 0) << 7);
-           if (odr_putc(o, oo) < 0)
-               return -1;
-       }
-       return 0;
+            oo = octs[n] | ((n > 0) << 7);
+            if (odr_putc(o, oo) < 0)
+                return -1;
+        }
+        return 0;
     }
 }
 
@@ -179,15 +179,23 @@ int ber_dectag(const unsigned char *b, int *zclass, int *tag,
     *zclass = *b >> 6;
     *constructed = (*b >> 5) & 0X01;
     if ((*tag = *b & 0x1F) <= 30)
-       return 1;
+        return 1;
     *tag = 0;
     do
     {
         if (l >= max)
             return -1;
-       *tag <<= 7;
-       *tag |= b[l] & 0X7F;
+        *tag <<= 7;
+        *tag |= b[l] & 0X7F;
     }
     while (b[l++] & 0X80);
     return l;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2c4256b..201e0aa 100644 (file)
@@ -54,7 +54,7 @@
 /*
  * Europagate, 1995
  *
- * $Id: cclerrms.c,v 1.2 2004-10-15 00:18:59 adam Exp $
+ * $Id: cclerrms.c,v 1.3 2005-06-25 15:46:03 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -108,3 +108,11 @@ const char *ccl_err_msg (int ccl_errno)
 {
     return err_msg_array[ccl_errno];
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 9037887..72f1aa6 100644 (file)
@@ -56,7 +56,7 @@
 /* CCL find (to rpn conversion)
  * Europagate, 1995
  *
- * $Id: cclfind.c,v 1.7 2005-03-15 16:32:52 adam Exp $
+ * $Id: cclfind.c,v 1.8 2005-06-25 15:46:03 adam Exp $
  *
  * Old Europagate log:
  *
@@ -140,7 +140,7 @@ static int qual_val_type (struct ccl_rpn_attr **qa, int type, int value,
         while (q)
         {
             if (q->type == type && q->kind == CCL_RPN_ATTR_NUMERIC &&
-               q->value.numeric == value)
+                q->value.numeric == value)
             {
                 if (attset)
                     *attset = q->set;
@@ -216,8 +216,8 @@ void ccl_rpn_delete (struct ccl_rpn_node *rpn)
         for (attr = rpn->u.t.attr_list; attr; attr = attr1)
         {
             attr1 = attr->next;
-           if (attr->kind == CCL_RPN_ATTR_STRING)
-               xfree(attr->value.str);
+            if (attr->kind == CCL_RPN_ATTR_STRING)
+                xfree(attr->value.str);
             if (attr->set)
                 xfree (attr->set);
             xfree (attr);
@@ -250,7 +250,7 @@ static struct ccl_rpn_node *search_terms (CCL_parser cclp,
                                           struct ccl_rpn_attr **qa);
 
 static struct ccl_rpn_attr *add_attr_node (struct ccl_rpn_node *p,
-                                          const char *set, int type)
+                                           const char *set, int type)
 {
     struct ccl_rpn_attr *n;
     
@@ -280,7 +280,7 @@ static struct ccl_rpn_attr *add_attr_node (struct ccl_rpn_node *p,
  * set: Attribute set name
  */
 static void add_attr_numeric (struct ccl_rpn_node *p, const char *set,
-                             int type, int value)
+                              int type, int value)
 {
     struct ccl_rpn_attr *n;
 
@@ -290,7 +290,7 @@ static void add_attr_numeric (struct ccl_rpn_node *p, const char *set,
 }
 
 static void add_attr_string (struct ccl_rpn_node *p, const char *set,
-                            int type, char *value)
+                             int type, char *value)
 {
     struct ccl_rpn_attr *n;
 
@@ -320,9 +320,9 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp,
     const char *truncation_aliases;
 
     truncation_aliases =
-       ccl_qual_search_special(cclp->bibset, "truncation");
+        ccl_qual_search_special(cclp->bibset, "truncation");
     if (!truncation_aliases)
-       truncation_aliases = "?";
+        truncation_aliases = "?";
 
     if (qual_val_type (qa, CCL_BIB1_STR, CCL_BIB1_STR_AND_LIST, 0))
         and_list = 1;
@@ -345,13 +345,13 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp,
         size_t max = 200;
         if (and_list || or_list || !multi)
             max = 1;
-       
-       /* ignore commas when dealing with and-lists .. */
+        
+        /* ignore commas when dealing with and-lists .. */
         if (and_list && lookahead && lookahead->kind == CCL_TOK_COMMA)
         {
-           lookahead = lookahead->next;
+            lookahead = lookahead->next;
             ADVANCE;
-           continue;
+            continue;
         }
         /* go through each TERM token. If no truncation attribute is yet
            met, then look for left/right truncation markers (?) and
@@ -360,8 +360,8 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp,
         {
             for (i = 0; i<lookahead->len; i++)
                 if (lookahead->name[i] == ' ')
-                   no_spaces++;
-               else if (strchr(truncation_aliases, lookahead->name[i]))
+                    no_spaces++;
+                else if (strchr(truncation_aliases, lookahead->name[i]))
                 {
                     if (no == 0 && i == 0 && lookahead->len >= 1)
                         left_trunc = 1;
@@ -409,48 +409,48 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp,
             struct ccl_rpn_attr *attr;
             
             for (attr = qa[i]; attr; attr = attr->next)
-               switch(attr->kind)
-               {
-               case CCL_RPN_ATTR_STRING:
-                   add_attr_string(p, attr->set, attr->type,
-                                   attr->value.str);
-                   break;
-               case CCL_RPN_ATTR_NUMERIC:
-                   if (attr->value.numeric > 0)
-                   {   /* deal only with REAL attributes (positive) */
-                       switch (attr->type)
-                       {
-                       case CCL_BIB1_REL:
-                           if (relation_value != -1)
-                               continue;
-                           relation_value = attr->value.numeric;
-                           break;
-                       case CCL_BIB1_POS:
-                           if (position_value != -1)
-                               continue;
-                           position_value = attr->value.numeric;
-                           break;
-                       case CCL_BIB1_STR:
-                           if (structure_value != -1)
-                               continue;
-                           structure_value = attr->value.numeric;
-                           break;
-                       case CCL_BIB1_TRU:
-                           if (truncation_value != -1)
-                               continue;
-                           truncation_value = attr->value.numeric;
-                           left_trunc = right_trunc = mid_trunc = 0;
-                           break;
-                       case CCL_BIB1_COM:
-                           if (completeness_value != -1)
-                               continue;
-                           completeness_value = attr->value.numeric;
-                           break;
-                       }
-                       add_attr_numeric(p, attr->set, attr->type,
-                                        attr->value.numeric);
-                   }
-               }
+                switch(attr->kind)
+                {
+                case CCL_RPN_ATTR_STRING:
+                    add_attr_string(p, attr->set, attr->type,
+                                    attr->value.str);
+                    break;
+                case CCL_RPN_ATTR_NUMERIC:
+                    if (attr->value.numeric > 0)
+                    {   /* deal only with REAL attributes (positive) */
+                        switch (attr->type)
+                        {
+                        case CCL_BIB1_REL:
+                            if (relation_value != -1)
+                                continue;
+                            relation_value = attr->value.numeric;
+                            break;
+                        case CCL_BIB1_POS:
+                            if (position_value != -1)
+                                continue;
+                            position_value = attr->value.numeric;
+                            break;
+                        case CCL_BIB1_STR:
+                            if (structure_value != -1)
+                                continue;
+                            structure_value = attr->value.numeric;
+                            break;
+                        case CCL_BIB1_TRU:
+                            if (truncation_value != -1)
+                                continue;
+                            truncation_value = attr->value.numeric;
+                            left_trunc = right_trunc = mid_trunc = 0;
+                            break;
+                        case CCL_BIB1_COM:
+                            if (completeness_value != -1)
+                                continue;
+                            completeness_value = attr->value.numeric;
+                            break;
+                        }
+                        add_attr_numeric(p, attr->set, attr->type,
+                                         attr->value.numeric);
+                    }
+                }
         }
         /* len now holds the number of characters in the RPN term */
         /* no holds the number of CCL tokens (1 or more) */
@@ -481,12 +481,12 @@ static struct ccl_rpn_node *search_term_x (CCL_parser cclp,
             }
             if (i == no-1 && right_trunc)
                 src_len--;
-           if (i && cclp->look_token->ws_prefix_len)
-           {
+            if (i && cclp->look_token->ws_prefix_len)
+            {
                 size_t len = strlen(p->u.t.term);
-               memcpy(p->u.t.term + len, cclp->look_token->ws_prefix_buf,
-                               cclp->look_token->ws_prefix_len);
-               p->u.t.term[len + cclp->look_token->ws_prefix_len] = '\0';
+                memcpy(p->u.t.term + len, cclp->look_token->ws_prefix_buf,
+                                cclp->look_token->ws_prefix_len);
+                p->u.t.term[len + cclp->look_token->ws_prefix_len] = '\0';
             }
             strxcat (p->u.t.term, src_str, src_len);
             ADVANCE;
@@ -547,7 +547,7 @@ static struct ccl_rpn_node *search_term (CCL_parser cclp,
 
 static
 struct ccl_rpn_node *qualifiers_order (CCL_parser cclp,
-                                      struct ccl_rpn_attr **ap, char *attset)
+                                       struct ccl_rpn_attr **ap, char *attset)
 {
     int rel = 0;
     struct ccl_rpn_node *p;
@@ -573,140 +573,140 @@ struct ccl_rpn_node *qualifiers_order (CCL_parser cclp,
     if (!rel)
     {
         cclp->error_code = CCL_ERR_BAD_RELATION;
-       return NULL;
+        return NULL;
     }
     ADVANCE;  /* skip relation */
     if (rel == 3 &&
-       qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_PORDER, 0))
+        qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_PORDER, 0))
     {
-       /* allow - inside term and treat it as range _always_ */
-       /* relation is =. Extract "embedded" - to separate terms */
-       if (KIND == CCL_TOK_TERM)
-       {
-           size_t i;
-           for (i = 0; i<cclp->look_token->len; i++)
-           {
-               if (cclp->look_token->name[i] == '-')
-                   break;
-           }
-           
-           if (cclp->look_token->len > 1 && i == 0)
-           {   /*  -xx*/
-               struct ccl_token *ntoken = ccl_token_add (cclp->look_token);
-
-               ntoken->kind = CCL_TOK_TERM;
-               ntoken->name = cclp->look_token->name + 1;
-               ntoken->len = cclp->look_token->len - 1;
-
-               cclp->look_token->len = 1;
-               cclp->look_token->name = "-";
-           }
-           else if (cclp->look_token->len > 1 && i == cclp->look_token->len-1)
-           {   /* xx- */
-               struct ccl_token *ntoken = ccl_token_add (cclp->look_token);
-
-               ntoken->kind = CCL_TOK_TERM;
-               ntoken->name = "-";
-               ntoken->len = 1;
-
-               (cclp->look_token->len)--;
-           }
-           else if (cclp->look_token->len > 2 && i < cclp->look_token->len)
-           {   /* xx-yy */
-               struct ccl_token *ntoken1 = ccl_token_add (cclp->look_token);
-               struct ccl_token *ntoken2 = ccl_token_add (ntoken1);
-
-               ntoken1->kind = CCL_TOK_TERM;  /* generate - */
-               ntoken1->name = "-";
-               ntoken1->len = 1;
-
-               ntoken2->kind = CCL_TOK_TERM;  /* generate yy */
-               ntoken2->name = cclp->look_token->name + (i+1);
-               ntoken2->len = cclp->look_token->len - (i+1);
-
-               cclp->look_token->len = i;     /* adjust xx */
-           }
-           else if (i == cclp->look_token->len &&
-                    cclp->look_token->next &&
-                    cclp->look_token->next->kind == CCL_TOK_TERM &&
-                    cclp->look_token->next->len > 1 &&
-                    cclp->look_token->next->name[0] == '-')
-                    
-           {   /* xx -yy */
-               /* we _know_ that xx does not have - in it */
-               struct ccl_token *ntoken = ccl_token_add (cclp->look_token);
-
-               ntoken->kind = CCL_TOK_TERM;    /* generate - */
-               ntoken->name = "-";
-               ntoken->len = 1;
-
-               (ntoken->next->name)++;        /* adjust yy */
-               (ntoken->next->len)--; 
-           }
-       }
+        /* allow - inside term and treat it as range _always_ */
+        /* relation is =. Extract "embedded" - to separate terms */
+        if (KIND == CCL_TOK_TERM)
+        {
+            size_t i;
+            for (i = 0; i<cclp->look_token->len; i++)
+            {
+                if (cclp->look_token->name[i] == '-')
+                    break;
+            }
+            
+            if (cclp->look_token->len > 1 && i == 0)
+            {   /*  -xx*/
+                struct ccl_token *ntoken = ccl_token_add (cclp->look_token);
+
+                ntoken->kind = CCL_TOK_TERM;
+                ntoken->name = cclp->look_token->name + 1;
+                ntoken->len = cclp->look_token->len - 1;
+
+                cclp->look_token->len = 1;
+                cclp->look_token->name = "-";
+            }
+            else if (cclp->look_token->len > 1 && i == cclp->look_token->len-1)
+            {   /* xx- */
+                struct ccl_token *ntoken = ccl_token_add (cclp->look_token);
+
+                ntoken->kind = CCL_TOK_TERM;
+                ntoken->name = "-";
+                ntoken->len = 1;
+
+                (cclp->look_token->len)--;
+            }
+            else if (cclp->look_token->len > 2 && i < cclp->look_token->len)
+            {   /* xx-yy */
+                struct ccl_token *ntoken1 = ccl_token_add (cclp->look_token);
+                struct ccl_token *ntoken2 = ccl_token_add (ntoken1);
+
+                ntoken1->kind = CCL_TOK_TERM;  /* generate - */
+                ntoken1->name = "-";
+                ntoken1->len = 1;
+
+                ntoken2->kind = CCL_TOK_TERM;  /* generate yy */
+                ntoken2->name = cclp->look_token->name + (i+1);
+                ntoken2->len = cclp->look_token->len - (i+1);
+
+                cclp->look_token->len = i;     /* adjust xx */
+            }
+            else if (i == cclp->look_token->len &&
+                     cclp->look_token->next &&
+                     cclp->look_token->next->kind == CCL_TOK_TERM &&
+                     cclp->look_token->next->len > 1 &&
+                     cclp->look_token->next->name[0] == '-')
+                     
+            {   /* xx -yy */
+                /* we _know_ that xx does not have - in it */
+                struct ccl_token *ntoken = ccl_token_add (cclp->look_token);
+
+                ntoken->kind = CCL_TOK_TERM;    /* generate - */
+                ntoken->name = "-";
+                ntoken->len = 1;
+
+                (ntoken->next->name)++;        /* adjust yy */
+                (ntoken->next->len)--; 
+            }
+        }
     }
         
     if (rel == 3 &&
-       KIND == CCL_TOK_TERM &&
-       cclp->look_token->next && cclp->look_token->next->len == 1 &&
-       cclp->look_token->next->name[0] == '-')
+        KIND == CCL_TOK_TERM &&
+        cclp->look_token->next && cclp->look_token->next->len == 1 &&
+        cclp->look_token->next->name[0] == '-')
     {
-       struct ccl_rpn_node *p1;
-       if (!(p1 = search_term (cclp, ap)))
-           return NULL;
-       ADVANCE;                   /* skip '-' */
-       if (KIND == CCL_TOK_TERM)  /* = term - term  ? */
-       {
-           struct ccl_rpn_node *p2;
-           
-           if (!(p2 = search_term (cclp, ap)))
-           {
-               ccl_rpn_delete (p1);
-               return NULL;
-           }
-           p = mk_node (CCL_RPN_AND);
-           p->u.p[0] = p1;
-           add_attr_numeric (p1, attset, CCL_BIB1_REL, 4);
-           p->u.p[1] = p2;
-           add_attr_numeric (p2, attset, CCL_BIB1_REL, 2);
-           return p;
-       }
-       else                       /* = term -    */
-       {
-           add_attr_numeric (p1, attset, CCL_BIB1_REL, 4);
-           return p1;
-       }
+        struct ccl_rpn_node *p1;
+        if (!(p1 = search_term (cclp, ap)))
+            return NULL;
+        ADVANCE;                   /* skip '-' */
+        if (KIND == CCL_TOK_TERM)  /* = term - term  ? */
+        {
+            struct ccl_rpn_node *p2;
+            
+            if (!(p2 = search_term (cclp, ap)))
+            {
+                ccl_rpn_delete (p1);
+                return NULL;
+            }
+            p = mk_node (CCL_RPN_AND);
+            p->u.p[0] = p1;
+            add_attr_numeric (p1, attset, CCL_BIB1_REL, 4);
+            p->u.p[1] = p2;
+            add_attr_numeric (p2, attset, CCL_BIB1_REL, 2);
+            return p;
+        }
+        else                       /* = term -    */
+        {
+            add_attr_numeric (p1, attset, CCL_BIB1_REL, 4);
+            return p1;
+        }
     }
     else if (rel == 3 &&
-            cclp->look_token->len == 1 &&
-            cclp->look_token->name[0] == '-')   /* = - term  ? */
+             cclp->look_token->len == 1 &&
+             cclp->look_token->name[0] == '-')   /* = - term  ? */
     {
-       ADVANCE;
-       if (!(p = search_term (cclp, ap)))
-           return NULL;
-       add_attr_numeric (p, attset, CCL_BIB1_REL, 2);
-       return p;
+        ADVANCE;
+        if (!(p = search_term (cclp, ap)))
+            return NULL;
+        add_attr_numeric (p, attset, CCL_BIB1_REL, 2);
+        return p;
     }
     else if (KIND == CCL_TOK_LP)
     {
-       ADVANCE;
-       if (!(p = find_spec (cclp, ap)))
-           return NULL;
-       if (KIND != CCL_TOK_RP)
-       {
-           cclp->error_code = CCL_ERR_RP_EXPECTED;
-           ccl_rpn_delete (p);
-           return NULL;
-       }
-       ADVANCE;
-       return p;
+        ADVANCE;
+        if (!(p = find_spec (cclp, ap)))
+            return NULL;
+        if (KIND != CCL_TOK_RP)
+        {
+            cclp->error_code = CCL_ERR_RP_EXPECTED;
+            ccl_rpn_delete (p);
+            return NULL;
+        }
+        ADVANCE;
+        return p;
     }
     else
     {
-       if (!(p = search_terms (cclp, ap)))
-           return NULL;
-       add_attr_numeric (p, attset, CCL_BIB1_REL, rel);
-       return p;
+        if (!(p = search_terms (cclp, ap)))
+            return NULL;
+        add_attr_numeric (p, attset, CCL_BIB1_REL, rel);
+        return p;
     }
     cclp->error_code = CCL_ERR_TERM_EXPECTED;
     return NULL;
@@ -719,33 +719,33 @@ struct ccl_rpn_node *qualifiers2 (CCL_parser cclp, struct ccl_rpn_attr **ap)
     struct ccl_rpn_node *p;
     
     if (qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_ORDER, &attset)
-       || qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_PORDER, &attset))
-       return qualifiers_order(cclp, ap, attset);
+        || qual_val_type(ap, CCL_BIB1_REL, CCL_BIB1_REL_PORDER, &attset))
+        return qualifiers_order(cclp, ap, attset);
 
     /* unordered relation */
     if (KIND != CCL_TOK_EQ)
     {
-       cclp->error_code = CCL_ERR_EQ_EXPECTED;
-       return NULL;
+        cclp->error_code = CCL_ERR_EQ_EXPECTED;
+        return NULL;
     }
     ADVANCE;
     if (KIND == CCL_TOK_LP)
     {
-       ADVANCE;
-       if (!(p = find_spec (cclp, ap)))
-       {
-           return NULL;
-       }
-       if (KIND != CCL_TOK_RP)
-       {
-           cclp->error_code = CCL_ERR_RP_EXPECTED;
-           ccl_rpn_delete (p);
-           return NULL;
-       }
-       ADVANCE;
+        ADVANCE;
+        if (!(p = find_spec (cclp, ap)))
+        {
+            return NULL;
+        }
+        if (KIND != CCL_TOK_RP)
+        {
+            cclp->error_code = CCL_ERR_RP_EXPECTED;
+            ccl_rpn_delete (p);
+            return NULL;
+        }
+        ADVANCE;
     }
     else
-       p = search_terms (cclp, ap);
+        p = search_terms (cclp, ap);
     return p;
 }
 
@@ -1197,3 +1197,11 @@ struct ccl_rpn_node *ccl_find_str (CCL_bibset bibset, const char *str,
     ccl_token_del (list);
     return p;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 06fe093..bb8196f 100644 (file)
@@ -53,7 +53,7 @@
 /* CCL print rpn tree - infix notation
  * Europagate, 1995
  *
- * $Id: cclptree.c,v 1.5 2005-06-24 19:56:52 adam Exp $
+ * $Id: cclptree.c,v 1.6 2005-06-25 15:46:03 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -180,13 +180,13 @@ static void ccl_pquery_complex (WRBUF w, struct ccl_rpn_node *p)
     switch (p->kind)
     {
     case CCL_RPN_AND:
-       wrbuf_puts(w, "@and ");
+        wrbuf_puts(w, "@and ");
         break;
     case CCL_RPN_OR:
-       wrbuf_puts(w, "@or ");
+        wrbuf_puts(w, "@or ");
         break;
     case CCL_RPN_NOT:
-       wrbuf_puts(w, "@not ");
+        wrbuf_puts(w, "@not ");
         break;
     case CCL_RPN_PROX:
         if (p->u.p[2] && p->u.p[2]->kind == CCL_RPN_TERM)
@@ -224,14 +224,14 @@ void ccl_pquery (WRBUF w, struct ccl_rpn_node *p)
 {
     struct ccl_rpn_attr *att;
     const char *cp;
-       
+        
     switch (p->kind)
     {
     case CCL_RPN_AND:
     case CCL_RPN_OR:
     case CCL_RPN_NOT:
     case CCL_RPN_PROX:
-       ccl_pquery_complex (w, p);
+        ccl_pquery_complex (w, p);
         break;
     case CCL_RPN_SET:
         wrbuf_puts (w, "@set ");
@@ -239,7 +239,7 @@ void ccl_pquery (WRBUF w, struct ccl_rpn_node *p)
         wrbuf_puts (w, " ");
         break;
     case CCL_RPN_TERM:
-       for (att = p->u.t.attr_list; att; att = att->next)
+        for (att = p->u.t.attr_list; att; att = att->next)
         {
             char tmpattr[128];
             wrbuf_puts (w, "@attr ");
@@ -272,3 +272,11 @@ void ccl_pquery (WRBUF w, struct ccl_rpn_node *p)
         break;
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 0684dc3..210be93 100644 (file)
@@ -48,7 +48,7 @@
 /* CCL qualifiers
  * Europagate, 1995
  *
- * $Id: cclqfile.c,v 1.6 2004-10-15 00:19:00 adam Exp $
+ * $Id: cclqfile.c,v 1.7 2005-06-25 15:46:03 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -87,11 +87,11 @@ void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name)
         int no_scan = 0;
         
         if (sscanf (cp, "%100s%n", qual_spec, &no_scan) < 1)
-           break;
+            break;
 
         if (!(split = strchr (qual_spec, '=')))
         {
-           /* alias specification .. */
+            /* alias specification .. */
             if (pair_no == 0)
             {
                 ccl_qual_add_combi (bibset, qual_name, cp);
@@ -99,23 +99,23 @@ void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name)
             }
             break;
         }
-       /* [set,]type=value ... */
+        /* [set,]type=value ... */
         cp += no_scan;
         
         *split++ = '\0';
 
-       setp = strchr (qual_spec, ',');
-       if (setp)
-       {
-           /* set,type=value ... */
-           *setp++ = '\0';
+        setp = strchr (qual_spec, ',');
+        if (setp)
+        {
+            /* set,type=value ... */
+            *setp++ = '\0';
             qual_type = setp;
-       }
-       else
-       {
-           /* type=value ... */
+        }
+        else
+        {
+            /* type=value ... */
             qual_type = qual_spec;
-       }
+        }
         while (pair_no < 128)
         {
             int type, value;
@@ -124,7 +124,7 @@ void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name)
             if ((split = strchr (qual_value, ',')))
                 *split++ = '\0';
 
-           value = 0;
+            value = 0;
             switch (qual_type[0])
             {
             case 'u':
@@ -175,49 +175,49 @@ void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name)
 
             type_ar[pair_no] = type;
 
-           if (value)
-           {
-               value_ar[pair_no] = value;
-               svalue_ar[pair_no] = 0;
-           }
-           else if (*qual_value >= '0' && *qual_value <= '9')
-           {
-               value_ar[pair_no] = atoi (qual_value);
-               svalue_ar[pair_no] = 0;
-           }
-           else
-           {
-               size_t len;
-               if (split)
-                   len = split - qual_value;
-               else
-                   len = strlen(qual_value);
-               svalue_ar[pair_no] = (char *) xmalloc(len+1);
-               memcpy(svalue_ar[pair_no], qual_value, len);
-               svalue_ar[pair_no][len] = '\0';
-           }
-           if (setp)
-           {
-               attsets[pair_no] = (char*) xmalloc (strlen(qual_spec)+1);
-               strcpy (attsets[pair_no], qual_spec);
-           }
-           else
-               attsets[pair_no] = 0;
+            if (value)
+            {
+                value_ar[pair_no] = value;
+                svalue_ar[pair_no] = 0;
+            }
+            else if (*qual_value >= '0' && *qual_value <= '9')
+            {
+                value_ar[pair_no] = atoi (qual_value);
+                svalue_ar[pair_no] = 0;
+            }
+            else
+            {
+                size_t len;
+                if (split)
+                    len = split - qual_value;
+                else
+                    len = strlen(qual_value);
+                svalue_ar[pair_no] = (char *) xmalloc(len+1);
+                memcpy(svalue_ar[pair_no], qual_value, len);
+                svalue_ar[pair_no][len] = '\0';
+            }
+            if (setp)
+            {
+                attsets[pair_no] = (char*) xmalloc (strlen(qual_spec)+1);
+                strcpy (attsets[pair_no], qual_spec);
+            }
+            else
+                attsets[pair_no] = 0;
             pair_no++;
             if (!split)
                 break;
         }
     }
     ccl_qual_add_set (bibset, qual_name, pair_no, type_ar, value_ar, svalue_ar,
-                     attsets);
+                      attsets);
 }
 
 void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name)
 {
     if (*qual_name == '@')
-       ccl_qual_add_special(bibset, qual_name+1, cp);
+        ccl_qual_add_special(bibset, qual_name+1, cp);
     else
-       ccl_qual_field(bibset, cp, qual_name);
+        ccl_qual_field(bibset, cp, qual_name);
 }
 
 void ccl_qual_buf(CCL_bibset bibset, const char *buf)
@@ -226,22 +226,22 @@ void ccl_qual_buf(CCL_bibset bibset, const char *buf)
     char line[256];
     while (1)
     {
-       const char *cp2 = cp1;
-       int len;
-       while (*cp2 && !strchr("\r\n", *cp2))
-           cp2++;
-       len = cp2 - cp1;
-       if (len > 0)
-       {
-           if (len >= (sizeof(line)-1))
-               len = sizeof(line)-1;
-           memcpy(line, cp1, len);
-           line[len] = '\0';
-           ccl_qual_line(bibset, line);
-       }
-       if (!*cp2)
-           break;
-       cp1 = cp2+1;
+        const char *cp2 = cp1;
+        int len;
+        while (*cp2 && !strchr("\r\n", *cp2))
+            cp2++;
+        len = cp2 - cp1;
+        if (len > 0)
+        {
+            if (len >= (sizeof(line)-1))
+                len = sizeof(line)-1;
+            memcpy(line, cp1, len);
+            line[len] = '\0';
+            ccl_qual_line(bibset, line);
+        }
+        if (!*cp2)
+            break;
+        cp1 = cp2+1;
     }
 }
 
@@ -252,13 +252,13 @@ void ccl_qual_line(CCL_bibset bibset, char *line)
     char *cp1, *cp = line;
     
     if (*cp == '#')
-       return;        /* ignore lines starting with # */
+        return;        /* ignore lines starting with # */
     if (sscanf (cp, "%100s%n", qual_name, &no_scan) < 1)
-       return;        /* also ignore empty lines */
+        return;        /* also ignore empty lines */
     cp += no_scan;
     cp1 = strchr(cp, '#');
     if (cp1)
-       *cp1 = '\0';
+        *cp1 = '\0';
     ccl_qual_fitem (bibset, cp, qual_name);
 }
 
@@ -280,7 +280,7 @@ void ccl_qual_file (CCL_bibset bibset, FILE *inf)
     char line[256];
 
     while (fgets (line, 255, inf))
-       ccl_qual_line(bibset, line);
+        ccl_qual_line(bibset, line);
 }
 
 int ccl_qual_fname (CCL_bibset bibset, const char *fname)
@@ -293,3 +293,11 @@ int ccl_qual_fname (CCL_bibset bibset, const char *fname)
     fclose (inf);
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 62c078f..24ea31c 100644 (file)
@@ -48,7 +48,7 @@
 /* CCL qualifiers
  * Europagate, 1995
  *
- * $Id: cclqual.c,v 1.2 2004-10-15 00:19:00 adam Exp $
+ * $Id: cclqual.c,v 1.3 2005-06-25 15:46:03 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -120,25 +120,25 @@ void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *v)
     const char *pe;
 
     for (p = bibset->special; p && strcmp(p->name, n); p = p->next)
-       ;
+        ;
     if (p)
-       xfree (p->value);
+        xfree (p->value);
     else
     {
-       p = (struct ccl_qualifier_special *) xmalloc (sizeof(*p));
-       p->name = ccl_strdup (n);
-       p->value = 0;
-       p->next = bibset->special;
-       bibset->special = p;
+        p = (struct ccl_qualifier_special *) xmalloc (sizeof(*p));
+        p->name = ccl_strdup (n);
+        p->value = 0;
+        p->next = bibset->special;
+        bibset->special = p;
     }
     while (strchr(" \t", *v))
-       ++v;
+        ++v;
     for (pe = v + strlen(v); pe != v; --pe)
-       if (!strchr(" \n\r\t", pe[-1]))
-           break;
+        if (!strchr(" \n\r\t", pe[-1]))
+            break;
     p->value = (char*) xmalloc (pe - v + 1);
     if (pe - v)
-       memcpy (p->value, v, pe - v);
+        memcpy (p->value, v, pe - v);
     p->value[pe - v] = '\0';
 }
 
@@ -166,7 +166,7 @@ void ccl_qual_add_combi (CCL_bibset b, const char *n, const char *names)
     int i, len;
     struct ccl_qualifier *q;
     for (q = b->list; q && strcmp(q->name, n); q = q->next)
-       ;
+        ;
     if (q)
         return ;
     q = (struct ccl_qualifier *) xmalloc (sizeof(*q));
@@ -199,8 +199,8 @@ void ccl_qual_add_combi (CCL_bibset b, const char *n, const char *names)
  */
 
 void ccl_qual_add_set (CCL_bibset b, const char *name, int no,
-                      int *type_ar, int *value_ar, char **svalue_ar,
-                      char **attsets)
+                       int *type_ar, int *value_ar, char **svalue_ar,
+                       char **attsets)
 {
     struct ccl_qualifier *q;
     struct ccl_rpn_attr **attrp;
@@ -212,7 +212,7 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no,
     if (!q)
     {
         struct ccl_qualifier *new_qual =
-           (struct ccl_qualifier *)xmalloc (sizeof(*new_qual));
+            (struct ccl_qualifier *)xmalloc (sizeof(*new_qual));
         ccl_assert (new_qual);
         
         new_qual->next = b->list;
@@ -238,20 +238,20 @@ void ccl_qual_add_set (CCL_bibset b, const char *name, int no,
 
         attr = (struct ccl_rpn_attr *)xmalloc (sizeof(*attr));
         ccl_assert (attr);
-       attr->set = *attsets++;
+        attr->set = *attsets++;
         attr->type = *type_ar++;
-       if (*svalue_ar)
-       {
-           attr->kind = CCL_RPN_ATTR_STRING;
-           attr->value.str = *svalue_ar;
-       }
-       else
-       {
-           attr->kind = CCL_RPN_ATTR_NUMERIC;
-           attr->value.numeric = *value_ar;
-       }
-       svalue_ar++;
-       value_ar++;
+        if (*svalue_ar)
+        {
+            attr->kind = CCL_RPN_ATTR_STRING;
+            attr->value.str = *svalue_ar;
+        }
+        else
+        {
+            attr->kind = CCL_RPN_ATTR_NUMERIC;
+            attr->value.numeric = *value_ar;
+        }
+        svalue_ar++;
+        value_ar++;
         *attrp = attr;
         attrp = &attr->next;
     }
@@ -287,26 +287,26 @@ void ccl_qual_rm (CCL_bibset *b)
         struct ccl_rpn_attr *attr, *attr1;
 
         for (attr = q->attr_list; attr; attr = attr1)
-       {
-           attr1 = attr->next;
-           if (attr->set)
-               xfree(attr->set);
-           if (attr->kind == CCL_RPN_ATTR_STRING)
-               xfree(attr->value.str);
-           xfree (attr);
-       }
+        {
+            attr1 = attr->next;
+            if (attr->set)
+                xfree(attr->set);
+            if (attr->kind == CCL_RPN_ATTR_STRING)
+                xfree(attr->value.str);
+            xfree (attr);
+        }
         q1 = q->next;
-       xfree (q->name);
+        xfree (q->name);
         if (q->sub)
             xfree (q->sub);
-       xfree (q);
+        xfree (q);
     }
     for (sp = (*b)->special; sp; sp = sp1)
     {
-       sp1 = sp->next;
-       xfree (sp->name);
-       xfree (sp->value);
-       xfree (sp);
+        sp1 = sp->next;
+        xfree (sp->name);
+        xfree (sp->value);
+        xfree (sp);
     }
     xfree (*b);
     *b = NULL;
@@ -320,7 +320,7 @@ void ccl_qual_rm (CCL_bibset *b)
  * return: Attribute info. NULL if not found.
  */
 struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp,
-                                     const char *name, size_t len,
+                                      const char *name, size_t len,
                                       int seq)
 {
     struct ccl_qualifier *q;
@@ -329,11 +329,11 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp,
 
     ccl_assert (cclp);
     if (!cclp->bibset)
-       return NULL;
+        return NULL;
 
     aliases = ccl_qual_search_special(cclp->bibset, "case");
     if (aliases)
-       case_sensitive = atoi(aliases);
+        case_sensitive = atoi(aliases);
 
     for (q = cclp->bibset->list; q; q = q->next)
         if (strlen(q->name) == len)
@@ -362,14 +362,22 @@ struct ccl_rpn_attr *ccl_qual_search (CCL_parser cclp,
 }
 
 const char *ccl_qual_search_special (CCL_bibset b,
-                                    const char *name)
+                                     const char *name)
 {
     struct ccl_qualifier_special *q;
     if (!b)
-       return 0;
+        return 0;
     for (q = b->special; q && strcmp(q->name, name); q = q->next)
-       ;
+        ;
     if (q)
-       return q->value;
+        return q->value;
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index bb38098..1131904 100644 (file)
@@ -48,7 +48,7 @@
 /* CCL string compare utilities
  * Europagate, 1995
  *
- * $Id: cclstr.c,v 1.2 2004-10-15 00:19:00 adam Exp $
+ * $Id: cclstr.c,v 1.3 2005-06-25 15:46:03 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -112,3 +112,11 @@ int ccl_memicmp (const char *s1, const char *s2, size_t n)
     }
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d7b0d5f..6eb1466 100644 (file)
@@ -48,7 +48,7 @@
 /* CCL - lexical analysis
  * Europagate, 1995
  *
- * $Id: ccltoken.c,v 1.7 2005-04-15 21:47:56 adam Exp $
+ * $Id: ccltoken.c,v 1.8 2005-06-25 15:46:03 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -109,7 +109,7 @@ static int token_cmp (CCL_parser cclp, const char *kw, struct ccl_token *token)
 
     aliases = ccl_qual_search_special(cclp->bibset, "case");
     if (aliases)
-       case_sensitive = atoi(aliases);
+        case_sensitive = atoi(aliases);
     if (!kw)
         return 0;
     while ((cp2 = strchr (cp1, ' ')))
@@ -127,7 +127,7 @@ static int token_cmp (CCL_parser cclp, const char *kw, struct ccl_token *token)
                     return 1;
             }
         }
-       cp1 = cp2+1;
+        cp1 = cp2+1;
     }
     if (case_sensitive)
         return token->len == strlen(cp1) 
@@ -149,112 +149,112 @@ struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command)
 
     while (1)
     {
-       const unsigned char *cp0 = cp;
-       while (*cp && strchr (" \t\r\n", *cp))
-           cp++;
-       if (!first)
-       {
-           first = last = (struct ccl_token *)xmalloc (sizeof (*first));
-           ccl_assert (first);
-           last->prev = NULL;
-       }
-       else
-       {
-           last->next = (struct ccl_token *)xmalloc (sizeof(*first));
-           ccl_assert (last->next);
-           last->next->prev = last;
-           last = last->next;
-       }
-       last->ws_prefix_buf = cp0;
-       last->ws_prefix_len = cp - cp0;
-       last->next = NULL;
-       last->name = (const char *) cp;
-       last->len = 1;
-       switch (*cp++)
-       {
+        const unsigned char *cp0 = cp;
+        while (*cp && strchr (" \t\r\n", *cp))
+            cp++;
+        if (!first)
+        {
+            first = last = (struct ccl_token *)xmalloc (sizeof (*first));
+            ccl_assert (first);
+            last->prev = NULL;
+        }
+        else
+        {
+            last->next = (struct ccl_token *)xmalloc (sizeof(*first));
+            ccl_assert (last->next);
+            last->next->prev = last;
+            last = last->next;
+        }
+        last->ws_prefix_buf = cp0;
+        last->ws_prefix_len = cp - cp0;
+        last->next = NULL;
+        last->name = (const char *) cp;
+        last->len = 1;
+        switch (*cp++)
+        {
         case '\0':
             last->kind = CCL_TOK_EOL;
             return first;
-       case '(':
-           last->kind = CCL_TOK_LP;
-           break;
-       case ')':
-           last->kind = CCL_TOK_RP;
-           break;
-       case ',':
-           last->kind = CCL_TOK_COMMA;
-           break;
-       case '%':
-       case '!':
-           last->kind = CCL_TOK_PROX;
+        case '(':
+            last->kind = CCL_TOK_LP;
+            break;
+        case ')':
+            last->kind = CCL_TOK_RP;
+            break;
+        case ',':
+            last->kind = CCL_TOK_COMMA;
+            break;
+        case '%':
+        case '!':
+            last->kind = CCL_TOK_PROX;
             while (isdigit(*cp))
-           {
-               ++ last->len;
-               cp++;
-           }
-           break;
-       case '>':
-       case '<':
-       case '=':
-           if (*cp == '=' || *cp == '<' || *cp == '>')
-           {
-               cp++;
-               last->kind = CCL_TOK_REL;
-               ++ last->len;
-           }
-           else if (cp[-1] == '=')
-               last->kind = CCL_TOK_EQ;
-           else
-               last->kind = CCL_TOK_REL;
-           break;
-       case '\"':
-           last->kind = CCL_TOK_TERM;
-           last->name = (const char *) cp;
-           last->len = 0;
-           while (*cp && *cp != '\"')
-           {
-               cp++;
-               ++ last->len;
-           }
-           if (*cp == '\"')
-               cp++;
-           break;
-       default:
-           if (!strchr ("(),%!><= \t\n\r", cp[-1]))
-           {
-               while (*cp && !strchr ("(),%!><= \t\n\r", *cp))
-               {
-                   cp++;
-                   ++ last->len;
-               }
-           }
-           last->kind = CCL_TOK_TERM;
+            {
+                ++ last->len;
+                cp++;
+            }
+            break;
+        case '>':
+        case '<':
+        case '=':
+            if (*cp == '=' || *cp == '<' || *cp == '>')
+            {
+                cp++;
+                last->kind = CCL_TOK_REL;
+                ++ last->len;
+            }
+            else if (cp[-1] == '=')
+                last->kind = CCL_TOK_EQ;
+            else
+                last->kind = CCL_TOK_REL;
+            break;
+        case '\"':
+            last->kind = CCL_TOK_TERM;
+            last->name = (const char *) cp;
+            last->len = 0;
+            while (*cp && *cp != '\"')
+            {
+                cp++;
+                ++ last->len;
+            }
+            if (*cp == '\"')
+                cp++;
+            break;
+        default:
+            if (!strchr ("(),%!><= \t\n\r", cp[-1]))
+            {
+                while (*cp && !strchr ("(),%!><= \t\n\r", *cp))
+                {
+                    cp++;
+                    ++ last->len;
+                }
+            }
+            last->kind = CCL_TOK_TERM;
 
-           aliases = ccl_qual_search_special(cclp->bibset, "and");
-           if (!aliases)
-               aliases = cclp->ccl_token_and;
-           if (token_cmp (cclp, aliases, last))
-               last->kind = CCL_TOK_AND;
+            aliases = ccl_qual_search_special(cclp->bibset, "and");
+            if (!aliases)
+                aliases = cclp->ccl_token_and;
+            if (token_cmp (cclp, aliases, last))
+                last->kind = CCL_TOK_AND;
 
-           aliases = ccl_qual_search_special(cclp->bibset, "or");
-           if (!aliases)
-               aliases = cclp->ccl_token_or;
-           if (token_cmp (cclp, aliases, last))
-               last->kind = CCL_TOK_OR;
+            aliases = ccl_qual_search_special(cclp->bibset, "or");
+            if (!aliases)
+                aliases = cclp->ccl_token_or;
+            if (token_cmp (cclp, aliases, last))
+                last->kind = CCL_TOK_OR;
 
-           aliases = ccl_qual_search_special(cclp->bibset, "not");
-           if (!aliases)
-               aliases = cclp->ccl_token_not;
+            aliases = ccl_qual_search_special(cclp->bibset, "not");
+            if (!aliases)
+                aliases = cclp->ccl_token_not;
             if (token_cmp (cclp, aliases, last))
-               last->kind = CCL_TOK_NOT;
+                last->kind = CCL_TOK_NOT;
 
-           aliases = ccl_qual_search_special(cclp->bibset, "set");
-           if (!aliases)
-               aliases = cclp->ccl_token_set;
+            aliases = ccl_qual_search_special(cclp->bibset, "set");
+            if (!aliases)
+                aliases = cclp->ccl_token_set;
 
-           if (token_cmp (cclp, aliases, last))
-               last->kind = CCL_TOK_SET;
-       }
+            if (token_cmp (cclp, aliases, last))
+                last->kind = CCL_TOK_SET;
+        }
     }
     return first;
 }
@@ -267,7 +267,7 @@ struct ccl_token *ccl_token_add (struct ccl_token *at)
     n->prev = at;
     at->next = n;
     if (n->next)
-       n->next->prev = n;
+        n->next->prev = n;
 
     n->kind = CCL_TOK_TERM;
     n->name = 0;
@@ -315,7 +315,7 @@ CCL_parser ccl_parser_create (void)
 {
     CCL_parser p = (CCL_parser)xmalloc (sizeof(*p));
     if (!p)
-       return p;
+        return p;
     p->look_token = NULL;
     p->error_code = 0;
     p->error_pos = NULL;
@@ -333,7 +333,7 @@ CCL_parser ccl_parser_create (void)
 void ccl_parser_destroy (CCL_parser p)
 {
     if (!p)
-       return;
+        return;
     xfree (p->ccl_token_and);
     xfree (p->ccl_token_or);
     xfree (p->ccl_token_not);
@@ -345,9 +345,9 @@ void ccl_parser_set_op_and (CCL_parser p, const char *op)
 {
     if (p && op)
     {
-       if (p->ccl_token_and)
-           xfree (p->ccl_token_and);
-       p->ccl_token_and = ccl_strdup (op);
+        if (p->ccl_token_and)
+            xfree (p->ccl_token_and);
+        p->ccl_token_and = ccl_strdup (op);
     }
 }
 
@@ -355,32 +355,40 @@ void ccl_parser_set_op_or (CCL_parser p, const char *op)
 {
     if (p && op)
     {
-       if (p->ccl_token_or)
-           xfree (p->ccl_token_or);
-       p->ccl_token_or = ccl_strdup (op);
+        if (p->ccl_token_or)
+            xfree (p->ccl_token_or);
+        p->ccl_token_or = ccl_strdup (op);
     }
 }
 void ccl_parser_set_op_not (CCL_parser p, const char *op)
 {
     if (p && op)
     {
-       if (p->ccl_token_not)
-           xfree (p->ccl_token_not);
-       p->ccl_token_not = ccl_strdup (op);
+        if (p->ccl_token_not)
+            xfree (p->ccl_token_not);
+        p->ccl_token_not = ccl_strdup (op);
     }
 }
 void ccl_parser_set_op_set (CCL_parser p, const char *op)
 {
     if (p && op)
     {
-       if (p->ccl_token_set)
-           xfree (p->ccl_token_set);
-       p->ccl_token_set = ccl_strdup (op);
+        if (p->ccl_token_set)
+            xfree (p->ccl_token_set);
+        p->ccl_token_set = ccl_strdup (op);
     }
 }
 
 void ccl_parser_set_case (CCL_parser p, int case_sensitivity_flag)
 {
     if (p)
-       p->ccl_case_sensitive = case_sensitivity_flag;
+        p->ccl_case_sensitive = case_sensitivity_flag;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 8d6774e..ff4bc47 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: charneg.c,v 1.4 2005-05-18 12:38:40 adam Exp $
+ * $Id: charneg.c,v 1.5 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -43,7 +43,7 @@ static Z_External* z_ext_record2(ODR o, int oid_class, int oid_value,
     }
     p->u.octet_aligned->len = p->u.octet_aligned->size = len;
     memcpy(p->u.octet_aligned->buf, buf, len);
-       
+        
     return p;
 }
 
@@ -108,7 +108,7 @@ static Z_OriginProposal_0 *z_get_OriginProposal_0(ODR o, const char *charset)
         
         p0->which = Z_OriginProposal_0_private;
         p0->u.zprivate = pc;
-       
+        
         pc->which = Z_PrivateCharacterSet_externallySpecified;
         pc->u.externallySpecified =
             z_ext_record2(o, CLASS_NEGOT, VAL_ID_CHARSET, charset);
@@ -119,17 +119,17 @@ static Z_OriginProposal_0 *z_get_OriginProposal_0(ODR o, const char *charset)
 static Z_OriginProposal *z_get_OriginProposal(
     ODR o, const char **charsets, int num_charsets,
     const char **langs, int num_langs, int selected)
-{      
+{       
     int i;
     Z_OriginProposal *p = (Z_OriginProposal *) odr_malloc(o, sizeof(*p));
-               
+                
     memset(p, 0, sizeof(*p));
 
     p->recordsInSelectedCharSets = (bool_t *)odr_malloc(o, sizeof(bool_t));
     *p->recordsInSelectedCharSets = (selected) ? 1:0;
 
-    if (charsets && num_charsets) {            
-       
+    if (charsets && num_charsets) {             
+        
         p->num_proposedCharSets = num_charsets;
         p->proposedCharSets = 
             (Z_OriginProposal_0**)
@@ -140,7 +140,7 @@ static Z_OriginProposal *z_get_OriginProposal(
                 z_get_OriginProposal_0(o, charsets[i]);
     }
     if (langs && num_langs) {
-       
+        
         p->num_proposedlanguages = num_langs;
 
         p->proposedlanguages = 
@@ -149,7 +149,7 @@ static Z_OriginProposal *z_get_OriginProposal(
         for (i = 0; i<num_langs; i++) {
 
             p->proposedlanguages[i] = (char *)langs[i];
-                       
+                        
         }
     }
     return p;
@@ -162,7 +162,7 @@ static Z_CharSetandLanguageNegotiation *z_get_CharSetandLanguageNegotiation(
         (Z_CharSetandLanguageNegotiation *) odr_malloc(o, sizeof(*p));
     
     memset(p, 0, sizeof(*p));
-       
+        
     return p;
 }
 
@@ -174,9 +174,9 @@ Z_External *yaz_set_proposal_charneg(ODR o,
 {
     Z_External *p = (Z_External *)odr_malloc(o, sizeof(*p));
     oident oid;
-       
+        
     p->descriptor = 0;
-    p->indirect_reference = 0; 
+    p->indirect_reference = 0;  
 
     oid.proto = PROTO_Z3950;
     oid.oclass = CLASS_NEGOT;
@@ -196,7 +196,7 @@ Z_External *yaz_set_proposal_charneg(ODR o,
 /* used by yaz_set_response_charneg */
 static Z_TargetResponse *z_get_TargetResponse(ODR o, const char *charset,
                                               const char *lang, int selected)
-{      
+{       
     Z_TargetResponse *p = (Z_TargetResponse *) odr_malloc(o, sizeof(*p));
     int form = get_form(charset);
 
@@ -219,13 +219,13 @@ static Z_TargetResponse *z_get_TargetResponse(ODR o, const char *charset,
             (Z_PrivateCharacterSet *)odr_malloc(o, sizeof(*pc));
         
         memset(pc, 0, sizeof(*pc));
-       
+        
         p->which = Z_TargetResponse_private;
         p->u.zprivate = pc;
-       
+        
         pc->which = Z_PrivateCharacterSet_externallySpecified;
         pc->u.externallySpecified =
-           z_ext_record2(o, CLASS_NEGOT, VAL_ID_CHARSET, charset);
+            z_ext_record2(o, CLASS_NEGOT, VAL_ID_CHARSET, charset);
     }
     p->recordsInSelectedCharSets = (bool_t *)odr_malloc(o, sizeof(bool_t));
     *p->recordsInSelectedCharSets = (selected) ? 1:0;
@@ -240,9 +240,9 @@ Z_External *yaz_set_response_charneg(ODR o, const char *charset,
 {
     Z_External *p = (Z_External *)odr_malloc(o, sizeof(*p));
     oident oid;
-       
+        
     p->descriptor = 0;
-    p->indirect_reference = 0; 
+    p->indirect_reference = 0;  
 
     oid.proto = PROTO_Z3950;
     oid.oclass = CLASS_NEGOT;
@@ -261,21 +261,21 @@ Z_External *yaz_set_response_charneg(ODR o, const char *charset,
 Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p)
 {
     int i;
-       
+        
     if (!p)
         return 0;
-       
+        
     for (i = 0; i < p->num_elements; i++) {
-       Z_External *pext;
+        Z_External *pext;
         if ((p->list[i]->which == Z_OtherInfo_externallyDefinedInfo) &&
             (pext = p->list[i]->information.externallyDefinedInfo)) {
-           
+            
             oident *ent = oid_getentbyoid(pext->direct_reference);
-           
+            
             if (ent && ent->value == VAL_CHARNEG3 
-               && ent->oclass == CLASS_NEGOT
-               &&  pext->which == Z_External_charSetandLanguageNegotiation)
-           {
+                && ent->oclass == CLASS_NEGOT
+                &&  pext->which == Z_External_charSetandLanguageNegotiation)
+            {
                 return pext->u.charNeg3;
             }
         }
@@ -287,30 +287,30 @@ Z_CharSetandLanguageNegotiation *yaz_get_charneg_record(Z_OtherInformation *p)
 int yaz_del_charneg_record(Z_OtherInformation **p)
 {
     int i;
-       
+        
     if (!*p)
         return 0;
-       
+        
     for (i = 0; i < (*p)->num_elements; i++) {
-       Z_External *pext;
+        Z_External *pext;
         if (((*p)->list[i]->which == Z_OtherInfo_externallyDefinedInfo) &&
             (pext = (*p)->list[i]->information.externallyDefinedInfo)) {
-           
+            
             oident *ent = oid_getentbyoid(pext->direct_reference);
-           
+            
             if (ent && ent->value == VAL_CHARNEG3 
-               && ent->oclass == CLASS_NEGOT
-               && pext->which == Z_External_charSetandLanguageNegotiation)
-           {
-               --((*p)->num_elements);
-               if ((*p)->num_elements == 0)
-                   *p = 0;
-               else
-               {
-                   for(; i < (*p)->num_elements; i++)
-                       (*p)->list[i] = (*p)->list[i+1];
-               }
-               return 1;
+                && ent->oclass == CLASS_NEGOT
+                && pext->which == Z_External_charSetandLanguageNegotiation)
+            {
+                --((*p)->num_elements);
+                if ((*p)->num_elements == 0)
+                    *p = 0;
+                else
+                {
+                    for(; i < (*p)->num_elements; i++)
+                        (*p)->list[i] = (*p)->list[i+1];
+                }
+                return 1;
             }
         }
     }
@@ -394,7 +394,7 @@ void yaz_get_response_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p,
                               char **charset, char **lang, int *selected)
 {
     Z_TargetResponse *res = p->u.response;
-       
+        
     if (charset && res->which == Z_TargetResponse_private &&
         res->u.zprivate->which == Z_PrivateCharacterSet_externallySpecified) {
 
@@ -407,7 +407,7 @@ void yaz_get_response_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p,
             memcpy (*charset, pext->u.octet_aligned->buf,
                     pext->u.octet_aligned->len);
             (*charset)[pext->u.octet_aligned->len] = 0;
-        }      
+        }       
     }
     if (charset && res->which == Z_TargetResponse_iso10646)
         *charset = set_form (res->u.iso10646->encodingLevel);
@@ -417,3 +417,11 @@ void yaz_get_response_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p,
     if(selected && res->recordsInSelectedCharSets)
         *selected = *res->recordsInSelectedCharSets;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 71ab081..68aeb67 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: comstack.c,v 1.14 2005-01-15 19:47:11 adam Exp $
+ * $Id: comstack.c,v 1.15 2005-06-25 15:46:03 adam Exp $
  */
 
 /** 
@@ -39,12 +39,12 @@ const char *cs_errmsg(int n)
     static char buf[250];
 
     if (n < CSNONE || n > CSLASTERROR) {
-       sprintf(buf, "unknown comstack error %d", n);
-       return buf;
+        sprintf(buf, "unknown comstack error %d", n);
+        return buf;
     }
     if (n == CSYSERR) {
-       sprintf(buf, "%s: %s", cs_errlist[n], strerror(errno));
-       return buf;
+        sprintf(buf, "%s: %s", cs_errlist[n], strerror(errno));
+        return buf;
     }
     return cs_errlist[n];
 }
@@ -81,30 +81,30 @@ COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp)
 
     if (strncmp (type_and_host, "tcp:", 4) == 0)
     {
-       t = tcpip_type;
+        t = tcpip_type;
         host = type_and_host + 4;
     }
     else if (strncmp (type_and_host, "ssl:", 4) == 0)
     {
 #if HAVE_OPENSSL_SSL_H
-       t = ssl_type;
+        t = ssl_type;
         host = type_and_host + 4;
 #else
-       return 0;
+        return 0;
 #endif
     }
     else if (strncmp (type_and_host, "unix:", 5) == 0)
     {
 #ifndef WIN32
-       t = unix_type;
+        t = unix_type;
         host = type_and_host + 5;
 #else
-       return 0;
+        return 0;
 #endif
     }
     else if (strncmp(type_and_host, "http:", 5) == 0)
     {
-       t = tcpip_type;
+        t = tcpip_type;
         host = type_and_host + 5;
         while (host[0] == '/')
             host++;
@@ -113,28 +113,28 @@ COMSTACK cs_create_host(const char *type_and_host, int blocking, void **vp)
     else if (strncmp(type_and_host, "https:", 6) == 0)
     {
 #if HAVE_OPENSSL_SSL_H
-       t = ssl_type;
+        t = ssl_type;
         host = type_and_host + 6;
         while (host[0] == '/')
             host++;
         proto = PROTO_HTTP;
 #else
-       return 0;
+        return 0;
 #endif
     }
     else
     {
-       t = tcpip_type;
-       host = type_and_host;
+        t = tcpip_type;
+        host = type_and_host;
     }
     cs = cs_create (t, blocking, proto);
     if (!cs)
-       return 0;
+        return 0;
 
     if (!(*vp = cs_straddr(cs, host)))
     {
-       cs_close (cs);
-       return 0;
+        cs_close (cs);
+        return 0;
     }    
     return cs;
 }
@@ -148,23 +148,23 @@ int cs_look (COMSTACK cs)
 int cs_complete_auto(const unsigned char *buf, int len)
 {
     if (len > 5 && buf[0] >= 0x20 && buf[0] < 0x7f
-               && buf[1] >= 0x20 && buf[1] < 0x7f
-               && buf[2] >= 0x20 && buf[2] < 0x7f)
+                && buf[1] >= 0x20 && buf[1] < 0x7f
+                && buf[2] >= 0x20 && buf[2] < 0x7f)
     {
         /* deal with HTTP request/response */
-       int i = 2, content_len = 0, chunked = 0;
-       
-       /* if dealing with HTTP responses - then default
-          content length is unlimited (socket close) */
-       if (!memcmp(buf, "HTTP/", 5))
-           content_len = -1; 
+        int i = 2, content_len = 0, chunked = 0;
+        
+        /* if dealing with HTTP responses - then default
+           content length is unlimited (socket close) */
+        if (!memcmp(buf, "HTTP/", 5))
+            content_len = -1; 
 
         while (i <= len-4)
         {
-           if (i > 8192)
-           {
-               return i;  /* do not allow more than 8K HTTP header */
-           }
+            if (i > 8192)
+            {
+                return i;  /* do not allow more than 8K HTTP header */
+            }
             if (buf[i] == '\r' && buf[i+1] == '\n')
             {
                 i += 2;
@@ -172,7 +172,7 @@ int cs_complete_auto(const unsigned char *buf, int len)
                 {
                     if (chunked)
                     { 
-                       /* inside chunked body .. */
+                        /* inside chunked body .. */
                         while(1)
                         {
                             int j, chunk_len = 0;
@@ -182,13 +182,13 @@ int cs_complete_auto(const unsigned char *buf, int len)
                             if (i <len-2)
                             {
                                 printf ("\n<<<");
-                               int j;
+                                int j;
                                 for (j = i; j <= i+4; j++)
                                     printf ("%c", buf[j]);
                                 printf (">>>\n");
                             }
 #endif
-                           /* read chunk length */
+                            /* read chunk length */
                             while (1)
                                 if (i >= len-2) {
 #if CHUNK_DEBUG
@@ -208,52 +208,52 @@ int cs_complete_auto(const unsigned char *buf, int len)
                                         (buf[i++] - ('a'-10));
                                 else
                                     break;
-                           /* move forward until CRLF - skip chunk ext */
-                           j = 0;
-                           while (buf[i] != '\r' && buf[i+1] != '\n')
-                           {
-                               if (i >= len-2)
-                                   return 0;   /* need more buffer .. */
-                               if (++j > 1000)
-                                   return i; /* enough.. stop */
-                               i++;
-                           }
-                           /* got CRLF */
+                            /* move forward until CRLF - skip chunk ext */
+                            j = 0;
+                            while (buf[i] != '\r' && buf[i+1] != '\n')
+                            {
+                                if (i >= len-2)
+                                    return 0;   /* need more buffer .. */
+                                if (++j > 1000)
+                                    return i; /* enough.. stop */
+                                i++;
+                            }
+                            /* got CRLF */
 #if CHUNK_DEBUG
-                           printf ("XXXXXX chunk_len=%d\n", chunk_len);
-#endif                     
-                           if (chunk_len < 0)
-                               return i+2;    /* bad chunk_len */
+                            printf ("XXXXXX chunk_len=%d\n", chunk_len);
+#endif                      
+                            if (chunk_len < 0)
+                                return i+2;    /* bad chunk_len */
                             if (chunk_len == 0)
-                               break;
+                                break;
                             i += chunk_len+2;
                         }
-                       /* consider trailing headers .. */
-                       while(i <= len-4)
-                       {
-                           if (buf[i] == '\r' &&  buf[i+1] == '\n' &&
-                               buf[i+2] == '\r' && buf[i+3] == '\n')
-                               if (len >= i+4)
-                                   return i+4;
-                           i++;
-                       }
+                        /* consider trailing headers .. */
+                        while(i <= len-4)
+                        {
+                            if (buf[i] == '\r' &&  buf[i+1] == '\n' &&
+                                buf[i+2] == '\r' && buf[i+3] == '\n')
+                                if (len >= i+4)
+                                    return i+4;
+                            i++;
+                        }
 #if CHUNK_DEBUG
 /* debugging */
-                       printf ("XXXXXXXXX not there yet 2\n");
-                       printf ("i=%d len=%d\n", i, len);
+                        printf ("XXXXXXXXX not there yet 2\n");
+                        printf ("i=%d len=%d\n", i, len);
 #endif
-                       return 0;
+                        return 0;
                     }
                     else
                     {   /* not chunked ; inside body */
                         /* i += 2 seems not to work with GCC -O2 .. 
                            so i+2 is used instead .. */
-                       if (content_len == -1)
-                           return 0;   /* no content length */
+                        if (content_len == -1)
+                            return 0;   /* no content length */
                         else if (len >= (i+2)+ content_len)
-                       {
+                        {
                             return (i+2)+ content_len;
-                       }
+                        }
                     }
                     break;
                 }
@@ -289,3 +289,11 @@ int cs_complete_auto(const unsigned char *buf, int len)
     }
     return completeBER(buf, len);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 797d8cd..83875f1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cqlstdio.c,v 1.3 2005-01-15 19:47:11 adam Exp $
+/* $Id: cqlstdio.c,v 1.4 2005-06-25 15:46:03 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -39,3 +39,11 @@ int cql_parser_stdio(CQL_parser cp, FILE *f)
 }
 
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b8d3881..41abd44 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cqlstrer.c,v 1.4 2005-01-15 19:47:11 adam Exp $
+/* $Id: cqlstrer.c,v 1.5 2005-06-25 15:46:03 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -17,7 +17,7 @@ See the file LICENSE details.
 /*
  * The error-messages associated with these codes are taken from
  * the SRW diagnostic specifications at
- *     http://www.loc.gov/srw/diagnostic-list.html
+ *      http://www.loc.gov/srw/diagnostic-list.html
  */
 const char *cql_strerror(int code) {
     static char buf[80];
@@ -64,3 +64,11 @@ const char *cql_strerror(int code) {
     sprintf(buf, "Unknown CQL error #%d", code);
     return buf;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 6e83a0a..2469b97 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cqlstring.c,v 1.4 2005-01-15 19:47:11 adam Exp $
+/* $Id: cqlstring.c,v 1.5 2005-06-25 15:46:03 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -44,3 +44,11 @@ int cql_parser_string(CQL_parser cp, const char *str)
     return cql_parser_stream(cp, getbuf, ungetbuf, &b);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index aaf8303..559b2d4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cqltransform.c,v 1.14 2005-06-23 15:03:40 adam Exp $
+/* $Id: cqltransform.c,v 1.15 2005-06-25 15:46:03 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -109,7 +109,7 @@ cql_transform_t cql_transform_open_fname(const char *fname)
 
 static const char *cql_lookup_property(cql_transform_t ct,
                                        const char *pat1, const char *pat2,
-                                      const char *pat3)
+                                       const char *pat3)
 {
     char pattern[120];
     struct cql_prop_entry *e;
@@ -123,7 +123,7 @@ static const char *cql_lookup_property(cql_transform_t ct,
     else if (pat1)
         sprintf (pattern, "%.39s", pat1);
     else
-       return 0;
+        return 0;
     
     for (e = ct->entry; e; e = e->next)
     {
@@ -134,10 +134,10 @@ static const char *cql_lookup_property(cql_transform_t ct,
 }
 
 int cql_pr_attr_uri(cql_transform_t ct, const char *category,
-                  const char *uri, const char *val, const char *default_val,
-                  void (*pr)(const char *buf, void *client_data),
-                  void *client_data,
-                  int errcode)
+                   const char *uri, const char *val, const char *default_val,
+                   void (*pr)(const char *buf, void *client_data),
+                   void *client_data,
+                   int errcode)
 {
     const char *res = 0;
     const char *eval = val ? val : default_val;
@@ -145,24 +145,24 @@ int cql_pr_attr_uri(cql_transform_t ct, const char *category,
     
     if (uri)
     {
-       struct cql_prop_entry *e;
-       
-       for (e = ct->entry; e; e = e->next)
-           if (!memcmp(e->pattern, "set.", 4) && e->value &&
-               !strcmp(e->value, uri))
-           {
-               prefix = e->pattern+4;
-               break;
-           }
-       /* must have a prefix now - if not it's an error */
+        struct cql_prop_entry *e;
+        
+        for (e = ct->entry; e; e = e->next)
+            if (!memcmp(e->pattern, "set.", 4) && e->value &&
+                !strcmp(e->value, uri))
+            {
+                prefix = e->pattern+4;
+                break;
+            }
+        /* must have a prefix now - if not it's an error */
     }
 
     if (!uri || prefix)
     {
-       if (!res)
-           res = cql_lookup_property(ct, category, prefix, eval);
-       if (!res)
-           res = cql_lookup_property(ct, category, prefix, "*");
+        if (!res)
+            res = cql_lookup_property(ct, category, prefix, eval);
+        if (!res)
+            res = cql_lookup_property(ct, category, prefix, "*");
     }
     if (res)
     {
@@ -190,22 +190,22 @@ int cql_pr_attr_uri(cql_transform_t ct, const char *category,
     if (errcode && !ct->error)
     {
         ct->error = errcode;
-       if (val)
-           ct->addinfo = xstrdup(val);
-       else
-           ct->addinfo = 0;
+        if (val)
+            ct->addinfo = xstrdup(val);
+        else
+            ct->addinfo = 0;
     }
     return 0;
 }
 
 int cql_pr_attr(cql_transform_t ct, const char *category,
-               const char *val, const char *default_val,
-               void (*pr)(const char *buf, void *client_data),
-               void *client_data,
-               int errcode)
+                const char *val, const char *default_val,
+                void (*pr)(const char *buf, void *client_data),
+                void *client_data,
+                int errcode)
 {
     return cql_pr_attr_uri(ct, category, 0 /* uri */,
-                          val, default_val, pr, client_data, errcode);
+                           val, default_val, pr, client_data, errcode);
 }
 
 
@@ -220,9 +220,9 @@ static const char *wcchar(const char *term, int length)
     char *whichp;
 
     for (whichp = "*?"; *whichp != '\0'; whichp++) {
-       current = (const char *) memchr(term, *whichp, length);
-       if (current != 0 && (best == 0 || current < best))
-           best = current;
+        current = (const char *) memchr(term, *whichp, length);
+        if (current != 0 && (best == 0 || current < best))
+            best = current;
     }
 
     return best;
@@ -249,7 +249,7 @@ void emit_term(cql_transform_t ct,
             cql_pr_attr(ct, "position", "first", 0,
                         pr, client_data, 32);
             term++;
-           length--;
+            length--;
         }
         else if (term[length-1] == '^')
         {
@@ -266,58 +266,58 @@ void emit_term(cql_transform_t ct,
 
     if (length > 0)
     {
-       /* Check for well-known globbing patterns that represent
-        * simple truncation attributes as expected by, for example,
-        * Bath-compliant server.  If we find such a pattern but
-        * there's no mapping for it, that's fine: we just use a
-        * general pattern-matching attribute.
-        */
+        /* Check for well-known globbing patterns that represent
+         * simple truncation attributes as expected by, for example,
+         * Bath-compliant server.  If we find such a pattern but
+         * there's no mapping for it, that's fine: we just use a
+         * general pattern-matching attribute.
+         */
         if (length > 1 && term[0] == '*' && term[length-1] == '*' &&
-           wcchar(term+1, length-2) == 0 &&
+            wcchar(term+1, length-2) == 0 &&
             cql_pr_attr(ct, "truncation", "both", 0,
-                       pr, client_data, 0)) {
-           term++;
-           length -= 2;
+                        pr, client_data, 0)) {
+            term++;
+            length -= 2;
         }
         else if (term[0] == '*' &&
-                wcchar(term+1, length-1) == 0 &&
-                cql_pr_attr(ct, "truncation", "left", 0,
-                            pr, client_data, 0)) {
-           term++;
-           length--;
+                 wcchar(term+1, length-1) == 0 &&
+                 cql_pr_attr(ct, "truncation", "left", 0,
+                             pr, client_data, 0)) {
+            term++;
+            length--;
         }
         else if (term[length-1] == '*' &&
-                wcchar(term, length-1) == 0 &&
-                cql_pr_attr(ct, "truncation", "right", 0,
-                            pr, client_data, 0)) {
-           length--;
+                 wcchar(term, length-1) == 0 &&
+                 cql_pr_attr(ct, "truncation", "right", 0,
+                             pr, client_data, 0)) {
+            length--;
         }
         else if (wcchar(term, length))
         {
-           /* We have one or more wildcard characters, but not in a
-            * way that can be dealt with using only the standard
-            * left-, right- and both-truncation attributes.  We need
-            * to translate the pattern into a Z39.58-type pattern,
-            * which has been supported in BIB-1 since 1996.  If
-            * there's no configuration element for "truncation.z3958"
-            * we indicate this as error 28 "Masking character not
-            * supported".
-            */
-           int i;
-           char *mem;
+            /* We have one or more wildcard characters, but not in a
+             * way that can be dealt with using only the standard
+             * left-, right- and both-truncation attributes.  We need
+             * to translate the pattern into a Z39.58-type pattern,
+             * which has been supported in BIB-1 since 1996.  If
+             * there's no configuration element for "truncation.z3958"
+             * we indicate this as error 28 "Masking character not
+             * supported".
+             */
+            int i;
+            char *mem;
             cql_pr_attr(ct, "truncation", "z3958", 0,
                         pr, client_data, 28);
-           mem = (char *) xmalloc(length+1);
+            mem = (char *) xmalloc(length+1);
             for (i = 0; i < length; i++) {
-               if (term[i] == '*')      mem[i] = '?';
-               else if (term[i] == '?') mem[i] = '#';
-               else                     mem[i] = term[i];
-           }
-           mem[length] = '\0';
-           term = mem;
+                if (term[i] == '*')      mem[i] = '?';
+                else if (term[i] == '?') mem[i] = '#';
+                else                     mem[i] = term[i];
+            }
+            mem[length] = '\0';
+            term = mem;
         }
         else {
-           /* No masking characters.  Use "truncation.none" if given. */
+            /* No masking characters.  Use "truncation.none" if given. */
             cql_pr_attr(ct, "truncation", "none", 0,
                         pr, client_data, 0);
         }
@@ -379,29 +379,29 @@ void cql_transform_r(cql_transform_t ct,
     switch (cn->which)
     {
     case CQL_NODE_ST:
-       ns = cn->u.st.index_uri;
+        ns = cn->u.st.index_uri;
         if (ns)
         {
             if (!strcmp(ns, cql_uri())
-               && cn->u.st.index && !strcmp(cn->u.st.index, "resultSet"))
+                && cn->u.st.index && !strcmp(cn->u.st.index, "resultSet"))
             {
                 (*pr)("@set \"", client_data);
                 (*pr)(cn->u.st.term, client_data);
                 (*pr)("\" ", client_data);
                 return ;
             }
-           cql_pr_attr_uri(ct, "index", ns,
-                           cn->u.st.index, "serverChoice",
-                           pr, client_data, 16);
+            cql_pr_attr_uri(ct, "index", ns,
+                            cn->u.st.index, "serverChoice",
+                            pr, client_data, 16);
+        }
+        else
+        {
+            if (!ct->error)
+            {
+                ct->error = 15;
+                ct->addinfo = 0;
+            }
         }
-       else
-       {
-           if (!ct->error)
-           {
-               ct->error = 15;
-               ct->addinfo = 0;
-           }
-       }
         if (cn->u.st.relation && !strcmp(cn->u.st.relation, "="))
             cql_pr_attr(ct, "relation", "eq", "scr",
                         pr, client_data, 19);
@@ -465,9 +465,9 @@ int cql_transform(cql_transform_t ct,
     for (e = ct->entry; e ; e = e->next)
     {
         if (!memcmp(e->pattern, "set.", 4))
-           cql_apply_prefix(nmem, cn, e->pattern+4, e->value);
+            cql_apply_prefix(nmem, cn, e->pattern+4, e->value);
         else if (!strcmp(e->pattern, "set"))
-           cql_apply_prefix(nmem, cn, 0, e->value);
+            cql_apply_prefix(nmem, cn, 0, e->value);
     }
     cql_transform_r (ct, cn, pr, client_data);
     nmem_destroy(nmem);
@@ -500,3 +500,11 @@ int cql_transform_error(cql_transform_t ct, const char **addinfo)
     *addinfo = ct->addinfo;
     return ct->error;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 511fa9f..9fa3ae6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cqlutil.c,v 1.7 2005-01-15 19:47:13 adam Exp $
+/* $Id: cqlutil.c,v 1.8 2005-06-25 15:46:04 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -36,10 +36,10 @@ struct cql_node *cql_node_dup (NMEM nmem, struct cql_node *cp)
                             cp->u.st.relation,
                             cp->u.st.term);
         cn->u.st.modifiers = cql_node_dup(nmem, cp->u.st.modifiers);
-       cn->u.st.index_uri = cp->u.st.index_uri ? 
-           nmem_strdup(nmem, cp->u.st.index_uri) : 0;
-       cn->u.st.relation_uri = cp->u.st.relation_uri ?
-           nmem_strdup(nmem, cp->u.st.relation_uri) : 0;
+        cn->u.st.index_uri = cp->u.st.index_uri ? 
+            nmem_strdup(nmem, cp->u.st.index_uri) : 0;
+        cn->u.st.relation_uri = cp->u.st.relation_uri ?
+            nmem_strdup(nmem, cp->u.st.relation_uri) : 0;
         break;
     case CQL_NODE_BOOL:
         cn = cql_node_mk_boolean(nmem, cp->u.boolean.value);
@@ -50,7 +50,7 @@ struct cql_node *cql_node_dup (NMEM nmem, struct cql_node *cp)
 }
 
 struct cql_node *cql_node_mk_sc(NMEM nmem,
-                               const char *index,
+                                const char *index,
                                 const char *relation,
                                 const char *term)
 {
@@ -90,44 +90,44 @@ const char *cql_uri()
 }
 
 struct cql_node *cql_apply_prefix(NMEM nmem,
-                                 struct cql_node *n, const char *prefix,
-                                 const char *uri)
+                                  struct cql_node *n, const char *prefix,
+                                  const char *uri)
 {
     if (n->which == CQL_NODE_ST)
     {
-       if (!n->u.st.index_uri && n->u.st.index)
-       {   /* not yet resolved.. */
-           const char *cp = strchr(n->u.st.index, '.');
-           if (prefix && cp && 
-               strlen(prefix) == (size_t) (cp - n->u.st.index) &&
-               !memcmp(n->u.st.index, prefix, strlen(prefix)))
-           {
-               char *nval = nmem_strdup(nmem, cp+1);
-               n->u.st.index_uri = nmem_strdup(nmem, uri);
-               n->u.st.index = nval;
-           }
-           else if (!prefix && !cp)
-           {
-               n->u.st.index_uri = nmem_strdup(nmem, uri);
-           }
-       }
-       if (!n->u.st.relation_uri && n->u.st.relation)
-       {
-           const char *cp = strchr(n->u.st.relation, '.');
-           if (prefix && cp &&
-               strlen(prefix) == (size_t)(cp - n->u.st.relation) &&
-               !memcmp(n->u.st.relation, prefix, strlen(prefix)))
-           {
-               char *nval = nmem_strdup(nmem, cp+1);
-               n->u.st.relation_uri = nmem_strdup(nmem, uri);
-               n->u.st.relation = nval;
-           }
-       }
+        if (!n->u.st.index_uri && n->u.st.index)
+        {   /* not yet resolved.. */
+            const char *cp = strchr(n->u.st.index, '.');
+            if (prefix && cp && 
+                strlen(prefix) == (size_t) (cp - n->u.st.index) &&
+                !memcmp(n->u.st.index, prefix, strlen(prefix)))
+            {
+                char *nval = nmem_strdup(nmem, cp+1);
+                n->u.st.index_uri = nmem_strdup(nmem, uri);
+                n->u.st.index = nval;
+            }
+            else if (!prefix && !cp)
+            {
+                n->u.st.index_uri = nmem_strdup(nmem, uri);
+            }
+        }
+        if (!n->u.st.relation_uri && n->u.st.relation)
+        {
+            const char *cp = strchr(n->u.st.relation, '.');
+            if (prefix && cp &&
+                strlen(prefix) == (size_t)(cp - n->u.st.relation) &&
+                !memcmp(n->u.st.relation, prefix, strlen(prefix)))
+            {
+                char *nval = nmem_strdup(nmem, cp+1);
+                n->u.st.relation_uri = nmem_strdup(nmem, uri);
+                n->u.st.relation = nval;
+            }
+        }
     }
     else if (n->which == CQL_NODE_BOOL)
     {
-       cql_apply_prefix(nmem, n->u.boolean.left, prefix, uri);
-       cql_apply_prefix(nmem, n->u.boolean.right, prefix, uri);
+        cql_apply_prefix(nmem, n->u.boolean.left, prefix, uri);
+        cql_apply_prefix(nmem, n->u.boolean.right, prefix, uri);
     }
     return n;
 }
@@ -147,3 +147,11 @@ void cql_node_destroy(struct cql_node *cn)
         cql_node_destroy(cn->u.boolean.modifiers);
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d3c082c..eda593d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: diag-entry.c,v 1.1 2005-04-22 08:27:58 adam Exp $
+ * $Id: diag-entry.c,v 1.2 2005-06-25 15:46:04 adam Exp $
  */
 
 #include "diag-entry.h"
@@ -15,3 +15,11 @@ const char *yaz_diag_to_str(struct yaz_diag_entry *tab, int code)
             return tab[i].msg;
     return "Unknown error";
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e8a3508..416ed1a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: diag-entry.h,v 1.1 2005-04-22 08:27:58 adam Exp $
+ * $Id: diag-entry.h,v 1.2 2005-06-25 15:46:04 adam Exp $
  */
 
 struct yaz_diag_entry {
@@ -11,3 +11,11 @@ struct yaz_diag_entry {
 };
 
 const char *yaz_diag_to_str(struct yaz_diag_entry *tab, int code);
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index deb81b5..7e81995 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: dumpber.c,v 1.3 2005-01-15 19:47:13 adam Exp $
+ * $Id: dumpber.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -23,87 +23,87 @@ static int do_dumpBER(FILE *f, const char *buf, int len, int level, int offset)
     const char *b = buf, *bp = buf;
     
     if (!len)
-       return 0;
+        return 0;
     if (!buf[0] && !buf[1])
-       return 0;
+        return 0;
     if ((res = ber_dectag((unsigned char*)b, &zclass, &tag, &cons, len)) <= 0)
-       return 0;
+        return 0;
     if (res > len)
     {
-       fprintf(stderr, "Unexpected end of buffer\n");
-       return 0;
+        fprintf(stderr, "Unexpected end of buffer\n");
+        return 0;
     }
     fprintf(f, "%5d: %*s", offset, level * 4, "");
     if (zclass == ODR_UNIVERSAL)
     {
-       static char *nl[] =
-       {
-           "[Univ 0]", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING",
-           "NULL", "OID", "OBJECT DESCIPTOR", "EXTERNAL", "REAL",
-           "ENUM", "[UNIV 11]", "[UNIV 12]", "[UNIV 13]", "[UNIV 14]",
-           "[UNIV 15]", "SEQUENCE", "SET", "NUMERICSTRING", "PRINTABLESTRING",
-           "[UNIV 20]", "[UNIV 21]", "[UNIV 22]", "[UNIV 23]", "[UNIV 24]",
-           "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", "[UNIV 28]"
-       };
+        static char *nl[] =
+        {
+            "[Univ 0]", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING",
+            "NULL", "OID", "OBJECT DESCIPTOR", "EXTERNAL", "REAL",
+            "ENUM", "[UNIV 11]", "[UNIV 12]", "[UNIV 13]", "[UNIV 14]",
+            "[UNIV 15]", "SEQUENCE", "SET", "NUMERICSTRING", "PRINTABLESTRING",
+            "[UNIV 20]", "[UNIV 21]", "[UNIV 22]", "[UNIV 23]", "[UNIV 24]",
+            "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", "[UNIV 28]"
+        };
 
-       if (tag >= 0 && tag < 28)
-           fprintf(f, "%s", nl[tag]);
-       else
-           fprintf(f, "[UNIV %d]", tag);
+        if (tag >= 0 && tag < 28)
+            fprintf(f, "%s", nl[tag]);
+        else
+            fprintf(f, "[UNIV %d]", tag);
     }
     else if (zclass == ODR_CONTEXT)
-       fprintf(f, "[%d]", tag);
+        fprintf(f, "[%d]", tag);
     else
-       fprintf(f, "[%d:%d]", zclass, tag);
+        fprintf(f, "[%d:%d]", zclass, tag);
     b += res;
     taglen = res;
     len -= res;
     bp = b;
     if ((res = ber_declen((unsigned char*)b, &ll, len)) <= 0)
     {
-       fprintf(f, "\n%*sBad length\n", level*4+5, "");
-       return 0;
+        fprintf(f, "\n%*sBad length\n", level*4+5, "");
+        return 0;
     }
     lenlen = res;
     b += res;
     len -= res;
     if (ll >= 0)
-       fprintf(f, " len=%d", ll);
+        fprintf(f, " len=%d", ll);
     else
-       fprintf(f, " len=?");
+        fprintf(f, " len=?");
     fprintf(f, "       tl=%d, ll=%d cons=%d\n", taglen, lenlen, cons);
     if (!cons)
     {
-       if (ll < 0 || ll > len)
-       {
-           fprintf(f, "%*sBad length on primitive type. ll=%d len=%d\n",
+        if (ll < 0 || ll > len)
+        {
+            fprintf(f, "%*sBad length on primitive type. ll=%d len=%d\n",
                     level*4+5, "", ll, len);
-           return 0;
-       }
-       return ll + (b - buf);
+            return 0;
+        }
+        return ll + (b - buf);
     }
     if (ll >= 0)
     {
         if (ll > len)
         {
-           fprintf(f, "%*sBad length of constructed type ll=%d len=%d.\n",
+            fprintf(f, "%*sBad length of constructed type ll=%d len=%d.\n",
                     level*4+5, "", ll, len);
-           return 0;
+            return 0;
         }
-       len = ll;
+        len = ll;
     }
     /* constructed - cycle through children */
     while ((ll == -1 && len >= 2) || (ll >= 0 && len))
     {
-       if (ll == -1 && *b == 0 && *(b + 1) == 0)
-           break;
-       if (!(res = do_dumpBER(f, b, len, level + 1, offset + (b - buf))))
-       {
-           fprintf(f, "%*sDump of content element failed.\n", level*4+5, "");
-           return 0;
-       }
-       b += res;
-       len -= res;
+        if (ll == -1 && *b == 0 && *(b + 1) == 0)
+            break;
+        if (!(res = do_dumpBER(f, b, len, level + 1, offset + (b - buf))))
+        {
+            fprintf(f, "%*sDump of content element failed.\n", level*4+5, "");
+            return 0;
+        }
+        b += res;
+        len -= res;
         if (len < 0)
         {
             fprintf(f, "%*sBad length\n", level*4+5, "");
@@ -112,13 +112,13 @@ static int do_dumpBER(FILE *f, const char *buf, int len, int level, int offset)
     }
     if (ll == -1)
     {
-       if (len < 2)
-       {
-           fprintf(f, "%*sBuffer too short in indefinite length.\n",
+        if (len < 2)
+        {
+            fprintf(f, "%*sBuffer too short in indefinite length.\n",
                     level*4+5, "");
-           return 0;
-       }
-       return (b - buf) + 2;
+            return 0;
+        }
+        return (b - buf) + 2;
     }
     return b - buf;
 }
@@ -127,3 +127,11 @@ int odr_dumpBER(FILE *f, const char *buf, int len)
 {
     return do_dumpBER(f, buf, len, 0, 0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 5084f2d..2392cc8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: eventl.c,v 1.8 2005-03-01 20:37:01 adam Exp $
+ * $Id: eventl.c,v 1.9 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -66,7 +66,7 @@ IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, int chan_id)
     }
 
     if (!(new_iochan = (IOCHAN)xmalloc(sizeof(*new_iochan))))
-       return 0;
+        return 0;
     new_iochan->destroyed = 0;
     new_iochan->fd = fd;
     new_iochan->flags = flags;
@@ -82,10 +82,10 @@ int event_loop(IOCHAN *iochans)
 {
     do /* loop as long as there are active associations to process */
     {
-       IOCHAN p, nextp;
-       fd_set in, out, except;
-       int res, max;
-       static struct timeval to;
+        IOCHAN p, nextp;
+        fd_set in, out, except;
+        int res, max;
+        static struct timeval to;
         time_t now = time(0);
 
         if (statserv_must_terminate())
@@ -93,27 +93,27 @@ int event_loop(IOCHAN *iochans)
             for (p = *iochans; p; p = p->next)
                 p->force_event = EVENT_TIMEOUT;
         }
-       FD_ZERO(&in);
-       FD_ZERO(&out);
-       FD_ZERO(&except);
-       to.tv_sec = 3600;
-       to.tv_usec = 0;
-       max = 0;
-       for (p = *iochans; p; p = p->next)
-       {
+        FD_ZERO(&in);
+        FD_ZERO(&out);
+        FD_ZERO(&except);
+        to.tv_sec = 3600;
+        to.tv_usec = 0;
+        max = 0;
+        for (p = *iochans; p; p = p->next)
+        {
             time_t w, ftime;
             yaz_log(log_level, "fd=%d flags=%d force_event=%d",
                     p->fd, p->flags, p->force_event);
-           if (p->force_event)
+            if (p->force_event)
                 to.tv_sec = 0;          /* polling select */
-           if (p->flags & EVENT_INPUT)
-               FD_SET(p->fd, &in);
-           if (p->flags & EVENT_OUTPUT)
-               FD_SET(p->fd, &out);
-           if (p->flags & EVENT_EXCEPT)
-               FD_SET(p->fd, &except);
-           if (p->fd > max)
-               max = p->fd;
+            if (p->flags & EVENT_INPUT)
+                FD_SET(p->fd, &in);
+            if (p->flags & EVENT_OUTPUT)
+                FD_SET(p->fd, &out);
+            if (p->flags & EVENT_EXCEPT)
+                FD_SET(p->fd, &except);
+            if (p->fd > max)
+                max = p->fd;
             if (p->max_idle && p->last_event)
             {
                 ftime = p->last_event + p->max_idle;
@@ -124,13 +124,13 @@ int event_loop(IOCHAN *iochans)
                 if (w < to.tv_sec)
                     to.tv_sec = w;
             }
-       }
+        }
         yaz_log(log_level, "select start %ld", (long) to.tv_sec);
-       res = YAZ_EV_SELECT(max + 1, &in, &out, &except, &to);
+        res = YAZ_EV_SELECT(max + 1, &in, &out, &except, &to);
         yaz_log(log_level, "select end");
-       if (res < 0)
-       {
-           if (yaz_errno() == EINTR)
+        if (res < 0)
+        {
+            if (yaz_errno() == EINTR)
             {
                 if (statserv_must_terminate())
                 {
@@ -146,71 +146,79 @@ int event_loop(IOCHAN *iochans)
                 COMSTACK conn = assoc->client_link;
 
                 cs_close(conn);
-               destroy_association(assoc);
-               iochan_destroy(*iochans);
+                destroy_association(assoc);
+                iochan_destroy(*iochans);
                 yaz_log(log_level, "error select, destroying iochan %p",
-                       *iochans);
+                        *iochans);
             }
-       }
+        }
         now = time(0);
-       for (p = *iochans; p; p = p->next)
-       {
-           int force_event = p->force_event;
-
-           p->force_event = 0;
-           if (!p->destroyed && (FD_ISSET(p->fd, &in) ||
-               force_event == EVENT_INPUT))
-           {
-               p->last_event = now;
-               (*p->fun)(p, EVENT_INPUT);
-           }
-           if (!p->destroyed && (FD_ISSET(p->fd, &out) ||
-               force_event == EVENT_OUTPUT))
-           {
-               p->last_event = now;
-               (*p->fun)(p, EVENT_OUTPUT);
-           }
-           if (!p->destroyed && (FD_ISSET(p->fd, &except) ||
-               force_event == EVENT_EXCEPT))
-           {
-               p->last_event = now;
-               (*p->fun)(p, EVENT_EXCEPT);
-           }
-           if (!p->destroyed && ((p->max_idle && now - p->last_event >=
-               p->max_idle) || force_event == EVENT_TIMEOUT))
-           {
-               p->last_event = now;
-               (*p->fun)(p, EVENT_TIMEOUT);
-           }
-       }
-       for (p = *iochans; p; p = nextp)
-       {
-           nextp = p->next;
-
-           if (p->destroyed)
-           {
-               IOCHAN tmp = p, pr;
+        for (p = *iochans; p; p = p->next)
+        {
+            int force_event = p->force_event;
+
+            p->force_event = 0;
+            if (!p->destroyed && (FD_ISSET(p->fd, &in) ||
+                force_event == EVENT_INPUT))
+            {
+                p->last_event = now;
+                (*p->fun)(p, EVENT_INPUT);
+            }
+            if (!p->destroyed && (FD_ISSET(p->fd, &out) ||
+                force_event == EVENT_OUTPUT))
+            {
+                p->last_event = now;
+                (*p->fun)(p, EVENT_OUTPUT);
+            }
+            if (!p->destroyed && (FD_ISSET(p->fd, &except) ||
+                force_event == EVENT_EXCEPT))
+            {
+                p->last_event = now;
+                (*p->fun)(p, EVENT_EXCEPT);
+            }
+            if (!p->destroyed && ((p->max_idle && now - p->last_event >=
+                p->max_idle) || force_event == EVENT_TIMEOUT))
+            {
+                p->last_event = now;
+                (*p->fun)(p, EVENT_TIMEOUT);
+            }
+        }
+        for (p = *iochans; p; p = nextp)
+        {
+            nextp = p->next;
+
+            if (p->destroyed)
+            {
+                IOCHAN tmp = p, pr;
 
                 /* We need to inform the threadlist that this channel has been destroyed */
                 statserv_remove(p);
 
-               /* Now reset the pointers */
+                /* Now reset the pointers */
                 if (p == *iochans)
-                   *iochans = p->next;
-               else
-               {
-                   for (pr = *iochans; pr; pr = pr->next)
-                       if (pr->next == p)
-                           break;
-                   assert(pr); /* grave error if it weren't there */
-                   pr->next = p->next;
-               }
-               if (nextp == p)
-                   nextp = p->next;
-               xfree(tmp);
-           }
-       }
+                    *iochans = p->next;
+                else
+                {
+                    for (pr = *iochans; pr; pr = pr->next)
+                        if (pr->next == p)
+                            break;
+                    assert(pr); /* grave error if it weren't there */
+                    pr->next = p->next;
+                }
+                if (nextp == p)
+                    nextp = p->next;
+                xfree(tmp);
+            }
+        }
     }
     while (*iochans);
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a737c13..a11fe47 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: eventl.h,v 1.5 2005-03-01 20:37:01 adam Exp $
+ * $Id: eventl.h,v 1.6 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -62,3 +62,11 @@ IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, int port);
 int event_loop(IOCHAN *iochans);
 void statserv_remove (IOCHAN pIOChannel);
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c2abea8..0a9df7a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: grs1disp.c,v 1.3 2005-01-15 19:47:13 adam Exp $
+ * $Id: grs1disp.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -120,3 +120,11 @@ void yaz_display_grs1(WRBUF wrbuf, Z_GenericRecord *r, int flags)
     display_grs1 (wrbuf, r, 0);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 9e02f33..4cfaa6a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ill-get.c,v 1.4 2005-01-16 22:12:39 adam Exp $
+ * $Id: ill-get.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -14,7 +14,7 @@
 #include <yaz/ill.h>
 
 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
-                     const char *sub, int val)
+                      const char *sub, int val)
 {
     ODR o = gc->odr;
     char element[128];
@@ -24,21 +24,21 @@ bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }    
 
     v = (gc->f)(gc->clientData, element);
     if (v)
-       val = atoi(v);
+        val = atoi(v);
     else if (val < 0)
-       return 0;
+        return 0;
     *r = val;
     return r;
 }
 
 int *ill_get_int (struct ill_get_ctl *gc, const char *name,
-                 const char *sub, int val)
+                  const char *sub, int val)
 {
     ODR o = gc->odr;
     char element[128];
@@ -47,23 +47,23 @@ int *ill_get_int (struct ill_get_ctl *gc, const char *name,
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }    
     v = (gc->f)(gc->clientData, element);
     if (v)
-       val = atoi(v);
+        val = atoi(v);
     return odr_intdup(o, val);
 }
 
 int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
-                        const char *sub, int val)
+                         const char *sub, int val)
 {
     return ill_get_int(gc, name, sub, val);
 }
 
 ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name,
-                                 const char *sub, const char *vdefault)
+                                  const char *sub, const char *vdefault)
 {
     ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
     char element[128];
@@ -72,27 +72,27 @@ ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name,
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     v = (gc->f)(gc->clientData, element);
     if (!v)
         v = vdefault;
     if (!v)
-       return 0;
+        return 0;
     r->which = ILL_String_GeneralString;
     r->u.GeneralString = odr_strdup (gc->odr, v);
     return r;
 }
 
 ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name,
-                              const char *sub)
+                               const char *sub)
 {
     return ill_get_ILL_String_x (gc, name, sub, 0);
 }
 
 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
-                                   const char *sub, const char *val)
+                                    const char *sub, const char *val)
 {
     char element[128];
     const char *v;
@@ -100,19 +100,19 @@ ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     v = (gc->f)(gc->clientData, element);
     if (!v)
-       v = val;
+        v = val;
     if (!v)
-       return 0;
+        return 0;
     return odr_strdup (gc->odr, v);
 }
 
 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
-                                   const char *sub, const char *val)
+                                    const char *sub, const char *val)
 {
     char element[128];
     const char *v;
@@ -120,14 +120,14 @@ ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     v = (gc->f)(gc->clientData, element);
     if (!v)
-       v = val;
+        v = val;
     if (!v)
-       return 0;
+        return 0;
     return odr_strdup (gc->odr, v);
 }
 
@@ -137,22 +137,22 @@ ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
     char element[128];
     ODR o = gc->odr;
     ILL_Person_Or_Institution_Symbol *p =
-       (ILL_Person_Or_Institution_Symbol *) odr_malloc (o, sizeof(*p));
+        (ILL_Person_Or_Institution_Symbol *) odr_malloc (o, sizeof(*p));
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
     if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
-       return p;
+        return p;
 
     p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
     if ((p->u.institution_symbol =
-        ill_get_ILL_String (gc, element, "institution")))
-       return p;
+         ill_get_ILL_String (gc, element, "institution")))
+        return p;
     return 0;
 }
 
@@ -162,28 +162,28 @@ static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
     char element[128];
     ODR o = gc->odr;
     ILL_Name_Of_Person_Or_Institution *p =
-       (ILL_Name_Of_Person_Or_Institution *) odr_malloc (o, sizeof(*p));
+        (ILL_Name_Of_Person_Or_Institution *) odr_malloc (o, sizeof(*p));
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
     if ((p->u.name_of_person =
-        ill_get_ILL_String (gc, element, "name-of-person")))
-       return p;
+         ill_get_ILL_String (gc, element, "name-of-person")))
+        return p;
 
     p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
     if ((p->u.name_of_institution =
-        ill_get_ILL_String (gc, element, "name-of-institution")))
-       return p;
+         ill_get_ILL_String (gc, element, "name-of-institution")))
+        return p;
     return 0;
 }
     
 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
-                                const char *name, const char *sub)
+                                 const char *name, const char *sub)
 {
     ODR o = gc->odr;
     char element[128];
@@ -192,19 +192,19 @@ ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
     p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
-       gc, element, "person-or-institution-symbol");
+        gc, element, "person-or-institution-symbol");
     p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
-       gc, element, "name-of-person-or-institution");
+        gc, element, "name-of-person-or-institution");
     return p;
 }
 
 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
-                                           const char *name, const char *sub)
+                                            const char *name, const char *sub)
 {
     ODR o = gc->odr;
     ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
@@ -213,17 +213,17 @@ ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }    
     r->initial_requester_id =
-       ill_get_System_Id (gc, element, "initial-requester-id");
+        ill_get_System_Id (gc, element, "initial-requester-id");
     r->transaction_group_qualifier =
-       ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", "");
+        ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", "");
     r->transaction_qualifier =
-       ill_get_ILL_String_x (gc, element, "transaction-qualifier", "");
+        ill_get_ILL_String_x (gc, element, "transaction-qualifier", "");
     r->sub_transaction_qualifier =
-       ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
+        ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
     return r;
 }
 
@@ -233,14 +233,14 @@ ILL_Service_Date_this *ill_get_Service_Date_this (
 {
     ODR o = gc->odr;
     ILL_Service_Date_this *r =
-       (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
+        (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
     char element[128];
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
     r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
@@ -252,19 +252,19 @@ ILL_Service_Date_original *ill_get_Service_Date_original (
 {
     ODR o = gc->odr;
     ILL_Service_Date_original *r =
-       (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
+        (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
     char element[128];
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0);
     r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
     if (!r->date && !r->time)
-       return 0;
+        return 0;
     return r;
 }
 
@@ -273,19 +273,19 @@ ILL_Service_Date_Time *ill_get_Service_Date_Time (
 {
     ODR o = gc->odr;
     ILL_Service_Date_Time *r =
-       (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
+        (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
     char element[128];
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }    
     r->date_time_of_this_service = ill_get_Service_Date_this (
-       gc, element, "this");
+        gc, element, "this");
     r->date_time_of_original_service = ill_get_Service_Date_original (
-       gc, element, "original");
+        gc, element, "original");
     return r;
 }
 
@@ -294,21 +294,21 @@ ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
 {
     ODR o = gc->odr;
     ILL_Requester_Optional_Messages_Type *r =
-       (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
+        (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
     char element[128];
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
     r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
     r->requester_SHIPPED =
-       ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
+        ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
     r->requester_CHECKED_IN =
-       ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
+        ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
     return r;
 }
 
@@ -322,11 +322,11 @@ ILL_Item_Id *ill_get_Item_Id (
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->item_type = ill_get_enumerated (gc, element, "item-type",
-                                      ILL_Item_Id_monograph);
+                                       ILL_Item_Id_monograph);
     r->held_medium_type = 0;
     r->call_number = ill_get_ILL_String(gc, element, "call-number");
     r->author = ill_get_ILL_String(gc, element, "author");
@@ -334,17 +334,17 @@ ILL_Item_Id *ill_get_Item_Id (
     r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
     r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
     r->place_of_publication =
-       ill_get_ILL_String(gc, element, "place-of-publication");
+        ill_get_ILL_String(gc, element, "place-of-publication");
     r->publisher = ill_get_ILL_String(gc, element, "publisher");
     r->series_title_number =
-       ill_get_ILL_String(gc, element, "series-title-number");
+        ill_get_ILL_String(gc, element, "series-title-number");
     r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
     r->edition = ill_get_ILL_String(gc, element, "edition");
     r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
     r->publication_date_of_component =
-       ill_get_ILL_String(gc, element, "publication-date-of-component");
+        ill_get_ILL_String(gc, element, "publication-date-of-component");
     r->author_of_article = ill_get_ILL_String(gc, element,
-                                             "author-of-article");
+                                              "author-of-article");
     r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article");
     r->pagination = ill_get_ILL_String(gc, element, "pagination");
     r->national_bibliography_no = 0;
@@ -352,9 +352,9 @@ ILL_Item_Id *ill_get_Item_Id (
     r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
     r->system_no = 0;
     r->additional_no_letters =
-       ill_get_ILL_String(gc, element, "additional-no-letters");
+        ill_get_ILL_String(gc, element, "additional-no-letters");
     r->verification_reference_source = 
-       ill_get_ILL_String(gc, element, "verification-reference-source");
+        ill_get_ILL_String(gc, element, "verification-reference-source");
     return r;
 }
 
@@ -369,13 +369,13 @@ ILL_Client_Id *ill_get_Client_Id (
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->client_name = ill_get_ILL_String (gc, element, "client-name");
     r->client_status = ill_get_ILL_String (gc, element, "client-status");
     r->client_identifier = ill_get_ILL_String (gc, element,
-                                              "client-identifier");
+                                               "client-identifier");
     return r;
 }
 
@@ -384,25 +384,25 @@ ILL_Postal_Address *ill_get_Postal_Address (
 {
     ODR o = gc->odr;
     ILL_Postal_Address *r =
-       (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
+        (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
     char element[128];
 
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->name_of_person_or_institution = 
-       ill_get_Name_Of_Person_Or_Institution (
-           gc, element, "name-of-person-or-institution");
+        ill_get_Name_Of_Person_Or_Institution (
+            gc, element, "name-of-person-or-institution");
     r->extended_postal_delivery_address =
-       ill_get_ILL_String (
-           gc, element, "extended-postal-delivery-address");
+        ill_get_ILL_String (
+            gc, element, "extended-postal-delivery-address");
     r->street_and_number =
-       ill_get_ILL_String (gc, element, "street-and-number");
+        ill_get_ILL_String (gc, element, "street-and-number");
     r->post_office_box =
-       ill_get_ILL_String (gc, element, "post-office-box");
+        ill_get_ILL_String (gc, element, "post-office-box");
     r->city = ill_get_ILL_String (gc, element, "city");
     r->region = ill_get_ILL_String (gc, element, "region");
     r->country = ill_get_ILL_String (gc, element, "country");
@@ -415,19 +415,19 @@ ILL_System_Address *ill_get_System_Address (
 {
     ODR o = gc->odr;
     ILL_System_Address *r =
-       (ILL_System_Address *) odr_malloc(o, sizeof(*r));
+        (ILL_System_Address *) odr_malloc(o, sizeof(*r));
     char element[128];
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->telecom_service_identifier =
-       ill_get_ILL_String (gc, element, "telecom-service-identifier");
+        ill_get_ILL_String (gc, element, "telecom-service-identifier");
     r->telecom_service_address =
-       ill_get_ILL_String (gc, element, "telecom-service-addreess");
+        ill_get_ILL_String (gc, element, "telecom-service-addreess");
     return r;
 }
 
@@ -436,19 +436,19 @@ ILL_Delivery_Address *ill_get_Delivery_Address (
 {
     ODR o = gc->odr;
     ILL_Delivery_Address *r =
-       (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
+        (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
     char element[128];
     
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->postal_address =
-       ill_get_Postal_Address (gc, element, "postal-address");
+        ill_get_Postal_Address (gc, element, "postal-address");
     r->electronic_address =
-       ill_get_System_Address (gc, element, "electronic-address");
+        ill_get_System_Address (gc, element, "electronic-address");
     return r;
 }
 
@@ -462,15 +462,15 @@ ILL_Search_Type *ill_get_Search_Type (
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
     r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
-                                               "need-before-date", 0);
+                                                "need-before-date", 0);
     r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
     r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
-                                        
+                                         
     return r;
 }
 
@@ -484,53 +484,53 @@ ILL_Request *ill_get_ILLRequest (
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->protocol_version_num =
-       ill_get_enumerated (gc, element, "protocol-version-num", 
-                           ILL_Request_version_2);
+        ill_get_enumerated (gc, element, "protocol-version-num", 
+                            ILL_Request_version_2);
     
     r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
     r->service_date_time =
-       ill_get_Service_Date_Time (gc, element, "service-date-time");
+        ill_get_Service_Date_Time (gc, element, "service-date-time");
     r->requester_id = ill_get_System_Id (gc, element, "requester-id");
     r->responder_id = ill_get_System_Id (gc, element, "responder-id");
     r->transaction_type =
-       ill_get_enumerated(gc, element, "transaction-type", 1);
+        ill_get_enumerated(gc, element, "transaction-type", 1);
 
     r->delivery_address =
-       ill_get_Delivery_Address (gc, element, "delivery-address");
+        ill_get_Delivery_Address (gc, element, "delivery-address");
     r->delivery_service = 0; /* TODO */
     /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
     r->billing_address =
-       ill_get_Delivery_Address (gc, element, "billing-address");
+        ill_get_Delivery_Address (gc, element, "billing-address");
 
     r->num_iLL_service_type = 1;
     r->iLL_service_type = (ILL_Service_Type **)
-       odr_malloc (o, sizeof(*r->iLL_service_type));
+        odr_malloc (o, sizeof(*r->iLL_service_type));
     *r->iLL_service_type =
-       ill_get_enumerated (gc, element, "ill-service-type",
-                           ILL_Service_Type_copy_non_returnable);
+        ill_get_enumerated (gc, element, "ill-service-type",
+                            ILL_Service_Type_copy_non_returnable);
 
     r->responder_specific_service = 0;
     r->requester_optional_messages =
-       ill_get_Requester_Optional_Messages_Type (
-           gc, element,"requester-optional-messages");
+        ill_get_Requester_Optional_Messages_Type (
+            gc, element,"requester-optional-messages");
     r->search_type = ill_get_Search_Type(gc, element, "search-type");
     r->num_supply_medium_info_type = 0;
     r->supply_medium_info_type = 0;
 
     r->place_on_hold = ill_get_enumerated (
-       gc, element, "place-on-hold", 
-       ILL_Place_On_Hold_Type_according_to_responder_policy);
+        gc, element, "place-on-hold", 
+        ILL_Place_On_Hold_Type_according_to_responder_policy);
     r->client_id = ill_get_Client_Id (gc, element, "client-id");
-                          
+                           
     r->item_id = ill_get_Item_Id (gc, element, "item-id");
     r->supplemental_item_description = 0;
     r->cost_info_type = 0;
     r->copyright_compliance =
-       ill_get_ILL_String(gc, element, "copyright-complicance");
+        ill_get_ILL_String(gc, element, "copyright-complicance");
     r->third_party_info_type = 0;
     r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
     r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
@@ -551,53 +551,53 @@ ILL_ItemRequest *ill_get_ItemRequest (
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->protocol_version_num =
-       ill_get_enumerated (gc, element, "protocol-version-num", 
-                           ILL_Request_version_2);
+        ill_get_enumerated (gc, element, "protocol-version-num", 
+                            ILL_Request_version_2);
     
     r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
     r->service_date_time =
-       ill_get_Service_Date_Time (gc, element, "service-date-time");
+        ill_get_Service_Date_Time (gc, element, "service-date-time");
     r->requester_id = ill_get_System_Id (gc, element, "requester-id");
     r->responder_id = ill_get_System_Id (gc, element, "responder-id");
     r->transaction_type =
-       ill_get_enumerated(gc, element, "transaction-type", 1);
+        ill_get_enumerated(gc, element, "transaction-type", 1);
 
     r->delivery_address =
-       ill_get_Delivery_Address (gc, element, "delivery-address");
+        ill_get_Delivery_Address (gc, element, "delivery-address");
     r->delivery_service = 0; /* TODO */
     /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
     r->billing_address =
-       ill_get_Delivery_Address (gc, element, "billing-address");
+        ill_get_Delivery_Address (gc, element, "billing-address");
 
     r->num_iLL_service_type = 1;
     r->iLL_service_type = (ILL_Service_Type **)
-       odr_malloc (o, sizeof(*r->iLL_service_type));
+        odr_malloc (o, sizeof(*r->iLL_service_type));
     *r->iLL_service_type =
-       ill_get_enumerated (gc, element, "ill-service-type",
-                           ILL_Service_Type_copy_non_returnable);
+        ill_get_enumerated (gc, element, "ill-service-type",
+                            ILL_Service_Type_copy_non_returnable);
 
     r->responder_specific_service = 0;
     r->requester_optional_messages =
-       ill_get_Requester_Optional_Messages_Type (
-           gc, element,"requester-optional-messages");
+        ill_get_Requester_Optional_Messages_Type (
+            gc, element,"requester-optional-messages");
     r->search_type = ill_get_Search_Type(gc, element, "search-type");
     r->num_supply_medium_info_type = 0;
     r->supply_medium_info_type = 0;
 
     r->place_on_hold = ill_get_enumerated (
-       gc, element, "place-on-hold", 
-       ILL_Place_On_Hold_Type_according_to_responder_policy);
+        gc, element, "place-on-hold", 
+        ILL_Place_On_Hold_Type_according_to_responder_policy);
     r->client_id = ill_get_Client_Id (gc, element, "client-id");
-                          
+                           
     r->item_id = ill_get_Item_Id (gc, element, "item-id");
     r->supplemental_item_description = 0;
     r->cost_info_type = 0;
     r->copyright_compliance =
-       ill_get_ILL_String(gc, element, "copyright-complicance");
+        ill_get_ILL_String(gc, element, "copyright-complicance");
     r->third_party_info_type = 0;
     r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
     r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
@@ -618,16 +618,16 @@ ILL_Cancel *ill_get_Cancel (
     strcpy(element, name);
     if (sub)
     {
-       strcat (element, ",");
-       strcat (element, sub);
+        strcat (element, ",");
+        strcat (element, sub);
     }
     r->protocol_version_num =
-       ill_get_enumerated (gc, element, "protocol-version-num", 
-                           ILL_Request_version_2);
+        ill_get_enumerated (gc, element, "protocol-version-num", 
+                            ILL_Request_version_2);
     
     r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
     r->service_date_time =
-       ill_get_Service_Date_Time (gc, element, "service-date-time");
+        ill_get_Service_Date_Time (gc, element, "service-date-time");
     r->requester_id = ill_get_System_Id (gc, element, "requester-id");
     r->responder_id = ill_get_System_Id (gc, element, "responder-id");
     r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
@@ -650,18 +650,26 @@ ILL_APDU *ill_get_APDU (
 
     v = (gc->f)(gc->clientData, element);
     if (!v)
-       v = "request";
+        v = "request";
     if (!strcmp (v, "request"))
     {
-       r->which = ILL_APDU_ILL_Request;
-       r->u.illRequest = ill_get_ILLRequest(gc, name, sub);
+        r->which = ILL_APDU_ILL_Request;
+        r->u.illRequest = ill_get_ILLRequest(gc, name, sub);
     }
     else if (!strcmp (v, "cancel"))
     {
-       r->which = ILL_APDU_Cancel;
-       r->u.Cancel = ill_get_Cancel(gc, name, sub);
+        r->which = ILL_APDU_Cancel;
+        r->u.Cancel = ill_get_Cancel(gc, name, sub);
     }
     else
-       return 0;
+        return 0;
     return r;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b09d0fd..a83029b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: initopt.c,v 1.5 2005-06-06 07:12:47 ja7 Exp $
+ * $Id: initopt.c,v 1.6 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -51,44 +51,52 @@ int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos)
     ODR_MASK_ZERO(opt);
     while (*cp)
     {
-       char this_opt[42];
-       int i, j;
-       if (*cp == ' ' || *cp == ',')
-       {
-           cp++;
-           continue;
-       }
-       for (i = 0; i < (sizeof(this_opt)-1) &&
-                cp[i] && cp[i] != ' ' && cp[i] != ','; i++)
-           this_opt[i] = cp[i];
-       this_opt[i] = 0;
-       for (j = 0; opt_array[j].name; j++)
-       {
-           if (yaz_matchstr(this_opt, opt_array[j].name) == 0)
-           {
-               ODR_MASK_SET(opt, opt_array[j].opt);
-               break;
-           }
-       }
-       if (!opt_array[j].name)
-       {
-           if (error_pos)
-           {
-               *error_pos = cp - opt_str;
-               return -1;
-           }
-       }
-       cp += i;
+        char this_opt[42];
+        int i, j;
+        if (*cp == ' ' || *cp == ',')
+        {
+            cp++;
+            continue;
+        }
+        for (i = 0; i < (sizeof(this_opt)-1) &&
+                 cp[i] && cp[i] != ' ' && cp[i] != ','; i++)
+            this_opt[i] = cp[i];
+        this_opt[i] = 0;
+        for (j = 0; opt_array[j].name; j++)
+        {
+            if (yaz_matchstr(this_opt, opt_array[j].name) == 0)
+            {
+                ODR_MASK_SET(opt, opt_array[j].opt);
+                break;
+            }
+        }
+        if (!opt_array[j].name)
+        {
+            if (error_pos)
+            {
+                *error_pos = cp - opt_str;
+                return -1;
+            }
+        }
+        cp += i;
     }
     return 0;
 }
 
 void yaz_init_opt_decode(Z_Options *opt, void (*pr)(const char *name,
-                                                   void *clientData),
-                        void *clientData)
+                                                    void *clientData),
+                         void *clientData)
 {
     int i;
     for (i = 0; opt_array[i].name; i++)
-       if (ODR_MASK_GET(opt, opt_array[i].opt))
-           (*pr)(opt_array[i].name, clientData);
+        if (ODR_MASK_GET(opt, opt_array[i].opt))
+            (*pr)(opt_array[i].name, clientData);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 54753f0..1a5e6b5 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: log.c,v 1.24 2005-05-18 12:30:00 adam Exp $
+ * $Id: log.c,v 1.25 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -118,11 +118,11 @@ void yaz_log_init_file (const char *fname)
         init_mutex();
     if (fname)
     {
-       strncpy(l_fname, fname, sizeof(l_fname)-1);
-       l_fname[sizeof(l_fname)-1] = '\0';
+        strncpy(l_fname, fname, sizeof(l_fname)-1);
+        l_fname[sizeof(l_fname)-1] = '\0';
     }
     else
-       l_fname[0] = '\0';
+        l_fname[0] = '\0';
     yaz_log_reopen();
 }
 
@@ -134,7 +134,7 @@ void yaz_log_reopen(void)
     if (!l_file)
         l_file = stderr;
     if (!*l_fname)
-       new_file = stderr;
+        new_file = stderr;
     else if (!(new_file = fopen(l_fname, "a")))
     {
         new_file=l_file;
@@ -203,7 +203,7 @@ void yaz_log_init_level (int level)
 void yaz_log_init_prefix (const char *prefix)
 {
     if (prefix && *prefix)
-       sprintf(l_prefix, "%.511s ", prefix);
+        sprintf(l_prefix, "%.511s ", prefix);
     else
         *l_prefix = 0;
 }
@@ -211,7 +211,7 @@ void yaz_log_init_prefix (const char *prefix)
 void yaz_log_init_prefix2 (const char *prefix)
 {
     if (prefix && *prefix)
-       sprintf(l_prefix2, "%.511s ", prefix);
+        sprintf(l_prefix2, "%.511s ", prefix);
     else
         *l_prefix2 = 0;
 }
@@ -263,7 +263,7 @@ void yaz_log(int level, const char *fmt, ...)
     int flen; 
 
     if (!(level & l_level))
-       return;
+        return;
     if (!mutex_init_flag)
         init_mutex();
     if (!l_file)
@@ -280,15 +280,15 @@ void yaz_log(int level, const char *fmt, ...)
 
     *flags = '\0';
     for (i = 0; level && mask_names[i].name; i++)
-       if ( mask_names[i].mask & level)
-       {
-           if (*mask_names[i].name && mask_names[i].mask && 
+        if ( mask_names[i].mask & level)
+        {
+            if (*mask_names[i].name && mask_names[i].mask && 
                  mask_names[i].mask != YLOG_ALL)
             {
-               sprintf(flags + strlen(flags), "[%s]", mask_names[i].name);
-               level &= ~mask_names[i].mask;
+                sprintf(flags + strlen(flags), "[%s]", mask_names[i].name);
+                level &= ~mask_names[i].mask;
             }
-       }
+        }
     va_start(ap, fmt);
 #ifdef WIN32
     _vsnprintf(buf, sizeof(buf)-1, fmt, ap);
@@ -313,16 +313,16 @@ void yaz_log(int level, const char *fmt, ...)
     ti = time(0);
     tim = localtime(&ti);
     if (l_level & YLOG_NOTIME)
-       tbuf[0] = '\0';
+        tbuf[0] = '\0';
     else
-       strftime(tbuf, TIMEFORMAT_LEN-1, l_actual_format, tim);
+        strftime(tbuf, TIMEFORMAT_LEN-1, l_actual_format, tim);
     tbuf[TIMEFORMAT_LEN-1] = '\0';
     fprintf(l_file, "%s %s%s %s%s\n", tbuf, l_prefix, flags,
             l_prefix2, buf);
     if (l_level & (YLOG_FLUSH|YLOG_DEBUG) )
         fflush(l_file);
     if (end_hook_func)
-       (*end_hook_func)(o_level, buf, end_hook_info);
+        (*end_hook_func)(o_level, buf, end_hook_info);
 }
 
 void yaz_log_time_format(const char *fmt)
@@ -452,3 +452,11 @@ int yaz_log_mask_str_x (const char *str, int level)
     }
     return level;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 7baa3aa..39e9893 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * All rights reserved.
  *
- * $Id: logrpn.c,v 1.10 2005-01-15 19:47:13 adam Exp $
+ * $Id: logrpn.c,v 1.11 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -190,20 +190,20 @@ static void wrbuf_term(WRBUF b, const char *term, int len)
 {
     int i;
     for (i = 0; i < len; i++)
-       if (strchr(" \"{", term[i]))
-           break;
+        if (strchr(" \"{", term[i]))
+            break;
     if (i == len && i)
-       wrbuf_printf(b, "%.*s ", len, term);
+        wrbuf_printf(b, "%.*s ", len, term);
     else
     {
-       wrbuf_putc(b, '"');
-       for (i = 0; i<len; i++)
-       {
-           if (term[i] == '"')
-               wrbuf_putc(b, '\\');
-           wrbuf_putc(b, term[i]);
-       }
-       wrbuf_printf(b, "\" ");
+        wrbuf_putc(b, '"');
+        for (i = 0; i<len; i++)
+        {
+            if (term[i] == '"')
+                wrbuf_putc(b, '\\');
+            wrbuf_putc(b, term[i]);
+        }
+        wrbuf_printf(b, "\" ");
     }
 }
 
@@ -222,29 +222,29 @@ static void wrbuf_attr(WRBUF b, Z_AttributeElement *element)
     switch (element->which) 
     {
     case Z_AttributeValue_numeric:
-       wrbuf_printf(b,"@attr %s%s%d=%d ", setname, sep,
-                    *element->attributeType, *element->value.numeric);
-       break;
+        wrbuf_printf(b,"@attr %s%s%d=%d ", setname, sep,
+                     *element->attributeType, *element->value.numeric);
+        break;
     case Z_AttributeValue_complex:
-       wrbuf_printf(b,"@attr %s%s\"%d=", setname, sep,
-                    *element->attributeType);
-       for (i = 0; i<element->value.complex->num_list; i++)
-       {
-           if (i)
-               wrbuf_printf(b,",");
-           if (element->value.complex->list[i]->which ==
-               Z_StringOrNumeric_string)
-               wrbuf_printf (b, "%s",
-                             element->value.complex->list[i]->u.string);
-           else if (element->value.complex->list[i]->which ==
-                    Z_StringOrNumeric_numeric)
-               wrbuf_printf (b, "%d", 
-                             *element->value.complex->list[i]->u.numeric);
-       }
-       wrbuf_printf(b, "\" ");
-       break;
+        wrbuf_printf(b,"@attr %s%s\"%d=", setname, sep,
+                     *element->attributeType);
+        for (i = 0; i<element->value.complex->num_list; i++)
+        {
+            if (i)
+                wrbuf_printf(b,",");
+            if (element->value.complex->list[i]->which ==
+                Z_StringOrNumeric_string)
+                wrbuf_printf (b, "%s",
+                              element->value.complex->list[i]->u.string);
+            else if (element->value.complex->list[i]->which ==
+                     Z_StringOrNumeric_numeric)
+                wrbuf_printf (b, "%d", 
+                              *element->value.complex->list[i]->u.numeric);
+        }
+        wrbuf_printf(b, "\" ");
+        break;
     default:
-       wrbuf_printf (b, "@attr 1=unknown ");
+        wrbuf_printf (b, "@attr 1=unknown ");
     }
 }
 
@@ -260,40 +260,40 @@ static void zlog_attributes (Z_AttributesPlusTerm *t, int depth,
     
     for (of = 0; of < num_attributes; of++)
     {
-       const char *attset_name = "";
+        const char *attset_name = "";
         Z_AttributeElement *element;
-       element = t->attributes->attributes[of];
-       if (element->attributeSet)
-       {
-           oident *attrset;
-           attrset = oid_getentbyoid (element->attributeSet);
-           attset_name = attrset->desc;
-       }
+        element = t->attributes->attributes[of];
+        if (element->attributeSet)
+        {
+            oident *attrset;
+            attrset = oid_getentbyoid (element->attributeSet);
+            attset_name = attrset->desc;
+        }
         switch (element->which) 
         {
         case Z_AttributeValue_numeric:
-           attrStr (*element->attributeType,
-                    *element->value.numeric, ast, str);
+            attrStr (*element->attributeType,
+                     *element->value.numeric, ast, str);
             yaz_log (loglevel, "%*.0s%s %s", depth, "", attset_name, str);
             break;
         case Z_AttributeValue_complex:
             yaz_log (loglevel, "%*.0s%s attributeType=%d complex",
-                 depth, "", attset_name, *element->attributeType);
+                  depth, "", attset_name, *element->attributeType);
             for (i = 0; i<element->value.complex->num_list; i++)
             {
                 if (element->value.complex->list[i]->which ==
                     Z_StringOrNumeric_string)
                     yaz_log (loglevel, "%*.0s  string: '%s'", depth, "",
-                            element->value.complex->list[i]->u.string);
+                             element->value.complex->list[i]->u.string);
                 else if (element->value.complex->list[i]->which ==
                          Z_StringOrNumeric_numeric)
                     yaz_log (loglevel, "%*.0s  numeric: '%d'", depth, "",
-                            *element->value.complex->list[i]->u.numeric);
+                             *element->value.complex->list[i]->u.numeric);
             }
             break;
         default:
             yaz_log (loglevel, "%.*s%s attribute unknown",
-                    depth, "", attset_name);
+                     depth, "", attset_name);
         }
     }
 }
@@ -303,15 +303,15 @@ static char *complex_op_name(Z_Operator *op)
     switch (op->which)
     {
     case Z_Operator_and:
-       return "and";
+        return "and";
     case Z_Operator_or:
-       return "or";
+        return "or";
     case Z_Operator_and_not:
-       return "not";
+        return "not";
     case Z_Operator_prox:
-       return "prox";
+        return "prox";
     default:
-       return "unknown complex operator";
+        return "unknown complex operator";
     }
 }
 
@@ -349,7 +349,7 @@ static void zlog_structure (Z_RPNStructure *zs, int depth,
         case Z_Operator_and_not:
             yaz_log (loglevel, "%*.0s %s", depth, "", complex_op_name(op) );
             break;
-       case Z_Operator_prox:
+        case Z_Operator_prox:
             yaz_log (loglevel, "%*.0s prox excl=%s dist=%d order=%s "
                      "rel=%s unit=%s",
                      depth, "", op->u.prox->exclusion ?
@@ -358,7 +358,7 @@ static void zlog_structure (Z_RPNStructure *zs, int depth,
                      *op->u.prox->ordered ? "T" : "F",
                      relToStr(*op->u.prox->relationType),
                      prox_unit_name(op->u.prox) );
-           break;
+            break;
         default:
             yaz_log (loglevel, "%*.0s unknown complex", depth, "");
             return;
@@ -376,16 +376,16 @@ static void zlog_structure (Z_RPNStructure *zs, int depth,
             {
             case Z_Term_general:
                 yaz_log (loglevel, "%*.0s term '%.*s' (general)", depth, "",
-                        zapt->term->u.general->len,
-                        zapt->term->u.general->buf);
+                         zapt->term->u.general->len,
+                         zapt->term->u.general->buf);
                 break;
             case Z_Term_characterString:
                 yaz_log (loglevel, "%*.0s term '%s' (string)", depth, "",
-                        zapt->term->u.characterString);
+                         zapt->term->u.characterString);
                 break;
             case Z_Term_numeric:
                 yaz_log (loglevel, "%*.0s term '%d' (numeric)", depth, "",
-                        *zapt->term->u.numeric);
+                         *zapt->term->u.numeric);
                 break;
             case Z_Term_null:
                 yaz_log (loglevel, "%*.0s term (null)", depth, "");
@@ -398,7 +398,7 @@ static void zlog_structure (Z_RPNStructure *zs, int depth,
         else if (zs->u.simple->which == Z_Operand_resultSetId)
         {
             yaz_log (loglevel, "%*.0s set '%s'", depth, "",
-                    zs->u.simple->u.resultSetId);
+                     zs->u.simple->u.resultSetId);
         }
         else
             yaz_log (loglevel, "%*.0s unknown simple structure", depth, "");
@@ -412,27 +412,27 @@ static void wrbuf_apt(WRBUF b, Z_AttributesPlusTerm *zapt)
     int num_attributes = zapt->attributes->num_attributes;
     int i;
     for (i = 0; i<num_attributes; i++)
-       wrbuf_attr(b,zapt->attributes->attributes[i]);
+        wrbuf_attr(b,zapt->attributes->attributes[i]);
     
     switch (zapt->term->which)
     {
     case Z_Term_general:
-       wrbuf_term(b, zapt->term->u.general->buf,
-                  zapt->term->u.general->len);
-       break;
+        wrbuf_term(b, zapt->term->u.general->buf,
+                   zapt->term->u.general->len);
+        break;
     case Z_Term_characterString:
-       wrbuf_printf(b, "@term string ");
-       wrbuf_term (b, zapt->term->u.characterString,
-                   strlen(zapt->term->u.characterString));
-       break;
+        wrbuf_printf(b, "@term string ");
+        wrbuf_term (b, zapt->term->u.characterString,
+                    strlen(zapt->term->u.characterString));
+        break;
     case Z_Term_numeric:
-       wrbuf_printf(b, "@term numeric %d ", *zapt->term->u.numeric);
-       break;
+        wrbuf_printf(b, "@term numeric %d ", *zapt->term->u.numeric);
+        break;
     case Z_Term_null:
-       wrbuf_printf(b, "@term null x");
-       break;
+        wrbuf_printf(b, "@term null x");
+        break;
     default:
-       wrbuf_printf(b, "@term null unknown%d ", zapt->term->which);
+        wrbuf_printf(b, "@term null unknown%d ", zapt->term->which);
     }
 }
     
@@ -444,32 +444,32 @@ static void wrbuf_structure (WRBUF b, Z_RPNStructure *zs, enum oid_value ast)
         wrbuf_printf(b, "@%s ", complex_op_name(op) );
         if (op->which== Z_Operator_prox)
         {
-           if (!op->u.prox->exclusion)
-               wrbuf_putc(b, 'n');
-           else if (*op->u.prox->exclusion)
-               wrbuf_putc(b, '1');
-           else
-               wrbuf_putc(b, '0');
+            if (!op->u.prox->exclusion)
+                wrbuf_putc(b, 'n');
+            else if (*op->u.prox->exclusion)
+                wrbuf_putc(b, '1');
+            else
+                wrbuf_putc(b, '0');
 
-           wrbuf_printf(b, " %d %d %d ", *op->u.prox->distance,
-                        *op->u.prox->ordered,
-                        *op->u.prox->relationType);
+            wrbuf_printf(b, " %d %d %d ", *op->u.prox->distance,
+                         *op->u.prox->ordered,
+                         *op->u.prox->relationType);
 
-           switch(op->u.prox->which)
-           {
-           case Z_ProximityOperator_known:
-               wrbuf_putc(b, 'k');
-               break;
-           case Z_ProximityOperator_private:
-               wrbuf_putc(b, 'p');
-               break;
-           default:
-               wrbuf_printf(b, "%d", op->u.prox->which);
-           }
-           if (op->u.prox->u.known)
-               wrbuf_printf(b, " %d ", *op->u.prox->u.known);
-           else
-               wrbuf_printf(b, " 0 ");
+            switch(op->u.prox->which)
+            {
+            case Z_ProximityOperator_known:
+                wrbuf_putc(b, 'k');
+                break;
+            case Z_ProximityOperator_private:
+                wrbuf_putc(b, 'p');
+                break;
+            default:
+                wrbuf_printf(b, "%d", op->u.prox->which);
+            }
+            if (op->u.prox->u.known)
+                wrbuf_printf(b, " %d ", *op->u.prox->u.known);
+            else
+                wrbuf_printf(b, " 0 ");
         }
         wrbuf_structure (b,zs->u.complex->s1, ast);
         wrbuf_structure (b,zs->u.complex->s2, ast);
@@ -477,12 +477,12 @@ static void wrbuf_structure (WRBUF b, Z_RPNStructure *zs, enum oid_value ast)
     else if (zs->which == Z_RPNStructure_simple)
     {
         if (zs->u.simple->which == Z_Operand_APT)
-           wrbuf_apt(b, zs->u.simple->u.attributesPlusTerm);
+            wrbuf_apt(b, zs->u.simple->u.attributesPlusTerm);
         else if (zs->u.simple->which == Z_Operand_resultSetId)
         {
             wrbuf_printf(b, "@set ");
-           wrbuf_term(b, zs->u.simple->u.resultSetId,
-                      strlen(zs->u.simple->u.resultSetId));
+            wrbuf_term(b, zs->u.simple->u.resultSetId,
+                       strlen(zs->u.simple->u.resultSetId));
         }
         else
             wrbuf_printf (b, "(unknown simple structure)");
@@ -500,12 +500,12 @@ void log_rpn_query_level (int loglevel, Z_RPNQuery *rpn)
     if (attrset)
     {
         ast = attrset->value;
-       yaz_log (loglevel, "RPN query. Type: %s", attrset->desc);
+        yaz_log (loglevel, "RPN query. Type: %s", attrset->desc);
     } 
     else
     {
-       ast = VAL_NONE;
-       yaz_log (loglevel, "RPN query. Unknown type");
+        ast = VAL_NONE;
+        yaz_log (loglevel, "RPN query. Unknown type");
     }
     zlog_structure (rpn->RPNStructure, 0, ast, loglevel);
 }
@@ -519,12 +519,12 @@ static void wrbuf_rpn_query(WRBUF b, Z_RPNQuery *rpn)
     if (attrset)
     {
         ast = attrset->value;
-       wrbuf_printf(b, " @attrset %s ", attrset->desc);
+        wrbuf_printf(b, " @attrset %s ", attrset->desc);
     } 
     else
     {
-       ast = VAL_NONE;
-       wrbuf_printf (b, "Unknown:");
+        ast = VAL_NONE;
+        wrbuf_printf (b, "Unknown:");
     }
     wrbuf_structure (b,rpn->RPNStructure, ast);
 
@@ -543,11 +543,11 @@ void log_scan_term_level (int loglevel,
         return;
     if (zapt->term->which == Z_Term_general) 
     {
-       yaz_log (loglevel, "%*.0s term '%.*s' (general)", depth, "",
-                zapt->term->u.general->len, zapt->term->u.general->buf);
+        yaz_log (loglevel, "%*.0s term '%.*s' (general)", depth, "",
+                 zapt->term->u.general->len, zapt->term->u.general->buf);
     }
     else
-       yaz_log (loglevel, "%*.0s term (not general)", depth, "");
+        yaz_log (loglevel, "%*.0s term (not general)", depth, "");
     zlog_attributes (zapt, depth+2, ast, loglevel);
 }
 
@@ -568,15 +568,15 @@ void yaz_log_zquery_level (int loglevel, Z_Query *q)
     switch (q->which)
     {
     case Z_Query_type_1: case Z_Query_type_101:
-       log_rpn_query_level (loglevel, q->u.type_1);
+        log_rpn_query_level (loglevel, q->u.type_1);
         break;
     case Z_Query_type_2:
-       yaz_log(loglevel, "CCL: %.*s", q->u.type_2->len, q->u.type_2->buf);
-       break;
+        yaz_log(loglevel, "CCL: %.*s", q->u.type_2->len, q->u.type_2->buf);
+        break;
     case Z_Query_type_100:
-       yaz_log(loglevel, "Z39.58: %.*s", q->u.type_100->len,
-               q->u.type_100->buf);
-       break;
+        yaz_log(loglevel, "Z39.58: %.*s", q->u.type_100->len,
+                q->u.type_100->buf);
+        break;
     case Z_Query_type_104:
         if (q->u.type_104->which == Z_External_CQL)
             yaz_log (loglevel, "CQL: %s", q->u.type_104->u.cql);
@@ -596,21 +596,21 @@ void wrbuf_put_zquery(WRBUF b, Z_Query *q)
     {
     case Z_Query_type_1: 
     case Z_Query_type_101:
-       wrbuf_printf(b,"RPN:");
-       wrbuf_rpn_query(b,q->u.type_1);
-       break;
+        wrbuf_printf(b,"RPN:");
+        wrbuf_rpn_query(b,q->u.type_1);
+        break;
     case Z_Query_type_2:
-       wrbuf_printf(b, "CCL: %.*s", q->u.type_2->len, q->u.type_2->buf);
-       break;
+        wrbuf_printf(b, "CCL: %.*s", q->u.type_2->len, q->u.type_2->buf);
+        break;
     case Z_Query_type_100:
-       wrbuf_printf(b, "Z39.58: %.*s", q->u.type_100->len,
-                    q->u.type_100->buf);
-       break;
+        wrbuf_printf(b, "Z39.58: %.*s", q->u.type_100->len,
+                     q->u.type_100->buf);
+        break;
     case Z_Query_type_104:
-       if (q->u.type_104->which == Z_External_CQL)
-           wrbuf_printf(b, "CQL: %s", q->u.type_104->u.cql);
-       else
-           wrbuf_printf(b,"Unknown type 104 query %d", q->u.type_104->which);
+        if (q->u.type_104->which == Z_External_CQL)
+            wrbuf_printf(b, "CQL: %s", q->u.type_104->u.cql);
+        else
+            wrbuf_printf(b,"Unknown type 104 query %d", q->u.type_104->which);
     }
 }
 
@@ -633,3 +633,11 @@ void wrbuf_diags(WRBUF b, int num_diagnostics,Z_DiagRec **diags)
             wrbuf_printf(b,"%s ",e->u.v3Addinfo);
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 69f33d1..514d8e4 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: marcdisp.c,v 1.22 2005-06-07 19:25:38 adam Exp $
+ * $Id: marcdisp.c,v 1.23 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -65,17 +65,17 @@ void yaz_marc_destroy(yaz_marc_t mt)
 static void marc_cdata (yaz_marc_t mt, const char *buf, size_t len, WRBUF wr)
 {
     if (mt->xml == YAZ_MARC_ISO2709)
-       wrbuf_iconv_write(wr, mt->iconv_cd, buf, len);
+        wrbuf_iconv_write(wr, mt->iconv_cd, buf, len);
     else if (mt->xml == YAZ_MARC_LINE)
-       wrbuf_iconv_write(wr, mt->iconv_cd, buf, len);
+        wrbuf_iconv_write(wr, mt->iconv_cd, buf, len);
     else
-       wrbuf_iconv_write_cdata(wr, mt->iconv_cd, buf, len);
+        wrbuf_iconv_write_cdata(wr, mt->iconv_cd, buf, len);
 }
 
 static int atoi_n_check(const char *buf, int size, int *val)
 {
     if (!isdigit(*(const unsigned char *) buf))
-       return 0;
+        return 0;
     *val = atoi_n(buf, size);
     return 1;
 }
@@ -95,64 +95,64 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
     int produce_warnings = 0;
 
     if (mt->debug)
-       produce_warnings = 1;
+        produce_warnings = 1;
     if (mt->xml == YAZ_MARC_SIMPLEXML || mt->xml == YAZ_MARC_OAIMARC
-       || mt->xml == YAZ_MARC_MARCXML || mt->xml == YAZ_MARC_XCHANGE)
-       produce_warnings = 1;
+        || mt->xml == YAZ_MARC_MARCXML || mt->xml == YAZ_MARC_XCHANGE)
+        produce_warnings = 1;
 
     record_length = atoi_n (buf, 5);
     if (record_length < 25)
     {
-       if (mt->debug)
-           wrbuf_printf(wr, "<!-- Record length %d - aborting -->\n",
-                           record_length);
+        if (mt->debug)
+            wrbuf_printf(wr, "<!-- Record length %d - aborting -->\n",
+                            record_length);
         return -1;
     }
     memcpy(lead, buf, 24);  /* se can modify the header for output */
 
     /* ballout if bsize is known and record_length is less than that */
     if (bsize != -1 && record_length > bsize)
-       return -1;
+        return -1;
     if (!atoi_n_check(buf+10, 1, &indicator_length))
     {
-       if (produce_warnings)
-           wrbuf_printf(wr, "<!-- Indicator length at offset 10 should hold a digit. Assuming 2 -->\n");
-       lead[10] = '2';
-       indicator_length = 2;
+        if (produce_warnings)
+            wrbuf_printf(wr, "<!-- Indicator length at offset 10 should hold a digit. Assuming 2 -->\n");
+        lead[10] = '2';
+        indicator_length = 2;
     }
     if (!atoi_n_check(buf+11, 1, &identifier_length))
     {
-       if (produce_warnings)
-           wrbuf_printf(wr, "<!-- Identifier length at offset 11 should hold a digit. Assuming 2 -->\n");
-       lead[11] = '2';
+        if (produce_warnings)
+            wrbuf_printf(wr, "<!-- Identifier length at offset 11 should hold a digit. Assuming 2 -->\n");
+        lead[11] = '2';
         identifier_length = 2;
     }
     if (!atoi_n_check(buf+12, 5, &base_address))
     {
-       if (produce_warnings)
-           wrbuf_printf(wr, "<!-- Base address at offsets 12..16 should hold a number. Assuming 0 -->\n");
-       base_address = 0;
+        if (produce_warnings)
+            wrbuf_printf(wr, "<!-- Base address at offsets 12..16 should hold a number. Assuming 0 -->\n");
+        base_address = 0;
     }
     if (!atoi_n_check(buf+20, 1, &length_data_entry))
     {
-       if (produce_warnings)
-           wrbuf_printf(wr, "<!-- Length data entry at offset 20 should hold a digit. Assuming 4 -->\n");
+        if (produce_warnings)
+            wrbuf_printf(wr, "<!-- Length data entry at offset 20 should hold a digit. Assuming 4 -->\n");
         length_data_entry = 4;
-       lead[20] = '4';
+        lead[20] = '4';
     }
     if (!atoi_n_check(buf+21, 1, &length_starting))
     {
-       if (produce_warnings)
-           wrbuf_printf(wr, "<!-- Length starting at offset 21 should hold a digit. Assuming 5 -->\n");
+        if (produce_warnings)
+            wrbuf_printf(wr, "<!-- Length starting at offset 21 should hold a digit. Assuming 5 -->\n");
         length_starting = 5;
-       lead[21] = '5';
+        lead[21] = '5';
     }
     if (!atoi_n_check(buf+22, 1, &length_implementation))
     {
-       if (produce_warnings)
-           wrbuf_printf(wr, "<!-- Length implementation at offset 22 should hold a digit. Assuming 0 -->\n");
-       length_implementation = 0;
-       lead[22] = '0';
+        if (produce_warnings)
+            wrbuf_printf(wr, "<!-- Length implementation at offset 22 should hold a digit. Assuming 0 -->\n");
+        length_implementation = 0;
+        lead[22] = '0';
     }
 
     if (mt->xml != YAZ_MARC_LINE)
@@ -161,8 +161,8 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
         int i;
         switch(mt->xml)
         {
-       case YAZ_MARC_ISO2709:
-           break;
+        case YAZ_MARC_ISO2709:
+            break;
         case YAZ_MARC_SIMPLEXML:
             wrbuf_puts (wr, "<iso2709\n");
             sprintf (str, " RecordStatus=\"%c\"\n", buf[5]);
@@ -196,184 +196,184 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
                 wr,
                 "<record xmlns=\"http://www.loc.gov/MARC21/slim\">\n"
                 "  <leader>");
-           lead[9] = 'a';                 /* set leader to signal unicode */
-           marc_cdata(mt, lead, 24, wr); 
+            lead[9] = 'a';                 /* set leader to signal unicode */
+            marc_cdata(mt, lead, 24, wr); 
             wrbuf_printf(wr, "</leader>\n");
             break;
-       case YAZ_MARC_XCHANGE:
+        case YAZ_MARC_XCHANGE:
             wrbuf_printf(
                 wr,
                 "<record xmlns=\"http://www.bs.dk/standards/MarcXchange\">\n"
                 "  <leader>");
-           marc_cdata(mt, lead, 24, wr);
+            marc_cdata(mt, lead, 24, wr);
             wrbuf_printf(wr, "</leader>\n");
             break;
         }
     }
     if (mt->debug)
     {
-       char str[40];
-
-       wrbuf_puts (wr, "<!--\n");
-       sprintf (str, "Record length         %5d\n", record_length);
-       wrbuf_puts (wr, str);
-       sprintf (str, "Indicator length      %5d\n", indicator_length);
-       wrbuf_puts (wr, str);
-       sprintf (str, "Identifier length     %5d\n", identifier_length);
-       wrbuf_puts (wr, str);
-       sprintf (str, "Base address          %5d\n", base_address);
-       wrbuf_puts (wr, str);
-       sprintf (str, "Length data entry     %5d\n", length_data_entry);
-       wrbuf_puts (wr, str);
-       sprintf (str, "Length starting       %5d\n", length_starting);
-       wrbuf_puts (wr, str);
-       sprintf (str, "Length implementation %5d\n", length_implementation);
-       wrbuf_puts (wr, str);
-       wrbuf_puts (wr, "-->\n");
+        char str[40];
+
+        wrbuf_puts (wr, "<!--\n");
+        sprintf (str, "Record length         %5d\n", record_length);
+        wrbuf_puts (wr, str);
+        sprintf (str, "Indicator length      %5d\n", indicator_length);
+        wrbuf_puts (wr, str);
+        sprintf (str, "Identifier length     %5d\n", identifier_length);
+        wrbuf_puts (wr, str);
+        sprintf (str, "Base address          %5d\n", base_address);
+        wrbuf_puts (wr, str);
+        sprintf (str, "Length data entry     %5d\n", length_data_entry);
+        wrbuf_puts (wr, str);
+        sprintf (str, "Length starting       %5d\n", length_starting);
+        wrbuf_puts (wr, str);
+        sprintf (str, "Length implementation %5d\n", length_implementation);
+        wrbuf_puts (wr, str);
+        wrbuf_puts (wr, "-->\n");
     }
 
     /* first pass. determine length of directory & base of data */
     for (entry_p = 24; buf[entry_p] != ISO2709_FS; )
     {
-       /* length of directory entry */
-       int l = 3 + length_data_entry + length_starting;
-       if (entry_p + l >= record_length)
-       {
-           wrbuf_printf (wr, "<!-- Directory offset %d: end of record. "
-                           "Missing FS char -->\n", entry_p);
+        /* length of directory entry */
+        int l = 3 + length_data_entry + length_starting;
+        if (entry_p + l >= record_length)
+        {
+            wrbuf_printf (wr, "<!-- Directory offset %d: end of record. "
+                            "Missing FS char -->\n", entry_p);
             return -1;
-       }
+        }
         if (mt->debug)
-           wrbuf_printf (wr, "<!-- Directory offset %d: Tag %.3s -->\n",
-                           entry_p, buf+entry_p);
-       /* check for digits in length info */
-       while (--l >= 3)
+            wrbuf_printf (wr, "<!-- Directory offset %d: Tag %.3s -->\n",
+                            entry_p, buf+entry_p);
+        /* check for digits in length info */
+        while (--l >= 3)
             if (!isdigit(*(const unsigned char *) (buf + entry_p+l)))
-               break;
+                break;
         if (l >= 3)
-       {
-           /* not all digits, so stop directory scan */
-           wrbuf_printf (wr, "<!-- Directory offset %d: Bad data for data "
-                           "length and/or length starting -->\n", entry_p);
-           break;
-       }
+        {
+            /* not all digits, so stop directory scan */
+            wrbuf_printf (wr, "<!-- Directory offset %d: Bad data for data "
+                            "length and/or length starting -->\n", entry_p);
+            break;
+        }
         entry_p += 3 + length_data_entry + length_starting;
     }
     end_of_directory = entry_p;
     if (base_address != entry_p+1)
     {
-       if (produce_warnings)
-           wrbuf_printf (wr,"<!-- Base address not at end of directory, "
-                         "base %d, end %d -->\n", base_address, entry_p+1);
+        if (produce_warnings)
+            wrbuf_printf (wr,"<!-- Base address not at end of directory, "
+                          "base %d, end %d -->\n", base_address, entry_p+1);
     }
     if (mt->xml == YAZ_MARC_ISO2709)
     {
-       WRBUF wr_head = wrbuf_alloc();
-       WRBUF wr_dir = wrbuf_alloc();
-       WRBUF wr_tmp = wrbuf_alloc();
-
-       int data_p = 0;
-       /* second pass. create directory for ISO2709 output */
-       for (entry_p = 24; entry_p != end_of_directory; )
-       {
-           int data_length, data_offset, end_offset;
-           int i, sz1, sz2;
-           
-           wrbuf_write(wr_dir, buf+entry_p, 3);
-           entry_p += 3;
-           
-           data_length = atoi_n (buf+entry_p, length_data_entry);
-           entry_p += length_data_entry;
-           data_offset = atoi_n (buf+entry_p, length_starting);
-           entry_p += length_starting;
-           i = data_offset + base_address;
-           end_offset = i+data_length-1;
-           
-           if (data_length <= 0 || data_offset < 0 || end_offset >= record_length)
-               return -1;
+        WRBUF wr_head = wrbuf_alloc();
+        WRBUF wr_dir = wrbuf_alloc();
+        WRBUF wr_tmp = wrbuf_alloc();
+
+        int data_p = 0;
+        /* second pass. create directory for ISO2709 output */
+        for (entry_p = 24; entry_p != end_of_directory; )
+        {
+            int data_length, data_offset, end_offset;
+            int i, sz1, sz2;
+            
+            wrbuf_write(wr_dir, buf+entry_p, 3);
+            entry_p += 3;
+            
+            data_length = atoi_n (buf+entry_p, length_data_entry);
+            entry_p += length_data_entry;
+            data_offset = atoi_n (buf+entry_p, length_starting);
+            entry_p += length_starting;
+            i = data_offset + base_address;
+            end_offset = i+data_length-1;
+            
+            if (data_length <= 0 || data_offset < 0 || end_offset >= record_length)
+                return -1;
         
-           while (i < end_offset &&
-                   buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
-               i++;
-           sz1 = 1+i - (data_offset + base_address);
-           if (mt->iconv_cd)
-           {
-               sz2 = wrbuf_iconv_write(wr_tmp, mt->iconv_cd,
-                                       buf + data_offset+base_address, sz1);
-               wrbuf_rewind(wr_tmp);
-           }
-           else
-               sz2 = sz1;
-           wrbuf_printf(wr_dir, "%0*d", length_data_entry, sz2);
-           wrbuf_printf(wr_dir, "%0*d", length_starting, data_p);
-           data_p += sz2;
-       }
-       wrbuf_putc(wr_dir, ISO2709_FS);
-       wrbuf_printf(wr_head, "%05d", data_p+1 + base_address);
-       wrbuf_write(wr_head, lead+5, 7);
-       wrbuf_printf(wr_head, "%05d", base_address);
-       wrbuf_write(wr_head, lead+17, 7);
-
-       wrbuf_write(wr, wrbuf_buf(wr_head), 24);
-       wrbuf_write(wr, wrbuf_buf(wr_dir), wrbuf_len(wr_dir));
-       wrbuf_free(wr_head, 1);
-       wrbuf_free(wr_dir, 1);
-       wrbuf_free(wr_tmp, 1);
+            while (i < end_offset &&
+                    buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
+                i++;
+            sz1 = 1+i - (data_offset + base_address);
+            if (mt->iconv_cd)
+            {
+                sz2 = wrbuf_iconv_write(wr_tmp, mt->iconv_cd,
+                                        buf + data_offset+base_address, sz1);
+                wrbuf_rewind(wr_tmp);
+            }
+            else
+                sz2 = sz1;
+            wrbuf_printf(wr_dir, "%0*d", length_data_entry, sz2);
+            wrbuf_printf(wr_dir, "%0*d", length_starting, data_p);
+            data_p += sz2;
+        }
+        wrbuf_putc(wr_dir, ISO2709_FS);
+        wrbuf_printf(wr_head, "%05d", data_p+1 + base_address);
+        wrbuf_write(wr_head, lead+5, 7);
+        wrbuf_printf(wr_head, "%05d", base_address);
+        wrbuf_write(wr_head, lead+17, 7);
+
+        wrbuf_write(wr, wrbuf_buf(wr_head), 24);
+        wrbuf_write(wr, wrbuf_buf(wr_dir), wrbuf_len(wr_dir));
+        wrbuf_free(wr_head, 1);
+        wrbuf_free(wr_dir, 1);
+        wrbuf_free(wr_tmp, 1);
     }
     /* third pass. create data output */
     for (entry_p = 24; entry_p != end_of_directory; )
     {
         int data_length;
-       int data_offset;
-       int end_offset;
-       int i, j;
-       char tag[4];
+        int data_offset;
+        int end_offset;
+        int i, j;
+        char tag[4];
         int identifier_flag = 0;
-       int entry_p0 = entry_p;
+        int entry_p0 = entry_p;
 
         memcpy (tag, buf+entry_p, 3);
-       entry_p += 3;
+        entry_p += 3;
         tag[3] = '\0';
-       data_length = atoi_n (buf+entry_p, length_data_entry);
-       entry_p += length_data_entry;
-       data_offset = atoi_n (buf+entry_p, length_starting);
-       entry_p += length_starting;
-       i = data_offset + base_address;
-       end_offset = i+data_length-1;
-
-       if (data_length <= 0 || data_offset < 0)
-           break;
+        data_length = atoi_n (buf+entry_p, length_data_entry);
+        entry_p += length_data_entry;
+        data_offset = atoi_n (buf+entry_p, length_starting);
+        entry_p += length_starting;
+        i = data_offset + base_address;
+        end_offset = i+data_length-1;
+
+        if (data_length <= 0 || data_offset < 0)
+            break;
         
-       if (mt->debug)
-       {
-           wrbuf_printf(wr, "<!-- Directory offset %d: data-length %d, "
-                           "data-offset %d -->\n",
-                   entry_p0, data_length, data_offset);
-       }
-       if (end_offset >= record_length)
-       {
-           wrbuf_printf (wr,"<!-- Directory offset %d: Data out of bounds "
-                           "%d >= %d -->\n",
-                                  entry_p0, end_offset, record_length);
-           break;
-       }
+        if (mt->debug)
+        {
+            wrbuf_printf(wr, "<!-- Directory offset %d: data-length %d, "
+                            "data-offset %d -->\n",
+                    entry_p0, data_length, data_offset);
+        }
+        if (end_offset >= record_length)
+        {
+            wrbuf_printf (wr,"<!-- Directory offset %d: Data out of bounds "
+                            "%d >= %d -->\n",
+                                   entry_p0, end_offset, record_length);
+            break;
+        }
         
         if (memcmp (tag, "00", 2))
             identifier_flag = 1;  /* if not 00X assume subfields */
         else if (indicator_length < 4 && indicator_length > 0)
         {
-           /* Danmarc 00X have subfields */
-           if (buf[i + indicator_length] == ISO2709_IDFS)
-               identifier_flag = 1;
-           else if (buf[i + indicator_length + 1] == ISO2709_IDFS)
-               identifier_flag = 2;
+            /* Danmarc 00X have subfields */
+            if (buf[i + indicator_length] == ISO2709_IDFS)
+                identifier_flag = 1;
+            else if (buf[i + indicator_length + 1] == ISO2709_IDFS)
+                identifier_flag = 2;
         }
 
-       if (mt->debug)
-       {
-           wrbuf_printf(wr, "<!-- identifier_flag = %d -->\n",
-                        identifier_flag);
-       } 
+        if (mt->debug)
+        {
+            wrbuf_printf(wr, "<!-- identifier_flag = %d -->\n",
+                         identifier_flag);
+        } 
        
         switch(mt->xml)
         {
@@ -383,16 +383,16 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
             break;
         case YAZ_MARC_SIMPLEXML:
             wrbuf_printf (wr, "<field tag=\"");
-           marc_cdata(mt, tag, strlen(tag), wr);
-           wrbuf_printf(wr, "\"");
+            marc_cdata(mt, tag, strlen(tag), wr);
+            wrbuf_printf(wr, "\"");
             break;
         case YAZ_MARC_OAIMARC:
             if (identifier_flag)
                 wrbuf_printf (wr, "  <varfield id=\"");
             else
                 wrbuf_printf (wr, "  <fixfield id=\"");
-           marc_cdata(mt, tag, strlen(tag), wr);
-           wrbuf_printf(wr, "\"");
+            marc_cdata(mt, tag, strlen(tag), wr);
+            wrbuf_printf(wr, "\"");
             break;
         case YAZ_MARC_MARCXML:
         case YAZ_MARC_XCHANGE:
@@ -400,43 +400,43 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
                 wrbuf_printf (wr, "  <datafield tag=\"");
             else
                 wrbuf_printf (wr, "  <controlfield tag=\"");
-           marc_cdata(mt, tag, strlen(tag), wr);
-           wrbuf_printf(wr, "\"");
+            marc_cdata(mt, tag, strlen(tag), wr);
+            wrbuf_printf(wr, "\"");
         }
         
         if (identifier_flag)
-       {
-           i += identifier_flag-1;
+        {
+            i += identifier_flag-1;
             for (j = 0; j<indicator_length; j++, i++)
             {
                 switch(mt->xml)
                 {
-               case YAZ_MARC_ISO2709:
-                   wrbuf_putc(wr, buf[i]);
-                   break;
+                case YAZ_MARC_ISO2709:
+                    wrbuf_putc(wr, buf[i]);
+                    break;
                 case YAZ_MARC_LINE:
                     wrbuf_putc(wr, buf[i]);
                     break;
                 case YAZ_MARC_SIMPLEXML:
                     wrbuf_printf(wr, " Indicator%d=\"", j+1);
-                   marc_cdata(mt, buf+i, 1, wr);
+                    marc_cdata(mt, buf+i, 1, wr);
                     wrbuf_printf(wr, "\"");
                     break;
                 case YAZ_MARC_OAIMARC:
                     wrbuf_printf(wr, " i%d=\"", j+1);
-                   marc_cdata(mt, buf+i, 1, wr);
+                    marc_cdata(mt, buf+i, 1, wr);
                     wrbuf_printf(wr, "\"");
                     break;
                 case YAZ_MARC_MARCXML:
                 case YAZ_MARC_XCHANGE:
                     wrbuf_printf(wr, " ind%d=\"", j+1);
-                   marc_cdata(mt, buf+i, 1, wr);
+                    marc_cdata(mt, buf+i, 1, wr);
                     wrbuf_printf(wr, "\"");
                 }
             }
-       }
+        }
         if (mt->xml == YAZ_MARC_SIMPLEXML || mt->xml == YAZ_MARC_MARCXML
-           || mt->xml == YAZ_MARC_OAIMARC || mt->xml == YAZ_MARC_XCHANGE)
+            || mt->xml == YAZ_MARC_OAIMARC || mt->xml == YAZ_MARC_XCHANGE)
         {
             wrbuf_puts (wr, ">");
             if (identifier_flag)
@@ -445,58 +445,58 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
         if (identifier_flag)
         {
             while (i < end_offset &&
-                   buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
+                    buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
             {
                 int i0;
                 i++;
                 switch(mt->xml)
                 {
-               case YAZ_MARC_ISO2709:
-                   --i;
-                   wrbuf_iconv_write(wr, mt->iconv_cd, 
-                                     buf+i, identifier_length);
-                   i += identifier_length;
-                   break;
+                case YAZ_MARC_ISO2709:
+                    --i;
+                    wrbuf_iconv_write(wr, mt->iconv_cd, 
+                                      buf+i, identifier_length);
+                    i += identifier_length;
+                    break;
                 case YAZ_MARC_LINE: 
                     wrbuf_puts (wr, mt->subfield_str); 
-                   marc_cdata(mt, buf+i, identifier_length-1, wr);
-                   i = i+identifier_length-1;
+                    marc_cdata(mt, buf+i, identifier_length-1, wr);
+                    i = i+identifier_length-1;
                     wrbuf_putc (wr, ' ');
                     break;
                 case YAZ_MARC_SIMPLEXML:
                     wrbuf_puts (wr, "  <subfield code=\"");
-                   marc_cdata(mt, buf+i, identifier_length-1, wr);
-                   i = i+identifier_length-1;
+                    marc_cdata(mt, buf+i, identifier_length-1, wr);
+                    i = i+identifier_length-1;
                     wrbuf_puts (wr, "\">");
                     break;
                 case YAZ_MARC_OAIMARC:
                     wrbuf_puts (wr, "    <subfield label=\"");
-                   marc_cdata(mt, buf+i, identifier_length-1, wr);
-                   i = i+identifier_length-1;
+                    marc_cdata(mt, buf+i, identifier_length-1, wr);
+                    i = i+identifier_length-1;
                     wrbuf_puts (wr, "\">");
                     break;
                 case YAZ_MARC_MARCXML:
                 case YAZ_MARC_XCHANGE:
                     wrbuf_puts (wr, "    <subfield code=\"");
-                   marc_cdata(mt, buf+i, identifier_length-1, wr);
-                   i = i+identifier_length-1;
+                    marc_cdata(mt, buf+i, identifier_length-1, wr);
+                    i = i+identifier_length-1;
                     wrbuf_puts (wr, "\">");
                     break;
                 }
                 i0 = i;
                 while (i < end_offset &&
-                       buf[i] != ISO2709_RS && buf[i] != ISO2709_IDFS &&
+                        buf[i] != ISO2709_RS && buf[i] != ISO2709_IDFS &&
                         buf[i] != ISO2709_FS)
                     i++;
                 marc_cdata(mt, buf + i0, i - i0, wr);
 
-               if (mt->xml == YAZ_MARC_ISO2709 && buf[i] != ISO2709_IDFS)
-                   marc_cdata(mt, buf + i, 1, wr);
+                if (mt->xml == YAZ_MARC_ISO2709 && buf[i] != ISO2709_IDFS)
+                    marc_cdata(mt, buf + i, 1, wr);
 
-               if (mt->xml == YAZ_MARC_SIMPLEXML || 
-                   mt->xml == YAZ_MARC_MARCXML ||
-                   mt->xml == YAZ_MARC_XCHANGE ||
-                   mt->xml == YAZ_MARC_OAIMARC)
+                if (mt->xml == YAZ_MARC_SIMPLEXML || 
+                    mt->xml == YAZ_MARC_MARCXML ||
+                    mt->xml == YAZ_MARC_XCHANGE ||
+                    mt->xml == YAZ_MARC_OAIMARC)
                     wrbuf_puts (wr, "</subfield>\n");
             }
         }
@@ -504,18 +504,18 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
         {
             int i0 = i;
             while (i < end_offset && 
-               buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
+                buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
                 i++;
-           marc_cdata(mt, buf + i0, i - i0, wr);
-           if (mt->xml == YAZ_MARC_ISO2709)
-               marc_cdata(mt, buf + i, 1, wr);
-       }
+            marc_cdata(mt, buf + i0, i - i0, wr);
+            if (mt->xml == YAZ_MARC_ISO2709)
+                marc_cdata(mt, buf + i, 1, wr);
+        }
         if (mt->xml == YAZ_MARC_LINE)
             wrbuf_puts (wr, mt->endline_str);
-       if (i < end_offset)
-           wrbuf_printf(wr, "<!-- separator but not at end of field length=%d-->\n", data_length);
-       if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
-           wrbuf_printf(wr, "<!-- no separator at end of field length=%d-->\n", data_length);
+        if (i < end_offset)
+            wrbuf_printf(wr, "<!-- separator but not at end of field length=%d-->\n", data_length);
+        if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
+            wrbuf_printf(wr, "<!-- no separator at end of field length=%d-->\n", data_length);
         switch(mt->xml)
         {
         case YAZ_MARC_SIMPLEXML:
@@ -552,8 +552,8 @@ int yaz_marc_decode_wrbuf (yaz_marc_t mt, const char *buf, int bsize, WRBUF wr)
         wrbuf_puts (wr, "</record>\n");
         break;
     case YAZ_MARC_ISO2709:
-       wrbuf_putc (wr, ISO2709_RS);
-       break;
+        wrbuf_putc (wr, ISO2709_RS);
+        break;
     }
     return record_length;
 }
@@ -617,9 +617,9 @@ int marc_display_exl (const char *buf, FILE *outf, int debug, int bsize)
     mt->debug = debug;
     r = yaz_marc_decode_wrbuf (mt, buf, bsize, mt->m_wr);
     if (!outf)
-       outf = stdout;
+        outf = stdout;
     if (r > 0)
-       fwrite (wrbuf_buf(mt->m_wr), 1, wrbuf_len(mt->m_wr), outf);
+        fwrite (wrbuf_buf(mt->m_wr), 1, wrbuf_len(mt->m_wr), outf);
     yaz_marc_destroy(mt);
     return r;
 }
@@ -636,3 +636,11 @@ int marc_display (const char *buf, FILE *outf)
     return marc_display_ex (buf, outf, 0);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index efbc7ef..b3faae7 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: matchstr.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: matchstr.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -30,28 +30,28 @@ int yaz_matchstr(const char *s1, const char *s2)
 {
     while (*s1 && *s2)
     {
-       unsigned char c1 = *s1;
-       unsigned char c2 = *s2;
+        unsigned char c1 = *s1;
+        unsigned char c2 = *s2;
 
         if (c2 == '?')
             return 0;
-       if (c1 == '-')
-           c1 = *++s1;
-       if (c2 == '-')
-           c2 = *++s2;
-       if (!c1 || !c2)
-           break;
+        if (c1 == '-')
+            c1 = *++s1;
+        if (c2 == '-')
+            c2 = *++s2;
+        if (!c1 || !c2)
+            break;
         if (c2 != '.')
         {
-           if (isupper(c1))
-               c1 = tolower(c1);
-           if (isupper(c2))
-               c2 = tolower(c2);
-           if (c1 != c2)
-               break;
+            if (isupper(c1))
+                c1 = tolower(c1);
+            if (isupper(c2))
+                c2 = tolower(c2);
+            if (c1 != c2)
+                break;
         }
-       s1++;
-       s2++;
+        s1++;
+        s2++;
     }
     return *s1 || *s2;
 }
@@ -81,3 +81,11 @@ void __assert_fail (const char *assertion, const char *file,
 }
 #endif
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 484836c..6fb23fd 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: nmem.c,v 1.18 2005-06-07 19:47:31 adam Exp $
+ * $Id: nmem.c,v 1.19 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -61,15 +61,15 @@ struct nmem_control
 struct align {
     char x;
     union {
-       char c;
-       short s;
-       int i;
-       long l;
+        char c;
+        short s;
+        int i;
+        long l;
 #if HAVE_LONG_LONG
-       long long ll;
+        long long ll;
 #endif
-       float f;
-       double d;
+        float f;
+        double d;
     } u;
 };
 
@@ -111,11 +111,11 @@ YAZ_EXPORT void nmem_mutex_create(NMEM_MUTEX *p)
 {
     if (!*p)
     {
-       *p = (NMEM_MUTEX) malloc (sizeof(**p));
+        *p = (NMEM_MUTEX) malloc (sizeof(**p));
 #ifdef WIN32
-       InitializeCriticalSection(&(*p)->m_handle);
+        InitializeCriticalSection(&(*p)->m_handle);
 #elif YAZ_POSIX_THREADS
-       pthread_mutex_init (&(*p)->m_handle, 0);
+        pthread_mutex_init (&(*p)->m_handle, 0);
 #elif YAZ_GNU_THREADS
         pth_mutex_init (&(*p)->m_handle);
 #endif
@@ -133,9 +133,9 @@ YAZ_EXPORT void nmem_mutex_enter(NMEM_MUTEX p)
     if (p)
     {
 #ifdef WIN32
-       EnterCriticalSection(&p->m_handle);
+        EnterCriticalSection(&p->m_handle);
 #elif YAZ_POSIX_THREADS
-       pthread_mutex_lock(&p->m_handle);
+        pthread_mutex_lock(&p->m_handle);
 #endif
     }
 }
@@ -145,9 +145,9 @@ YAZ_EXPORT void nmem_mutex_leave(NMEM_MUTEX p)
     if (p)
     {
 #ifdef WIN32
-       LeaveCriticalSection(&p->m_handle);
+        LeaveCriticalSection(&p->m_handle);
 #elif YAZ_POSIX_THREADS
-       pthread_mutex_unlock(&p->m_handle);
+        pthread_mutex_unlock(&p->m_handle);
 #endif
     }
 }
@@ -157,10 +157,10 @@ YAZ_EXPORT void nmem_mutex_destroy(NMEM_MUTEX *p)
     if (*p)
     {
 #ifdef WIN32
-       DeleteCriticalSection(&(*p)->m_handle);
+        DeleteCriticalSection(&(*p)->m_handle);
 #endif
-       free (*p);
-       *p = 0;
+        free (*p);
+        *p = 0;
     }
 }
 
@@ -203,8 +203,8 @@ void nmem_print_list_l (int level)
     yaz_log (level, "nmem print list");
     NMEM_ENTER;
     for (p = nmem_debug_list; p; p = p->next)
-       yaz_log (level, " %s:%d p=%p size=%d", p->file, p->line, p->p,
-                nmem_total(p->p));
+        yaz_log (level, " %s:%d p=%p size=%d", p->file, p->line, p->p,
+                 nmem_total(p->p));
     NMEM_LEAVE;
 }
 #endif
@@ -219,28 +219,28 @@ static nmem_block *get_block(size_t size)
         yaz_log (log_level, "nmem get_block size=%ld", (long) size);
 
     for (r = freelist, l = 0; r; l = r, r = r->next)
-       if (r->size >= size)
-           break;
+        if (r->size >= size)
+            break;
     if (r)
     {
         if (log_level)
-           yaz_log (log_level, "nmem get_block found free block p=%p", r);
-       if (l)
-           l->next = r->next;
-       else
-           freelist = r->next;
+            yaz_log (log_level, "nmem get_block found free block p=%p", r);
+        if (l)
+            l->next = r->next;
+        else
+            freelist = r->next;
     }
     else
     {
-       int get = NMEM_CHUNK;
+        int get = NMEM_CHUNK;
 
-       if (get < size)
-           get = size;
+        if (get < size)
+            get = size;
         if(log_level)
-           yaz_log (log_level, "nmem get_block alloc new block size=%d", get);
+            yaz_log (log_level, "nmem get_block alloc new block size=%d", get);
 
-       r = (nmem_block *)xmalloc(sizeof(*r));
-       r->buf = (char *)xmalloc(r->size = get);
+        r = (nmem_block *)xmalloc(sizeof(*r));
+        r->buf = (char *)xmalloc(r->size = get);
     }
     r->top = 0;
     return r;
@@ -252,13 +252,13 @@ void nmem_reset(NMEM n)
     
     yaz_log (log_level, "nmem_reset p=%p", n);
     if (!n)
-       return;
+        return;
     NMEM_ENTER;
     while (n->blocks)
     {
-       t = n->blocks;
-       n->blocks = n->blocks->next;
-       free_block(t);
+        t = n->blocks;
+        n->blocks = n->blocks->next;
+        free_block(t);
     }
     n->total = 0;
     NMEM_LEAVE;
@@ -290,9 +290,9 @@ void *nmem_malloc(NMEM n, int size)
     p = n->blocks;
     if (!p || p->size < size + p->top)
     {
-       p = get_block(size);
-       p->next = n->blocks;
-       n->blocks = p;
+        p = get_block(size);
+        p->next = n->blocks;
+        n->blocks = p;
     }
     r = p->buf + p->top;
     /* align size */
@@ -327,9 +327,9 @@ NMEM nmem_create(void)
     nmem_active_no++;
     r = cfreelist;
     if (r)
-       cfreelist = cfreelist->next;
+        cfreelist = cfreelist->next;
     else
-       r = (nmem_control *)xmalloc(sizeof(*r));
+        r = (nmem_control *)xmalloc(sizeof(*r));
     NMEM_LEAVE;
 
 #if NMEM_DEBUG
@@ -342,11 +342,11 @@ NMEM nmem_create(void)
 
 #if NMEM_DEBUG
     for (debug_p = nmem_debug_list; debug_p; debug_p = debug_p->next)
-       if (debug_p->p == r)
-       {
-           yaz_log (YLOG_FATAL, "multi used block in nmem");
-           abort ();
-       }
+        if (debug_p->p == r)
+        {
+            yaz_log (YLOG_FATAL, "multi used block in nmem");
+            abort ();
+        }
     debug_p = xmalloc (sizeof(*debug_p));
     strncpy (debug_p->file, file, sizeof(debug_p->file)-1);
     debug_p->file[sizeof(debug_p->file)-1] = '\0';
@@ -371,28 +371,28 @@ void nmem_destroy(NMEM n)
     int ok = 0;
 #endif
     if (!n)
-       return;
+        return;
     
 #if NMEM_DEBUG
     yaz_log (log_level, "%s:%d: nmem_destroy %d p=%p", file, line,
                      nmem_active_no-1, n);
     NMEM_ENTER;
     for (debug_p = &nmem_debug_list; *debug_p; debug_p = &(*debug_p)->next)
-       if ((*debug_p)->p == n)
-       {
-           struct nmem_debug_info *debug_save = *debug_p;
-           *debug_p = (*debug_p)->next;
-           xfree (debug_save);
-           ok = 1;
-           break;
-       }
+        if ((*debug_p)->p == n)
+        {
+            struct nmem_debug_info *debug_save = *debug_p;
+            *debug_p = (*debug_p)->next;
+            xfree (debug_save);
+            ok = 1;
+            break;
+        }
     NMEM_LEAVE;
     nmem_print_list();
     if (!ok)
     {
-       yaz_log (YLOG_WARN, "%s:%d destroying unallocated nmem block p=%p",
-                file, line, n);
-       return;
+        yaz_log (YLOG_WARN, "%s:%d destroying unallocated nmem block p=%p",
+                 file, line, n);
+        return;
     }
 #endif
     nmem_reset(n);
@@ -408,9 +408,9 @@ void nmem_transfer (NMEM dst, NMEM src)
     nmem_block *t;
     while ((t = src->blocks))
     {
-       src->blocks = t->next;
-       t->next = dst->blocks;
-       dst->blocks = t;
+        src->blocks = t->next;
+        t->next = dst->blocks;
+        dst->blocks = t;
     }
     dst->total += src->total;
     src->total = 0;
@@ -432,13 +432,13 @@ void nmem_init (void)
     if (++nmem_init_flag == 1)
     {
 #ifdef WIN32
-       InitializeCriticalSection(&critical_section);
+        InitializeCriticalSection(&critical_section);
 #elif YAZ_GNU_THREADS
         pth_init ();
 #endif
-       nmem_active_no = 0;
-       freelist = NULL;
-       cfreelist = NULL;
+        nmem_active_no = 0;
+        freelist = NULL;
+        cfreelist = NULL;
     }
     if (!log_level_initialized)
     {
@@ -452,21 +452,21 @@ void nmem_exit (void)
     if (--nmem_init_flag == 0)
     {
         oid_exit();
-       while (freelist)
-       {
-           struct nmem_block *fl = freelist;
-           freelist = freelist->next;
-           xfree (fl->buf);
-           xfree (fl);
-       }
-       while (cfreelist)
-       {
-           struct nmem_control *cfl = cfreelist;
-           cfreelist = cfreelist->next;
-           xfree (cfl);
-       }
+        while (freelist)
+        {
+            struct nmem_block *fl = freelist;
+            freelist = freelist->next;
+            xfree (fl->buf);
+            xfree (fl);
+        }
+        while (cfreelist)
+        {
+            struct nmem_control *cfl = cfreelist;
+            cfreelist = cfreelist->next;
+            xfree (cfl);
+        }
 #ifdef WIN32
-       DeleteCriticalSection(&critical_section);
+        DeleteCriticalSection(&critical_section);
 #endif
     }
 }
@@ -474,16 +474,16 @@ void nmem_exit (void)
 
 #ifdef WIN32
 BOOL WINAPI DllMain (HINSTANCE hinstDLL,
-                    DWORD reason,
-                    LPVOID reserved)
+                     DWORD reason,
+                     LPVOID reserved)
 {
     switch (reason)
     {
     case DLL_PROCESS_ATTACH:
-       nmem_init ();
-       break;
+        nmem_init ();
+        break;
     case DLL_PROCESS_DETACH:
-       nmem_exit ();
+        nmem_exit ();
     }
     return TRUE;
 }
@@ -516,16 +516,16 @@ void yaz_strerror(char *buf, int max)
     if (err)
     {
         FormatMessage(
-               FORMAT_MESSAGE_FROM_SYSTEM,
-               NULL,
-               err,
-               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default lang */
-               (LPTSTR) buf,
-               max-1,
-               NULL);
+                FORMAT_MESSAGE_FROM_SYSTEM,
+                NULL,
+                err,
+                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default lang */
+                (LPTSTR) buf,
+                max-1,
+                NULL);
     }
     else
-       *buf = '\0';
+        *buf = '\0';
 #else
 /* UNIX */
 #if HAVE_STRERROR_R
@@ -544,7 +544,15 @@ void yaz_strerror(char *buf, int max)
 /* UNIX */
 #endif
     if ((cp = strrchr(buf, '\n')))
-       *cp = '\0';
+        *cp = '\0';
     if ((cp = strrchr(buf, '\r')))
-       *cp = '\0';
+        *cp = '\0';
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e680a98..2c8e7d8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: nmemsdup.c,v 1.4 2005-05-02 19:14:33 adam Exp $
+ * $Id: nmemsdup.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -45,36 +45,44 @@ void nmem_strsplit_blank(NMEM nmem, const char *dstr, char ***darray, int *num)
 }
 
 void nmem_strsplit(NMEM nmem, const char *delim, const char *dstr,
-                  char ***darray, int *num)
+                   char ***darray, int *num)
 {
     const char *cp = dstr;
     for (*num = 0; *cp; (*num)++)
     {
-       while (*cp && strchr(delim, *cp))
-           cp++;
-       if (!*cp)
-           break;
-       while (*cp && !strchr(delim, *cp))
-           cp++;
+        while (*cp && strchr(delim, *cp))
+            cp++;
+        if (!*cp)
+            break;
+        while (*cp && !strchr(delim, *cp))
+            cp++;
     }
     if (!*num)
-       *darray = 0;
+        *darray = 0;
     else
     {
-       size_t i = 0;
-       *darray = nmem_malloc(nmem, *num * sizeof(**darray));
-       for (cp = dstr; *cp; )
-       {
-           const char *cp0;
-           while (*cp && strchr(delim, *cp))
-               cp++;
-           if (!*cp)
-               break;
-           cp0 = cp;
-           while (*cp && !strchr(delim, *cp))
-               cp++;
-           (*darray)[i++] = nmem_strdupn(nmem, cp0, cp - cp0);
-       }
+        size_t i = 0;
+        *darray = nmem_malloc(nmem, *num * sizeof(**darray));
+        for (cp = dstr; *cp; )
+        {
+            const char *cp0;
+            while (*cp && strchr(delim, *cp))
+                cp++;
+            if (!*cp)
+                break;
+            cp0 = cp;
+            while (*cp && !strchr(delim, *cp))
+                cp++;
+            (*darray)[i++] = nmem_strdupn(nmem, cp0, cp - cp0);
+        }
     }
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 75b37ab..abc355a 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: odr-priv.h,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr-priv.h,v 1.6 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -71,7 +71,7 @@ struct Odr_private {
     int error_id;
     char element[80];
     void (*stream_write)(ODR o, void *handle, int type,
-                        const char *buf, int len);
+                         const char *buf, int len);
     void (*stream_close)(void *handle);
 };
 
@@ -113,3 +113,11 @@ struct Odr_private {
 )
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e370929..8d4cff8 100644 (file)
--- a/src/odr.c
+++ b/src/odr.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr.c,v 1.11 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr.c,v 1.12 2005-06-25 15:46:04 adam Exp $
  *
  */
 
@@ -106,34 +106,34 @@ void odr_setelement(ODR o, const char *element)
 }
 
 void odr_FILE_write(ODR o, void *handle, int type,
-                   const char *buf, int len)
+                    const char *buf, int len)
 {
     int i;
 #if 0
     if (type  == ODR_OCTETSTRING)
     {
-       const char **stack_names = odr_get_element_path(o);
-       for (i = 0; stack_names[i]; i++)
-           fprintf((FILE*) handle, "[%s]", stack_names[i]);
-       fputs("\n", (FILE*) handle);
+        const char **stack_names = odr_get_element_path(o);
+        for (i = 0; stack_names[i]; i++)
+            fprintf((FILE*) handle, "[%s]", stack_names[i]);
+        fputs("\n", (FILE*) handle);
     }
 #endif
     for (i = 0; i<len; i++)
     {
-       unsigned c = ((const unsigned char *) buf)[i];
-       if (i == 2000 && len > 3100)
-       {
-           fputs(" ..... ", (FILE*) handle);
-               i = len - 1000;
-       }
-       if (strchr("\r\n\f\t", c) || (c >= ' ' && c <= 126))
-           putc(c, (FILE*) handle);
-       else
-       {
-           char x[5];
-           sprintf(x, "\\X%02X", c);
-           fputs(x, (FILE*) handle);
-       }
+        unsigned c = ((const unsigned char *) buf)[i];
+        if (i == 2000 && len > 3100)
+        {
+            fputs(" ..... ", (FILE*) handle);
+                i = len - 1000;
+        }
+        if (strchr("\r\n\f\t", c) || (c >= ' ' && c <= 126))
+            putc(c, (FILE*) handle);
+        else
+        {
+            char x[5];
+            sprintf(x, "\\X%02X", c);
+            fputs(x, (FILE*) handle);
+        }
     }
 }
 
@@ -141,7 +141,7 @@ void odr_FILE_close(void *handle)
 {
     FILE *f = (FILE *) handle;
     if (f && f != stderr && f != stdout)
-       fclose(f);
+        fclose(f);
 }
 
 void odr_setprint(ODR o, FILE *file)
@@ -150,10 +150,10 @@ void odr_setprint(ODR o, FILE *file)
 }
 
 void odr_set_stream(ODR o, void *handle,
-                   void (*stream_write)(ODR o, 
-                                        void *handle, int type,
-                                        const char *buf, int len),
-                   void (*stream_close)(void *handle))
+                    void (*stream_write)(ODR o, 
+                                         void *handle, int type,
+                                         const char *buf, int len),
+                    void (*stream_close)(void *handle))
 {
     o->print = (FILE*) handle;
     o->op->stream_write = stream_write;
@@ -231,7 +231,7 @@ void odr_destroy(ODR o)
     if (o->buf && o->can_grow)
        xfree(o->buf);
     if (o->op->stream_close)
-       o->op->stream_close(o->print);
+        o->op->stream_close(o->print);
     if (o->op->iconv_handle != 0)
         yaz_iconv_close (o->op->iconv_handle);
     xfree(o->op);
@@ -276,3 +276,11 @@ void odr_printf(ODR o, const char *fmt, ...)
     o->op->stream_write(o, o->print, ODR_VISIBLESTRING, buf, strlen(buf));
     va_end(ap);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 96e72b9..d1d6a71 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_any.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_any.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
 int odr_any(ODR o, Odr_any **p, int opt, const char *name)
 {
     if (o->error)
-       return 0;
+        return 0;
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "ANY (len=%d)\n", (*p)->len);
-       return 1;
+        odr_prname(o, name);
+        odr_printf(o, "ANY (len=%d)\n", (*p)->len);
+        return 1;
     }
     if (o->direction == ODR_DECODE)
-       *p = (Odr_oct *)odr_malloc(o, sizeof(**p));
+        *p = (Odr_oct *)odr_malloc(o, sizeof(**p));
     if (ber_any(o, p))
-       return 1;
+        return 1;
     *p = 0;
     return odr_missing(o, opt, name);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 20362bd..69ceac9 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_bit.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_bit.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -26,27 +26,27 @@ int odr_bitstring(ODR o, Odr_bitmask **p, int opt, const char *name)
     int res, cons = 0;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_BITSTRING;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_BITSTRING;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
-       return 0;
+        return 0;
     if (!res)
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "BITSTRING(len=%d)\n",(*p)->top + 1);
-       return 1;
+        odr_prname(o, name);
+        odr_printf(o, "BITSTRING(len=%d)\n",(*p)->top + 1);
+        return 1;
     }
     if (o->direction == ODR_DECODE)
     {
-       *p = (Odr_bitmask *)odr_malloc(o, sizeof(Odr_bitmask));
-       memset((*p)->bits, 0, ODR_BITMASK_SIZE);
-       (*p)->top = -1;
+        *p = (Odr_bitmask *)odr_malloc(o, sizeof(Odr_bitmask));
+        memset((*p)->bits, 0, ODR_BITMASK_SIZE);
+        (*p)->top = -1;
     }
 #if 0
     /* ignoring the cons helps with at least one target. 
@@ -57,3 +57,11 @@ int odr_bitstring(ODR o, Odr_bitmask **p, int opt, const char *name)
     return ber_bitstring(o, *p, cons);
 #endif
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d1582f5..f02cbdd 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_bool.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_bool.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -25,25 +25,33 @@ int odr_bool(ODR o, int **p, int opt, const char *name)
     int res, cons = 0;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_BOOLEAN;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_BOOLEAN;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
-       return 0;
+        return 0;
     if (!res)
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "%s\n", (**p ? "TRUE" : "FALSE"));
-       return 1;
+        odr_prname(o, name);
+        odr_printf(o, "%s\n", (**p ? "TRUE" : "FALSE"));
+        return 1;
     }
     if (cons)
-       return 0;
+        return 0;
     if (o->direction == ODR_DECODE)
-       *p = (int *)odr_malloc(o, sizeof(int));
+        *p = (int *)odr_malloc(o, sizeof(int));
     return ber_boolean(o, *p);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index f91c589..3020e2d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_choice.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_choice.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
 #include "odr-priv.h"
 
 int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
-              const char *name)
+               const char *name)
 {
     int i, cl = -1, tg, cn, *which = (int *)whichp, bias = o->choice_bias;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->direction != ODR_DECODE && !*(char**)p)
-       return 0;
+        return 0;
 
     if (o->direction == ODR_DECODE)
     {
@@ -35,56 +35,56 @@ int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
 
     if (o->direction == ODR_PRINT)
     {
-       if (name)
-       {
-           odr_prname(o, name);
-           odr_printf(o, "choice\n");
-       }
+        if (name)
+        {
+            odr_prname(o, name);
+            odr_printf(o, "choice\n");
+        }
     }
     for (i = 0; arm[i].fun; i++)
     {
-       if (o->direction == ODR_DECODE)
-       {
-           if (bias >= 0 && bias != arm[i].which)
-               continue;
-           *which = arm[i].which;
-       }
-       else if (*which != arm[i].which)
-           continue;
+        if (o->direction == ODR_DECODE)
+        {
+            if (bias >= 0 && bias != arm[i].which)
+                continue;
+            *which = arm[i].which;
+        }
+        else if (*which != arm[i].which)
+            continue;
 
-       if (arm[i].tagmode != ODR_NONE)
-       {
-           if (o->direction == ODR_DECODE && cl < 0)
-           {
-               if (o->op->stackp > -1 && !odr_constructed_more(o))
-                   return 0;
-               if (ber_dectag(o->bp, &cl, &tg, &cn, odr_max(o)) <= 0)
-                   return 0;
-           }
-           else if (o->direction != ODR_DECODE)
-           {
-               cl = arm[i].zclass;
-               tg = arm[i].tag;
-           }
-           if (tg == arm[i].tag && cl == arm[i].zclass)
-           {
-               if (arm[i].tagmode == ODR_IMPLICIT)
-               {
-                   odr_implicit_settag(o, cl, tg);
-                   return (*arm[i].fun)(o, (char **)p, 0, arm[i].name);
-               }
-               /* explicit */
-               if (!odr_constructed_begin(o, p, cl, tg, 0))
-                   return 0;
-               return (*arm[i].fun)(o, (char **)p, 0, arm[i].name) &&
-                   odr_constructed_end(o);
-           }
-       }
-       else  /* no tagging. Have to poll type */
-       {
-           if ((*arm[i].fun)(o, (char **)p, 1, arm[i].name) && *(char**)p)
-               return 1;
-       }
+        if (arm[i].tagmode != ODR_NONE)
+        {
+            if (o->direction == ODR_DECODE && cl < 0)
+            {
+                if (o->op->stackp > -1 && !odr_constructed_more(o))
+                    return 0;
+                if (ber_dectag(o->bp, &cl, &tg, &cn, odr_max(o)) <= 0)
+                    return 0;
+            }
+            else if (o->direction != ODR_DECODE)
+            {
+                cl = arm[i].zclass;
+                tg = arm[i].tag;
+            }
+            if (tg == arm[i].tag && cl == arm[i].zclass)
+            {
+                if (arm[i].tagmode == ODR_IMPLICIT)
+                {
+                    odr_implicit_settag(o, cl, tg);
+                    return (*arm[i].fun)(o, (char **)p, 0, arm[i].name);
+                }
+                /* explicit */
+                if (!odr_constructed_begin(o, p, cl, tg, 0))
+                    return 0;
+                return (*arm[i].fun)(o, (char **)p, 0, arm[i].name) &&
+                    odr_constructed_end(o);
+            }
+        }
+        else  /* no tagging. Have to poll type */
+        {
+            if ((*arm[i].fun)(o, (char **)p, 1, arm[i].name) && *(char**)p)
+                return 1;
+        }
     }
     return 0;
 }
@@ -99,3 +99,11 @@ void odr_choice_enable_bias (ODR o, int mode)
 {
     o->enable_bias = mode;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 81fa4e1..f560815 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_cons.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_cons.c,v 1.6 2005-06-25 15:46:04 adam Exp $
  *
  */
 
@@ -23,29 +23,29 @@ void odr_setlenlen(ODR o, int len)
 }
 
 int odr_constructed_begin(ODR o, void *p, int zclass, int tag,
-                         const char *name)
+                          const char *name)
 {
     int res;
     int cons = 1;
     int lenlen = o->lenlen;
 
     if (o->error)
-       return 0;
+        return 0;
     o->lenlen = 1; /* reset lenlen */
     if (o->t_class < 0)
     {
-       o->t_class = zclass;
-       o->t_tag = tag;
+        o->t_class = zclass;
+        o->t_tag = tag;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, 1, name)) < 0)
-       return 0;
+        return 0;
     if (!res || !cons)
-       return 0;
+        return 0;
 
     if (o->op->stackp == ODR_MAX_STACK - 1)
     {
         odr_seterror(o, OSTACK, 30);
-       return 0;
+        return 0;
     }
     o->op->stack[++(o->op->stackp)].lenb = o->bp;
     o->op->stack[o->op->stackp].len_offset = odr_tell(o);
@@ -56,49 +56,49 @@ int odr_constructed_begin(ODR o, void *p, int zclass, int tag,
 #endif
     if (o->direction == ODR_ENCODE)
     {
-       static unsigned char dummy[sizeof(int)+1];
+        static unsigned char dummy[sizeof(int)+1];
 
-       o->op->stack[o->op->stackp].lenlen = lenlen;
+        o->op->stack[o->op->stackp].lenlen = lenlen;
 
-       if (odr_write(o, dummy, lenlen) < 0)  /* dummy */
+        if (odr_write(o, dummy, lenlen) < 0)  /* dummy */
         {
-           o->op->stack_names[o->op->stackp] = 0;
+            o->op->stack_names[o->op->stackp] = 0;
             --(o->op->stackp);
-           return 0;
+            return 0;
         }
     }
     else if (o->direction == ODR_DECODE)
     {
-       if ((res = ber_declen(o->bp, &o->op->stack[o->op->stackp].len,
+        if ((res = ber_declen(o->bp, &o->op->stack[o->op->stackp].len,
                               odr_max(o))) < 0)
         {
             odr_seterror(o, OOTHER, 31);
-           o->op->stack_names[o->op->stackp] = 0;
+            o->op->stack_names[o->op->stackp] = 0;
             --(o->op->stackp);
-           return 0;
+            return 0;
         }
-       o->op->stack[o->op->stackp].lenlen = res;
-       o->bp += res;
+        o->op->stack[o->op->stackp].lenlen = res;
+        o->bp += res;
         if (o->op->stack[o->op->stackp].len > odr_max(o))
         {
             odr_seterror(o, OOTHER, 32);
-           o->op->stack_names[o->op->stackp] = 0;
+            o->op->stack_names[o->op->stackp] = 0;
             --(o->op->stackp);
-           return 0;
+            return 0;
         }
     }
     else if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "{\n");
-       o->indent++;
+        odr_prname(o, name);
+        odr_printf(o, "{\n");
+        o->indent++;
     }
     else
     {
         odr_seterror(o, OOTHER, 33);
-       o->op->stack_names[o->op->stackp] = 0;
+        o->op->stack_names[o->op->stackp] = 0;
         --(o->op->stackp);
-       return 0;
+        return 0;
     }
     o->op->stack[o->op->stackp].base = o->bp;
     o->op->stack[o->op->stackp].base_offset = odr_tell(o);
@@ -108,13 +108,13 @@ int odr_constructed_begin(ODR o, void *p, int zclass, int tag,
 int odr_constructed_more(ODR o)
 {
     if (o->error)
-       return 0;
+        return 0;
     if (o->op->stackp < 0)
-       return 0;
+        return 0;
     if (o->op->stack[o->op->stackp].len >= 0)
-       return o->bp - o->op->stack[o->op->stackp].base < o->op->stack[o->op->stackp].len;
+        return o->bp - o->op->stack[o->op->stackp].base < o->op->stack[o->op->stackp].len;
     else
-       return (!(*o->bp == 0 && *(o->bp + 1) == 0));
+        return (!(*o->bp == 0 && *(o->bp + 1) == 0));
 }
 
 int odr_constructed_end(ODR o)
@@ -123,11 +123,11 @@ int odr_constructed_end(ODR o)
     int pos;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->op->stackp < 0)
     {
         odr_seterror(o, OOTHER, 34);
-       return 0;
+        return 0;
     }
     o->op->stack_names[o->op->stackp] = 0;
     switch (o->direction)
@@ -137,8 +137,8 @@ int odr_constructed_end(ODR o)
         {
             if (*o->bp++ == 0 && *(o->bp++) == 0)
             {
-                   o->op->stackp--;
-                   return 1;
+                    o->op->stackp--;
+                    return 1;
             }
             else
             {
@@ -191,3 +191,11 @@ int odr_constructed_end(ODR o)
         return 0;
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 20e10d9..1b3f81f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_enum.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_enum.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_enum.c
@@ -35,7 +35,7 @@ int odr_enum(ODR o, int **p, int opt, const char *name)
         return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
+        odr_prname(o, name);
         odr_printf(o, "%d\n", **p);
         return 1;
     }
@@ -48,3 +48,11 @@ int odr_enum(ODR o, int **p, int opt, const char *name)
         *p = (int *)odr_malloc(o, sizeof(int));
     return ber_integer(o, *p);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c7c7169..b7001d3 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_int.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_int.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_int.c
@@ -35,7 +35,7 @@ int odr_integer(ODR o, int **p, int opt, const char *name)
         return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
+        odr_prname(o, name);
         odr_printf(o, "%d\n", **p);
         return 1;
     }
@@ -48,3 +48,11 @@ int odr_integer(ODR o, int **p, int opt, const char *name)
         *p = (int *)odr_malloc(o, sizeof(int));
     return ber_integer(o, *p);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2bd75ee..e35de26 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_mem.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_mem.c,v 1.5 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_mem.c
@@ -32,14 +32,14 @@ NMEM odr_extract_mem(ODR o)
 void *odr_malloc(ODR o, int size)
 {
     if (o && !o->mem)
-       o->mem = nmem_create();
+        o->mem = nmem_create();
     return nmem_malloc(o ? o->mem : 0, size);
 }
 
 char *odr_strdup(ODR o, const char *str)
 {
     if (o && !o->mem)
-       o->mem = nmem_create();
+        o->mem = nmem_create();
     return nmem_strdup(o->mem, str);
 }
 
@@ -51,7 +51,7 @@ char *odr_strdupn(ODR o, const char *str, size_t n)
 int *odr_intdup(ODR o, int v)
 {
     if (o && !o->mem)
-       o->mem = nmem_create();
+        o->mem = nmem_create();
     return nmem_intdup(o->mem, v);
 }
 
@@ -68,19 +68,19 @@ int odr_grow_block(ODR b, int min_bytes)
     int togrow;
 
     if (!b->can_grow)
-       return -1;
+        return -1;
     if (!b->size)
-       togrow = 1024;
+        togrow = 1024;
     else
-       togrow = b->size;
+        togrow = b->size;
     if (togrow < min_bytes)
-       togrow = min_bytes;
+        togrow = min_bytes;
     if (b->size && !(b->buf =
-                    (unsigned char *) xrealloc(b->buf, b->size += togrow)))
-       abort();
+                     (unsigned char *) xrealloc(b->buf, b->size += togrow)))
+        abort();
     else if (!b->size && !(b->buf = (unsigned char *)
-                          xmalloc(b->size = togrow)))
-       abort();
+                           xmalloc(b->size = togrow)))
+        abort();
 #ifdef ODR_DEBUG
     fprintf(stderr, "New size for encode_buffer: %d\n", b->size);
 #endif
@@ -92,26 +92,34 @@ int odr_write(ODR o, unsigned char *buf, int bytes)
     if (o->pos + bytes >= o->size && odr_grow_block(o, bytes))
     {
         odr_seterror(o, OSPACE, 40);
-       return -1;
+        return -1;
     }
     memcpy(o->buf + o->pos, buf, bytes);
     o->pos += bytes;
     if (o->pos > o->top)
-       o->top = o->pos;
+        o->top = o->pos;
     return 0;
 }
 
 int odr_seek(ODR o, int whence, int offset)
 {
     if (whence == ODR_S_CUR)
-       offset += o->pos;
+        offset += o->pos;
     else if (whence == ODR_S_END)
-       offset += o->top;
+        offset += o->top;
     if (offset > o->size && odr_grow_block(o, offset - o->size))
     {
         odr_seterror(o, OSPACE, 41);
-       return -1;
+        return -1;
     }
     o->pos = offset;
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index afb893d..877f8be 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_null.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_null.c,v 1.6 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_null.c
@@ -23,32 +23,40 @@ int odr_null(ODR o, Odr_null **p, int opt, const char *name)
     int res, cons = 0;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_NULL;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_NULL;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
-       return 0;
+        return 0;
     if (!res)
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "NULL\n");
-       return 1;
+        odr_prname(o, name);
+        odr_printf(o, "NULL\n");
+        return 1;
     }
     if (cons)
     {
 #ifdef ODR_STRICT_NULL
         odr_seterror(OPROTO, 42);
-       return 0;
+        return 0;
 #else
-       /* Warning: Bad NULL */
+        /* Warning: Bad NULL */
 #endif
     }
     if (o->direction == ODR_DECODE)
-       *p = odr_nullval();
+        *p = odr_nullval();
     return ber_null(o);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 8d3cc05..0832643 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_oct.c,v 1.8 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_oct.c,v 1.9 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_oct.c
@@ -23,35 +23,35 @@ int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name)
     int res, cons = 0;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_OCTETSTRING;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_OCTETSTRING;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
-       return 0;
+        return 0;
     if (!res)
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "OCTETSTRING(len=%d) ", (*p)->len);
+        odr_prname(o, name);
+        odr_printf(o, "OCTETSTRING(len=%d) ", (*p)->len);
 
-       o->op->stream_write(o, o->print, ODR_OCTETSTRING,
-                           (char*) (*p)->buf, (*p)->len);
+        o->op->stream_write(o, o->print, ODR_OCTETSTRING,
+                            (char*) (*p)->buf, (*p)->len);
         odr_printf(o, "\n");
-       return 1;
+        return 1;
     }
     if (o->direction == ODR_DECODE)
     {
-       *p = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct));
-       (*p)->size= 0;
-       (*p)->len = 0;
-       (*p)->buf = 0;
+        *p = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct));
+        (*p)->size= 0;
+        (*p)->len = 0;
+        (*p)->buf = 0;
     }
     if (ber_octetstring(o, *p, cons))
-       return 1;
+        return 1;
     odr_seterror(o, OOTHER, 43);
     return 0;
 }
@@ -65,40 +65,40 @@ int odr_cstring(ODR o, char **p, int opt, const char *name)
     Odr_oct *t;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_OCTETSTRING;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_OCTETSTRING;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
-       return 0;
+        return 0;
     if (!res)
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "'%s'\n", *p);
-       return 1;
+        odr_prname(o, name);
+        odr_printf(o, "'%s'\n", *p);
+        return 1;
     }
     t = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)); /* wrapper for octstring */
     if (o->direction == ODR_ENCODE)
     {
-       t->buf = (unsigned char *) *p;
-       t->size = t->len = strlen(*p);
+        t->buf = (unsigned char *) *p;
+        t->size = t->len = strlen(*p);
     }
     else
     {
-       t->size= 0;
-       t->len = 0;
-       t->buf = 0;
+        t->size= 0;
+        t->len = 0;
+        t->buf = 0;
     }
     if (!ber_octetstring(o, t, cons))
-       return 0;
+        return 0;
     if (o->direction == ODR_DECODE)
     {
-       *p = (char *) t->buf;
-       *(*p + t->len) = '\0';  /* ber_octs reserves space for this */
+        *p = (char *) t->buf;
+        *(*p + t->len) = '\0';  /* ber_octs reserves space for this */
     }
     return 1;
 }
@@ -112,21 +112,21 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name)
     Odr_oct *t;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_OCTETSTRING;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_OCTETSTRING;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
-       return 0;
+        return 0;
     if (!res)
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
-       odr_prname(o, name);
-       odr_printf(o, "'%s'\n", *p);
-       return 1;
+        odr_prname(o, name);
+        odr_printf(o, "'%s'\n", *p);
+        return 1;
     }
     t = (Odr_oct *)odr_malloc(o, sizeof(Odr_oct)); /* wrapper for octstring */
     if (o->direction == ODR_ENCODE)
@@ -160,12 +160,12 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name)
     }
     else
     {
-       t->size= 0;
-       t->len = 0;
-       t->buf = 0;
+        t->size= 0;
+        t->len = 0;
+        t->buf = 0;
     }
     if (!ber_octetstring(o, t, cons))
-       return 0;
+        return 0;
     if (o->direction == ODR_DECODE)
     {
         *p = 0;
@@ -199,3 +199,11 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name)
     }
     return 1;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 5b579cc..8530f7b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_oid.c,v 1.6 2005-05-26 21:46:40 adam Exp $
+ * $Id: odr_oid.c,v 1.7 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_oid.c
@@ -24,33 +24,41 @@ int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
     int res, cons = 0;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_OID;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_OID;
     }
     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
-       return 0;
+        return 0;
     if (!res)
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     if (cons)
     {
         odr_seterror(o, OPROTO, 46);
-       return 0;
+        return 0;
     }
     if (o->direction == ODR_PRINT)
     {
-       int i;
+        int i;
 
-       odr_prname(o, name);
-       odr_printf(o, "OID:");
-       for (i = 0; (*p)[i] > -1; i++)
-           odr_printf(o, " %d", (*p)[i]);
-       odr_printf(o, "\n");
-       return 1;
+        odr_prname(o, name);
+        odr_printf(o, "OID:");
+        for (i = 0; (*p)[i] > -1; i++)
+            odr_printf(o, " %d", (*p)[i]);
+        odr_printf(o, "\n");
+        return 1;
     }
     if (o->direction == ODR_DECODE)
-       *p = (int *)odr_malloc(o, OID_SIZE * sizeof(**p));
+        *p = (int *)odr_malloc(o, OID_SIZE * sizeof(**p));
     return ber_oidc(o, *p, OID_SIZE);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 7d41c10..3e2a03b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_seq.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_seq.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_seq.c
@@ -19,22 +19,22 @@ int odr_sequence_begin(ODR o, void *p, int size, const char *name)
     char **pp = (char**) p;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_SEQUENCE;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_SEQUENCE;
     }
     if (o->direction == ODR_DECODE)
-       *pp = 0;
+        *pp = 0;
     if (odr_constructed_begin(o, p, o->t_class, o->t_tag, name))
     {
-       if (o->direction == ODR_DECODE && size)
-           *pp = (char *)odr_malloc(o, size);
-       return 1;
+        if (o->direction == ODR_DECODE && size)
+            *pp = (char *)odr_malloc(o, size);
+        return 1;
     }
     else
-       return 0;
+        return 0;
 }
 
 int odr_set_begin(ODR o, void *p, int size, const char *name)
@@ -42,22 +42,22 @@ int odr_set_begin(ODR o, void *p, int size, const char *name)
     char **pp = (char**) p;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = ODR_UNIVERSAL;
-       o->t_tag = ODR_SET;
+        o->t_class = ODR_UNIVERSAL;
+        o->t_tag = ODR_SET;
     }
     if (o->direction == ODR_DECODE)
-       *pp = 0;
+        *pp = 0;
     if (odr_constructed_begin(o, p, o->t_class, o->t_tag, name))
     {
-       if (o->direction == ODR_DECODE && size)
-           *pp = (char *)odr_malloc(o, size);
-       return 1;
+        if (o->direction == ODR_DECODE && size)
+            *pp = (char *)odr_malloc(o, size);
+        return 1;
     }
     else
-       return 0;
+        return 0;
 }
 
 int odr_sequence_end(ODR o)
@@ -83,48 +83,48 @@ static int odr_sequence_x (ODR o, Odr_fun type, void *p, int *num)
 
     switch (o->direction)
     {
-       case ODR_DECODE:
-           *num = 0;
-           *pp = (char **)odr_nullval();
-           while (odr_sequence_more(o))
-           {
-               /* outgrown array? */
-               if (*num * (int) sizeof(void*) >= size)
-               {
-                   /* double the buffer size */
-                   tmp = (char **)odr_malloc(o, sizeof(void*) *
-                                             (size += size ? size : 128));
-                   if (*num)
-                   {
-                       memcpy(tmp, *pp, *num * sizeof(void*));
-                       /*
-                        * For now, we just throw the old *p away, since we use
-                        * nibble memory anyway (disgusting, isn't it?).
-                        */
-                   }
-                   *pp = tmp;
-               }
-               if (!(*type)(o, (*pp) + *num, 0, 0))
-                   return 0;
-               (*num)++;
-           }
-           break;
-       case ODR_ENCODE: case ODR_PRINT:
+        case ODR_DECODE:
+            *num = 0;
+            *pp = (char **)odr_nullval();
+            while (odr_sequence_more(o))
+            {
+                /* outgrown array? */
+                if (*num * (int) sizeof(void*) >= size)
+                {
+                    /* double the buffer size */
+                    tmp = (char **)odr_malloc(o, sizeof(void*) *
+                                              (size += size ? size : 128));
+                    if (*num)
+                    {
+                        memcpy(tmp, *pp, *num * sizeof(void*));
+                        /*
+                         * For now, we just throw the old *p away, since we use
+                         * nibble memory anyway (disgusting, isn't it?).
+                         */
+                    }
+                    *pp = tmp;
+                }
+                if (!(*type)(o, (*pp) + *num, 0, 0))
+                    return 0;
+                (*num)++;
+            }
+            break;
+        case ODR_ENCODE: case ODR_PRINT:
 #ifdef ODR_DEBUG
-           fprintf(stderr, "[seqof: num=%d]", *num);
+            fprintf(stderr, "[seqof: num=%d]", *num);
 #endif
-           for (i = 0; i < *num; i++)
-           {
+            for (i = 0; i < *num; i++)
+            {
 #ifdef ODR_DEBUG
-               fprintf(stderr, "[seqof: elem #%d]", i);
+                fprintf(stderr, "[seqof: elem #%d]", i);
 #endif
-               if (!(*type)(o, *pp + i, 0, 0))
-                   return 0;
-           }
-           break;
-       default:
+                if (!(*type)(o, *pp + i, 0, 0))
+                    return 0;
+            }
+            break;
+        default:
             odr_seterror(o, OOTHER, 47);
-           return 0;
+            return 0;
     }
     return odr_sequence_end(o);
 }
@@ -132,21 +132,29 @@ static int odr_sequence_x (ODR o, Odr_fun type, void *p, int *num)
 int odr_set_of(ODR o, Odr_fun type, void *p, int *num, const char *name)
 {
     if (!odr_set_begin(o, p, 0, name)) {
-       if (o->direction == ODR_DECODE)
-           *num = 0;
-       return 0;
+        if (o->direction == ODR_DECODE)
+            *num = 0;
+        return 0;
     }
     return odr_sequence_x (o, type, p, num);
 }
 
 int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num,
-                   const char *name)
+                    const char *name)
 {
     if (!odr_sequence_begin(o, p, 0, name)) {
-       if (o->direction == ODR_DECODE)
-           *num = 0;
-       return 0;
+        if (o->direction == ODR_DECODE)
+            *num = 0;
+        return 0;
     }
     return odr_sequence_x (o, type, p, num);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c0c569d..6c534fd 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_tag.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_tag.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_tag.c
@@ -19,14 +19,14 @@ int odr_peektag(ODR o, int *zclass, int *tag, int *cons)
     if (o->direction != ODR_DECODE)
     {
         odr_seterror(o, OOTHER, 48);
-       return 0;
+        return 0;
     }
     if (o->op->stackp > -1 && !odr_constructed_more(o))
-       return 0;
+        return 0;
     if (ber_dectag(o->bp, zclass, tag, cons, odr_max(o)) <= 0)
     {
         odr_seterror(o, OREQUIRED, 49);
-       return 0;
+        return 0;
     }
     return 1;
 }
@@ -34,11 +34,11 @@ int odr_peektag(ODR o, int *zclass, int *tag, int *cons)
 int odr_implicit_settag(ODR o, int zclass, int tag)
 {
     if (o->error)
-       return 0;
+        return 0;
     if (o->t_class < 0)
     {
-       o->t_class = zclass;
-       o->t_tag = tag;
+        o->t_class = zclass;
+        o->t_tag = tag;
     }
     return 1;
 }
@@ -48,13 +48,21 @@ int odr_initmember(ODR o, void *p, int size)
     char **pp = (char **) p;
 
     if (o->error)
-       return 0;
+        return 0;
     if (o->direction == ODR_DECODE)
-       *pp = (char *)odr_malloc(o, size);
+        *pp = (char *)odr_malloc(o, size);
     else if (!*pp)
     {
-       o->t_class = -1;
-       return 0;
+        o->t_class = -1;
+        return 0;
     }
     return 1;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 1077254..f01d6eb 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_use.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_use.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_use.c
@@ -19,31 +19,31 @@ int odr_external(ODR o, Odr_external **p, int opt, const char *name)
     Odr_external *pp;
     static Odr_arm arm[] =
     {
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single, 
-        (Odr_fun)odr_any, "single"},
-       {ODR_IMPLICIT, ODR_CONTEXT, 1, ODR_EXTERNAL_octet,
-        (Odr_fun)odr_octetstring, "octet"},
-       {ODR_IMPLICIT, ODR_CONTEXT, 2, ODR_EXTERNAL_arbitrary,
-        (Odr_fun)odr_bitstring, "arbitrary"},
-       {-1, -1, -1, -1, 0, 0}
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single, 
+         (Odr_fun)odr_any, "single"},
+        {ODR_IMPLICIT, ODR_CONTEXT, 1, ODR_EXTERNAL_octet,
+         (Odr_fun)odr_octetstring, "octet"},
+        {ODR_IMPLICIT, ODR_CONTEXT, 2, ODR_EXTERNAL_arbitrary,
+         (Odr_fun)odr_bitstring, "arbitrary"},
+        {-1, -1, -1, -1, 0, 0}
     };
 
     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
     if (!odr_sequence_begin(o, p, sizeof(Odr_external), name))
-       return odr_missing(o, opt, name);
+        return odr_missing(o, opt, name);
     pp = *p;
     return
-       odr_oid(o, &pp->direct_reference, 1, "direct") &&
-       odr_integer(o, &pp->indirect_reference, 1, "indirect") &&
-       odr_graphicstring(o, &pp->descriptor, 1, "descriptor") &&
-       odr_choice(o, arm, &pp->u, &pp->which, 0) &&
-       odr_sequence_end(o);
+        odr_oid(o, &pp->direct_reference, 1, "direct") &&
+        odr_integer(o, &pp->indirect_reference, 1, "indirect") &&
+        odr_graphicstring(o, &pp->descriptor, 1, "descriptor") &&
+        odr_choice(o, arm, &pp->u, &pp->which, 0) &&
+        odr_sequence_end(o);
 }
 
 int odr_visiblestring(ODR o, char **p, int opt, const char *name)
 {
     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
-                           ODR_VISIBLESTRING, opt, name);
+                            ODR_VISIBLESTRING, opt, name);
 }    
 
 /*
@@ -53,17 +53,25 @@ int odr_visiblestring(ODR o, char **p, int opt, const char *name)
 int odr_generalstring(ODR o, char **p, int opt, const char *name)
 {
     return odr_implicit_tag(o, odr_iconv_string, p, ODR_UNIVERSAL,
-                           ODR_GENERALSTRING,opt, name);
+                            ODR_GENERALSTRING,opt, name);
 }    
 
 int odr_graphicstring(ODR o, char **p, int opt, const char *name)
 {
     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
-                       ODR_GRAPHICSTRING, opt, name);
+                        ODR_GRAPHICSTRING, opt, name);
 }    
 
 int odr_generalizedtime(ODR o, char **p, int opt, const char *name)
 {
     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
-                           ODR_GENERALIZEDTIME, opt, name);
+                            ODR_GENERALIZEDTIME, opt, name);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 6beac3b..a433c35 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_util.c,v 1.7 2005-01-15 19:47:14 adam Exp $
+ * $Id: odr_util.c,v 1.8 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file odr_util.c
 void odr_prname(ODR o, const char *name)
 {
     if (name)
-       odr_printf(o, "%*s%s ", o->indent*4, "", name);
+        odr_printf(o, "%*s%s ", o->indent*4, "", name);
     else
-       odr_printf(o, "%*s", o->indent*4, "");
+        odr_printf(o, "%*s", o->indent*4, "");
 }
 
 int odp_more_chunks(ODR o, const unsigned char *base, int len)
 {
     if (!len)
-       return 0;
+        return 0;
     if (len < 0) /* indefinite length */
     {
-       if (*o->bp == 0 && *(o->bp + 1) == 0)
-       {
-           o->bp += 2;
-           return 0;
-       }
-       else
-           return 1;
+        if (*o->bp == 0 && *(o->bp + 1) == 0)
+        {
+            o->bp += 2;
+            return 0;
+        }
+        else
+            return 1;
     }
     else
         return o->bp - base < len;
@@ -49,9 +49,9 @@ Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o)
     Odr_oid *r;
 
     if (!o)
-       return 0;
+        return 0;
     if (!(r = (int *)nmem_malloc(nmem, (oid_oidlen(o) + 1) * sizeof(int))))
-       return 0;
+        return 0;
     oid_oidcpy(r, o);
     return r;
 }
@@ -59,7 +59,7 @@ Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o)
 Odr_oid *odr_oiddup(ODR odr, Odr_oid *o)
 {
     if (!odr->mem)
-       odr->mem = nmem_create();
+        odr->mem = nmem_create();
     return odr_oiddup_nmem (odr->mem, o);
 }
 
@@ -70,13 +70,13 @@ Odr_oid *odr_getoidbystr_nmem(NMEM nmem, const char *str)
     Odr_oid *ret;
 
     if (!isdigit(*(const unsigned char *) str))
-       return 0;
+        return 0;
     while ((p = strchr(p, '.')))
-       num++, p++;
+        num++, p++;
     ret = (int *)nmem_malloc(nmem, sizeof(*ret)*(num + 1));
     p = str;
     do
-       ret[i++] = atoi(p);
+        ret[i++] = atoi(p);
     while ((p = strchr(p, '.')) && *++p);
     ret[i] = -1;
     return ret;
@@ -85,7 +85,7 @@ Odr_oid *odr_getoidbystr_nmem(NMEM nmem, const char *str)
 Odr_oid *odr_getoidbystr(ODR o, const char *str)
 {
     if (!o->mem)
-       o->mem = nmem_create();
+        o->mem = nmem_create();
     return odr_getoidbystr_nmem (o->mem, str);
 }
 
@@ -107,8 +107,8 @@ int odr_missing(ODR o, int opt, const char *name)
  * any) and a separator character.  Copy `prefix', a forward slash and
  * the old value into the new area and return its address.  Can be
  * used as follows:
- *     initRequest->implementationName = odr_prepend(o,
- *             initRequest->implementationName, "ZOOM-C");
+ *      initRequest->implementationName = odr_prepend(o,
+ *              initRequest->implementationName, "ZOOM-C");
  */
 char *odr_prepend(ODR o, const char *prefix, const char *old)
 {
@@ -118,11 +118,19 @@ char *odr_prepend(ODR o, const char *prefix, const char *old)
 
     *res = '\0';
     if (prefix != 0)
-       strcpy (res, prefix);
+        strcpy (res, prefix);
     if (prefix != 0 && old != 0)
-       strcat (res, "/");
+        strcat (res, "/");
     if (old !=0)
-       strcat (res, old);
+        strcat (res, old);
 
     return res;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a37e89d..b5cafbe 100644 (file)
--- a/src/oid.c
+++ b/src/oid.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: oid.c,v 1.10 2005-06-21 07:33:08 adam Exp $
+ * $Id: oid.c,v 1.11 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -304,7 +304,7 @@ static oident standard_oids[] =
     {PROTO_Z3950,   CLASS_TAGSET,  VAL_CIMI1,        {14,6,-1},
      "CIMI-tagset"},
     {PROTO_Z3950,   CLASS_TAGSET,  VAL_THESAURUS,    {14,1000,81,1,-1},
-     "thesaurus-tagset"},      /* What is this Satan-spawn doing here? */
+     "thesaurus-tagset"},       /* What is this Satan-spawn doing here? */
     {PROTO_Z3950,   CLASS_TAGSET,  VAL_EXPLAIN,      {14,1000,81,2,-1},
      "Explain-tagset"},
     {PROTO_Z3950,   CLASS_TAGSET,  VAL_ZTHES,        {14,8,-1},
@@ -385,10 +385,10 @@ void oid_transfer (struct oident *oidentp)
 {
     while (*oidentp->oidsuffix >= 0)
     {
-       oid_addent (oidentp->oidsuffix, oidentp->proto,
-                   oidentp->oclass,
-                   oidentp->desc, oidentp->value);
-       oidentp++;
+        oid_addent (oidentp->oidsuffix, oidentp->proto,
+                    oidentp->oclass,
+                    oidentp->desc, oidentp->value);
+        oidentp++;
     }
 }
 
@@ -396,18 +396,18 @@ void oid_init (void)
 {
     if (oid_init_flag == 0)
     {
-       /* oid_transfer is thread safe, so there's nothing wrong in having
-          two threads calling it simultaniously. On the other hand
-          no thread may exit oid_init before all OID's bave been
-          transferred - which is why checked is set after oid_transfer... 
-       */
-       nmem_mutex_create (&oid_mutex);
-       nmem_mutex_enter (oid_mutex);
-       if (!oid_nmem)
-           oid_nmem = nmem_create ();
-       nmem_mutex_leave (oid_mutex);
-       oid_transfer (standard_oids);
-       oid_init_flag = 1;
+        /* oid_transfer is thread safe, so there's nothing wrong in having
+           two threads calling it simultaniously. On the other hand
+           no thread may exit oid_init before all OID's bave been
+           transferred - which is why checked is set after oid_transfer... 
+        */
+        nmem_mutex_create (&oid_mutex);
+        nmem_mutex_enter (oid_mutex);
+        if (!oid_nmem)
+            oid_nmem = nmem_create ();
+        nmem_mutex_leave (oid_mutex);
+        oid_transfer (standard_oids);
+        oid_init_flag = 1;
     }
 }
 
@@ -437,11 +437,11 @@ static struct oident *oid_getentbyoid_x(int *o)
         proto = PROTO_GENERAL;
     for (ol = oident_table; ol; ol = ol->next)
     {
-       struct oident *p = &ol->oident;
+        struct oident *p = &ol->oident;
         if (p->proto == proto && !oid_oidcmp(o + prelen, p->oidsuffix))
             return p;
-       if (p->proto == PROTO_GENERAL && !oid_oidcmp (o, p->oidsuffix))
-           return p;
+        if (p->proto == PROTO_GENERAL && !oid_oidcmp (o, p->oidsuffix))
+            return p;
     }
     return 0;
 }
@@ -456,21 +456,21 @@ int *oid_ent_to_oid(struct oident *ent, int *ret)
     oid_init ();
     for (ol = oident_table; ol; ol = ol->next)
     {
-       struct oident *p = &ol->oident;
+        struct oident *p = &ol->oident;
         if (ent->value == p->value &&
             (p->proto == PROTO_GENERAL || (ent->proto == p->proto &&  
-           (ent->oclass == p->oclass || ent->oclass == CLASS_GENERAL))))
-       {
-           if (p->proto == PROTO_Z3950)
-               oid_oidcpy(ret, z3950_prefix);
-           else if (p->proto == PROTO_SR)
-               oid_oidcpy(ret, sr_prefix);
-           else
-               ret[0] = -1;
-           oid_oidcat(ret, p->oidsuffix);
-           ent->desc = p->desc;
-           return ret;
-       }
+            (ent->oclass == p->oclass || ent->oclass == CLASS_GENERAL))))
+        {
+            if (p->proto == PROTO_Z3950)
+                oid_oidcpy(ret, z3950_prefix);
+            else if (p->proto == PROTO_SR)
+                oid_oidcpy(ret, sr_prefix);
+            else
+                ret[0] = -1;
+            oid_oidcat(ret, p->oidsuffix);
+            ent->desc = p->desc;
+            return ret;
+        }
     }
     ret[0] = -1;
     return 0;
@@ -487,44 +487,44 @@ int *oid_getoidbyent(struct oident *ent)
 }
 
 struct oident *oid_addent (int *oid, enum oid_proto proto,
-                          enum oid_class oclass,
-                          const char *desc, int value)
+                           enum oid_class oclass,
+                           const char *desc, int value)
 {
     struct oident *oident = 0;
 
     nmem_mutex_enter (oid_mutex);
     if (!oident)
     {
-       struct oident_list *oident_list;
-       oident_list = (struct oident_list *)
-           nmem_malloc (oid_nmem, sizeof(*oident_list));
-       oident = &oident_list->oident;
-       oident->proto = proto;
-       oident->oclass = oclass;
-
-       if (!desc)
-       {
-           char desc_str[OID_SIZE*10];
-           int i;
-
-           *desc_str = '\0';
-           if (*oid >= 0)
-           {
-               sprintf (desc_str, "%d", *oid);
-               for (i = 1; i < OID_SIZE && oid[i] >= 0; i++)
-                   sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
-           }
-           oident->desc = nmem_strdup(oid_nmem, desc_str);
-       }
-       else
-           oident->desc = nmem_strdup(oid_nmem, desc);
-       if (value == VAL_DYNAMIC)
-           oident->value = (enum oid_value) (++oid_value_dynamic);
-       else
-           oident->value = (enum oid_value) value;
-       oid_oidcpy (oident->oidsuffix, oid);
-       oident_list->next = oident_table;
-       oident_table = oident_list;
+        struct oident_list *oident_list;
+        oident_list = (struct oident_list *)
+            nmem_malloc (oid_nmem, sizeof(*oident_list));
+        oident = &oident_list->oident;
+        oident->proto = proto;
+        oident->oclass = oclass;
+
+        if (!desc)
+        {
+            char desc_str[OID_SIZE*10];
+            int i;
+
+            *desc_str = '\0';
+            if (*oid >= 0)
+            {
+                sprintf (desc_str, "%d", *oid);
+                for (i = 1; i < OID_SIZE && oid[i] >= 0; i++)
+                    sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
+            }
+            oident->desc = nmem_strdup(oid_nmem, desc_str);
+        }
+        else
+            oident->desc = nmem_strdup(oid_nmem, desc);
+        if (value == VAL_DYNAMIC)
+            oident->value = (enum oid_value) (++oid_value_dynamic);
+        else
+            oident->value = (enum oid_value) value;
+        oid_oidcpy (oident->oidsuffix, oid);
+        oident_list->next = oident_table;
+        oident_table = oident_list;
     }
     nmem_mutex_leave (oid_mutex);
     return oident;
@@ -535,12 +535,12 @@ struct oident *oid_getentbyoid(int *oid)
     struct oident *oident;
 
     if (!oid)
-       return 0;
+        return 0;
     oid_init ();
     oident = oid_getentbyoid_x (oid);
     if (!oident)
-       oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL,
-                            NULL, VAL_DYNAMIC);
+        oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL,
+                             NULL, VAL_DYNAMIC);
     return oident;
 }
 
@@ -557,7 +557,7 @@ static oid_value oid_getval_raw(const char *name)
         {
             if (i < OID_SIZE-1)
                 oid[i++] = val;
-           val = 0;
+            val = 0;
             name++;
         }
     }
@@ -566,7 +566,7 @@ static oid_value oid_getval_raw(const char *name)
     oident = oid_getentbyoid_x (oid);
     if (!oident)
         oident = oid_addent (oid, PROTO_GENERAL, CLASS_GENERAL, NULL,
-                        VAL_DYNAMIC);
+                         VAL_DYNAMIC);
     return oident->value;
 }
 
@@ -578,10 +578,10 @@ oid_value oid_getvalbyname(const char *name)
     if (isdigit (*(const unsigned char *) name))
         return oid_getval_raw (name);
     for (ol = oident_table; ol; ol = ol->next)
-       if (!yaz_matchstr(ol->oident.desc, name))
-       {
-           return ol->oident.value;
-       }
+        if (!yaz_matchstr(ol->oident.desc, name))
+        {
+            return ol->oident.value;
+        }
     return VAL_NONE;
 }
 
@@ -620,9 +620,9 @@ char *oid_to_dotstring(const int *oid, char *oidbuf) {
 
     oidbuf[0] = '\0';
     for (i = 0; oid[i] != -1; i++) {
-       sprintf(tmpbuf, "%d", oid[i]);
-       if (i > 0) strcat(oidbuf, ".");
-       strcat(oidbuf, tmpbuf);
+        sprintf(tmpbuf, "%d", oid[i]);
+        if (i > 0) strcat(oidbuf, ".");
+        strcat(oidbuf, tmpbuf);
     }
 
     return oidbuf;
@@ -635,3 +635,11 @@ char *oid_name_to_dotstring(oid_class oclass, const char *name, char *oidbuf) {
     return oid_to_dotstring(oid, oidbuf);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 1cef0d3..cfa9efe 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: opacdisp.c,v 1.6 2005-03-02 23:59:22 adam Exp $
+ * $Id: opacdisp.c,v 1.7 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file opacdisp.c
 #include <yaz/marcdisp.h>
 
 static void opac_element_str(WRBUF wrbuf, int l, const char *elem,
-                            const char *data)
+                             const char *data)
 {
     if (data)
     {
-       while (--l >= 0)
-           wrbuf_puts(wrbuf, " ");
-       wrbuf_puts(wrbuf, "<");
-       wrbuf_puts(wrbuf, elem);
-       wrbuf_puts(wrbuf, ">");
-       wrbuf_xmlputs(wrbuf, data);
-       wrbuf_puts(wrbuf, "</");
-       wrbuf_puts(wrbuf, elem);
-       wrbuf_puts(wrbuf, ">\n");
+        while (--l >= 0)
+            wrbuf_puts(wrbuf, " ");
+        wrbuf_puts(wrbuf, "<");
+        wrbuf_puts(wrbuf, elem);
+        wrbuf_puts(wrbuf, ">");
+        wrbuf_xmlputs(wrbuf, data);
+        wrbuf_puts(wrbuf, "</");
+        wrbuf_puts(wrbuf, elem);
+        wrbuf_puts(wrbuf, ">\n");
     }
 }
 
@@ -38,15 +38,15 @@ static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data)
 {
     if (data)
     {
-       while (--l >= 0)
-           wrbuf_puts(wrbuf, " ");
-       wrbuf_puts(wrbuf, "<");
-       wrbuf_puts(wrbuf, elem);
-       if (*data)
+        while (--l >= 0)
+            wrbuf_puts(wrbuf, " ");
+        wrbuf_puts(wrbuf, "<");
+        wrbuf_puts(wrbuf, elem);
+        if (*data)
             wrbuf_puts(wrbuf, " value=\"1\"");
-       else
+        else
             wrbuf_puts(wrbuf, " value=\"0\"");
-       wrbuf_puts(wrbuf, "/>\n");
+        wrbuf_puts(wrbuf, "/>\n");
     }
 }
 
@@ -57,103 +57,103 @@ void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
     wrbuf_puts(wrbuf, "<opacRecord>\n");
     if (r->bibliographicRecord)
     {
-       Z_External *ext = r->bibliographicRecord;
-       
-       wrbuf_puts (wrbuf, "  <bibliographicRecord>\n");
-       if (ext->which == Z_External_octet)
-           yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
-                                 ext->u.octet_aligned->len, wrbuf);
-       wrbuf_puts (wrbuf, "  </bibliographicRecord>\n");
+        Z_External *ext = r->bibliographicRecord;
+        
+        wrbuf_puts (wrbuf, "  <bibliographicRecord>\n");
+        if (ext->which == Z_External_octet)
+            yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
+                                  ext->u.octet_aligned->len, wrbuf);
+        wrbuf_puts (wrbuf, "  </bibliographicRecord>\n");
     }
     wrbuf_puts(wrbuf, "<holdings>\n");
 
     for (i = 0; i < r->num_holdingsData; i++)
     {
-       Z_HoldingsRecord *h = r->holdingsData[i];
-       wrbuf_puts(wrbuf, " <holding>\n");
+        Z_HoldingsRecord *h = r->holdingsData[i];
+        wrbuf_puts(wrbuf, " <holding>\n");
 
-       if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
-       {
-           Z_External *ext = h->u.marcHoldingsRecord;
+        if (h->which == Z_HoldingsRecord_marcHoldingsRecord)
+        {
+            Z_External *ext = h->u.marcHoldingsRecord;
 
-           wrbuf_puts (wrbuf, "  <marcHoldingsRecord>\n");
-           if (ext->which == Z_External_octet)
-               yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
-                                     ext->u.octet_aligned->len, wrbuf);
-           wrbuf_puts (wrbuf, "  </marcHoldingsRecord>\n");
-       }
-       else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
-       {
-           int j;
-           
-           Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
-       
-           opac_element_str(wrbuf, 2, "typeOfRecord", d->typeOfRecord);
-           opac_element_str(wrbuf, 2, "encodingLevel", d->encodingLevel);
-           opac_element_str(wrbuf, 2, "format", d->format);
-           opac_element_str(wrbuf, 2, "receiptAcqStatus", d->receiptAcqStatus);
-           opac_element_str (wrbuf, 2, "generalRetention", d->generalRetention);
-           opac_element_str (wrbuf, 2, "completeness", d->completeness);
-           opac_element_str (wrbuf, 2, "dateOfReport", d->dateOfReport);
-           opac_element_str (wrbuf, 2, "nucCode", d->nucCode);
-           opac_element_str (wrbuf, 2, "localLocation", d->localLocation);
-           opac_element_str (wrbuf, 2, "shelvingLocation", d->shelvingLocation);
-           opac_element_str (wrbuf, 2, "callNumber", d->callNumber);
-           opac_element_str (wrbuf, 2, "shelvingData", d->shelvingData);
-           
-           opac_element_str (wrbuf, 2, "copyNumber", d->copyNumber);
-           opac_element_str (wrbuf, 2, "publicNote", d->publicNote);
-           opac_element_str (wrbuf, 2, "reproductionNote", d->reproductionNote);
-           opac_element_str (wrbuf, 2, "termsUseRepro", d->termsUseRepro);
-           opac_element_str (wrbuf, 2, "enumAndChron", d->enumAndChron);
-           if (d->num_volumes)
-           {
-               wrbuf_puts (wrbuf, "  <volumes>\n");
-               for (j = 0; j<d->num_volumes; j++)
-               {
-                   wrbuf_puts (wrbuf, "   <volume>\n");
-                   opac_element_str (wrbuf, 4, "enumeration",
-                                     d->volumes[j]->enumeration);
-                   opac_element_str (wrbuf, 4, "chronology",
-                                     d->volumes[j]->chronology);
-                   opac_element_str (wrbuf, 4, "enumAndChron",
-                                     d->volumes[j]->enumAndChron);
-                   wrbuf_puts (wrbuf, "   </volume>\n");
-               }
-               wrbuf_puts (wrbuf, "  </volumes>\n");
-           }
-           if (d->num_circulationData)
-           {
-               wrbuf_puts (wrbuf, "  <circulations>\n");
-               for (j = 0; j<d->num_circulationData; j++)
-               {
-                   wrbuf_puts (wrbuf,"   <circulation>\n");
-                   opac_element_bool (wrbuf, 4, "availableNow",
-                                      d->circulationData[j]->availableNow);
-                   opac_element_str (wrbuf, 4, "availabiltyDate",
-                                     d->circulationData[j]->availablityDate);
-                   opac_element_str (wrbuf, 4, "availableThru",
-                                     d->circulationData[j]->availableThru);
-                   opac_element_str (wrbuf, 4, "restrictions",
-                                     d->circulationData[j]->restrictions);
-                   opac_element_str (wrbuf, 4, "itemId",
-                                     d->circulationData[j]->itemId);
-                   opac_element_bool (wrbuf, 4, "renewable",
-                                      d->circulationData[j]->renewable);
-                   opac_element_bool (wrbuf, 4, "onHold",
-                                      d->circulationData[j]->onHold);
-                   opac_element_str (wrbuf, 4, "enumAndChron",
-                                     d->circulationData[j]->enumAndChron);
-                   opac_element_str (wrbuf, 4, "midspine",
-                                     d->circulationData[j]->midspine);
-                   opac_element_str (wrbuf, 4, "temporaryLocation",
-                                     d->circulationData[j]->temporaryLocation);
-                   wrbuf_puts (wrbuf, "   </circulation>\n");
-               }
-               wrbuf_puts (wrbuf, "  </circulations>\n");
-           }
-       }
-       wrbuf_puts(wrbuf, " </holding>\n");
+            wrbuf_puts (wrbuf, "  <marcHoldingsRecord>\n");
+            if (ext->which == Z_External_octet)
+                yaz_marc_decode_wrbuf(mt, ext->u.octet_aligned->buf,
+                                      ext->u.octet_aligned->len, wrbuf);
+            wrbuf_puts (wrbuf, "  </marcHoldingsRecord>\n");
+        }
+        else if (h->which == Z_HoldingsRecord_holdingsAndCirc)
+        {
+            int j;
+            
+            Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
+        
+            opac_element_str(wrbuf, 2, "typeOfRecord", d->typeOfRecord);
+            opac_element_str(wrbuf, 2, "encodingLevel", d->encodingLevel);
+            opac_element_str(wrbuf, 2, "format", d->format);
+            opac_element_str(wrbuf, 2, "receiptAcqStatus", d->receiptAcqStatus);
+            opac_element_str (wrbuf, 2, "generalRetention", d->generalRetention);
+            opac_element_str (wrbuf, 2, "completeness", d->completeness);
+            opac_element_str (wrbuf, 2, "dateOfReport", d->dateOfReport);
+            opac_element_str (wrbuf, 2, "nucCode", d->nucCode);
+            opac_element_str (wrbuf, 2, "localLocation", d->localLocation);
+            opac_element_str (wrbuf, 2, "shelvingLocation", d->shelvingLocation);
+            opac_element_str (wrbuf, 2, "callNumber", d->callNumber);
+            opac_element_str (wrbuf, 2, "shelvingData", d->shelvingData);
+            
+            opac_element_str (wrbuf, 2, "copyNumber", d->copyNumber);
+            opac_element_str (wrbuf, 2, "publicNote", d->publicNote);
+            opac_element_str (wrbuf, 2, "reproductionNote", d->reproductionNote);
+            opac_element_str (wrbuf, 2, "termsUseRepro", d->termsUseRepro);
+            opac_element_str (wrbuf, 2, "enumAndChron", d->enumAndChron);
+            if (d->num_volumes)
+            {
+                wrbuf_puts (wrbuf, "  <volumes>\n");
+                for (j = 0; j<d->num_volumes; j++)
+                {
+                    wrbuf_puts (wrbuf, "   <volume>\n");
+                    opac_element_str (wrbuf, 4, "enumeration",
+                                      d->volumes[j]->enumeration);
+                    opac_element_str (wrbuf, 4, "chronology",
+                                      d->volumes[j]->chronology);
+                    opac_element_str (wrbuf, 4, "enumAndChron",
+                                      d->volumes[j]->enumAndChron);
+                    wrbuf_puts (wrbuf, "   </volume>\n");
+                }
+                wrbuf_puts (wrbuf, "  </volumes>\n");
+            }
+            if (d->num_circulationData)
+            {
+                wrbuf_puts (wrbuf, "  <circulations>\n");
+                for (j = 0; j<d->num_circulationData; j++)
+                {
+                    wrbuf_puts (wrbuf,"   <circulation>\n");
+                    opac_element_bool (wrbuf, 4, "availableNow",
+                                       d->circulationData[j]->availableNow);
+                    opac_element_str (wrbuf, 4, "availabiltyDate",
+                                      d->circulationData[j]->availablityDate);
+                    opac_element_str (wrbuf, 4, "availableThru",
+                                      d->circulationData[j]->availableThru);
+                    opac_element_str (wrbuf, 4, "restrictions",
+                                      d->circulationData[j]->restrictions);
+                    opac_element_str (wrbuf, 4, "itemId",
+                                      d->circulationData[j]->itemId);
+                    opac_element_bool (wrbuf, 4, "renewable",
+                                       d->circulationData[j]->renewable);
+                    opac_element_bool (wrbuf, 4, "onHold",
+                                       d->circulationData[j]->onHold);
+                    opac_element_str (wrbuf, 4, "enumAndChron",
+                                      d->circulationData[j]->enumAndChron);
+                    opac_element_str (wrbuf, 4, "midspine",
+                                      d->circulationData[j]->midspine);
+                    opac_element_str (wrbuf, 4, "temporaryLocation",
+                                      d->circulationData[j]->temporaryLocation);
+                    wrbuf_puts (wrbuf, "   </circulation>\n");
+                }
+                wrbuf_puts (wrbuf, "  </circulations>\n");
+            }
+        }
+        wrbuf_puts(wrbuf, " </holding>\n");
     }
     wrbuf_puts(wrbuf, "</holdings>\n");
     wrbuf_puts(wrbuf, "</opacRecord>\n");
@@ -168,3 +168,11 @@ void yaz_display_OPAC(WRBUF wrbuf, Z_OPACRecord *opac_rec, int flags)
     yaz_marc_destroy(mt);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a08b184..c91e7f0 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: options.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: options.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file options.c
@@ -46,44 +46,52 @@ int options (const char *desc, char **argv, int argc, char **arg)
         int desc_char = desc[i++];
         int type = 0;
         if (desc[i] == ':')
-       {       /* string argument */
+        {       /* string argument */
             type = desc[i++];
-       }
+        }
         if (desc_char == ch)
-       { /* option with argument */
+        { /* option with argument */
             if (type)
-           {
+            {
                 if (argv[arg_no][arg_off])
-               {
+                {
                     *arg = argv[arg_no]+arg_off;
                     arg_no++;
                     arg_off =  0;
-               }
+                }
                 else
-               {
+                {
                     arg_no++;
                     arg_off = 0;
                     if (arg_no < argc)
                         *arg = argv[arg_no++];
                     else
                         *arg = "";
-               }
-           }
+                }
+            }
             else /* option with no argument */
-           {
+            {
                 if (argv[arg_no][arg_off])
                     arg_off++;
                 else
-               {
+                {
                     arg_off = 0;
                     arg_no++;
-               }
-           }
+                }
+            }
             return ch;
-       }               
+        }               
     }
     *arg = argv[arg_no]+arg_off-1;
     arg_no = arg_no + 1;
     arg_off = 0;
     return -1;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 580c610..4cf95c8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: otherinfo.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: otherinfo.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file otherinfo.c
@@ -18,56 +18,56 @@ void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip)
     switch (apdu->which)
     {
     case Z_APDU_initRequest:
-       *oip = &apdu->u.initRequest->otherInfo;
-       break;
+        *oip = &apdu->u.initRequest->otherInfo;
+        break;
     case Z_APDU_searchRequest:
-       *oip = &apdu->u.searchRequest->otherInfo;
-       break;
+        *oip = &apdu->u.searchRequest->otherInfo;
+        break;
     case Z_APDU_presentRequest:
-       *oip = &apdu->u.presentRequest->otherInfo;
-       break;
+        *oip = &apdu->u.presentRequest->otherInfo;
+        break;
     case Z_APDU_sortRequest:
-       *oip = &apdu->u.sortRequest->otherInfo;
-       break;
+        *oip = &apdu->u.sortRequest->otherInfo;
+        break;
     case Z_APDU_scanRequest:
-       *oip = &apdu->u.scanRequest->otherInfo;
-       break;
+        *oip = &apdu->u.scanRequest->otherInfo;
+        break;
     case Z_APDU_extendedServicesRequest:
-       *oip = &apdu->u.extendedServicesRequest->otherInfo;
-       break;
+        *oip = &apdu->u.extendedServicesRequest->otherInfo;
+        break;
     case Z_APDU_deleteResultSetRequest:
-       *oip = &apdu->u.deleteResultSetRequest->otherInfo;
-       break;
+        *oip = &apdu->u.deleteResultSetRequest->otherInfo;
+        break;
     case Z_APDU_initResponse:
-       *oip = &apdu->u.initResponse->otherInfo;
-       break;
+        *oip = &apdu->u.initResponse->otherInfo;
+        break;
     case Z_APDU_searchResponse:
-       *oip = &apdu->u.searchResponse->otherInfo;
-       break;
+        *oip = &apdu->u.searchResponse->otherInfo;
+        break;
     case Z_APDU_presentResponse:
-       *oip = &apdu->u.presentResponse->otherInfo;
-       break;
+        *oip = &apdu->u.presentResponse->otherInfo;
+        break;
     case Z_APDU_sortResponse:
-       *oip = &apdu->u.sortResponse->otherInfo;
-       break;
+        *oip = &apdu->u.sortResponse->otherInfo;
+        break;
     case Z_APDU_scanResponse:
-       *oip = &apdu->u.scanResponse->otherInfo;
-       break;
+        *oip = &apdu->u.scanResponse->otherInfo;
+        break;
     case Z_APDU_extendedServicesResponse:
-       *oip = &apdu->u.extendedServicesResponse->otherInfo;
-       break;
+        *oip = &apdu->u.extendedServicesResponse->otherInfo;
+        break;
     case Z_APDU_deleteResultSetResponse:
-       *oip = &apdu->u.deleteResultSetResponse->otherInfo;
-       break;
+        *oip = &apdu->u.deleteResultSetResponse->otherInfo;
+        break;
     case Z_APDU_duplicateDetectionRequest:
-       *oip = &apdu->u.duplicateDetectionRequest->otherInfo;
-       break;
+        *oip = &apdu->u.duplicateDetectionRequest->otherInfo;
+        break;
     case Z_APDU_duplicateDetectionResponse:
-       *oip = &apdu->u.duplicateDetectionResponse->otherInfo;
-       break;
+        *oip = &apdu->u.duplicateDetectionResponse->otherInfo;
+        break;
     default:
-       *oip = 0;
-       break;
+        *oip = 0;
+        break;
     }
 }
 
@@ -83,75 +83,75 @@ Z_OtherInformationUnit *yaz_oi_update (
     otherInformation = *otherInformationP;
     if (!otherInformation)
     {
-       if (!odr)
-           return 0;
-       otherInformation = *otherInformationP = (Z_OtherInformation *)
-           odr_malloc (odr, sizeof(*otherInformation));
-       otherInformation->num_elements = 0;
-       otherInformation->list = 0;
+        if (!odr)
+            return 0;
+        otherInformation = *otherInformationP = (Z_OtherInformation *)
+            odr_malloc (odr, sizeof(*otherInformation));
+        otherInformation->num_elements = 0;
+        otherInformation->list = 0;
     }
     for (i = 0; i<otherInformation->num_elements; i++)
     {
-       if (!oid)
-       {
-           if (!otherInformation->list[i]->category)
-               return otherInformation->list[i];
-       }
-       else
-       {
-           if (otherInformation->list[i]->category &&
-               categoryValue ==
-               *otherInformation->list[i]->category->categoryValue &&
-               !oid_oidcmp (oid, otherInformation->list[i]->category->
-                            categoryTypeId))
-           {
-               Z_OtherInformationUnit *this_list = otherInformation->list[i];
+        if (!oid)
+        {
+            if (!otherInformation->list[i]->category)
+                return otherInformation->list[i];
+        }
+        else
+        {
+            if (otherInformation->list[i]->category &&
+                categoryValue ==
+                *otherInformation->list[i]->category->categoryValue &&
+                !oid_oidcmp (oid, otherInformation->list[i]->category->
+                             categoryTypeId))
+            {
+                Z_OtherInformationUnit *this_list = otherInformation->list[i];
 
-               if (delete_flag)
-               {
-                   (otherInformation->num_elements)--;
-                   while (i < otherInformation->num_elements)
-                   {
-                       otherInformation->list[i] =
-                           otherInformation->list[i+1];
-                       i++;
-                   }
-               }
-               return this_list;
-           }
-       }
+                if (delete_flag)
+                {
+                    (otherInformation->num_elements)--;
+                    while (i < otherInformation->num_elements)
+                    {
+                        otherInformation->list[i] =
+                            otherInformation->list[i+1];
+                        i++;
+                    }
+                }
+                return this_list;
+            }
+        }
     }
     if (!odr)
-       return 0;
+        return 0;
     else
     {
-       Z_OtherInformationUnit **newlist = (Z_OtherInformationUnit**)
-           odr_malloc(odr, (otherInformation->num_elements+1) *
-                      sizeof(*newlist));
-       for (i = 0; i<otherInformation->num_elements; i++)
-           newlist[i] = otherInformation->list[i];
-       otherInformation->list = newlist;
-       
-       otherInformation->list[i] = (Z_OtherInformationUnit*)
-           odr_malloc (odr, sizeof(Z_OtherInformationUnit));
-       if (oid)
-       {
-           otherInformation->list[i]->category = (Z_InfoCategory*)
-               odr_malloc (odr, sizeof(Z_InfoCategory));
-           otherInformation->list[i]->category->categoryTypeId = (int*)
-               odr_oiddup (odr, oid);
-           otherInformation->list[i]->category->categoryValue = (int*)
-               odr_malloc (odr, sizeof(int));
-           *otherInformation->list[i]->category->categoryValue =
-               categoryValue;
-       }
-       else
-           otherInformation->list[i]->category = 0;
-       otherInformation->list[i]->which = Z_OtherInfo_characterInfo;
-       otherInformation->list[i]->information.characterInfo = 0;
-       
-       otherInformation->num_elements = i+1;
-       return otherInformation->list[i];
+        Z_OtherInformationUnit **newlist = (Z_OtherInformationUnit**)
+            odr_malloc(odr, (otherInformation->num_elements+1) *
+                       sizeof(*newlist));
+        for (i = 0; i<otherInformation->num_elements; i++)
+            newlist[i] = otherInformation->list[i];
+        otherInformation->list = newlist;
+        
+        otherInformation->list[i] = (Z_OtherInformationUnit*)
+            odr_malloc (odr, sizeof(Z_OtherInformationUnit));
+        if (oid)
+        {
+            otherInformation->list[i]->category = (Z_InfoCategory*)
+                odr_malloc (odr, sizeof(Z_InfoCategory));
+            otherInformation->list[i]->category->categoryTypeId = (int*)
+                odr_oiddup (odr, oid);
+            otherInformation->list[i]->category->categoryValue = (int*)
+                odr_malloc (odr, sizeof(int));
+            *otherInformation->list[i]->category->categoryValue =
+                categoryValue;
+        }
+        else
+            otherInformation->list[i]->category = 0;
+        otherInformation->list[i]->which = Z_OtherInfo_characterInfo;
+        otherInformation->list[i]->information.characterInfo = 0;
+        
+        otherInformation->num_elements = i+1;
+        return otherInformation->list[i];
     }
 }
 
@@ -161,9 +161,9 @@ void yaz_oi_set_string_oid (
     const char *str)
 {
     Z_OtherInformationUnit *oi =
-       yaz_oi_update(otherInformation, odr, oid, categoryValue, 0);
+        yaz_oi_update(otherInformation, odr, oid, categoryValue, 0);
     if (!oi)
-       return;
+        return;
     oi->which = Z_OtherInfo_characterInfo;
     oi->information.characterInfo = odr_strdup (odr, str);
 }
@@ -179,9 +179,9 @@ void yaz_oi_set_string_oidval (
     ent.oclass = CLASS_USERINFO;
     ent.value = (oid_value) oidval;
     if (!oid_ent_to_oid (&ent, oid))
-       return ;
+        return ;
     yaz_oi_set_string_oid(otherInformation,
-                         odr, oid, categoryValue, str);
+                          odr, oid, categoryValue, str);
 }
 
 char *yaz_oi_get_string_oid (
@@ -191,13 +191,13 @@ char *yaz_oi_get_string_oid (
     Z_OtherInformationUnit *oi;
     
     if ((oi = yaz_oi_update(otherInformation, 0, oid, 1, delete_flag)) &&
-       oi->which == Z_OtherInfo_characterInfo)
-       return oi->information.characterInfo;
+        oi->which == Z_OtherInfo_characterInfo)
+        return oi->information.characterInfo;
     return 0;
 }
 
 char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation,
-                              int oidval, int categoryValue, int delete_flag)
+                               int oidval, int categoryValue, int delete_flag)
 {
     int oid[OID_SIZE];
     struct oident ent;
@@ -206,8 +206,16 @@ char *yaz_oi_get_string_oidval(Z_OtherInformation **otherInformation,
     ent.value = (oid_value) oidval;
 
     if (!oid_ent_to_oid (&ent, oid))
-       return 0;
+        return 0;
     return yaz_oi_get_string_oid (otherInformation, oid, categoryValue,
-                                 delete_flag);
+                                  delete_flag);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 5ddd11a..9dbba8b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: pquery.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: pquery.c,v 1.6 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file pquery.c
@@ -37,7 +37,7 @@ static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
                                       oid_proto, 
                                       int num_attr, int max_attr, 
                                       int *attr_list, char **attr_clist,
-                                     oid_value *attr_set);
+                                      oid_value *attr_set);
 
 static enum oid_value query_oid_getvalbyname (struct yaz_pqf_parser *li)
 {
@@ -58,7 +58,7 @@ static int compare_term (struct yaz_pqf_parser *li, const char *src,
     size_t len=strlen(src);
     
     if (li->lex_len == len+off && !memcmp (li->lex_buf+off, src, len-off))
-       return 1;
+        return 1;
     return 0;
 }
 
@@ -75,34 +75,34 @@ static int query_token (struct yaz_pqf_parser *li)
     li->lex_len = 0;
     if ((sep_match = strchr (li->left_sep, **qptr)))
     {
-       sep_char = li->right_sep[sep_match - li->left_sep];
+        sep_char = li->right_sep[sep_match - li->left_sep];
         ++(*qptr);
     }
     li->lex_buf = *qptr;
    
     if (**qptr == li->escape_char && isdigit (((const unsigned char *) *qptr)[1]))
     {
-       ++(li->lex_len);
-       ++(*qptr);
-       return 'l';
+        ++(li->lex_len);
+        ++(*qptr);
+        return 'l';
     }
     while (**qptr && **qptr != sep_char)
     {
-       if (**qptr == '\\')
-       {
-           ++(li->lex_len);
-           ++(*qptr);
-       }
-       ++(li->lex_len);
-       ++(*qptr);
+        if (**qptr == '\\')
+        {
+            ++(li->lex_len);
+            ++(*qptr);
+        }
+        ++(li->lex_len);
+        ++(*qptr);
     }
     if (**qptr)
-       ++(*qptr);
+        ++(*qptr);
     if (sep_char == ' ' &&
         li->lex_len >= 1 && li->lex_buf[0] == li->escape_char)
     {
-       if (compare_term (li, "and", 1))
-           return 'a';
+        if (compare_term (li, "and", 1))
+            return 'a';
         if (compare_term (li, "or", 1))
             return 'o';
         if (compare_term (li, "not", 1))
@@ -131,110 +131,110 @@ static int escape_string(char *out_buf, const char *in, int len)
 
     char *out = out_buf;
     while (--len >= 0)
-       if (*in == '\\' && len > 0)
-       {
-           --len;
-           switch (*++in)
-           {
-           case 't':
-               *out++ = '\t';
-               break;
-           case 'n':
-               *out++ = '\n';
-               break;
-           case 'r':
-               *out++ = '\r';
-               break;
-           case 'f':
-               *out++ = '\f';
-               break;
-           case 'x':
-               if (len > 1)
-               {
-                   char s[4];
-                   int n = 0;
-                   s[0] = *++in;
-                   s[1] = *++in;
-                   s[2] = '\0';
-                   len = len - 2;
-                   sscanf (s, "%x", &n);
-                   *out++ = n;
-               }
-               break;
-           case '0':
-           case '1':
-           case '2':
-           case '3':
-               if (len > 1)
-               {
-                   char s[4];
-                   int n = 0;
-                   s[0] = *in;
-                   s[1] = *++in;                   
-                   s[2] = *++in;
-                   s[3] = '\0';
-                   len = len - 2;
-                   sscanf (s, "%o", &n);
-                   *out++ = n;
-               }
-               break;
-           default:
-               *out++ = *in;
-               break;
-           }
-           in++;
-       }
-       else
-           *out++ = *in++;
+        if (*in == '\\' && len > 0)
+        {
+            --len;
+            switch (*++in)
+            {
+            case 't':
+                *out++ = '\t';
+                break;
+            case 'n':
+                *out++ = '\n';
+                break;
+            case 'r':
+                *out++ = '\r';
+                break;
+            case 'f':
+                *out++ = '\f';
+                break;
+            case 'x':
+                if (len > 1)
+                {
+                    char s[4];
+                    int n = 0;
+                    s[0] = *++in;
+                    s[1] = *++in;
+                    s[2] = '\0';
+                    len = len - 2;
+                    sscanf (s, "%x", &n);
+                    *out++ = n;
+                }
+                break;
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+                if (len > 1)
+                {
+                    char s[4];
+                    int n = 0;
+                    s[0] = *in;
+                    s[1] = *++in;                   
+                    s[2] = *++in;
+                    s[3] = '\0';
+                    len = len - 2;
+                    sscanf (s, "%o", &n);
+                    *out++ = n;
+                }
+                break;
+            default:
+                *out++ = *in;
+                break;
+            }
+            in++;
+        }
+        else
+            *out++ = *in++;
     return out - out_buf;
 }
 
 static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
-                             int num_attr, int *attr_list,
-                             char **attr_clist, oid_value *attr_set)
+                              int num_attr, int *attr_list,
+                              char **attr_clist, oid_value *attr_set)
 {
     const char *cp;
     if (!(cp = strchr (li->lex_buf, '=')) ||
-       (size_t) (cp-li->lex_buf) > li->lex_len)
+        (size_t) (cp-li->lex_buf) > li->lex_len)
     {
-       attr_set[num_attr] = query_oid_getvalbyname (li);
-       if (attr_set[num_attr] == VAL_NONE)
+        attr_set[num_attr] = query_oid_getvalbyname (li);
+        if (attr_set[num_attr] == VAL_NONE)
         {
             li->error = YAZ_PQF_ERROR_ATTSET;
-           return 0;
+            return 0;
         }
-       if (!lex (li))
+        if (!lex (li))
         {
             li->error = YAZ_PQF_ERROR_MISSING;
             return 0;
         }
-       if (!(cp = strchr (li->lex_buf, '=')))
+        if (!(cp = strchr (li->lex_buf, '=')))
         {
             li->error = YAZ_PQF_ERROR_BADATTR;
-           return 0;
+            return 0;
         }
     }
     else 
     {
-       if (num_attr > 0)
-           attr_set[num_attr] = attr_set[num_attr-1];
-       else
-           attr_set[num_attr] = VAL_NONE;
+        if (num_attr > 0)
+            attr_set[num_attr] = attr_set[num_attr-1];
+        else
+            attr_set[num_attr] = VAL_NONE;
     }
     attr_list[2*num_attr] = atoi(li->lex_buf);
-       cp++;
+        cp++;
     if (*cp >= '0' && *cp <= '9')
     {
-       attr_list[2*num_attr+1] = atoi (cp);
-       attr_clist[num_attr] = 0;
+        attr_list[2*num_attr+1] = atoi (cp);
+        attr_clist[num_attr] = 0;
     }
     else
     {
-       int len = li->lex_len - (cp - li->lex_buf);
-       attr_list[2*num_attr+1] = 0;
-       attr_clist[num_attr] = (char *) odr_malloc (o, len+1);
-       len = escape_string(attr_clist[num_attr], cp, len);
-       attr_clist[num_attr][len] = '\0';
+        int len = li->lex_len - (cp - li->lex_buf);
+        attr_list[2*num_attr+1] = 0;
+        attr_clist[num_attr] = (char *) odr_malloc (o, len+1);
+        len = escape_string(attr_clist[num_attr], cp, len);
+        attr_clist[num_attr][len] = '\0';
     }
     return 1;
 }
@@ -242,7 +242,7 @@ static int p_query_parse_attr(struct yaz_pqf_parser *li, ODR o,
 static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
                                        oid_proto proto, 
                                        int num_attr, int *attr_list,
-                                      char **attr_clist, oid_value *attr_set)
+                                       char **attr_clist, oid_value *attr_set)
 {
     Z_AttributesPlusTerm *zapt;
     Odr_oct *term_octet;
@@ -261,7 +261,7 @@ static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
         int *attr_tmp;
 
         elements = (Z_AttributeElement**)
-           odr_malloc (o, num_attr * sizeof(*elements));
+            odr_malloc (o, num_attr * sizeof(*elements));
 
         attr_tmp = (int *)odr_malloc (o, num_attr * 2 * sizeof(int));
         memcpy (attr_tmp, attr_list, num_attr * 2 * sizeof(int));
@@ -276,40 +276,40 @@ static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
             elements[k] =
                 (Z_AttributeElement*)odr_malloc (o,sizeof(**elements));
             elements[k]->attributeType = &attr_tmp[2*i];
-           elements[k]->attributeSet =
-               yaz_oidval_to_z3950oid(o, CLASS_ATTSET, attr_set[i]);
-
-           if (attr_clist[i])
-           {
-               elements[k]->which = Z_AttributeValue_complex;
-               elements[k]->value.complex = (Z_ComplexAttribute *)
-                   odr_malloc (o, sizeof(Z_ComplexAttribute));
-               elements[k]->value.complex->num_list = 1;
-               elements[k]->value.complex->list =
-                   (Z_StringOrNumeric **)
-                   odr_malloc (o, 1 * sizeof(Z_StringOrNumeric *));
-               elements[k]->value.complex->list[0] =
-                   (Z_StringOrNumeric *)
-                   odr_malloc (o, sizeof(Z_StringOrNumeric));
-               elements[k]->value.complex->list[0]->which =
-                   Z_StringOrNumeric_string;
-               elements[k]->value.complex->list[0]->u.string =
-                   attr_clist[i];
-               elements[k]->value.complex->semanticAction = (int **)
-                   odr_nullval();
-               elements[k]->value.complex->num_semanticAction = 0;
-           }
-           else
-           {
-               elements[k]->which = Z_AttributeValue_numeric;
-               elements[k]->value.numeric = &attr_tmp[2*i+1];
-           }
+            elements[k]->attributeSet =
+                yaz_oidval_to_z3950oid(o, CLASS_ATTSET, attr_set[i]);
+
+            if (attr_clist[i])
+            {
+                elements[k]->which = Z_AttributeValue_complex;
+                elements[k]->value.complex = (Z_ComplexAttribute *)
+                    odr_malloc (o, sizeof(Z_ComplexAttribute));
+                elements[k]->value.complex->num_list = 1;
+                elements[k]->value.complex->list =
+                    (Z_StringOrNumeric **)
+                    odr_malloc (o, 1 * sizeof(Z_StringOrNumeric *));
+                elements[k]->value.complex->list[0] =
+                    (Z_StringOrNumeric *)
+                    odr_malloc (o, sizeof(Z_StringOrNumeric));
+                elements[k]->value.complex->list[0]->which =
+                    Z_StringOrNumeric_string;
+                elements[k]->value.complex->list[0]->u.string =
+                    attr_clist[i];
+                elements[k]->value.complex->semanticAction = (int **)
+                    odr_nullval();
+                elements[k]->value.complex->num_semanticAction = 0;
+            }
+            else
+            {
+                elements[k]->which = Z_AttributeValue_numeric;
+                elements[k]->value.numeric = &attr_tmp[2*i+1];
+            }
             k++;
         }
         num_attr = k;
     }
     zapt->attributes = (Z_AttributeList *)
-       odr_malloc (o, sizeof(*zapt->attributes));
+        odr_malloc (o, sizeof(*zapt->attributes));
     zapt->attributes->num_attributes = num_attr;
     zapt->attributes->attributes = elements;
 
@@ -341,8 +341,8 @@ static Z_AttributesPlusTerm *rpn_term (struct yaz_pqf_parser *li, ODR o,
         break;
     case Z_Term_external:
         term->which = Z_Term_external;
-       term->u.external = 0;
-       break;
+        term->u.external = 0;
+        break;
     default:
         term->which = Z_Term_null;
         term->u.null = odr_nullval();
@@ -364,7 +364,7 @@ static Z_Operand *rpn_simple (struct yaz_pqf_parser *li, ODR o, oid_proto proto,
         zo->which = Z_Operand_APT;
         if (!(zo->u.attributesPlusTerm =
               rpn_term (li, o, proto, num_attr, attr_list, attr_clist,
-                       attr_set)))
+                        attr_set)))
             return 0;
         lex (li);
         break;
@@ -451,7 +451,7 @@ static Z_ProximityOperator *rpn_proximity (struct yaz_pqf_parser *li, ODR o)
 static Z_Complex *rpn_complex (struct yaz_pqf_parser *li, ODR o, oid_proto proto,
                                int num_attr, int max_attr, 
                                int *attr_list, char **attr_clist,
-                              oid_value *attr_set)
+                               oid_value *attr_set)
 {
     Z_Complex *zc;
     Z_Operator *zo;
@@ -488,7 +488,7 @@ static Z_Complex *rpn_complex (struct yaz_pqf_parser *li, ODR o, oid_proto proto
     lex (li);
     if (!(zc->s1 =
           rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                        attr_clist, attr_set)))
+                         attr_clist, attr_set)))
         return NULL;
     if (!(zc->s2 =
           rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
@@ -515,9 +515,9 @@ static void rpn_term_type (struct yaz_pqf_parser *li, ODR o)
         li->term_type = Z_Term_null;
     else if (compare_term(li, "range", 0))
     {
-       /* prepare for external: range search .. */
+        /* prepare for external: range search .. */
         li->term_type = Z_Term_external;
-       li->external_type = VAL_MULTISRCH2;
+        li->external_type = VAL_MULTISRCH2;
     }
     lex (li);
 }
@@ -526,8 +526,8 @@ static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
                                       oid_proto proto, 
                                       int num_attr, int max_attr, 
                                       int *attr_list,
-                                     char **attr_clist,
-                                     oid_value *attr_set)
+                                      char **attr_clist,
+                                      oid_value *attr_set)
 {
     Z_RPNStructure *sz;
 
@@ -564,20 +564,20 @@ static Z_RPNStructure *rpn_structure (struct yaz_pqf_parser *li, ODR o,
             li->error = YAZ_PQF_ERROR_TOOMANY;
             return 0;
         }
-       if (!p_query_parse_attr(li, o, num_attr, attr_list,
+        if (!p_query_parse_attr(li, o, num_attr, attr_list,
                                 attr_clist, attr_set))
             return 0;
-       num_attr++;
+        num_attr++;
         lex (li);
         return
             rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                          attr_clist,  attr_set);
+                           attr_clist,  attr_set);
     case 'y':
-       lex (li);
+        lex (li);
         rpn_term_type (li, o);
         return
             rpn_structure (li, o, proto, num_attr, max_attr, attr_list,
-                          attr_clist, attr_set);
+                           attr_clist, attr_set);
     case 0:                /* operator/operand expected! */
         li->error = YAZ_PQF_ERROR_MISSING;
         return 0;
@@ -618,7 +618,7 @@ Z_RPNQuery *p_query_rpn_mk (ODR o, struct yaz_pqf_parser *li, oid_proto proto,
     if (!zq->attributeSetId)
     {
         li->error = YAZ_PQF_ERROR_ATTSET;
-       return 0;
+        return 0;
     }
 
     if (!(zq->RPNStructure = rpn_structure (li, o, proto, 0, 512,
@@ -806,3 +806,11 @@ int yaz_pqf_error (YAZ_PQF_Parser p, const char **msg, size_t *off)
     *off = p->query_ptr - p->query_buf;
     return p->error;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b076241..d784b83 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: prt-ext.c,v 1.5 2005-01-27 09:08:42 adam Exp $
+ * $Id: prt-ext.c,v 1.6 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -60,8 +60,8 @@ Z_ext_typeent *z_ext_getentbyref(oid_value val)
     Z_ext_typeent *i;
 
     for (i = type_table; i->dref != VAL_NONE; i++)
-       if (i->dref == val)
-           return i;
+        if (i->dref == val)
+            return i;
     return 0;
 }
 
@@ -91,52 +91,52 @@ int z_External(ODR o, Z_External **p, int opt, const char *name)
 
     static Odr_arm arm[] =
     {
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_single,
-        (Odr_fun)odr_any, 0},
-       {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_External_octet,
-        (Odr_fun)odr_octetstring, 0},
-       {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_External_arbitrary,
-        (Odr_fun)odr_bitstring, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_sutrs,
-        (Odr_fun)z_SUTRS, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_explainRecord,
-        (Odr_fun)z_ExplainRecord, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_single,
+         (Odr_fun)odr_any, 0},
+        {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_External_octet,
+         (Odr_fun)odr_octetstring, 0},
+        {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_External_arbitrary,
+         (Odr_fun)odr_bitstring, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_sutrs,
+         (Odr_fun)z_SUTRS, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_explainRecord,
+         (Odr_fun)z_ExplainRecord, 0},
 
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport1,
-        (Odr_fun)z_ResourceReport1, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport2,
-        (Odr_fun)z_ResourceReport2, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_promptObject1,
-        (Odr_fun)z_PromptObject1, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1,
-        (Odr_fun)z_GenericRecord, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_extendedService,
-        (Odr_fun)z_TaskPackage, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport1,
+         (Odr_fun)z_ResourceReport1, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_resourceReport2,
+         (Odr_fun)z_ResourceReport2, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_promptObject1,
+         (Odr_fun)z_PromptObject1, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_grs1,
+         (Odr_fun)z_GenericRecord, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_extendedService,
+         (Odr_fun)z_TaskPackage, 0},
 
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
-        (Odr_fun)z_IOItemOrder, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_diag1,
-        (Odr_fun)z_DiagnosticFormat, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1,
-        (Odr_fun)z_Espec1, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_summary,
-        (Odr_fun)z_BriefBib, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_OPAC,
-        (Odr_fun)z_OPACRecord, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_itemOrder,
+         (Odr_fun)z_IOItemOrder, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_diag1,
+         (Odr_fun)z_DiagnosticFormat, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_espec1,
+         (Odr_fun)z_Espec1, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_summary,
+         (Odr_fun)z_BriefBib, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_OPAC,
+         (Odr_fun)z_OPACRecord, 0},
 
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_searchResult1,
-        (Odr_fun)z_SearchInfoReport, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_update,
-        (Odr_fun)z_IUUpdate, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_dateTime,
-        (Odr_fun)z_DateTime, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_universeReport,
-        (Odr_fun)z_UniverseReport, 0},
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_ESAdmin,
-        (Odr_fun)z_Admin, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_searchResult1,
+         (Odr_fun)z_SearchInfoReport, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_update,
+         (Odr_fun)z_IUUpdate, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_dateTime,
+         (Odr_fun)z_DateTime, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_universeReport,
+         (Odr_fun)z_UniverseReport, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_ESAdmin,
+         (Odr_fun)z_Admin, 0},
 
-       {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_update0,
-        (Odr_fun)z_IU0Update, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_update0,
+         (Odr_fun)z_IU0Update, 0},
         {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_userInfo1,
          (Odr_fun)z_OtherInformation, 0},
         {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_charSetandLanguageNegotiation,
@@ -154,90 +154,90 @@ int z_External(ODR o, Z_External **p, int opt, const char *name)
          (Odr_fun)z_InternationalString, 0},
         {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_OCLCUserInfo,
          (Odr_fun)z_OCLC_UserInformation, 0},
-       {-1, -1, -1, -1, 0, 0}
+        {-1, -1, -1, -1, 0, 0}
     };
 
     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
     if (!odr_sequence_begin(o, p, sizeof(**p), name))
-       return opt && odr_ok(o);
+        return opt && odr_ok(o);
     if (!(odr_oid(o, &(*p)->direct_reference, 1, 0) &&
-         odr_integer(o, &(*p)->indirect_reference, 1, 0) &&
-         odr_graphicstring(o, &(*p)->descriptor, 1, 0)))
-       return 0;
+          odr_integer(o, &(*p)->indirect_reference, 1, 0) &&
+          odr_graphicstring(o, &(*p)->descriptor, 1, 0)))
+        return 0;
 #if PRT_EXT_DEBUG
     /* debugging purposes only */
     if (o->direction == ODR_DECODE)
     {
-       yaz_log(YLOG_LOG, "z_external decode");
-       if ((*p)->direct_reference)
-       {
-           yaz_log(YLOG_LOG, "direct reference");
-           if ((oid = oid_getentbyoid((*p)->direct_reference)))
-           {
-               yaz_log(YLOG_LOG, "oid %s", oid->desc);
-               if ((type = z_ext_getentbyref(oid->value)))
-                   yaz_log(YLOG_LOG, "type");
-           }
-       }
+        yaz_log(YLOG_LOG, "z_external decode");
+        if ((*p)->direct_reference)
+        {
+            yaz_log(YLOG_LOG, "direct reference");
+            if ((oid = oid_getentbyoid((*p)->direct_reference)))
+            {
+                yaz_log(YLOG_LOG, "oid %s", oid->desc);
+                if ((type = z_ext_getentbyref(oid->value)))
+                    yaz_log(YLOG_LOG, "type");
+            }
+        }
     }
 #endif
     /* Do we know this beast? */
     if (o->direction == ODR_DECODE && (*p)->direct_reference &&
-       (oid = oid_getentbyoid((*p)->direct_reference)) &&
-       (type = z_ext_getentbyref(oid->value)))
+        (oid = oid_getentbyoid((*p)->direct_reference)) &&
+        (type = z_ext_getentbyref(oid->value)))
     {
-       int zclass, tag, cons;
-       /* OID is present and we know it */
+        int zclass, tag, cons;
+        /* OID is present and we know it */
 
-       if (!odr_peektag(o, &zclass, &tag, &cons))
-           return opt && odr_ok(o);
+        if (!odr_peektag(o, &zclass, &tag, &cons))
+            return opt && odr_ok(o);
 #if PRT_EXT_DEBUG
-       yaz_log(YLOG_LOG, "odr_peektag OK tag=%d cons=%d zclass=%d what=%d",
-               tag, cons, zclass, type->what);
+        yaz_log(YLOG_LOG, "odr_peektag OK tag=%d cons=%d zclass=%d what=%d",
+                tag, cons, zclass, type->what);
 #endif
-       if (zclass == ODR_CONTEXT && tag == 1 && cons == 0)
-       {
-           /* we have an OCTET STRING. decode BER contents from it */
-           const unsigned char *o_bp;
-           unsigned char *o_buf;
-           int o_size;
-           char *voidp = 0;
-           Odr_oct *oct;
-           int r;
-           if (!odr_implicit_tag(o, odr_octetstring, &oct,
-                                ODR_CONTEXT, 1, 0, "octetaligned"))
-               return 0;
+        if (zclass == ODR_CONTEXT && tag == 1 && cons == 0)
+        {
+            /* we have an OCTET STRING. decode BER contents from it */
+            const unsigned char *o_bp;
+            unsigned char *o_buf;
+            int o_size;
+            char *voidp = 0;
+            Odr_oct *oct;
+            int r;
+            if (!odr_implicit_tag(o, odr_octetstring, &oct,
+                                 ODR_CONTEXT, 1, 0, "octetaligned"))
+                return 0;
 
-           /* Save our decoding ODR members */
-           o_bp = o->bp; 
-           o_buf = o->buf;
-           o_size = o->size;
+            /* Save our decoding ODR members */
+            o_bp = o->bp; 
+            o_buf = o->buf;
+            o_size = o->size;
 
-           /* Set up the OCTET STRING buffer */
-           o->bp = o->buf = oct->buf;
-           o->size = oct->len;
+            /* Set up the OCTET STRING buffer */
+            o->bp = o->buf = oct->buf;
+            o->size = oct->len;
 
-           /* and decode that */
-           r = (*type->fun)(o, &voidp, 0, 0);
-           (*p)->which = type->what;
-           (*p)->u.single_ASN1_type = (Odr_any*) voidp;
-               
-           /* Restore our decoding ODR member */
-           o->bp = o_bp; 
-           o->buf = o_buf;
-           o->size = o_size;
+            /* and decode that */
+            r = (*type->fun)(o, &voidp, 0, 0);
+            (*p)->which = type->what;
+            (*p)->u.single_ASN1_type = (Odr_any*) voidp;
+                
+            /* Restore our decoding ODR member */
+            o->bp = o_bp; 
+            o->buf = o_buf;
+            o->size = o_size;
 
-           return r && odr_sequence_end(o);
-       }
-       if (zclass == ODR_CONTEXT && tag == 0 && cons == 1)
-       { 
-           /* It's single ASN.1 type, bias the CHOICE. */
-           odr_choice_bias(o, type->what);
-       }
+            return r && odr_sequence_end(o);
+        }
+        if (zclass == ODR_CONTEXT && tag == 0 && cons == 1)
+        { 
+            /* It's single ASN.1 type, bias the CHOICE. */
+            odr_choice_bias(o, type->what);
+        }
     }
     return
-       odr_choice(o, arm, &(*p)->u, &(*p)->which, name) &&
-       odr_sequence_end(o);
+        odr_choice(o, arm, &(*p)->u, &(*p)->which, name) &&
+        odr_sequence_end(o);
 }
 
 Z_External *z_ext_record(ODR o, int format, const char *buf, int len)
@@ -249,66 +249,74 @@ Z_External *z_ext_record(ODR o, int format, const char *buf, int len)
     thisext->indirect_reference = 0;
 
     thisext->direct_reference = 
-       yaz_oidval_to_z3950oid (o, CLASS_RECSYN, format);    
+        yaz_oidval_to_z3950oid (o, CLASS_RECSYN, format);    
     if (!thisext->direct_reference)
-       return 0;
+        return 0;
 
     if (len < 0) /* Structured data */
     {
-       /*
-        * We cheat on the pointers here. Obviously, the record field
-        * of the backend-fetch structure should have been a union for
-        * correctness, but we're stuck with this for backwards
-        * compatibility.
-        */
-       thisext->u.grs1 = (Z_GenericRecord*) buf;
+        /*
+         * We cheat on the pointers here. Obviously, the record field
+         * of the backend-fetch structure should have been a union for
+         * correctness, but we're stuck with this for backwards
+         * compatibility.
+         */
+        thisext->u.grs1 = (Z_GenericRecord*) buf;
 
-       switch (format)
-       {
-       case VAL_SUTRS:
-           thisext->which = Z_External_sutrs;
-           break;
-       case VAL_GRS1:
-           thisext->which = Z_External_grs1;
-           break;
-       case VAL_EXPLAIN:
-           thisext->which = Z_External_explainRecord;
-           break;
-       case VAL_SUMMARY:
-           thisext->which = Z_External_summary;
-           break;
-       case VAL_OPAC:
-           thisext->which = Z_External_OPAC;
-           break;
-       case VAL_EXTENDED:
-           thisext->which = Z_External_extendedService;
-           break;
-       default:
-           return 0;
-       }
+        switch (format)
+        {
+        case VAL_SUTRS:
+            thisext->which = Z_External_sutrs;
+            break;
+        case VAL_GRS1:
+            thisext->which = Z_External_grs1;
+            break;
+        case VAL_EXPLAIN:
+            thisext->which = Z_External_explainRecord;
+            break;
+        case VAL_SUMMARY:
+            thisext->which = Z_External_summary;
+            break;
+        case VAL_OPAC:
+            thisext->which = Z_External_OPAC;
+            break;
+        case VAL_EXTENDED:
+            thisext->which = Z_External_extendedService;
+            break;
+        default:
+            return 0;
+        }
     }
     else if (format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */
     {
-       Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs));
-       
-       thisext->which = Z_External_sutrs;
-       thisext->u.sutrs = sutrs;
-       sutrs->buf = (unsigned char *)odr_malloc(o, len);
-       sutrs->len = sutrs->size = len;
-       memcpy(sutrs->buf, buf, len);
+        Odr_oct *sutrs = (Odr_oct *)odr_malloc(o, sizeof(*sutrs));
+        
+        thisext->which = Z_External_sutrs;
+        thisext->u.sutrs = sutrs;
+        sutrs->buf = (unsigned char *)odr_malloc(o, len);
+        sutrs->len = sutrs->size = len;
+        memcpy(sutrs->buf, buf, len);
     }
     else
     {
-       thisext->which = Z_External_octet;
-       if (!(thisext->u.octet_aligned = (Odr_oct *)
-             odr_malloc(o, sizeof(Odr_oct))))
-           return 0;
-       if (!(thisext->u.octet_aligned->buf = (unsigned char *)
-             odr_malloc(o, len)))
-           return 0;
-       memcpy(thisext->u.octet_aligned->buf, buf, len);
-       thisext->u.octet_aligned->len = thisext->u.octet_aligned->size = len;
+        thisext->which = Z_External_octet;
+        if (!(thisext->u.octet_aligned = (Odr_oct *)
+              odr_malloc(o, sizeof(Odr_oct))))
+            return 0;
+        if (!(thisext->u.octet_aligned->buf = (unsigned char *)
+              odr_malloc(o, len)))
+            return 0;
+        memcpy(thisext->u.octet_aligned->buf, buf, len);
+        thisext->u.octet_aligned->len = thisext->u.octet_aligned->size = len;
     }
     return thisext;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 06ee114..f923526 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * All rights reserved.
  *
- * $Id: readconf.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: readconf.c,v 1.6 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
 #define l_isspace(c) ((c) == '\t' || (c) == ' ' || (c) == '\n' || (c) == '\r')
 
 int readconf_line(FILE *f, int *lineno, char *line, int len,
-                 char *argv[], int num)
+                  char *argv[], int num)
 {
     char *p;
     int argc;
     
     while ((p = fgets(line, len, f)))
     {
-       (*lineno)++;
-       while (*p && l_isspace(*p))
-           p++;
-       if (*p && *p != '#')
-           break;
+        (*lineno)++;
+        while (*p && l_isspace(*p))
+            p++;
+        if (*p && *p != '#')
+            break;
     }
     if (!p)
-       return 0;
+        return 0;
     
     for (argc = 0; *p ; argc++)
     {
-       if (*p == '#')  /* trailing comment */
-           break;
-       argv[argc] = p;
-       while (*p && !l_isspace(*p))
-           p++;
-       if (*p)
-       {
-           *(p++) = '\0';
-           while (*p && l_isspace(*p))
-               p++;
-       }
+        if (*p == '#')  /* trailing comment */
+            break;
+        argv[argc] = p;
+        while (*p && !l_isspace(*p))
+            p++;
+        if (*p)
+        {
+            *(p++) = '\0';
+            while (*p && l_isspace(*p))
+                p++;
+        }
     }
     return argc;
 }
@@ -60,7 +60,7 @@ int readconf_line(FILE *f, int *lineno, char *line, int len,
  * Read lines of a configuration file.
  */
 int readconf(char *name, void *rprivate,
-            int (*fun)(char *name, void *rprivate, int argc, char *argv[]))
+             int (*fun)(char *name, void *rprivate, int argc, char *argv[]))
 {
     FILE *f;
     char line[512], *m_argv[50];
@@ -69,23 +69,31 @@ int readconf(char *name, void *rprivate,
     
     if (!(f = fopen(name, "r")))
     {
-       yaz_log(YLOG_WARN|YLOG_ERRNO, "readconf: %s", name);
-       return -1;
+        yaz_log(YLOG_WARN|YLOG_ERRNO, "readconf: %s", name);
+        return -1;
     }
     for (;;)
     {
-       int res;
-       
-       if (!(m_argc = readconf_line(f, &lineno, line, 512, m_argv, 50)))
-       {
-           fclose(f);
-           return 0;
-       }
+        int res;
+        
+        if (!(m_argc = readconf_line(f, &lineno, line, 512, m_argv, 50)))
+        {
+            fclose(f);
+            return 0;
+        }
 
-       if ((res = (*fun)(name, rprivate, m_argc, m_argv)))
-       {
-           fclose(f);
-           return res;
-       }
+        if ((res = (*fun)(name, rprivate, m_argc, m_argv)))
+        {
+            fclose(f);
+            return res;
+        }
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d774b9a..1290b59 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: requestq.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: requestq.c,v 1.4 2005-06-25 15:46:04 adam Exp $
  */
 /**
  * \file requestq.c
@@ -20,9 +20,9 @@
 void request_enq(request_q *q, request *r)
 {
     if (q->tail)
-       q->tail->next = r;
+        q->tail->next = r;
     else
-       q->head = r;
+        q->head = r;
     q->tail = r;
     q->num++;
 }
@@ -37,10 +37,10 @@ request *request_deq(request_q *q)
     request *r = q->head;
 
     if (!r)
-       return 0;
+        return 0;
     q->head = q->head->next;
     if (!q->head)
-       q->tail = 0;
+        q->tail = 0;
     q->num--;
     return r;
 }
@@ -56,7 +56,7 @@ void request_delq(request_q *q)
     request *r1, *r = q->list;
     while (r)
     {
-       xfree (r->response);
+        xfree (r->response);
         r1 = r;
         r = r->next;
         xfree (r1);
@@ -68,13 +68,13 @@ request *request_get(request_q *q)
     request *r = q->list;
 
     if (r)
-       q->list = r->next;
+        q->list = r->next;
     else
     {
-       if (!(r = (request *)xmalloc(sizeof(*r))))
-           abort();
-       r->response = 0;
-       r->size_response = 0;
+        if (!(r = (request *)xmalloc(sizeof(*r))))
+            abort();
+        r->response = 0;
+        r->size_response = 0;
     }
     r->q = q;
     r->len_refid = 0;
@@ -96,3 +96,11 @@ void request_release(request *r)
     q->list = r;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 9add9b8..267da8b 100644 (file)
@@ -2,7 +2,7 @@
  * NT Service interface Utility.
  *  Based on code written by
  *     Chas Woodfield, Fretwell Downing Informatics.
- * $Id: service.c,v 1.2 2004-10-15 00:19:00 adam Exp $
+ * $Id: service.c,v 1.3 2005-06-25 15:46:04 adam Exp $
  */
 
 /**
@@ -464,3 +464,11 @@ BOOL EventHandlerRoutine(DWORD dwCtrlType)
     }
 }
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 4a76ca9..2737052 100644 (file)
@@ -2,7 +2,7 @@
  * NT Service interface Utility.
  *  Based on code written by
  *     Chas Woodfield, Fretwell Downing Datasystems.
- * $Id: service.h,v 1.2 2004-10-15 00:19:00 adam Exp $
+ * $Id: service.h,v 1.3 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file service.h
@@ -46,3 +46,11 @@ void RunAppService(void *pHandle);
 void StopAppService(void *pHandle);
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 73d443a..e28b63a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.57 2005-06-13 10:27:00 adam Exp $
+ * $Id: seshigh.c,v 1.58 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file seshigh.c
@@ -81,7 +81,7 @@ static int process_gdu_response(association *assoc, request *req, Z_GDU *res);
 static int process_z_response(association *assoc, request *req, Z_APDU *res);
 static Z_APDU *process_initRequest(association *assoc, request *reqb);
 static Z_External *init_diagnostics(ODR odr, int errcode,
-                                   const char *errstring);
+                                    const char *errstring);
 static Z_APDU *process_searchRequest(association *assoc, request *reqb,
     int *fd);
 static Z_APDU *response_searchRequest(association *assoc, request *reqb,
@@ -119,8 +119,8 @@ static void get_logbits()
 static void wr_diag(WRBUF w, int error, const char *addinfo)
 {
     wrbuf_printf(w, "ERROR [%d] %s%s%s",
-                error, diagbib1_str(error),
-                addinfo ? "--" : "", addinfo ? addinfo : "");
+                 error, diagbib1_str(error),
+                 addinfo ? "--" : "", addinfo ? addinfo : "");
 }
 
 
@@ -131,7 +131,7 @@ static void wr_diag(WRBUF w, int error, const char *addinfo)
  * Returns: 0 or a new association handle.
  */
 association *create_association(IOCHAN channel, COMSTACK link,
-                               const char *apdufile)
+                                const char *apdufile)
 {
     association *anew;
 
@@ -162,14 +162,14 @@ association *create_association(IOCHAN channel, COMSTACK link,
         }       
         else if (*apdufile != '-')
         {
-           char filename[256];
-           sprintf(filename, "%.200s.%ld", apdufile, (long)getpid());
-           if (!(f = fopen(filename, "w")))
-           {
-               yaz_log(YLOG_WARN|YLOG_ERRNO, "%s", filename);
-               return 0;
-           }
-           setvbuf(f, 0, _IONBF, 0);
+            char filename[256];
+            sprintf(filename, "%.200s.%ld", apdufile, (long)getpid());
+            if (!(f = fopen(filename, "w")))
+            {
+                yaz_log(YLOG_WARN|YLOG_ERRNO, "%s", filename);
+                return 0;
+            }
+            setvbuf(f, 0, _IONBF, 0);
             odr_setprint(anew->print, f);
         }
     }
@@ -489,36 +489,36 @@ static int srw_bend_init(association *assoc, Z_SRW_diagnostic **d, int *num)
     statserv_options_block *cb = statserv_getcontrol();
     if (!assoc->init)
     {
-       const char *encoding = "UTF-8";
-       Z_External *ce;
-       bend_initresult *binitres;
+        const char *encoding = "UTF-8";
+        Z_External *ce;
+        bend_initresult *binitres;
 
-       yaz_log(YLOG_LOG, "srw_bend_init config=%s", cb->configname);
-       assoc_init_reset(assoc);
-       
-       assoc->maximumRecordSize = 3000000;
-       assoc->preferredMessageSize = 3000000;
+        yaz_log(YLOG_LOG, "srw_bend_init config=%s", cb->configname);
+        assoc_init_reset(assoc);
+        
+        assoc->maximumRecordSize = 3000000;
+        assoc->preferredMessageSize = 3000000;
 #if 1
-       ce = yaz_set_proposal_charneg(assoc->decode, &encoding, 1, 0, 0, 1);
-       assoc->init->charneg_request = ce->u.charNeg3;
+        ce = yaz_set_proposal_charneg(assoc->decode, &encoding, 1, 0, 0, 1);
+        assoc->init->charneg_request = ce->u.charNeg3;
 #endif
-       assoc->backend = 0;
-       if (!(binitres = (*cb->bend_init)(assoc->init)))
-       {
-           assoc->state = ASSOC_DEAD;
-           yaz_add_srw_diagnostic(assoc->encode, d, num,
-                           YAZ_SRW_AUTHENTICATION_ERROR, 0);
-           return 0;
-       }
-       assoc->backend = binitres->handle;
-       if (binitres->errcode)
-       {
-           assoc->state = ASSOC_DEAD;
-           yaz_add_srw_diagnostic(assoc->encode, d, num, binitres->errcode,
-                                  binitres->errstring);
-           return 0;
-       }
-       return 1;
+        assoc->backend = 0;
+        if (!(binitres = (*cb->bend_init)(assoc->init)))
+        {
+            assoc->state = ASSOC_DEAD;
+            yaz_add_srw_diagnostic(assoc->encode, d, num,
+                            YAZ_SRW_AUTHENTICATION_ERROR, 0);
+            return 0;
+        }
+        assoc->backend = binitres->handle;
+        if (binitres->errcode)
+        {
+            assoc->state = ASSOC_DEAD;
+            yaz_add_srw_diagnostic(assoc->encode, d, num, binitres->errcode,
+                                   binitres->errstring);
+            return 0;
+        }
+        return 1;
     }
     return 1;
 }
@@ -630,7 +630,7 @@ static int srw_bend_fetch(association *assoc, int pos,
 }
 
 static int cql2pqf(ODR odr, const char *cql, cql_transform_t ct,
-                  Z_Query *query_result)
+                   Z_Query *query_result)
 {
     /* have a CQL query and  CQL to PQF transform .. */
     CQL_parser cp = cql_parser_create();
@@ -638,70 +638,70 @@ static int cql2pqf(ODR odr, const char *cql, cql_transform_t ct,
     int srw_errcode = 0;
     const char *add = 0;
     char rpn_buf[512];
-           
+            
     r = cql_parser_string(cp, cql);
     if (r)
     {
-       /* CQL syntax error */
-       srw_errcode = 10; 
+        /* CQL syntax error */
+        srw_errcode = 10; 
     }
     if (!r)
     {
-       /* Syntax OK */
-       r = cql_transform_buf(ct,
-                             cql_parser_result(cp),
-                             rpn_buf, sizeof(rpn_buf)-1);
-       if (r)
-           srw_errcode  = cql_transform_error(ct, &add);
+        /* Syntax OK */
+        r = cql_transform_buf(ct,
+                              cql_parser_result(cp),
+                              rpn_buf, sizeof(rpn_buf)-1);
+        if (r)
+            srw_errcode  = cql_transform_error(ct, &add);
     }
     if (!r)
     {
-       /* Syntax & transform OK. */
-       /* Convert PQF string to Z39.50 to RPN query struct */
-       YAZ_PQF_Parser pp = yaz_pqf_create();
-       Z_RPNQuery *rpnquery = yaz_pqf_parse(pp, odr, rpn_buf);
-       if (!rpnquery)
-       {
-           size_t off;
-           const char *pqf_msg;
-           int code = yaz_pqf_error(pp, &pqf_msg, &off);
-           yaz_log(YLOG_WARN, "PQF Parser Error %s (code %d)",
-                   pqf_msg, code);
-           srw_errcode = 10;
-       }
-       else
-       {
-           query_result->which = Z_Query_type_1;
-           query_result->u.type_1 = rpnquery;
-       }
-       yaz_pqf_destroy(pp);
+        /* Syntax & transform OK. */
+        /* Convert PQF string to Z39.50 to RPN query struct */
+        YAZ_PQF_Parser pp = yaz_pqf_create();
+        Z_RPNQuery *rpnquery = yaz_pqf_parse(pp, odr, rpn_buf);
+        if (!rpnquery)
+        {
+            size_t off;
+            const char *pqf_msg;
+            int code = yaz_pqf_error(pp, &pqf_msg, &off);
+            yaz_log(YLOG_WARN, "PQF Parser Error %s (code %d)",
+                    pqf_msg, code);
+            srw_errcode = 10;
+        }
+        else
+        {
+            query_result->which = Z_Query_type_1;
+            query_result->u.type_1 = rpnquery;
+        }
+        yaz_pqf_destroy(pp);
     }
     cql_parser_destroy(cp);
     return srw_errcode;
 }
 
 static int cql2pqf_scan(ODR odr, const char *cql, cql_transform_t ct,
-                       Z_AttributesPlusTerm *result)
+                        Z_AttributesPlusTerm *result)
 {
     Z_Query query;
     Z_RPNQuery *rpn;
     int srw_error = cql2pqf(odr, cql, ct, &query);
     if (srw_error)
-       return srw_error;
+        return srw_error;
     if (query.which != Z_Query_type_1 && query.which != Z_Query_type_101)
-       return 10; /* bad query type */
+        return 10; /* bad query type */
     rpn = query.u.type_1;
     if (!rpn->RPNStructure) 
-       return 10; /* must be structure */
+        return 10; /* must be structure */
     if (rpn->RPNStructure->which != Z_RPNStructure_simple)
-       return 10; /* must be simple */
+        return 10; /* must be simple */
     if (rpn->RPNStructure->u.simple->which != Z_Operand_APT)
-       return 10; /* must be attributes plus term node .. */
+        return 10; /* must be attributes plus term node .. */
     memcpy(result, rpn->RPNStructure->u.simple->u.attributesPlusTerm,
-          sizeof(*result));
+           sizeof(*result));
     return 0;
 }
-                  
+                   
 static void srw_bend_search(association *assoc, request *req,
                             Z_SRW_searchRetrieveRequest *srw_req,
                             Z_SRW_searchRetrieveResponse *srw_res,
@@ -715,203 +715,203 @@ static void srw_bend_search(association *assoc, request *req,
     srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics);
     if (srw_res->num_diagnostics == 0 && assoc->init)
     {
-       bend_search_rr rr;
-       rr.setname = "default";
-       rr.replace_set = 1;
-       rr.num_bases = 1;
-       rr.basenames = &srw_req->database;
-       rr.referenceId = 0;
-       rr.srw_sortKeys = 0;
-       
-       rr.query = (Z_Query *) odr_malloc (assoc->decode, sizeof(*rr.query));
-       rr.query->u.type_1 = 0;
-       
-       if (srw_req->query_type == Z_SRW_query_type_cql)
-       {
-           if (assoc->cql_transform)
-           {
-               int srw_errcode = cql2pqf(assoc->encode, srw_req->query.cql,
-                                         assoc->cql_transform, rr.query);
-               if (srw_errcode)
-               {
-                   yaz_add_srw_diagnostic(assoc->encode,
-                                          &srw_res->diagnostics,
-                                          &srw_res->num_diagnostics,
-                                          srw_errcode, 0);
-               }
-           }
-           else
-           {
-               /* CQL query to backend. Wrap it - Z39.50 style */
-               ext = (Z_External *) odr_malloc(assoc->decode, sizeof(*ext));
-               ext->direct_reference = odr_getoidbystr(assoc->decode, 
-                                                       "1.2.840.10003.16.2");
-               ext->indirect_reference = 0;
-               ext->descriptor = 0;
-               ext->which = Z_External_CQL;
-               ext->u.cql = srw_req->query.cql;
-               
-               rr.query->which = Z_Query_type_104;
-               rr.query->u.type_104 =  ext;
-           }
-       }
-       else if (srw_req->query_type == Z_SRW_query_type_pqf)
-       {
-           Z_RPNQuery *RPNquery;
-           YAZ_PQF_Parser pqf_parser;
-           
-           pqf_parser = yaz_pqf_create ();
-           
-           RPNquery = yaz_pqf_parse (pqf_parser, assoc->decode,
-                                     srw_req->query.pqf);
-           if (!RPNquery)
-           {
-               const char *pqf_msg;
-               size_t off;
-               int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
-               yaz_log(log_requestdetail, "Parse error %d %s near offset %d",
-                       code, pqf_msg, off);
-               srw_error = YAZ_SRW_QUERY_SYNTAX_ERROR;
-           }
-           
-           rr.query->which = Z_Query_type_1;
-           rr.query->u.type_1 =  RPNquery;
-           
-           yaz_pqf_destroy (pqf_parser);
-       }
-       else
-       {
-           yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                                  &srw_res->num_diagnostics,
-                                  YAZ_SRW_UNSUPP_QUERY_TYPE, 0);
-       }
-       if (rr.query->u.type_1)
-       {
-           rr.stream = assoc->encode;
-           rr.decode = assoc->decode;
-           rr.print = assoc->print;
-           rr.request = req;
-           if ( srw_req->sort.sortKeys )
-               rr.srw_sortKeys = odr_strdup(assoc->encode, 
-                                            srw_req->sort.sortKeys );
-           rr.association = assoc;
-           rr.fd = 0;
-           rr.hits = 0;
-           rr.errcode = 0;
-           rr.errstring = 0;
-           rr.search_info = 0;
-           yaz_log_zquery_level(log_requestdetail,rr.query);
-           
-           (assoc->init->bend_search)(assoc->backend, &rr);
-           if (rr.errcode)
-           {
-               if (rr.errcode == YAZ_BIB1_DATABASE_UNAVAILABLE)
-               {
-                   *http_code = 404;
-               }
-               else
-               {
-                   srw_error = yaz_diag_bib1_to_srw (rr.errcode);
-                   yaz_add_srw_diagnostic(assoc->encode,
-                                          &srw_res->diagnostics,
-                                          &srw_res->num_diagnostics,
-                                          srw_error, rr.errstring);
-               }
-           }
-           else
-           {
-               int number = srw_req->maximumRecords ? *srw_req->maximumRecords : 0;
-               int start = srw_req->startRecord ? *srw_req->startRecord : 1;
-               
-               yaz_log(log_requestdetail, "Request to pack %d+%d out of %d",
-                       start, number, rr.hits);
-               
-               srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits);
-               if (number > 0)
-               {
-                   int i;
-                   
-                   if (start > rr.hits)
-                   {
-                       yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                                              &srw_res->num_diagnostics,
-                                              YAZ_SRW_FIRST_RECORD_POSITION_OUT_OF_RANGE, 0);
-                   }
-                   else
-                   {
-                       int j = 0;
-                       int packing = Z_SRW_recordPacking_string;
-                       if (start + number > rr.hits)
-                           number = rr.hits - start + 1;
-                       if (srw_req->recordPacking && 
-                           !strcmp(srw_req->recordPacking, "xml"))
-                           packing = Z_SRW_recordPacking_XML;
-                       srw_res->records = (Z_SRW_record *)
-                           odr_malloc(assoc->encode,
-                                      number * sizeof(*srw_res->records));
-                       for (i = 0; i<number; i++)
-                       {
-                           int errcode;
-                           
-                           srw_res->records[j].recordPacking = packing;
-                           srw_res->records[j].recordData_buf = 0;
-                           yaz_log(YLOG_DEBUG, "srw_bend_fetch %d", i+start);
-                           errcode = srw_bend_fetch(assoc, i+start, srw_req,
-                                                    srw_res->records + j);
-                           if (errcode)
-                           {
-                               yaz_add_srw_diagnostic(assoc->encode,
-                                                      &srw_res->diagnostics,
-                                                      &srw_res->num_diagnostics,
-                                                      yaz_diag_bib1_to_srw (errcode),
-                                                      rr.errstring);
-                               
-                               break;
-                           }
-                           if (srw_res->records[j].recordData_buf)
-                               j++;
-                       }
-                       srw_res->num_records = j;
-                       if (!j)
-                           srw_res->records = 0;
-                   }
-               }
-           }
-       }
+        bend_search_rr rr;
+        rr.setname = "default";
+        rr.replace_set = 1;
+        rr.num_bases = 1;
+        rr.basenames = &srw_req->database;
+        rr.referenceId = 0;
+        rr.srw_sortKeys = 0;
+        
+        rr.query = (Z_Query *) odr_malloc (assoc->decode, sizeof(*rr.query));
+        rr.query->u.type_1 = 0;
+        
+        if (srw_req->query_type == Z_SRW_query_type_cql)
+        {
+            if (assoc->cql_transform)
+            {
+                int srw_errcode = cql2pqf(assoc->encode, srw_req->query.cql,
+                                          assoc->cql_transform, rr.query);
+                if (srw_errcode)
+                {
+                    yaz_add_srw_diagnostic(assoc->encode,
+                                           &srw_res->diagnostics,
+                                           &srw_res->num_diagnostics,
+                                           srw_errcode, 0);
+                }
+            }
+            else
+            {
+                /* CQL query to backend. Wrap it - Z39.50 style */
+                ext = (Z_External *) odr_malloc(assoc->decode, sizeof(*ext));
+                ext->direct_reference = odr_getoidbystr(assoc->decode, 
+                                                        "1.2.840.10003.16.2");
+                ext->indirect_reference = 0;
+                ext->descriptor = 0;
+                ext->which = Z_External_CQL;
+                ext->u.cql = srw_req->query.cql;
+                
+                rr.query->which = Z_Query_type_104;
+                rr.query->u.type_104 =  ext;
+            }
+        }
+        else if (srw_req->query_type == Z_SRW_query_type_pqf)
+        {
+            Z_RPNQuery *RPNquery;
+            YAZ_PQF_Parser pqf_parser;
+            
+            pqf_parser = yaz_pqf_create ();
+            
+            RPNquery = yaz_pqf_parse (pqf_parser, assoc->decode,
+                                      srw_req->query.pqf);
+            if (!RPNquery)
+            {
+                const char *pqf_msg;
+                size_t off;
+                int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
+                yaz_log(log_requestdetail, "Parse error %d %s near offset %d",
+                        code, pqf_msg, off);
+                srw_error = YAZ_SRW_QUERY_SYNTAX_ERROR;
+            }
+            
+            rr.query->which = Z_Query_type_1;
+            rr.query->u.type_1 =  RPNquery;
+            
+            yaz_pqf_destroy (pqf_parser);
+        }
+        else
+        {
+            yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+                                   &srw_res->num_diagnostics,
+                                   YAZ_SRW_UNSUPP_QUERY_TYPE, 0);
+        }
+        if (rr.query->u.type_1)
+        {
+            rr.stream = assoc->encode;
+            rr.decode = assoc->decode;
+            rr.print = assoc->print;
+            rr.request = req;
+            if ( srw_req->sort.sortKeys )
+                rr.srw_sortKeys = odr_strdup(assoc->encode, 
+                                             srw_req->sort.sortKeys );
+            rr.association = assoc;
+            rr.fd = 0;
+            rr.hits = 0;
+            rr.errcode = 0;
+            rr.errstring = 0;
+            rr.search_info = 0;
+            yaz_log_zquery_level(log_requestdetail,rr.query);
+            
+            (assoc->init->bend_search)(assoc->backend, &rr);
+            if (rr.errcode)
+            {
+                if (rr.errcode == YAZ_BIB1_DATABASE_UNAVAILABLE)
+                {
+                    *http_code = 404;
+                }
+                else
+                {
+                    srw_error = yaz_diag_bib1_to_srw (rr.errcode);
+                    yaz_add_srw_diagnostic(assoc->encode,
+                                           &srw_res->diagnostics,
+                                           &srw_res->num_diagnostics,
+                                           srw_error, rr.errstring);
+                }
+            }
+            else
+            {
+                int number = srw_req->maximumRecords ? *srw_req->maximumRecords : 0;
+                int start = srw_req->startRecord ? *srw_req->startRecord : 1;
+                
+                yaz_log(log_requestdetail, "Request to pack %d+%d out of %d",
+                        start, number, rr.hits);
+                
+                srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits);
+                if (number > 0)
+                {
+                    int i;
+                    
+                    if (start > rr.hits)
+                    {
+                        yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+                                               &srw_res->num_diagnostics,
+                                               YAZ_SRW_FIRST_RECORD_POSITION_OUT_OF_RANGE, 0);
+                    }
+                    else
+                    {
+                        int j = 0;
+                        int packing = Z_SRW_recordPacking_string;
+                        if (start + number > rr.hits)
+                            number = rr.hits - start + 1;
+                        if (srw_req->recordPacking && 
+                            !strcmp(srw_req->recordPacking, "xml"))
+                            packing = Z_SRW_recordPacking_XML;
+                        srw_res->records = (Z_SRW_record *)
+                            odr_malloc(assoc->encode,
+                                       number * sizeof(*srw_res->records));
+                        for (i = 0; i<number; i++)
+                        {
+                            int errcode;
+                            
+                            srw_res->records[j].recordPacking = packing;
+                            srw_res->records[j].recordData_buf = 0;
+                            yaz_log(YLOG_DEBUG, "srw_bend_fetch %d", i+start);
+                            errcode = srw_bend_fetch(assoc, i+start, srw_req,
+                                                     srw_res->records + j);
+                            if (errcode)
+                            {
+                                yaz_add_srw_diagnostic(assoc->encode,
+                                                       &srw_res->diagnostics,
+                                                       &srw_res->num_diagnostics,
+                                                       yaz_diag_bib1_to_srw (errcode),
+                                                       rr.errstring);
+                                
+                                break;
+                            }
+                            if (srw_res->records[j].recordData_buf)
+                                j++;
+                        }
+                        srw_res->num_records = j;
+                        if (!j)
+                            srw_res->records = 0;
+                    }
+                }
+            }
+        }
     }
     if (log_request)
     {
-       const char *querystr = "?";
-       const char *querytype = "?";
+        const char *querystr = "?";
+        const char *querytype = "?";
         WRBUF wr = wrbuf_alloc();
 
-       switch (srw_req->query_type)
-       {
-       case Z_SRW_query_type_cql:
-           querytype = "CQL";
-           querystr = srw_req->query.cql;
-           break;
-       case Z_SRW_query_type_pqf:
-           querytype = "PQF";
-           querystr = srw_req->query.pqf;
-           break;
-       }
+        switch (srw_req->query_type)
+        {
+        case Z_SRW_query_type_cql:
+            querytype = "CQL";
+            querystr = srw_req->query.cql;
+            break;
+        case Z_SRW_query_type_pqf:
+            querytype = "PQF";
+            querystr = srw_req->query.pqf;
+            break;
+        }
         wrbuf_printf(wr, "SRWSearch ");
         if (srw_res->num_diagnostics)
             wrbuf_printf(wr, "ERROR %s", srw_res->diagnostics[0].uri);
-       else if (*http_code != 200)
-           wrbuf_printf(wr, "ERROR info:http/%d", *http_code);
+        else if (*http_code != 200)
+            wrbuf_printf(wr, "ERROR info:http/%d", *http_code);
         else if (srw_res->numberOfRecords)
-       {
+        {
             wrbuf_printf(wr, "OK %d",
-                        (srw_res->numberOfRecords ?
-                         *srw_res->numberOfRecords : 0));
-       }
-       wrbuf_printf(wr, " %s %d+%d", 
-                    (srw_res->resultSetId ?
-                     srw_res->resultSetId : "-"),
-                    (srw_req->startRecord ? *srw_req->startRecord : 1), 
-                    srw_res->num_records);
+                         (srw_res->numberOfRecords ?
+                          *srw_res->numberOfRecords : 0));
+        }
+        wrbuf_printf(wr, " %s %d+%d", 
+                     (srw_res->resultSetId ?
+                      srw_res->resultSetId : "-"),
+                     (srw_req->startRecord ? *srw_req->startRecord : 1), 
+                     srw_res->num_records);
         yaz_log(log_request, "%s %s: %s", wrbuf_buf(wr), querytype, querystr);
         wrbuf_free(wr, 1);
     }
@@ -922,32 +922,32 @@ static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr)
 #if HAVE_XML2
     xmlNodePtr ptr = rr->server_node_ptr;
     if (!ptr)
-       return 0;
+        return 0;
     for (ptr = ptr->children; ptr; ptr = ptr->next)
     {
-       if (ptr->type != XML_ELEMENT_NODE)
-           continue;
-       if (!strcmp((const char *) ptr->name, "explain"))
-       {
-           int len;
-           xmlDocPtr doc = xmlNewDoc("1.0");
-           xmlChar *buf_out;
-           char *content;
+        if (ptr->type != XML_ELEMENT_NODE)
+            continue;
+        if (!strcmp((const char *) ptr->name, "explain"))
+        {
+            int len;
+            xmlDocPtr doc = xmlNewDoc("1.0");
+            xmlChar *buf_out;
+            char *content;
 
-           ptr = xmlCopyNode(ptr, 1);
+            ptr = xmlCopyNode(ptr, 1);
         
-           xmlDocSetRootElement(doc, ptr);
-           
-           xmlDocDumpMemory(doc, &buf_out, &len);
-           content = (char*) odr_malloc(rr->stream, 1+len);
-           memcpy(content, buf_out, len);
-           content[len] = '\0';
-           
-           xmlFree(buf_out);
-           xmlFreeDoc(doc);
-           rr->explain_buf = content;
-           return 0;
-       }
+            xmlDocSetRootElement(doc, ptr);
+            
+            xmlDocDumpMemory(doc, &buf_out, &len);
+            content = (char*) odr_malloc(rr->stream, 1+len);
+            memcpy(content, buf_out, len);
+            content[len] = '\0';
+            
+            xmlFree(buf_out);
+            xmlFreeDoc(doc);
+            rr->explain_buf = content;
+            return 0;
+        }
     }
 #endif
     return 0;
@@ -963,40 +963,40 @@ static void srw_bend_explain(association *assoc, request *req,
     srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics);
     if (assoc->init)
     {
-       bend_explain_rr rr;
-       
-       rr.stream = assoc->encode;
-       rr.decode = assoc->decode;
-       rr.print = assoc->print;
-       rr.explain_buf = 0;
-       rr.database = srw_req->database;
-       rr.server_node_ptr = assoc->server_node_ptr;
-       rr.schema = "http://explain.z3950.org/dtd/2.0/";
-       if (assoc->init->bend_explain)
-           (*assoc->init->bend_explain)(assoc->backend, &rr);
-       else
-           srw_bend_explain_default(assoc->backend, &rr);
-
-       if (rr.explain_buf)
-       {
-           int packing = Z_SRW_recordPacking_string;
-           if (srw_req->recordPacking && 
-               !strcmp(srw_req->recordPacking, "xml"))
-               packing = Z_SRW_recordPacking_XML;
-           srw_res->record.recordSchema = rr.schema;
-           srw_res->record.recordPacking = packing;
-           srw_res->record.recordData_buf = rr.explain_buf;
-           srw_res->record.recordData_len = strlen(rr.explain_buf);
-           srw_res->record.recordPosition = 0;
-           *http_code = 200;
-       }
+        bend_explain_rr rr;
+        
+        rr.stream = assoc->encode;
+        rr.decode = assoc->decode;
+        rr.print = assoc->print;
+        rr.explain_buf = 0;
+        rr.database = srw_req->database;
+        rr.server_node_ptr = assoc->server_node_ptr;
+        rr.schema = "http://explain.z3950.org/dtd/2.0/";
+        if (assoc->init->bend_explain)
+            (*assoc->init->bend_explain)(assoc->backend, &rr);
+        else
+            srw_bend_explain_default(assoc->backend, &rr);
+
+        if (rr.explain_buf)
+        {
+            int packing = Z_SRW_recordPacking_string;
+            if (srw_req->recordPacking && 
+                !strcmp(srw_req->recordPacking, "xml"))
+                packing = Z_SRW_recordPacking_XML;
+            srw_res->record.recordSchema = rr.schema;
+            srw_res->record.recordPacking = packing;
+            srw_res->record.recordData_buf = rr.explain_buf;
+            srw_res->record.recordData_len = strlen(rr.explain_buf);
+            srw_res->record.recordPosition = 0;
+            *http_code = 200;
+        }
     }
 }
 
 static void srw_bend_scan(association *assoc, request *req,
-                         Z_SRW_scanRequest *srw_req,
-                         Z_SRW_scanResponse *srw_res,
-                         int *http_code)
+                          Z_SRW_scanRequest *srw_req,
+                          Z_SRW_scanResponse *srw_res,
+                          int *http_code)
 {
     yaz_log(log_requestdetail, "Got SRW ScanRequest");
 
@@ -1004,170 +1004,170 @@ static void srw_bend_scan(association *assoc, request *req,
     srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics);
     if (srw_res->num_diagnostics == 0 && assoc->init)
     {
-       struct scan_entry *save_entries;
-
-       bend_scan_rr *bsrr = (bend_scan_rr *)
-           odr_malloc (assoc->encode, sizeof(*bsrr));
-       bsrr->num_bases = 1;
-       bsrr->basenames = &srw_req->database;
-
-       bsrr->num_entries = srw_req->maximumTerms ?
-           *srw_req->maximumTerms : 10;
-       bsrr->term_position = srw_req->responsePosition ?
-           *srw_req->responsePosition : 1;
-
-       bsrr->errcode = 0;
-       bsrr->errstring = 0;
-       bsrr->referenceId = 0;
-       bsrr->stream = assoc->encode;
-       bsrr->print = assoc->print;
-       bsrr->step_size = odr_intdup(assoc->decode, 0);
-       bsrr->entries = 0;
-
-       if (bsrr->num_entries > 0) 
-       {
-           int i;
-           bsrr->entries = odr_malloc(assoc->decode, sizeof(*bsrr->entries) *
-                                      bsrr->num_entries);
-           for (i = 0; i<bsrr->num_entries; i++)
-           {
-               bsrr->entries[i].term = 0;
-               bsrr->entries[i].occurrences = 0;
-               bsrr->entries[i].errcode = 0;
-               bsrr->entries[i].errstring = 0;
-               bsrr->entries[i].display_term = 0;
-           }
-       }
-       save_entries = bsrr->entries;  /* save it so we can compare later */
-
-       if (srw_req->query_type == Z_SRW_query_type_pqf &&
-           assoc->init->bend_scan)
-       {
-           Odr_oid *scan_attributeSet = 0;
-           oident *attset;
-           YAZ_PQF_Parser pqf_parser = yaz_pqf_create();
-           
-           bsrr->term = yaz_pqf_scan(pqf_parser, assoc->decode,
-                                     &scan_attributeSet, 
-                                     srw_req->scanClause.pqf); 
-           if (scan_attributeSet &&
-               (attset = oid_getentbyoid(scan_attributeSet)) &&
-               (attset->oclass == CLASS_ATTSET ||
-                attset->oclass == CLASS_GENERAL))
-               bsrr->attributeset = attset->value;
-           else
-               bsrr->attributeset = VAL_NONE;
-           yaz_pqf_destroy(pqf_parser);
-           bsrr->scanClause = 0;
-           ((int (*)(void *, bend_scan_rr *))
-            (*assoc->init->bend_scan))(assoc->backend, bsrr);
-       }
-       else if (srw_req->query_type == Z_SRW_query_type_cql
-                && assoc->init->bend_srw_scan)
-       {
-           if (assoc->cql_transform)
-           {
-               int srw_error;
-               bsrr->scanClause = 0;
-               bsrr->attributeset = VAL_NONE;
-               bsrr->term = odr_malloc(assoc->decode, sizeof(*bsrr->term));
-               srw_error = cql2pqf_scan(assoc->encode,
-                                            srw_req->scanClause.cql,
-                                            assoc->cql_transform,
-                                            bsrr->term);
-               if (srw_error)
-                   yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                                          &srw_res->num_diagnostics,
-                                          srw_error, 0);
-               else
-               {
-                   ((int (*)(void *, bend_scan_rr *))
-                    (*assoc->init->bend_scan))(assoc->backend, bsrr);
-               }
-           }
-           else
-           {
-               bsrr->term = 0;
-               bsrr->attributeset = VAL_NONE;
-               bsrr->scanClause = srw_req->scanClause.cql;
-               ((int (*)(void *, bend_scan_rr *))
-                (*assoc->init->bend_srw_scan))(assoc->backend, bsrr);
-           }
-       }
-       else
-       {
-           yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                                  &srw_res->num_diagnostics,
-                                  YAZ_SRW_UNSUPP_OPERATION, "scan");
-       }
-       if (bsrr->errcode)
-       {
-           int srw_error;
-           if (bsrr->errcode == YAZ_BIB1_DATABASE_UNAVAILABLE)
-           {
-               *http_code = 404;
-               return;
-           }
-           srw_error = yaz_diag_bib1_to_srw (bsrr->errcode);
-
-           yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
-                                  &srw_res->num_diagnostics,
-                                  srw_error, bsrr->errstring);
-       }
-       else if (srw_res->num_diagnostics == 0 && bsrr->num_entries)
-       {
-           int i;
-           srw_res->terms = (Z_SRW_scanTerm*)
-               odr_malloc(assoc->encode, sizeof(*srw_res->terms) *
-                          bsrr->num_entries);
-
-           srw_res->num_terms =  bsrr->num_entries;
-           for (i = 0; i<bsrr->num_entries; i++)
-           {
-               Z_SRW_scanTerm *t = srw_res->terms + i;
-               t->value = odr_strdup(assoc->encode, bsrr->entries[i].term);
-               t->numberOfRecords =
-                   odr_intdup(assoc->encode, bsrr->entries[i].occurrences);
-               t->displayTerm = 0;
+        struct scan_entry *save_entries;
+
+        bend_scan_rr *bsrr = (bend_scan_rr *)
+            odr_malloc (assoc->encode, sizeof(*bsrr));
+        bsrr->num_bases = 1;
+        bsrr->basenames = &srw_req->database;
+
+        bsrr->num_entries = srw_req->maximumTerms ?
+            *srw_req->maximumTerms : 10;
+        bsrr->term_position = srw_req->responsePosition ?
+            *srw_req->responsePosition : 1;
+
+        bsrr->errcode = 0;
+        bsrr->errstring = 0;
+        bsrr->referenceId = 0;
+        bsrr->stream = assoc->encode;
+        bsrr->print = assoc->print;
+        bsrr->step_size = odr_intdup(assoc->decode, 0);
+        bsrr->entries = 0;
+
+        if (bsrr->num_entries > 0) 
+        {
+            int i;
+            bsrr->entries = odr_malloc(assoc->decode, sizeof(*bsrr->entries) *
+                                       bsrr->num_entries);
+            for (i = 0; i<bsrr->num_entries; i++)
+            {
+                bsrr->entries[i].term = 0;
+                bsrr->entries[i].occurrences = 0;
+                bsrr->entries[i].errcode = 0;
+                bsrr->entries[i].errstring = 0;
+                bsrr->entries[i].display_term = 0;
+            }
+        }
+        save_entries = bsrr->entries;  /* save it so we can compare later */
+
+        if (srw_req->query_type == Z_SRW_query_type_pqf &&
+            assoc->init->bend_scan)
+        {
+            Odr_oid *scan_attributeSet = 0;
+            oident *attset;
+            YAZ_PQF_Parser pqf_parser = yaz_pqf_create();
+            
+            bsrr->term = yaz_pqf_scan(pqf_parser, assoc->decode,
+                                      &scan_attributeSet, 
+                                      srw_req->scanClause.pqf); 
+            if (scan_attributeSet &&
+                (attset = oid_getentbyoid(scan_attributeSet)) &&
+                (attset->oclass == CLASS_ATTSET ||
+                 attset->oclass == CLASS_GENERAL))
+                bsrr->attributeset = attset->value;
+            else
+                bsrr->attributeset = VAL_NONE;
+            yaz_pqf_destroy(pqf_parser);
+            bsrr->scanClause = 0;
+            ((int (*)(void *, bend_scan_rr *))
+             (*assoc->init->bend_scan))(assoc->backend, bsrr);
+        }
+        else if (srw_req->query_type == Z_SRW_query_type_cql
+                 && assoc->init->bend_srw_scan)
+        {
+            if (assoc->cql_transform)
+            {
+                int srw_error;
+                bsrr->scanClause = 0;
+                bsrr->attributeset = VAL_NONE;
+                bsrr->term = odr_malloc(assoc->decode, sizeof(*bsrr->term));
+                srw_error = cql2pqf_scan(assoc->encode,
+                                             srw_req->scanClause.cql,
+                                             assoc->cql_transform,
+                                             bsrr->term);
+                if (srw_error)
+                    yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+                                           &srw_res->num_diagnostics,
+                                           srw_error, 0);
+                else
+                {
+                    ((int (*)(void *, bend_scan_rr *))
+                     (*assoc->init->bend_scan))(assoc->backend, bsrr);
+                }
+            }
+            else
+            {
+                bsrr->term = 0;
+                bsrr->attributeset = VAL_NONE;
+                bsrr->scanClause = srw_req->scanClause.cql;
+                ((int (*)(void *, bend_scan_rr *))
+                 (*assoc->init->bend_srw_scan))(assoc->backend, bsrr);
+            }
+        }
+        else
+        {
+            yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+                                   &srw_res->num_diagnostics,
+                                   YAZ_SRW_UNSUPP_OPERATION, "scan");
+        }
+        if (bsrr->errcode)
+        {
+            int srw_error;
+            if (bsrr->errcode == YAZ_BIB1_DATABASE_UNAVAILABLE)
+            {
+                *http_code = 404;
+                return;
+            }
+            srw_error = yaz_diag_bib1_to_srw (bsrr->errcode);
+
+            yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+                                   &srw_res->num_diagnostics,
+                                   srw_error, bsrr->errstring);
+        }
+        else if (srw_res->num_diagnostics == 0 && bsrr->num_entries)
+        {
+            int i;
+            srw_res->terms = (Z_SRW_scanTerm*)
+                odr_malloc(assoc->encode, sizeof(*srw_res->terms) *
+                           bsrr->num_entries);
+
+            srw_res->num_terms =  bsrr->num_entries;
+            for (i = 0; i<bsrr->num_entries; i++)
+            {
+                Z_SRW_scanTerm *t = srw_res->terms + i;
+                t->value = odr_strdup(assoc->encode, bsrr->entries[i].term);
+                t->numberOfRecords =
+                    odr_intdup(assoc->encode, bsrr->entries[i].occurrences);
+                t->displayTerm = 0;
                 if (save_entries == bsrr->entries && 
-                   bsrr->entries[i].display_term)
+                    bsrr->entries[i].display_term)
                 {
                     /* the entries was _not_ set by the handler. So it's
                        safe to test for new member display_term. It is
                        NULL'ed by us.
                     */
                     t->displayTerm = odr_strdup(assoc->encode, 
-                                               bsrr->entries[i].display_term);
+                                                bsrr->entries[i].display_term);
                 }
-               t->whereInList = 0;
-           }
-       }
+                t->whereInList = 0;
+            }
+        }
     }
     if (log_request)
     {
         WRBUF wr = wrbuf_alloc();
-       const char *querytype = 0;
-       const char *querystr = 0;
-
-       switch(srw_req->query_type)
-       {
-       case Z_SRW_query_type_pqf:
-           querytype = "PQF";
-           querystr = srw_req->scanClause.pqf;
-           break;
-       case Z_SRW_query_type_cql:
-           querytype = "CQL";
-           querystr = srw_req->scanClause.cql;
-           break;
-       default:
-           querytype = "Unknown";
-           querystr = "";
-       }
+        const char *querytype = 0;
+        const char *querystr = 0;
+
+        switch(srw_req->query_type)
+        {
+        case Z_SRW_query_type_pqf:
+            querytype = "PQF";
+            querystr = srw_req->scanClause.pqf;
+            break;
+        case Z_SRW_query_type_cql:
+            querytype = "CQL";
+            querystr = srw_req->scanClause.cql;
+            break;
+        default:
+            querytype = "Unknown";
+            querystr = "";
+        }
         wrbuf_printf(wr, "SRWScan %d+%d",
-                    (srw_req->responsePosition ? 
-                     *srw_req->responsePosition : 1),
-                    (srw_req->maximumTerms ?
-                     *srw_req->maximumTerms : 1));
+                     (srw_req->responsePosition ? 
+                      *srw_req->responsePosition : 1),
+                     (srw_req->maximumTerms ?
+                      *srw_req->maximumTerms : 1));
         if (srw_res->num_diagnostics)
             wrbuf_printf(wr, " ERROR %s", srw_res->diagnostics[0].uri);
         else
@@ -1198,8 +1198,8 @@ static void process_http_request(association *assoc, request *req)
 
     if (!control_association(assoc, host, 0))
     {
-       p = z_get_HTTP_Response(o, 404);
-       r = 1;
+        p = z_get_HTTP_Response(o, 404);
+        r = 1;
     }
     if (r == 2 && !strcmp(hreq->path, "/test")) 
     {   
@@ -1265,8 +1265,8 @@ static void process_http_request(association *assoc, request *req)
                 res->u.scan_response->diagnostics = diagnostic;
                 res->u.scan_response->num_diagnostics = num_diagnostic;
             }
-           srw_bend_scan(assoc, req, sr->u.scan_request,
-                             res->u.scan_response, &http_code);
+            srw_bend_scan(assoc, req, sr->u.scan_request,
+                              res->u.scan_response, &http_code);
             if (http_code == 200)
                 soap_package->u.generic->p = res;
         }
@@ -1594,18 +1594,18 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
     statserv_options_block *cb = 0;  /* by default no control for backend */
 
     if (control_association(assoc, get_vhost(req->otherInfo), 1))
-       cb = statserv_getcontrol();  /* got control block for backend */
+        cb = statserv_getcontrol();  /* got control block for backend */
     
     yaz_log(log_requestdetail, "Got initRequest");
     if (req->implementationId)
         yaz_log(log_requestdetail, "Id:        %s",
-               req->implementationId);
+                req->implementationId);
     if (req->implementationName)
         yaz_log(log_requestdetail, "Name:      %s",
-               req->implementationName);
+                req->implementationName);
     if (req->implementationVersion)
         yaz_log(log_requestdetail, "Version:   %s",
-               req->implementationVersion);
+                req->implementationVersion);
     
     assoc_init_reset(assoc);
 
@@ -1624,42 +1624,42 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
     assoc->backend = 0;
     if (cb)
     {
-       if (req->implementationVersion)
-           yaz_log(log_requestdetail, "Config:    %s",
-                   cb->configname);
+        if (req->implementationVersion)
+            yaz_log(log_requestdetail, "Config:    %s",
+                    cb->configname);
     
         iochan_settimeout(assoc->client_chan, cb->idle_timeout * 60);
-       
-       /* we have a backend control block, so call that init function */
-       if (!(binitres = (*cb->bend_init)(assoc->init)))
-       {
-           yaz_log(YLOG_WARN, "Bad response from backend.");
-           return 0;
-       }
-       assoc->backend = binitres->handle;
+        
+        /* we have a backend control block, so call that init function */
+        if (!(binitres = (*cb->bend_init)(assoc->init)))
+        {
+            yaz_log(YLOG_WARN, "Bad response from backend.");
+            return 0;
+        }
+        assoc->backend = binitres->handle;
     }
     else
     {
-       /* no backend. return error */
-       binitres = odr_malloc(assoc->encode, sizeof(*binitres));
-       binitres->errstring = 0;
-       binitres->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR;
-       iochan_settimeout(assoc->client_chan, 10);
+        /* no backend. return error */
+        binitres = odr_malloc(assoc->encode, sizeof(*binitres));
+        binitres->errstring = 0;
+        binitres->errcode = YAZ_BIB1_PERMANENT_SYSTEM_ERROR;
+        iochan_settimeout(assoc->client_chan, 10);
     }
     if ((assoc->init->bend_sort))
-       yaz_log (YLOG_DEBUG, "Sort handler installed");
+        yaz_log (YLOG_DEBUG, "Sort handler installed");
     if ((assoc->init->bend_search))
-       yaz_log (YLOG_DEBUG, "Search handler installed");
+        yaz_log (YLOG_DEBUG, "Search handler installed");
     if ((assoc->init->bend_present))
-       yaz_log (YLOG_DEBUG, "Present handler installed");   
+        yaz_log (YLOG_DEBUG, "Present handler installed");   
     if ((assoc->init->bend_esrequest))
-       yaz_log (YLOG_DEBUG, "ESRequest handler installed");   
+        yaz_log (YLOG_DEBUG, "ESRequest handler installed");   
     if ((assoc->init->bend_delete))
-       yaz_log (YLOG_DEBUG, "Delete handler installed");   
+        yaz_log (YLOG_DEBUG, "Delete handler installed");   
     if ((assoc->init->bend_scan))
-       yaz_log (YLOG_DEBUG, "Scan handler installed");   
+        yaz_log (YLOG_DEBUG, "Scan handler installed");   
     if ((assoc->init->bend_segment))
-       yaz_log (YLOG_DEBUG, "Segment handler installed");   
+        yaz_log (YLOG_DEBUG, "Segment handler installed");   
     
     resp->referenceId = req->referenceId;
     *options = '\0';
@@ -1764,7 +1764,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
-    version = odr_strdup(assoc->encode, "$Revision: 1.57 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.58 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
@@ -1776,27 +1776,27 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
     {
         assoc->state = ASSOC_DEAD;
         resp->userInformationField =
-           init_diagnostics(assoc->encode, binitres->errcode,
-                            binitres->errstring);
+            init_diagnostics(assoc->encode, binitres->errcode,
+                             binitres->errstring);
         *resp->result = 0;
     }
     if (log_request)
     {
-       WRBUF wr = wrbuf_alloc();
-       wrbuf_printf(wr, "Init ");
-       if (binitres->errcode)
-           wrbuf_printf(wr, "ERROR %d", binitres->errcode);
-       else
-           wrbuf_printf(wr, "OK -");
-       wrbuf_printf(wr, " ID:%s Name:%s Version:%s",
-                    (req->implementationId ? req->implementationId :"-"), 
-                    (req->implementationName ?
-                     req->implementationName : "-"),
-                    (req->implementationVersion ?
-                     req->implementationVersion : "-")
-           );
-       yaz_log(log_request, "%s", wrbuf_buf(wr));
-       wrbuf_free(wr, 1);
+        WRBUF wr = wrbuf_alloc();
+        wrbuf_printf(wr, "Init ");
+        if (binitres->errcode)
+            wrbuf_printf(wr, "ERROR %d", binitres->errcode);
+        else
+            wrbuf_printf(wr, "OK -");
+        wrbuf_printf(wr, " ID:%s Name:%s Version:%s",
+                     (req->implementationId ? req->implementationId :"-"), 
+                     (req->implementationName ?
+                      req->implementationName : "-"),
+                     (req->implementationVersion ?
+                      req->implementationVersion : "-")
+            );
+        yaz_log(log_request, "%s", wrbuf_buf(wr));
+        wrbuf_free(wr, 1);
     }
     return apdu;
 }
@@ -1822,11 +1822,11 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo)
     Z_Records *rec = (Z_Records *) odr_malloc (assoc->encode, sizeof(*rec));
 
     yaz_log(log_requestdetail, "[%d] %s%s%s", error, diagbib1_str(error),
-           addinfo ? " -- " : "", addinfo ? addinfo : "");
+            addinfo ? " -- " : "", addinfo ? addinfo : "");
 
     rec->which = Z_Records_NSD;
     rec->u.nonSurrogateDiagnostic = zget_DefaultDiagFormat(assoc->encode,
-                                                          error, addinfo);
+                                                           error, addinfo);
     return rec;
 }
 
@@ -1834,11 +1834,11 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo)
  * surrogate diagnostic.
  */
 static Z_NamePlusRecord *surrogatediagrec(association *assoc, 
-                                         const char *dbname,
+                                          const char *dbname,
                                           int error, const char *addinfo)
 {
     yaz_log(log_requestdetail, "[%d] %s%s%s", error, diagbib1_str(error),
-           addinfo ? " -- " : "", addinfo ? addinfo : "");
+            addinfo ? " -- " : "", addinfo ? addinfo : "");
     return zget_surrogateDiagRec(assoc->encode, dbname, error, addinfo);
 }
 
@@ -1898,7 +1898,7 @@ static Z_Records *pack_records(association *a, char *setname, int start,
         freq.schema = 0;
         (*a->init->bend_fetch)(a->backend, &freq);
 
-       *next = freq.last_in_set ? 0 : recno + 1;
+        *next = freq.last_in_set ? 0 : recno + 1;
 
         /* backend should be able to signal whether error is system-wide
            or only pertaining to current record */
@@ -1911,7 +1911,7 @@ static Z_Records *pack_records(association *a, char *setname, int start,
                 /* for 'present request out of range',
                    set addinfo to record position if not set */
                 if (freq.errcode == YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE  && 
-                               freq.errstring == 0)
+                                freq.errstring == 0)
                 {
                     sprintf (s, "%d", recno);
                     freq.errstring = s;
@@ -1926,11 +1926,11 @@ static Z_Records *pack_records(association *a, char *setname, int start,
             reclist->num_records++;
             continue;
         }
-       if (freq.record == 0)  /* no error and no record ? */
-       {
-           *next = 0;   /* signal end-of-set and stop */
-           break;
-       }
+        if (freq.record == 0)  /* no error and no record ? */
+        {
+            *next = 0;   /* signal end-of-set and stop */
+            break;
+        }
         if (freq.len >= 0)
             this_length = freq.len;
         else
@@ -1976,10 +1976,10 @@ static Z_Records *pack_records(association *a, char *setname, int start,
         if (!(thisrec = (Z_NamePlusRecord *)
               odr_malloc(a->encode, sizeof(*thisrec))))
             return 0;
-       if (freq.basename)
-           thisrec->databaseName = odr_strdup(a->encode, freq.basename);
-       else
-           thisrec->databaseName = 0;
+        if (freq.basename)
+            thisrec->databaseName = odr_strdup(a->encode, freq.basename);
+        else
+            thisrec->databaseName = 0;
         thisrec->which = Z_NamePlusRecord_databaseRecord;
 
         if (freq.output_format_raw)
@@ -2039,19 +2039,19 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb,
         bsrr->errstring = NULL;
         bsrr->search_info = NULL;
 
-       if (assoc->cql_transform &&
-           req->query->which == Z_Query_type_104 &&
-           req->query->u.type_104->which == Z_External_CQL)
-       {
-           /* have a CQL query and a CQL to PQF transform .. */
-           int srw_errcode = 
-               cql2pqf(bsrr->stream, req->query->u.type_104->u.cql,
-                       assoc->cql_transform, bsrr->query);
-           if (srw_errcode)
-               bsrr->errcode = yaz_diag_srw_to_bib1(srw_errcode);
-       }
-       if (!bsrr->errcode)
-           (assoc->init->bend_search)(assoc->backend, bsrr);
+        if (assoc->cql_transform &&
+            req->query->which == Z_Query_type_104 &&
+            req->query->u.type_104->which == Z_External_CQL)
+        {
+            /* have a CQL query and a CQL to PQF transform .. */
+            int srw_errcode = 
+                cql2pqf(bsrr->stream, req->query->u.type_104->u.cql,
+                        assoc->cql_transform, bsrr->query);
+            if (srw_errcode)
+                bsrr->errcode = yaz_diag_srw_to_bib1(srw_errcode);
+        }
+        if (!bsrr->errcode)
+            (assoc->init->bend_search)(assoc->backend, bsrr);
         if (!bsrr->request)  /* backend not ready with the search response */
             return 0;  /* should not be used any more */
     }
@@ -2146,8 +2146,8 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
             else
                 form = prefformat->value;
             resp->records = pack_records(assoc, req->resultSetName, 1,
-                                        toget, compp, next, presst, form, req->referenceId,
-                                        req->preferredRecordSyntax, NULL);
+                                         toget, compp, next, presst, form, req->referenceId,
+                                         req->preferredRecordSyntax, NULL);
             if (!resp->records)
                 return 0;
             resp->numberOfRecordsReturned = toget;
@@ -2174,13 +2174,13 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
     {
         WRBUF wr = wrbuf_alloc();
         if (bsrt->errcode)
-           wrbuf_printf(wr, "ERROR %d", bsrt->errcode);
-       else
-           wrbuf_printf(wr, "OK %d", bsrt->hits);
-       wrbuf_printf(wr, " %s 1+%d ",
-                    req->resultSetName, returnedrecs);
+            wrbuf_printf(wr, "ERROR %d", bsrt->errcode);
+        else
+            wrbuf_printf(wr, "OK %d", bsrt->hits);
+        wrbuf_printf(wr, " %s 1+%d ",
+                     req->resultSetName, returnedrecs);
         wrbuf_put_zquery(wr, req->query);
-       
+        
         yaz_log(log_request, "Search %s", wrbuf_buf(wr));
         wrbuf_free(wr, 1);
     }
@@ -2249,7 +2249,7 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
             resp->records = diagrec(assoc, bprr->errcode, bprr->errstring);
             *resp->presentStatus = Z_PresentStatus_failure;
             errcode = bprr->errcode;
-           errstring = bprr->errstring;
+            errstring = bprr->errstring;
         }
     }
     apdu = (Z_APDU *)odr_malloc (assoc->encode, sizeof(*apdu));
@@ -2266,8 +2266,8 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
         *num = *req->numberOfRecordsRequested;
         resp->records =
             pack_records(assoc, req->resultSetId, *req->resultSetStartPoint,
-                        num, req->recordComposition, next,
-                        resp->presentStatus,
+                         num, req->recordComposition, next,
+                         resp->presentStatus,
                          form, req->referenceId, req->preferredRecordSyntax, 
                          &errcode);
     }
@@ -2277,7 +2277,7 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
         wrbuf_printf(wr, "Present ");
 
         if (*resp->presentStatus == Z_PresentStatus_failure)
-           wrbuf_printf(wr, "ERROR %d", errcode);
+            wrbuf_printf(wr, "ERROR %d", errcode);
         else if (*resp->presentStatus == Z_PresentStatus_success)
             wrbuf_printf(wr, "OK -");
         else
@@ -2396,7 +2396,7 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
 
     if (bsrr->errcode)
         diagrecs_p = zget_DiagRecs(assoc->encode,
-                                  bsrr->errcode, bsrr->errstring);
+                                   bsrr->errcode, bsrr->errstring);
     else
     {
         int i;
@@ -2454,8 +2454,8 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
             else
             {
                 Z_DiagRecs *drecs = zget_DiagRecs(assoc->encode,
-                                                 bsrr->entries[i].errcode,
-                                                 bsrr->entries[i].errstring);
+                                                  bsrr->entries[i].errcode,
+                                                  bsrr->entries[i].errstring);
                 assert (drecs->num_diagRecs == 1);
                 e->which = Z_Entry_surrogateDiagnostic;
                 assert (drecs->diagRecs[0]);
@@ -2472,20 +2472,20 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
     {
         WRBUF wr = wrbuf_alloc();
         if (bsrr->errcode)
-           wr_diag(wr, bsrr->errcode, bsrr->errstring);
+            wr_diag(wr, bsrr->errcode, bsrr->errstring);
         else if (*res->scanStatus == Z_Scan_success)
             wrbuf_printf(wr, "OK");
-       else
-           wrbuf_printf(wr, "Partial");
+        else
+            wrbuf_printf(wr, "Partial");
 
         wrbuf_printf(wr, " %d+%d %d ",
-                    (req->preferredPositionInResponse ?
-                     *req->preferredPositionInResponse : 1),
-                    *req->numberOfTermsRequested,
-                    (res->stepSize ? *res->stepSize : 0));
+                     (req->preferredPositionInResponse ?
+                      *req->preferredPositionInResponse : 1),
+                     *req->numberOfTermsRequested,
+                     (res->stepSize ? *res->stepSize : 0));
         wrbuf_scan_term(wr, req->termListAndStartPoint, 
-                       bsrr->attributeset);
-       
+                        bsrr->attributeset);
+        
         yaz_log(log_request, "Scan %s", wrbuf_buf(wr) );
         wrbuf_free(wr, 1);
     }
@@ -2532,7 +2532,7 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb,
     if (bsrr->errcode)
     {
         Z_DiagRecs *dr = zget_DiagRecs(assoc->encode,
-                                      bsrr->errcode, bsrr->errstring);
+                                       bsrr->errcode, bsrr->errstring);
         res->diagnostics = dr->diagRecs;
         res->num_diagnostics = dr->num_diagRecs;
     }
@@ -2550,11 +2550,11 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb,
     {
         WRBUF wr = wrbuf_alloc();
         wrbuf_printf(wr, "Sort ");
-       if (bsrr->errcode)
-           wrbuf_printf(wr, " ERROR %d", bsrr->errcode);
-       else
-           wrbuf_printf(wr,  "OK -");
-       wrbuf_printf(wr, " (");
+        if (bsrr->errcode)
+            wrbuf_printf(wr, " ERROR %d", bsrr->errcode);
+        else
+            wrbuf_printf(wr,  "OK -");
+        wrbuf_printf(wr, " (");
         for (i = 0; i<req->num_inputResultSetNames; i++)
         {
             if (i)
@@ -2807,8 +2807,8 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd)
     else
     {
         Z_DiagRecs *diagRecs =
-           zget_DiagRecs(assoc->encode, esrequest.errcode,
-                         esrequest.errstring);
+            zget_DiagRecs(assoc->encode, esrequest.errcode,
+                          esrequest.errstring);
         /* Backend indicates error, request will not be processed */
         yaz_log(YLOG_DEBUG,"Request could not be processed...failure !");
         *resp->operationStatus = Z_ExtendedServicesResponse_failure;
@@ -2832,3 +2832,11 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd)
     return apdu;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b9fdf02..f6070d1 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: session.h,v 1.8 2005-03-08 11:07:49 adam Exp $
+ * $Id: session.h,v 1.9 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file session.h
@@ -112,7 +112,7 @@ typedef struct association
 } association;
 
 association *create_association(IOCHAN channel, COMSTACK link,
-                               const char *apdufile);
+                                const char *apdufile);
 void destroy_association(association *h);
 void ir_session(IOCHAN h, int event);
 
@@ -130,3 +130,11 @@ int statserv_must_terminate(void);
 int control_association(association *assoc, const char *host, int force);
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 05ad935..378bd75 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: siconv.c,v 1.12 2005-05-08 07:35:23 adam Exp $
+ * $Id: siconv.c,v 1.13 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file siconv.c
 #include <yaz/yaz-util.h>
 
 unsigned long yaz_marc8_1_conv (unsigned char *inp, size_t inbytesleft,
-                             size_t *no_read, int *combining);
+                              size_t *no_read, int *combining);
 unsigned long yaz_marc8_2_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
 unsigned long yaz_marc8_3_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
 unsigned long yaz_marc8_4_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
 unsigned long yaz_marc8_5_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
 unsigned long yaz_marc8_6_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
 unsigned long yaz_marc8_7_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
 unsigned long yaz_marc8_8_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
 unsigned long yaz_marc8_9_conv (unsigned char *inp, size_t inbytesleft,
-                               size_t *no_read, int *combining);
+                                size_t *no_read, int *combining);
     
 #define NEW_COMB 1
 
@@ -61,7 +61,7 @@ struct yaz_iconv_struct {
                                  size_t inbytesleft, size_t *no_read);
     size_t (*write_handle)(yaz_iconv_t cd, unsigned long x,
                            char **outbuf, size_t *outbytesleft,
-                          int last);
+                           int last);
     int marc8_esc_mode;
 #if NEW_COMB
     int comb_offset;
@@ -255,109 +255,109 @@ static unsigned long yaz_read_wchar_t (yaz_iconv_t cd, unsigned char *inp,
 
 #if NEW_COMB
 static unsigned long yaz_read_marc8_comb (yaz_iconv_t cd, unsigned char *inp,
-                                         size_t inbytesleft, size_t *no_read,
-                                         int *comb);
+                                          size_t inbytesleft, size_t *no_read,
+                                          int *comb);
 
 static unsigned long yaz_read_marc8 (yaz_iconv_t cd, unsigned char *inp,
-                                    size_t inbytesleft, size_t *no_read)
+                                     size_t inbytesleft, size_t *no_read)
 {
     unsigned long x;
     if (cd->comb_offset < cd->comb_size)
     {
-       *no_read = cd->comb_no_read[cd->comb_offset];
-       x = cd->comb_x[cd->comb_offset];
-       cd->comb_offset++;
-       return x;
+        *no_read = cd->comb_no_read[cd->comb_offset];
+        x = cd->comb_x[cd->comb_offset];
+        cd->comb_offset++;
+        return x;
     }
 
     cd->comb_offset = 0;
     for (cd->comb_size = 0; cd->comb_size < 8; cd->comb_size++)
     {
-       int comb = 0;
-       x = yaz_read_marc8_comb(cd, inp, inbytesleft, no_read, &comb);
-       if (!comb || !x)
-           break;
-       cd->comb_x[cd->comb_size] = x;
-       cd->comb_no_read[cd->comb_size] = *no_read;
-       inp += *no_read;
-       inbytesleft = inbytesleft - *no_read;
+        int comb = 0;
+        x = yaz_read_marc8_comb(cd, inp, inbytesleft, no_read, &comb);
+        if (!comb || !x)
+            break;
+        cd->comb_x[cd->comb_size] = x;
+        cd->comb_no_read[cd->comb_size] = *no_read;
+        inp += *no_read;
+        inbytesleft = inbytesleft - *no_read;
     }
     return x;
 }
 
 static unsigned long yaz_read_marc8_comb (yaz_iconv_t cd, unsigned char *inp,
-                                         size_t inbytesleft, size_t *no_read,
-                                         int *comb)
+                                          size_t inbytesleft, size_t *no_read,
+                                          int *comb)
 {
     *no_read = 0;
     while(inbytesleft >= 1 && inp[0] == 27)
     {
-       size_t inbytesleft0 = inbytesleft;
-       inp++;
-       inbytesleft--;
-       while(inbytesleft > 0 && strchr("(,$!", *inp))
-       {
-           inbytesleft--;
-           inp++;
-       }
-       if (inbytesleft <= 0)
-       {
-           *no_read = 0;
-           cd->my_errno = YAZ_ICONV_EINVAL;
-           return 0;
-       }
-       cd->marc8_esc_mode = *inp++;
-       inbytesleft--;
-       (*no_read) += inbytesleft0 - inbytesleft;
+        size_t inbytesleft0 = inbytesleft;
+        inp++;
+        inbytesleft--;
+        while(inbytesleft > 0 && strchr("(,$!", *inp))
+        {
+            inbytesleft--;
+            inp++;
+        }
+        if (inbytesleft <= 0)
+        {
+            *no_read = 0;
+            cd->my_errno = YAZ_ICONV_EINVAL;
+            return 0;
+        }
+        cd->marc8_esc_mode = *inp++;
+        inbytesleft--;
+        (*no_read) += inbytesleft0 - inbytesleft;
     }
     if (inbytesleft <= 0)
-       return 0;
+        return 0;
     else
     {
-       unsigned long x;
-       size_t no_read_sub = 0;
-       *comb = 0;
-
-       switch(cd->marc8_esc_mode)
-       {
-       case 'B':  /* Basic ASCII */
-       case 'E':  /* ANSEL */
-       case 's':  /* ASCII */
-           x = yaz_marc8_1_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case 'g':  /* Greek */
-           x = yaz_marc8_2_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case 'b':  /* Subscripts */
-           x = yaz_marc8_3_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case 'p':  /* Superscripts */
-           x = yaz_marc8_4_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case '2':  /* Basic Hebrew */
-           x = yaz_marc8_5_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case 'N':  /* Basic Cyrillic */
-       case 'Q':  /* Extended Cyrillic */
-           x = yaz_marc8_6_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case '3':  /* Basic Arabic */
-       case '4':  /* Extended Arabic */
-           x = yaz_marc8_7_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case 'S':  /* Greek */
-           x = yaz_marc8_8_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       case '1':  /* Chinese, Japanese, Korean (EACC) */
-           x = yaz_marc8_9_conv(inp, inbytesleft, &no_read_sub, comb);
-           break;
-       default:
-           *no_read = 0;
-           cd->my_errno = YAZ_ICONV_EILSEQ;
-           return 0;
-       }
-       *no_read += no_read_sub;
-       return x;
+        unsigned long x;
+        size_t no_read_sub = 0;
+        *comb = 0;
+
+        switch(cd->marc8_esc_mode)
+        {
+        case 'B':  /* Basic ASCII */
+        case 'E':  /* ANSEL */
+        case 's':  /* ASCII */
+            x = yaz_marc8_1_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case 'g':  /* Greek */
+            x = yaz_marc8_2_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case 'b':  /* Subscripts */
+            x = yaz_marc8_3_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case 'p':  /* Superscripts */
+            x = yaz_marc8_4_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case '2':  /* Basic Hebrew */
+            x = yaz_marc8_5_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case 'N':  /* Basic Cyrillic */
+        case 'Q':  /* Extended Cyrillic */
+            x = yaz_marc8_6_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case '3':  /* Basic Arabic */
+        case '4':  /* Extended Arabic */
+            x = yaz_marc8_7_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case 'S':  /* Greek */
+            x = yaz_marc8_8_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        case '1':  /* Chinese, Japanese, Korean (EACC) */
+            x = yaz_marc8_9_conv(inp, inbytesleft, &no_read_sub, comb);
+            break;
+        default:
+            *no_read = 0;
+            cd->my_errno = YAZ_ICONV_EILSEQ;
+            return 0;
+        }
+        *no_read += no_read_sub;
+        return x;
     }
 }
 #else
@@ -366,106 +366,106 @@ static unsigned long yaz_read_marc8 (yaz_iconv_t cd, unsigned char *inp,
 {
     if (cd->marc8_comb_x)
     {
-       unsigned long x = cd->marc8_comb_x;
-       *no_read = cd->marc8_comb_no_read;
-       cd->marc8_comb_x = 0;
-       return x;
+        unsigned long x = cd->marc8_comb_x;
+        *no_read = cd->marc8_comb_no_read;
+        cd->marc8_comb_x = 0;
+        return x;
     }
     *no_read = 0;
     while(inbytesleft >= 1 && inp[0] == 27)
     {
-       size_t inbytesleft0 = inbytesleft;
-       inp++;
-       inbytesleft--;
-       while(inbytesleft > 0 && strchr("(,$!", *inp))
-       {
-           inbytesleft--;
-           inp++;
-       }
-       if (inbytesleft <= 0)
-       {
-           *no_read = 0;
-           cd->my_errno = YAZ_ICONV_EINVAL;
-           return 0;
-       }
-       cd->marc8_esc_mode = *inp++;
-       inbytesleft--;
-       (*no_read) += inbytesleft0 - inbytesleft;
+        size_t inbytesleft0 = inbytesleft;
+        inp++;
+        inbytesleft--;
+        while(inbytesleft > 0 && strchr("(,$!", *inp))
+        {
+            inbytesleft--;
+            inp++;
+        }
+        if (inbytesleft <= 0)
+        {
+            *no_read = 0;
+            cd->my_errno = YAZ_ICONV_EINVAL;
+            return 0;
+        }
+        cd->marc8_esc_mode = *inp++;
+        inbytesleft--;
+        (*no_read) += inbytesleft0 - inbytesleft;
     }
     if (inbytesleft <= 0)
-       return 0;
+        return 0;
     else
     {
-       unsigned long x;
-       int comb = 0;
-       size_t no_read_sub = 0;
-
-       switch(cd->marc8_esc_mode)
-       {
-       case 'B':  /* Basic ASCII */
-       case 'E':  /* ANSEL */
-       case 's':  /* ASCII */
-           x = yaz_marc8_1_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case 'g':  /* Greek */
-           x = yaz_marc8_2_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case 'b':  /* Subscripts */
-           x = yaz_marc8_3_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case 'p':  /* Superscripts */
-           x = yaz_marc8_4_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case '2':  /* Basic Hebrew */
-           x = yaz_marc8_5_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case 'N':  /* Basic Cyrillic */
-       case 'Q':  /* Extended Cyrillic */
-           x = yaz_marc8_6_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case '3':  /* Basic Arabic */
-       case '4':  /* Extended Arabic */
-           x = yaz_marc8_7_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case 'S':  /* Greek */
-           x = yaz_marc8_8_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       case '1':  /* Chinese, Japanese, Korean (EACC) */
-           x = yaz_marc8_9_conv(inp, inbytesleft, &no_read_sub, &comb);
-           break;
-       default:
-           *no_read = 0;
-           cd->my_errno = YAZ_ICONV_EILSEQ;
-           return 0;
-       }
+        unsigned long x;
+        int comb = 0;
+        size_t no_read_sub = 0;
+
+        switch(cd->marc8_esc_mode)
+        {
+        case 'B':  /* Basic ASCII */
+        case 'E':  /* ANSEL */
+        case 's':  /* ASCII */
+            x = yaz_marc8_1_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case 'g':  /* Greek */
+            x = yaz_marc8_2_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case 'b':  /* Subscripts */
+            x = yaz_marc8_3_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case 'p':  /* Superscripts */
+            x = yaz_marc8_4_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case '2':  /* Basic Hebrew */
+            x = yaz_marc8_5_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case 'N':  /* Basic Cyrillic */
+        case 'Q':  /* Extended Cyrillic */
+            x = yaz_marc8_6_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case '3':  /* Basic Arabic */
+        case '4':  /* Extended Arabic */
+            x = yaz_marc8_7_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case 'S':  /* Greek */
+            x = yaz_marc8_8_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        case '1':  /* Chinese, Japanese, Korean (EACC) */
+            x = yaz_marc8_9_conv(inp, inbytesleft, &no_read_sub, &comb);
+            break;
+        default:
+            *no_read = 0;
+            cd->my_errno = YAZ_ICONV_EILSEQ;
+            return 0;
+        }
 #if 0
-       printf ("esc mode=%c x=%04lX comb=%d\n", cd->marc8_esc_mode, x, comb);
+        printf ("esc mode=%c x=%04lX comb=%d\n", cd->marc8_esc_mode, x, comb);
 #endif
-       *no_read += no_read_sub;
-
-       if (comb && cd->marc8_comb_x == 0)
-       {
-           size_t tmp_read = 0;
-           unsigned long next_x;
-
-           /* read next char .. */
-           next_x = yaz_read_marc8(cd, inp + *no_read,
-                                   inbytesleft - *no_read, &tmp_read);
-           /* save this x for later .. */
-           cd->marc8_comb_x = x;
-           /* save next read for later .. */
-           cd->marc8_comb_no_read = tmp_read;
-           /* return next x - thereby swap */
-           x = next_x;
-       }
-       return x;
+        *no_read += no_read_sub;
+
+        if (comb && cd->marc8_comb_x == 0)
+        {
+            size_t tmp_read = 0;
+            unsigned long next_x;
+
+            /* read next char .. */
+            next_x = yaz_read_marc8(cd, inp + *no_read,
+                                    inbytesleft - *no_read, &tmp_read);
+            /* save this x for later .. */
+            cd->marc8_comb_x = x;
+            /* save next read for later .. */
+            cd->marc8_comb_no_read = tmp_read;
+            /* return next x - thereby swap */
+            x = next_x;
+        }
+        return x;
     }
 }
 #endif
 
 static size_t yaz_write_UTF8 (yaz_iconv_t cd, unsigned long x,
                               char **outbuf, size_t *outbytesleft,
-                             int last)
+                              int last)
 {
     unsigned char *outp = (unsigned char *) *outbuf;
     if (x <= 0x7f && *outbytesleft >= 1)
@@ -525,7 +525,7 @@ static size_t yaz_write_UTF8 (yaz_iconv_t cd, unsigned long x,
 
 static size_t yaz_write_ISO8859_1 (yaz_iconv_t cd, unsigned long x,
                                    char **outbuf, size_t *outbytesleft,
-                                  int last)
+                                   int last)
 {
     /* list of two char unicode sequence that, when combined, are
        equivalent to single unicode chars that can be represented in
@@ -535,112 +535,112 @@ static size_t yaz_write_ISO8859_1 (yaz_iconv_t cd, unsigned long x,
        we get a better chance of a successful MARC-8 -> ISO-8859-1
        conversion */
     static struct {
-       unsigned long x1, x2;
-       unsigned y;
+        unsigned long x1, x2;
+        unsigned y;
     } comb[] = {
-       { 'A', 0x0300, 0xc0}, /* LATIN CAPITAL LETTER A WITH GRAVE */
-       { 'A', 0x0301, 0xc1}, /* LATIN CAPITAL LETTER A WITH ACUTE */
-       { 'A', 0x0302, 0xc2}, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
-       { 'A', 0x0303, 0xc3}, /* LATIN CAPITAL LETTER A WITH TILDE */
-       { 'A', 0x0308, 0xc4}, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
-       { 'A', 0x030a, 0xc5}, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
-       /* no need for 0xc6      LATIN CAPITAL LETTER AE */
-       { 'C', 0x0327, 0xc7}, /* LATIN CAPITAL LETTER C WITH CEDILLA */
-       { 'E', 0x0300, 0xc8}, /* LATIN CAPITAL LETTER E WITH GRAVE */
-       { 'E', 0x0301, 0xc9}, /* LATIN CAPITAL LETTER E WITH ACUTE */
-       { 'E', 0x0302, 0xca}, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
-       { 'E', 0x0308, 0xcb}, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
-       { 'I', 0x0300, 0xcc}, /* LATIN CAPITAL LETTER I WITH GRAVE */
-       { 'I', 0x0301, 0xcd}, /* LATIN CAPITAL LETTER I WITH ACUTE */
-       { 'I', 0x0302, 0xce}, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
-       { 'I', 0x0308, 0xcf}, /* LATIN CAPITAL LETTER I WITH DIAERESIS */
-       { 'N', 0x0303, 0xd1}, /* LATIN CAPITAL LETTER N WITH TILDE */
-       { 'O', 0x0300, 0xd2}, /* LATIN CAPITAL LETTER O WITH GRAVE */
-       { 'O', 0x0301, 0xd3}, /* LATIN CAPITAL LETTER O WITH ACUTE */
-       { 'O', 0x0302, 0xd4}, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
-       { 'O', 0x0303, 0xd5}, /* LATIN CAPITAL LETTER O WITH TILDE */
-       { 'O', 0x0308, 0xd6}, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
-       /* omitted:    0xd7      MULTIPLICATION SIGN */
-       /* omitted:    0xd8      LATIN CAPITAL LETTER O WITH STROKE */
-       { 'U', 0x0300, 0xd9}, /* LATIN CAPITAL LETTER U WITH GRAVE */
-       { 'U', 0x0301, 0xda}, /* LATIN CAPITAL LETTER U WITH ACUTE */
-       { 'U', 0x0302, 0xdb}, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
-       { 'U', 0x0308, 0xdc}, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
-       { 'Y', 0x0301, 0xdd}, /* LATIN CAPITAL LETTER Y WITH ACUTE */
-       /* omitted:    0xde      LATIN CAPITAL LETTER THORN */
-       /* omitted:    0xdf      LATIN SMALL LETTER SHARP S */
-       { 'a', 0x0300, 0xe0}, /* LATIN SMALL LETTER A WITH GRAVE */
-       { 'a', 0x0301, 0xe1}, /* LATIN SMALL LETTER A WITH ACUTE */
-       { 'a', 0x0302, 0xe2}, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
-       { 'a', 0x0303, 0xe3}, /* LATIN SMALL LETTER A WITH TILDE */
-       { 'a', 0x0308, 0xe4}, /* LATIN SMALL LETTER A WITH DIAERESIS */
+        { 'A', 0x0300, 0xc0}, /* LATIN CAPITAL LETTER A WITH GRAVE */
+        { 'A', 0x0301, 0xc1}, /* LATIN CAPITAL LETTER A WITH ACUTE */
+        { 'A', 0x0302, 0xc2}, /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
+        { 'A', 0x0303, 0xc3}, /* LATIN CAPITAL LETTER A WITH TILDE */
+        { 'A', 0x0308, 0xc4}, /* LATIN CAPITAL LETTER A WITH DIAERESIS */
+        { 'A', 0x030a, 0xc5}, /* LATIN CAPITAL LETTER A WITH RING ABOVE */
+        /* no need for 0xc6      LATIN CAPITAL LETTER AE */
+        { 'C', 0x0327, 0xc7}, /* LATIN CAPITAL LETTER C WITH CEDILLA */
+        { 'E', 0x0300, 0xc8}, /* LATIN CAPITAL LETTER E WITH GRAVE */
+        { 'E', 0x0301, 0xc9}, /* LATIN CAPITAL LETTER E WITH ACUTE */
+        { 'E', 0x0302, 0xca}, /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
+        { 'E', 0x0308, 0xcb}, /* LATIN CAPITAL LETTER E WITH DIAERESIS */
+        { 'I', 0x0300, 0xcc}, /* LATIN CAPITAL LETTER I WITH GRAVE */
+        { 'I', 0x0301, 0xcd}, /* LATIN CAPITAL LETTER I WITH ACUTE */
+        { 'I', 0x0302, 0xce}, /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
+        { 'I', 0x0308, 0xcf}, /* LATIN CAPITAL LETTER I WITH DIAERESIS */
+        { 'N', 0x0303, 0xd1}, /* LATIN CAPITAL LETTER N WITH TILDE */
+        { 'O', 0x0300, 0xd2}, /* LATIN CAPITAL LETTER O WITH GRAVE */
+        { 'O', 0x0301, 0xd3}, /* LATIN CAPITAL LETTER O WITH ACUTE */
+        { 'O', 0x0302, 0xd4}, /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
+        { 'O', 0x0303, 0xd5}, /* LATIN CAPITAL LETTER O WITH TILDE */
+        { 'O', 0x0308, 0xd6}, /* LATIN CAPITAL LETTER O WITH DIAERESIS */
+        /* omitted:    0xd7      MULTIPLICATION SIGN */
+        /* omitted:    0xd8      LATIN CAPITAL LETTER O WITH STROKE */
+        { 'U', 0x0300, 0xd9}, /* LATIN CAPITAL LETTER U WITH GRAVE */
+        { 'U', 0x0301, 0xda}, /* LATIN CAPITAL LETTER U WITH ACUTE */
+        { 'U', 0x0302, 0xdb}, /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
+        { 'U', 0x0308, 0xdc}, /* LATIN CAPITAL LETTER U WITH DIAERESIS */
+        { 'Y', 0x0301, 0xdd}, /* LATIN CAPITAL LETTER Y WITH ACUTE */
+        /* omitted:    0xde      LATIN CAPITAL LETTER THORN */
+        /* omitted:    0xdf      LATIN SMALL LETTER SHARP S */
+        { 'a', 0x0300, 0xe0}, /* LATIN SMALL LETTER A WITH GRAVE */
+        { 'a', 0x0301, 0xe1}, /* LATIN SMALL LETTER A WITH ACUTE */
+        { 'a', 0x0302, 0xe2}, /* LATIN SMALL LETTER A WITH CIRCUMFLEX */
+        { 'a', 0x0303, 0xe3}, /* LATIN SMALL LETTER A WITH TILDE */
+        { 'a', 0x0308, 0xe4}, /* LATIN SMALL LETTER A WITH DIAERESIS */
         { 'a', 0x030a, 0xe5}, /* LATIN SMALL LETTER A WITH RING ABOVE */
-       /* omitted:    0xe6      LATIN SMALL LETTER AE */
-       { 'c', 0x0327, 0xe7}, /* LATIN SMALL LETTER C WITH CEDILLA */
-       { 'e', 0x0300, 0xe8}, /* LATIN SMALL LETTER E WITH GRAVE */
-       { 'e', 0x0301, 0xe9}, /* LATIN SMALL LETTER E WITH ACUTE */
-       { 'e', 0x0302, 0xea}, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
-       { 'e', 0x0308, 0xeb}, /* LATIN SMALL LETTER E WITH DIAERESIS */
-       { 'i', 0x0300, 0xec}, /* LATIN SMALL LETTER I WITH GRAVE */
-       { 'i', 0x0301, 0xed}, /* LATIN SMALL LETTER I WITH ACUTE */
-       { 'i', 0x0302, 0xee}, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
-       { 'i', 0x0308, 0xef}, /* LATIN SMALL LETTER I WITH DIAERESIS */
-       /* omitted:    0xf0      LATIN SMALL LETTER ETH */
-       { 'n', 0x0303, 0xf1}, /* LATIN SMALL LETTER N WITH TILDE */
-       { 'o', 0x0300, 0xf2}, /* LATIN SMALL LETTER O WITH GRAVE */
-       { 'o', 0x0301, 0xf3}, /* LATIN SMALL LETTER O WITH ACUTE */
-       { 'o', 0x0302, 0xf4}, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
-       { 'o', 0x0303, 0xf5}, /* LATIN SMALL LETTER O WITH TILDE */
-       { 'o', 0x0308, 0xf6}, /* LATIN SMALL LETTER O WITH DIAERESIS */
-       /* omitted:    0xf7      DIVISION SIGN */
-       /* omitted:    0xf8      LATIN SMALL LETTER O WITH STROKE */
-       { 'u', 0x0300, 0xf9}, /* LATIN SMALL LETTER U WITH GRAVE */
-       { 'u', 0x0301, 0xfa}, /* LATIN SMALL LETTER U WITH ACUTE */
-       { 'u', 0x0302, 0xfb}, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */
-       { 'u', 0x0308, 0xfc}, /* LATIN SMALL LETTER U WITH DIAERESIS */
-       { 'y', 0x0301, 0xfd}, /* LATIN SMALL LETTER Y WITH ACUTE */
-       /* omitted:    0xfe      LATIN SMALL LETTER THORN */
-       { 'y', 0x0308, 0xff}, /* LATIN SMALL LETTER Y WITH DIAERESIS */
-       
-       { 0, 0, 0}
+        /* omitted:    0xe6      LATIN SMALL LETTER AE */
+        { 'c', 0x0327, 0xe7}, /* LATIN SMALL LETTER C WITH CEDILLA */
+        { 'e', 0x0300, 0xe8}, /* LATIN SMALL LETTER E WITH GRAVE */
+        { 'e', 0x0301, 0xe9}, /* LATIN SMALL LETTER E WITH ACUTE */
+        { 'e', 0x0302, 0xea}, /* LATIN SMALL LETTER E WITH CIRCUMFLEX */
+        { 'e', 0x0308, 0xeb}, /* LATIN SMALL LETTER E WITH DIAERESIS */
+        { 'i', 0x0300, 0xec}, /* LATIN SMALL LETTER I WITH GRAVE */
+        { 'i', 0x0301, 0xed}, /* LATIN SMALL LETTER I WITH ACUTE */
+        { 'i', 0x0302, 0xee}, /* LATIN SMALL LETTER I WITH CIRCUMFLEX */
+        { 'i', 0x0308, 0xef}, /* LATIN SMALL LETTER I WITH DIAERESIS */
+        /* omitted:    0xf0      LATIN SMALL LETTER ETH */
+        { 'n', 0x0303, 0xf1}, /* LATIN SMALL LETTER N WITH TILDE */
+        { 'o', 0x0300, 0xf2}, /* LATIN SMALL LETTER O WITH GRAVE */
+        { 'o', 0x0301, 0xf3}, /* LATIN SMALL LETTER O WITH ACUTE */
+        { 'o', 0x0302, 0xf4}, /* LATIN SMALL LETTER O WITH CIRCUMFLEX */
+        { 'o', 0x0303, 0xf5}, /* LATIN SMALL LETTER O WITH TILDE */
+        { 'o', 0x0308, 0xf6}, /* LATIN SMALL LETTER O WITH DIAERESIS */
+        /* omitted:    0xf7      DIVISION SIGN */
+        /* omitted:    0xf8      LATIN SMALL LETTER O WITH STROKE */
+        { 'u', 0x0300, 0xf9}, /* LATIN SMALL LETTER U WITH GRAVE */
+        { 'u', 0x0301, 0xfa}, /* LATIN SMALL LETTER U WITH ACUTE */
+        { 'u', 0x0302, 0xfb}, /* LATIN SMALL LETTER U WITH CIRCUMFLEX */
+        { 'u', 0x0308, 0xfc}, /* LATIN SMALL LETTER U WITH DIAERESIS */
+        { 'y', 0x0301, 0xfd}, /* LATIN SMALL LETTER Y WITH ACUTE */
+        /* omitted:    0xfe      LATIN SMALL LETTER THORN */
+        { 'y', 0x0308, 0xff}, /* LATIN SMALL LETTER Y WITH DIAERESIS */
+        
+        { 0, 0, 0}
     };
     unsigned char *outp = (unsigned char *) *outbuf;
 
     if (!last && x > 32 && x < 127 && cd->compose_char == 0)
     {
         cd->compose_char = x;
-       return 0;
+        return 0;
     }
     else if (cd->compose_char)
     {
-       int i;
-       for (i = 0; comb[i].x1; i++)
-           if (cd->compose_char == comb[i].x1 && x == comb[i].x2)
-           {
-               x = comb[i].y;
-               break;
-           }
-       if (!comb[i].x1) 
-       {   /* not found */
-           if (*outbytesleft >= 1)
+        int i;
+        for (i = 0; comb[i].x1; i++)
+            if (cd->compose_char == comb[i].x1 && x == comb[i].x2)
             {
-               *outp++ = (unsigned char) cd->compose_char;
+                x = comb[i].y;
+                break;
+            }
+        if (!comb[i].x1) 
+        {   /* not found */
+            if (*outbytesleft >= 1)
+            {
+                *outp++ = (unsigned char) cd->compose_char;
                 (*outbytesleft)--;
                 *outbuf = (char *) outp;
-               if (!last && x > 32 && x < 127)
-               {
-                   cd->compose_char = x;
-                   return 0;
-               }
-           }
-           else
-           {
+                if (!last && x > 32 && x < 127)
+                {
+                    cd->compose_char = x;
+                    return 0;
+                }
+            }
+            else
+            {
                 cd->my_errno = YAZ_ICONV_E2BIG;
                 return (size_t)(-1);
             }
-       }
-       /* compose_char and old x combined to one new char: x */
-       cd->compose_char = 0;
+        }
+        /* compose_char and old x combined to one new char: x */
+        cd->compose_char = 0;
     }
     if (x > 255 || x < 1)
     {
@@ -664,7 +664,7 @@ static size_t yaz_write_ISO8859_1 (yaz_iconv_t cd, unsigned long x,
 
 static size_t yaz_write_UCS4 (yaz_iconv_t cd, unsigned long x,
                               char **outbuf, size_t *outbytesleft,
-                             int last)
+                              int last)
 {
     unsigned char *outp = (unsigned char *) *outbuf;
     if (*outbytesleft >= 4)
@@ -686,7 +686,7 @@ static size_t yaz_write_UCS4 (yaz_iconv_t cd, unsigned long x,
 
 static size_t yaz_write_UCS4LE (yaz_iconv_t cd, unsigned long x,
                                 char **outbuf, size_t *outbytesleft,
-                               int last)
+                                int last)
 {
     unsigned char *outp = (unsigned char *) *outbuf;
     if (*outbytesleft >= 4)
@@ -709,7 +709,7 @@ static size_t yaz_write_UCS4LE (yaz_iconv_t cd, unsigned long x,
 #if HAVE_WCHAR_H
 static size_t yaz_write_wchar_t (yaz_iconv_t cd, unsigned long x,
                                  char **outbuf, size_t *outbytesleft,
-                                int last)
+                                 int last)
 {
     unsigned char *outp = (unsigned char *) *outbuf;
 
@@ -866,8 +866,8 @@ size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft,
             *inbuf += no_read;
         }
         cd->init_flag = 0;
-       cd->unget_x = 0;
-       cd->no_read_x = 0;
+        cd->unget_x = 0;
+        cd->no_read_x = 0;
     }
     while (1)
     {
@@ -879,35 +879,35 @@ size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft,
             r = *inbuf - inbuf0;
             break;
         }
-       if (!cd->unget_x)
-       {
-           x = (cd->read_handle)(cd, (unsigned char *) *inbuf, *inbytesleft,
-                                 &no_read);
-           if (no_read == 0)
-           {
-               r = (size_t)(-1);
-               break;
-           }
-       }
-       else
-       {
-           x = cd->unget_x;
-           no_read = cd->no_read_x;
-       }
-       if (x)
-       {
-           r = (cd->write_handle)(cd, x, outbuf, outbytesleft,
-                                  (*inbytesleft - no_read) == 0 ? 1 : 0);
-           if (r)
-           {
-               /* unable to write it. save it because read_handle cannot
-                  rewind .. */
-               cd->unget_x = x;
-               cd->no_read_x = no_read;
-               break;
-           }
-           cd->unget_x = 0;
-       }
+        if (!cd->unget_x)
+        {
+            x = (cd->read_handle)(cd, (unsigned char *) *inbuf, *inbytesleft,
+                                  &no_read);
+            if (no_read == 0)
+            {
+                r = (size_t)(-1);
+                break;
+            }
+        }
+        else
+        {
+            x = cd->unget_x;
+            no_read = cd->no_read_x;
+        }
+        if (x)
+        {
+            r = (cd->write_handle)(cd, x, outbuf, outbytesleft,
+                                   (*inbytesleft - no_read) == 0 ? 1 : 0);
+            if (r)
+            {
+                /* unable to write it. save it because read_handle cannot
+                   rewind .. */
+                cd->unget_x = x;
+                cd->no_read_x = no_read;
+                break;
+            }
+            cd->unget_x = 0;
+        }
         *inbytesleft -= no_read;
         (*inbuf) += no_read;
     }
@@ -930,3 +930,11 @@ int yaz_iconv_close (yaz_iconv_t cd)
 }
 
     
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 3de5e29..68ebb95 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: soap.c,v 1.10 2005-01-15 19:47:14 adam Exp $
+ * $Id: soap.c,v 1.11 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file soap.c
@@ -22,10 +22,10 @@ static const char *soap_v1_1 = "http://schemas.xmlsoap.org/soap/envelope/";
 static const char *soap_v1_2 = "http://www.w3.org/2001/06/soap-envelope";
 
 int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, 
-                        char **content_buf, int *content_len,
-                        Z_SOAP_Handler *handlers,
-                        const char *encoding,
-                        const char *stylesheet)
+                         char **content_buf, int *content_len,
+                         Z_SOAP_Handler *handlers,
+                         const char *encoding,
+                         const char *stylesheet)
 {
     if (o->direction == ODR_DECODE)
     {
@@ -156,7 +156,7 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
                 {
                     p->which = Z_SOAP_generic;
                     p->u.generic = (Z_SOAP_Generic *)
-                       odr_malloc(o, sizeof(*p->u.generic));
+                        odr_malloc(o, sizeof(*p->u.generic));
                     p->u.generic->no = i;
                     p->u.generic->ns = handlers[i].ns;
                     p->u.generic->p = handler_data;
@@ -203,26 +203,26 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
                                     handlers[no].client_data,
                                     handlers[no].ns);
             if (ret)
-           {
-               xmlFreeDoc(doc);
+            {
+                xmlFreeDoc(doc);
                 return ret;
-           }
+            }
         }
         if (p->which == Z_SOAP_generic && !strcmp(p->ns, "SRU"))
         {
             xmlDocSetRootElement(doc, body_ptr->children);
-           body_ptr->children = 0;
-           xmlFreeNode(envelope_ptr);
+            body_ptr->children = 0;
+            xmlFreeNode(envelope_ptr);
+        }
+        if (stylesheet)
+        {
+            char *content = odr_malloc(o, strlen(stylesheet) + 40);
+            
+            xmlNodePtr pi, ptr = xmlDocGetRootElement(doc);
+            sprintf(content, "type=\"text/xsl\" href=\"%s\"", stylesheet);
+            pi = xmlNewPI("xml-stylesheet", content);
+            xmlAddPrevSibling(ptr, pi);
         }
-       if (stylesheet)
-       {
-           char *content = odr_malloc(o, strlen(stylesheet) + 40);
-           
-           xmlNodePtr pi, ptr = xmlDocGetRootElement(doc);
-           sprintf(content, "type=\"text/xsl\" href=\"%s\"", stylesheet);
-           pi = xmlNewPI("xml-stylesheet", content);
-           xmlAddPrevSibling(ptr, pi);
-       }
         if (1)
         {
             xmlChar *buf_out;
@@ -243,9 +243,9 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
 }
 #else
 int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp, 
-                        char **content_buf, int *content_len,
-                        Z_SOAP_Handler *handlers, const char *encoding,
-                        const char *stylesheet)
+                         char **content_buf, int *content_len,
+                         Z_SOAP_Handler *handlers, const char *encoding,
+                         const char *stylesheet)
 {
     static char *err_xml =
         "<?xml version=\"1.0\"?>\n"
@@ -268,12 +268,12 @@ int z_soap_codec_enc_xsl(ODR o, Z_SOAP **pp,
 }
 #endif
 int z_soap_codec_enc(ODR o, Z_SOAP **pp, 
-                    char **content_buf, int *content_len,
-                    Z_SOAP_Handler *handlers,
-                    const char *encoding)
+                     char **content_buf, int *content_len,
+                     Z_SOAP_Handler *handlers,
+                     const char *encoding)
 {
     return z_soap_codec_enc_xsl(o, pp, content_buf, content_len, handlers,
-                               encoding, 0);
+                                encoding, 0);
 }
 
 int z_soap_codec(ODR o, Z_SOAP **pp, 
@@ -299,3 +299,11 @@ int z_soap_error(ODR o, Z_SOAP *p,
     return -1;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 75e6ade..7b5d096 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: sortspec.c,v 1.4 2005-01-15 19:47:14 adam Exp $
+ * $Id: sortspec.c,v 1.5 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file sortspec.c
@@ -28,52 +28,52 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
     sksl->specs = (Z_SortKeySpec **)odr_malloc (out, sizeof(sksl->specs) * 20);
     
     while ((sscanf (arg, "%31s %31s%n", sort_string_buf,
-                   sort_flags, &off)) == 2  && off > 1)
+                    sort_flags, &off)) == 2  && off > 1)
     {
         int i;
         char *sort_string_sep;
-       char *sort_string = sort_string_buf;
+        char *sort_string = sort_string_buf;
         Z_SortKeySpec *sks = (Z_SortKeySpec *)odr_malloc (out, sizeof(*sks));
         Z_SortKey *sk = (Z_SortKey *)odr_malloc (out, sizeof(*sk));
-       
+        
         arg += off;
         sksl->specs[sksl->num_specs++] = sks;
         sks->sortElement = (Z_SortElement *)
-           odr_malloc (out, sizeof(*sks->sortElement));
+            odr_malloc (out, sizeof(*sks->sortElement));
         sks->sortElement->which = Z_SortElement_generic;
         sks->sortElement->u.generic = sk;
         
         if ((sort_string_sep = strchr (sort_string, '=')))
         {
-           int i = 0;
+            int i = 0;
             sk->which = Z_SortKey_sortAttributes;
             sk->u.sortAttributes = (Z_SortAttributes *)
-               odr_malloc (out, sizeof(*sk->u.sortAttributes));
+                odr_malloc (out, sizeof(*sk->u.sortAttributes));
             sk->u.sortAttributes->id = 
-               yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1);
+                yaz_oidval_to_z3950oid(out, CLASS_ATTSET, VAL_BIB1);
             sk->u.sortAttributes->list = (Z_AttributeList *)
-               odr_malloc (out, sizeof(*sk->u.sortAttributes->list));
+                odr_malloc (out, sizeof(*sk->u.sortAttributes->list));
             sk->u.sortAttributes->list->attributes = (Z_AttributeElement **)
-               odr_malloc (out, 10 * 
-                           sizeof(*sk->u.sortAttributes->list->attributes));
-           while (i < 10 && sort_string && sort_string_sep)
-           {
-               Z_AttributeElement *el = (Z_AttributeElement *)
-                   odr_malloc (out, sizeof(*el));
-               sk->u.sortAttributes->list->attributes[i] = el;
-               el->attributeSet = 0;
-               el->attributeType = odr_intdup (out, atoi (sort_string));
-               el->which = Z_AttributeValue_numeric;
-               el->value.numeric =
-                   odr_intdup (out, atoi (sort_string_sep + 1));
-               i++;
-               sort_string = strchr(sort_string, ',');
-               if (sort_string)
-               {
-                   sort_string++;
-                   sort_string_sep = strchr (sort_string, '=');
-               }
-           }
+                odr_malloc (out, 10 * 
+                            sizeof(*sk->u.sortAttributes->list->attributes));
+            while (i < 10 && sort_string && sort_string_sep)
+            {
+                Z_AttributeElement *el = (Z_AttributeElement *)
+                    odr_malloc (out, sizeof(*el));
+                sk->u.sortAttributes->list->attributes[i] = el;
+                el->attributeSet = 0;
+                el->attributeType = odr_intdup (out, atoi (sort_string));
+                el->which = Z_AttributeValue_numeric;
+                el->value.numeric =
+                    odr_intdup (out, atoi (sort_string_sep + 1));
+                i++;
+                sort_string = strchr(sort_string, ',');
+                if (sort_string)
+                {
+                    sort_string++;
+                    sort_string_sep = strchr (sort_string, '=');
+                }
+            }
             sk->u.sortAttributes->list->num_attributes = i;
         }
         else
@@ -86,7 +86,7 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
 
         sks->which = Z_SortKeySpec_null;
         sks->u.null = odr_nullval ();
-       
+        
         for (i = 0; sort_flags[i]; i++)
         {
             switch (sort_flags[i])
@@ -113,6 +113,14 @@ Z_SortKeySpecList *yaz_sort_spec (ODR out, const char *arg)
         }
     }
     if (!sksl->num_specs)
-       return 0;
+        return 0;
     return sksl;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 414a475..1165999 100644 (file)
--- a/src/srw.c
+++ b/src/srw.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: srw.c,v 1.34 2005-02-04 20:27:19 adam Exp $
+ * $Id: srw.c,v 1.35 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file srw.c
@@ -31,14 +31,14 @@ static void add_XML_n(xmlNodePtr ptr, const char *elem, char *val, int len)
 }
 
 xmlNodePtr add_xsd_string_n(xmlNodePtr ptr, const char *elem, const char *val,
-                           int len)
+                            int len)
 {
     if (val)
     {
         xmlNodePtr c = xmlNewChild(ptr, 0, elem, 0);
         xmlNodePtr t = xmlNewTextLen(val, len);
         xmlAddChild(c, t);
-       return t;
+        return t;
     }
     return 0;
 }
@@ -96,7 +96,7 @@ static int match_xsd_string_n(xmlNodePtr ptr, const char *elem, ODR o,
     ptr = ptr->children;
     if (!ptr || ptr->type != XML_TEXT_NODE)
     {
-       *val = "";
+        *val = "";
         return 1;
     }
     *val = odr_strdup(o, ptr->content);
@@ -121,7 +121,7 @@ static int match_xsd_XML_n(xmlNodePtr ptr, const char *elem, ODR o,
         return 0;
     ptr = ptr->children;
     while (ptr && (ptr->type == XML_TEXT_NODE || ptr->type == XML_COMMENT_NODE))
-       ptr = ptr->next;
+        ptr = ptr->next;
     if (!ptr)
         return 0;
     buf = xmlBufferCreate();
@@ -171,65 +171,65 @@ static int match_xsd_integer(xmlNodePtr ptr, const char *elem, ODR o, int **val)
 }
 
 static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec,
-                         void *client_data, const char *ns)
+                          void *client_data, const char *ns)
 {
     if (o->direction == ODR_DECODE)
     {
-       int pack = Z_SRW_recordPacking_string;
-       xmlNodePtr ptr;
-       rec->recordSchema = 0;
-       rec->recordData_buf = 0;
-       rec->recordData_len = 0;
-       rec->recordPosition = 0;
-       for (ptr = pptr->children; ptr; ptr = ptr->next)
-       {
-           char *spack = 0;
-           
-           if (match_xsd_string(ptr, "recordSchema", o, 
-                                &rec->recordSchema))
-               ;
-           else if (match_xsd_string(ptr, "recordPacking", o, &spack))
-           {
-               if (spack && !strcmp(spack, "xml"))
-                   pack = Z_SRW_recordPacking_XML;
-               if (spack && !strcmp(spack, "string"))
-                   pack = Z_SRW_recordPacking_string;
-           }
-           else if (match_xsd_integer(ptr, "recordPosition", o, 
-                                      &rec->recordPosition))
-               ;
-           else 
-           {
-               if (pack == Z_SRW_recordPacking_XML)
-                   match_xsd_XML_n(ptr, "recordData", o, 
-                                   &rec->recordData_buf,
-                                   &rec->recordData_len);
-               if (pack == Z_SRW_recordPacking_string)
-                   match_xsd_string_n(ptr, "recordData", o, 
-                                      &rec->recordData_buf,
-                                      &rec->recordData_len);
-           }
-       }
-       rec->recordPacking = pack;
+        int pack = Z_SRW_recordPacking_string;
+        xmlNodePtr ptr;
+        rec->recordSchema = 0;
+        rec->recordData_buf = 0;
+        rec->recordData_len = 0;
+        rec->recordPosition = 0;
+        for (ptr = pptr->children; ptr; ptr = ptr->next)
+        {
+            char *spack = 0;
+            
+            if (match_xsd_string(ptr, "recordSchema", o, 
+                                 &rec->recordSchema))
+                ;
+            else if (match_xsd_string(ptr, "recordPacking", o, &spack))
+            {
+                if (spack && !strcmp(spack, "xml"))
+                    pack = Z_SRW_recordPacking_XML;
+                if (spack && !strcmp(spack, "string"))
+                    pack = Z_SRW_recordPacking_string;
+            }
+            else if (match_xsd_integer(ptr, "recordPosition", o, 
+                                       &rec->recordPosition))
+                ;
+            else 
+            {
+                if (pack == Z_SRW_recordPacking_XML)
+                    match_xsd_XML_n(ptr, "recordData", o, 
+                                    &rec->recordData_buf,
+                                    &rec->recordData_len);
+                if (pack == Z_SRW_recordPacking_string)
+                    match_xsd_string_n(ptr, "recordData", o, 
+                                       &rec->recordData_buf,
+                                       &rec->recordData_len);
+            }
+        }
+        rec->recordPacking = pack;
     }
     else if (o->direction == ODR_ENCODE)
     {
-       xmlNodePtr ptr = pptr;
-       add_xsd_string(ptr, "recordSchema", rec->recordSchema);
-       switch(rec->recordPacking)
-       {
-       case Z_SRW_recordPacking_string:
-           add_xsd_string(ptr, "recordPacking", "string");
-           add_xsd_string_n(ptr, "recordData", rec->recordData_buf,
-                            rec->recordData_len);
-           break;
-       case Z_SRW_recordPacking_XML:
-           add_xsd_string(ptr, "recordPacking", "xml");
-           add_XML_n(ptr, "recordData", rec->recordData_buf,
-                     rec->recordData_len);
-           break;
-       }
-       add_xsd_integer(ptr, "recordPosition", rec->recordPosition);
+        xmlNodePtr ptr = pptr;
+        add_xsd_string(ptr, "recordSchema", rec->recordSchema);
+        switch(rec->recordPacking)
+        {
+        case Z_SRW_recordPacking_string:
+            add_xsd_string(ptr, "recordPacking", "string");
+            add_xsd_string_n(ptr, "recordData", rec->recordData_buf,
+                             rec->recordData_len);
+            break;
+        case Z_SRW_recordPacking_XML:
+            add_xsd_string(ptr, "recordPacking", "xml");
+            add_XML_n(ptr, "recordData", rec->recordData_buf,
+                      rec->recordData_len);
+            break;
+        }
+        add_xsd_integer(ptr, "recordPosition", rec->recordPosition);
     }
     return 0;
 }
@@ -255,10 +255,10 @@ static int yaz_srw_records(ODR o, xmlNodePtr pptr, Z_SRW_record **recs,
         {
             if (ptr->type == XML_ELEMENT_NODE &&
                 !strcmp(ptr->name, "record"))
-           {
-               yaz_srw_record(o, ptr, (*recs)+i, client_data, ns);
-               i++;
-           }
+            {
+                yaz_srw_record(o, ptr, (*recs)+i, client_data, ns);
+                i++;
+            }
         }
     }
     else if (o->direction == ODR_ENCODE)
@@ -267,7 +267,7 @@ static int yaz_srw_records(ODR o, xmlNodePtr pptr, Z_SRW_record **recs,
         for (i = 0; i < *num; i++)
         {
             xmlNodePtr rptr = xmlNewChild(pptr, 0, "record", 0);
-           yaz_srw_record(o, rptr, (*recs)+i, client_data, ns);
+            yaz_srw_record(o, rptr, (*recs)+i, client_data, ns);
         }
     }
     return 0;
@@ -290,12 +290,12 @@ static int yaz_srw_diagnostics(ODR o, xmlNodePtr pptr, Z_SRW_diagnostic **recs,
         if (!*num)
             return 1;
         *recs = (Z_SRW_diagnostic *) odr_malloc(o, *num * sizeof(**recs));
-       for (i = 0; i < *num; i++)
-       {
+        for (i = 0; i < *num; i++)
+        {
             (*recs)[i].uri = 0;
             (*recs)[i].details = 0;
             (*recs)[i].message = 0;
-       } 
+        } 
         for (i = 0, ptr = pptr->children; ptr; ptr = ptr->next)
         {
             if (ptr->type == XML_ELEMENT_NODE &&
@@ -308,7 +308,7 @@ static int yaz_srw_diagnostics(ODR o, xmlNodePtr pptr, Z_SRW_diagnostic **recs,
                 for (rptr = ptr->children; rptr; rptr = rptr->next)
                 {
                     if (match_xsd_string(rptr, "uri", o, 
-                                        &(*recs)[i].uri))
+                                         &(*recs)[i].uri))
                         ;
                     else if (match_xsd_string(rptr, "details", o, 
                                               &(*recs)[i].details))
@@ -324,23 +324,23 @@ static int yaz_srw_diagnostics(ODR o, xmlNodePtr pptr, Z_SRW_diagnostic **recs,
     else if (o->direction == ODR_ENCODE)
     {
         int i;
-       xmlNsPtr ns_diag =
-           xmlNewNs(pptr, "http://www.loc.gov/zing/srw/diagnostic/", 0);
+        xmlNsPtr ns_diag =
+            xmlNewNs(pptr, "http://www.loc.gov/zing/srw/diagnostic/", 0);
         for (i = 0; i < *num; i++)
         {
-           const char *std_diag = "info:srw/diagnostic/1/";
+            const char *std_diag = "info:srw/diagnostic/1/";
             xmlNodePtr rptr = xmlNewChild(pptr, ns_diag, "diagnostic", 0);
             add_xsd_string(rptr, "uri", (*recs)[i].uri);
-           if ((*recs)[i].message)
-               add_xsd_string(rptr, "message", (*recs)[i].message);
-           else if ((*recs)[i].uri && 
-                    !strncmp((*recs)[i].uri, std_diag, strlen(std_diag)))
-           {
-               int no = atoi((*recs)[i].uri + strlen(std_diag));
-               const char *message = yaz_diag_srw_str(no);
-               if (message)
-                   add_xsd_string(rptr, "message", message);
-           }
+            if ((*recs)[i].message)
+                add_xsd_string(rptr, "message", (*recs)[i].message);
+            else if ((*recs)[i].uri && 
+                     !strncmp((*recs)[i].uri, std_diag, strlen(std_diag)))
+            {
+                int no = atoi((*recs)[i].uri + strlen(std_diag));
+                const char *message = yaz_diag_srw_str(no);
+                if (message)
+                    add_xsd_string(rptr, "message", message);
+            }
             add_xsd_string(rptr, "details", (*recs)[i].details);
         }
     }
@@ -348,43 +348,43 @@ static int yaz_srw_diagnostics(ODR o, xmlNodePtr pptr, Z_SRW_diagnostic **recs,
 }
 
 static int yaz_srw_term(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm *term,
-                       void *client_data, const char *ns)
+                        void *client_data, const char *ns)
 {
     if (o->direction == ODR_DECODE)
     {
-       xmlNodePtr ptr;
-       term->value = 0;
-       term->numberOfRecords = 0;
-       term->displayTerm = 0;
-       term->whereInList = 0;
-       for (ptr = pptr->children; ptr; ptr = ptr->next)
-       {
-           if (match_xsd_string(ptr, "value", o,  &term->value))
-               ;
-           else if (match_xsd_integer(ptr, "numberOfRecords", o, 
-                                  &term->numberOfRecords))
-               ;
-           else if (match_xsd_string(ptr, "displayTerm", o, 
-                                     &term->displayTerm))
-               ;
-           else if (match_xsd_string(ptr, "whereInList", o, 
-                                     &term->whereInList))
-               ;
-       }
+        xmlNodePtr ptr;
+        term->value = 0;
+        term->numberOfRecords = 0;
+        term->displayTerm = 0;
+        term->whereInList = 0;
+        for (ptr = pptr->children; ptr; ptr = ptr->next)
+        {
+            if (match_xsd_string(ptr, "value", o,  &term->value))
+                ;
+            else if (match_xsd_integer(ptr, "numberOfRecords", o, 
+                                   &term->numberOfRecords))
+                ;
+            else if (match_xsd_string(ptr, "displayTerm", o, 
+                                      &term->displayTerm))
+                ;
+            else if (match_xsd_string(ptr, "whereInList", o, 
+                                      &term->whereInList))
+                ;
+        }
     }
     else if (o->direction == ODR_ENCODE)
     {
-       xmlNodePtr ptr = pptr;
-       add_xsd_string(ptr, "value", term->value);
-       add_xsd_integer(ptr, "numberOfRecords", term->numberOfRecords);
-       add_xsd_string(ptr, "displayTerm", term->displayTerm);
-       add_xsd_string(ptr, "whereInList", term->whereInList);
+        xmlNodePtr ptr = pptr;
+        add_xsd_string(ptr, "value", term->value);
+        add_xsd_integer(ptr, "numberOfRecords", term->numberOfRecords);
+        add_xsd_string(ptr, "displayTerm", term->displayTerm);
+        add_xsd_string(ptr, "whereInList", term->whereInList);
     }
     return 0;
 }
 
 static int yaz_srw_terms(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm **terms,
-                        int *num, void *client_data, const char *ns)
+                         int *num, void *client_data, const char *ns)
 {
     if (o->direction == ODR_DECODE)
     {
@@ -404,7 +404,7 @@ static int yaz_srw_terms(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm **terms,
         {
             if (ptr->type == XML_ELEMENT_NODE &&
                 !strcmp(ptr->name, "term"))
-               yaz_srw_term(o, ptr, (*terms)+i, client_data, ns);
+                yaz_srw_term(o, ptr, (*terms)+i, client_data, ns);
         }
     }
     else if (o->direction == ODR_ENCODE)
@@ -413,7 +413,7 @@ static int yaz_srw_terms(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm **terms,
         for (i = 0; i < *num; i++)
         {
             xmlNodePtr rptr = xmlNewChild(pptr, 0, "term", 0);
-           yaz_srw_term(o, rptr, (*terms)+i, client_data, ns);
+            yaz_srw_term(o, rptr, (*terms)+i, client_data, ns);
         }
     }
     return 0;
@@ -425,20 +425,20 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
     xmlNodePtr pptr = (xmlNodePtr) vptr;
     if (o->direction == ODR_DECODE)
     {
-       Z_SRW_PDU **p = handler_data;
+        Z_SRW_PDU **p = handler_data;
         xmlNodePtr method = pptr->children;
 
         while (method && method->type == XML_TEXT_NODE)
             method = method->next;
         
-       if (!method)
-           return -1;
+        if (!method)
+            return -1;
         if (method->type != XML_ELEMENT_NODE)
             return -1;
 
-       *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(**p));
-       (*p)->srw_version = odr_strdup(o, "1.1");
-       
+        *p = (Z_SRW_PDU *) odr_malloc(o, sizeof(**p));
+        (*p)->srw_version = odr_strdup(o, "1.1");
+        
         if (!strcmp(method->name, "searchRetrieveRequest"))
         {
             xmlNodePtr ptr = method->children;
@@ -446,7 +446,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
 
             (*p)->which = Z_SRW_searchRetrieve_request;
             req = (*p)->u.request = (Z_SRW_searchRetrieveRequest *)
-               odr_malloc(o, sizeof(*req));
+                odr_malloc(o, sizeof(*req));
             req->query_type = Z_SRW_query_type_cql;
             req->query.cql = 0;
             req->sort_type = Z_SRW_sort_type_none;
@@ -455,15 +455,15 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
             req->maximumRecords = 0;
             req->recordSchema = 0;
             req->recordPacking = 0;
-           req->recordXPath = 0;
-           req->resultSetTTL = 0;
-           req->stylesheet = 0;
+            req->recordXPath = 0;
+            req->resultSetTTL = 0;
+            req->stylesheet = 0;
             req->database = 0;
 
             for (; ptr; ptr = ptr->next)
             {
-               if (match_xsd_string(ptr, "version", o,
-                                    &(*p)->srw_version))
+                if (match_xsd_string(ptr, "version", o,
+                                     &(*p)->srw_version))
                     ;
                 else if (match_xsd_string(ptr, "query", o, 
                                      &req->query.cql))
@@ -511,7 +511,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
 
             (*p)->which = Z_SRW_searchRetrieve_response;
             res = (*p)->u.response = (Z_SRW_searchRetrieveResponse *)
-               odr_malloc(o, sizeof(*res));
+                odr_malloc(o, sizeof(*res));
 
             res->numberOfRecords = 0;
             res->resultSetId = 0;
@@ -525,7 +525,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
             for (; ptr; ptr = ptr->next)
             {
                 if (match_xsd_string(ptr, "version", o,
-                                    &(*p)->srw_version))
+                                     &(*p)->srw_version))
                     ;
                 else if (match_xsd_integer(ptr, "numberOfRecords", o, 
                                       &res->numberOfRecords))
@@ -552,29 +552,29 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
         else if (!strcmp(method->name, "explainRequest"))
         {
             Z_SRW_explainRequest *req;
-           xmlNodePtr ptr = method->children;
+            xmlNodePtr ptr = method->children;
             
             (*p)->which = Z_SRW_explain_request;
             req = (*p)->u.explain_request = (Z_SRW_explainRequest *)
-               odr_malloc(o, sizeof(*req));
-           req->recordPacking = 0;
-           req->database = 0;
-           req->stylesheet = 0;
-           for (; ptr; ptr = ptr->next)
-           {
+                odr_malloc(o, sizeof(*req));
+            req->recordPacking = 0;
+            req->database = 0;
+            req->stylesheet = 0;
+            for (; ptr; ptr = ptr->next)
+            {
                 if (match_xsd_string(ptr, "version", o,
                                            &(*p)->srw_version))
-                   ;
-               else if (match_xsd_string(ptr, "stylesheet", o,
-                                         &req->stylesheet))
-                   ;
-               else if (match_xsd_string(ptr, "recordPacking", o,
-                                    &req->recordPacking))
-                   ;
-               else if (match_xsd_string(ptr, "database", o,
-                                    &req->database))
                     ;
-           }
+                else if (match_xsd_string(ptr, "stylesheet", o,
+                                          &req->stylesheet))
+                    ;
+                else if (match_xsd_string(ptr, "recordPacking", o,
+                                     &req->recordPacking))
+                    ;
+                else if (match_xsd_string(ptr, "database", o,
+                                     &req->database))
+                    ;
+            }
         }
         else if (!strcmp(method->name, "explainResponse"))
         {
@@ -583,27 +583,27 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
 
             (*p)->which = Z_SRW_explain_response;
             res = (*p)->u.explain_response = (Z_SRW_explainResponse*)
-               odr_malloc(o, sizeof(*res));
+                odr_malloc(o, sizeof(*res));
             res->diagnostics = 0;
             res->num_diagnostics = 0;
-           res->record.recordSchema = 0;
-           res->record.recordData_buf = 0;
-           res->record.recordData_len = 0;
-           res->record.recordPosition = 0;
+            res->record.recordSchema = 0;
+            res->record.recordData_buf = 0;
+            res->record.recordData_len = 0;
+            res->record.recordPosition = 0;
 
-           for (; ptr; ptr = ptr->next)
-           {
+            for (; ptr; ptr = ptr->next)
+            {
                 if (match_xsd_string(ptr, "version", o,
                                            &(*p)->srw_version))
-                   ;
-               else if (match_element(ptr, "record"))
-                   yaz_srw_record(o, ptr, &res->record, client_data, ns);
-               else if (match_element(ptr, "diagnostics"))
+                    ;
+                else if (match_element(ptr, "record"))
+                    yaz_srw_record(o, ptr, &res->record, client_data, ns);
+                else if (match_element(ptr, "diagnostics"))
                     yaz_srw_diagnostics(o, ptr, &res->diagnostics,
                                         &res->num_diagnostics,
                                         client_data, ns);
-               ;
-           }
+                ;
+            }
         }
         else if (!strcmp(method->name, "scanRequest"))
         {
@@ -612,40 +612,40 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
 
             (*p)->which = Z_SRW_scan_request;
             req = (*p)->u.scan_request = (Z_SRW_scanRequest *)
-               odr_malloc(o, sizeof(*req));
-           req->query_type = Z_SRW_query_type_cql;
-           req->scanClause.cql = 0;
-           req->responsePosition = 0;
-           req->maximumTerms = 0;
-           req->stylesheet = 0;
-           req->database = 0;
-           
-           for (; ptr; ptr = ptr->next)
-           {
-               if (match_xsd_string(ptr, "version", o,
-                                    &(*p)->srw_version))
-                   ;
-               else if (match_xsd_string(ptr, "scanClause", o,
-                                    &req->scanClause.cql))
-                   ;
-               else if (match_xsd_string(ptr, "pScanClause", o,
-                                         &req->scanClause.pqf))
-               {
-                   req->query_type = Z_SRW_query_type_pqf;
-               }
-               else if (match_xsd_integer(ptr, "responsePosition", o,
-                                          &req->responsePosition))
-                   ;
-               else if (match_xsd_integer(ptr, "maximumTerms", o,
-                                          &req->maximumTerms))
+                odr_malloc(o, sizeof(*req));
+            req->query_type = Z_SRW_query_type_cql;
+            req->scanClause.cql = 0;
+            req->responsePosition = 0;
+            req->maximumTerms = 0;
+            req->stylesheet = 0;
+            req->database = 0;
+            
+            for (; ptr; ptr = ptr->next)
+            {
+                if (match_xsd_string(ptr, "version", o,
+                                     &(*p)->srw_version))
+                    ;
+                else if (match_xsd_string(ptr, "scanClause", o,
+                                     &req->scanClause.cql))
+                    ;
+                else if (match_xsd_string(ptr, "pScanClause", o,
+                                          &req->scanClause.pqf))
+                {
+                    req->query_type = Z_SRW_query_type_pqf;
+                }
+                else if (match_xsd_integer(ptr, "responsePosition", o,
+                                           &req->responsePosition))
+                    ;
+                else if (match_xsd_integer(ptr, "maximumTerms", o,
+                                           &req->maximumTerms))
+                    ;
+                else if (match_xsd_string(ptr, "stylesheet", o,
+                                          &req->stylesheet))
                     ;
-               else if (match_xsd_string(ptr, "stylesheet", o,
-                                         &req->stylesheet))
-                   ;
-               else if (match_xsd_string(ptr, "database", o,
-                                         &req->database))
+                else if (match_xsd_string(ptr, "database", o,
+                                          &req->database))
                     ;
-           }
+            }
         }
         else if (!strcmp(method->name, "scanResponse"))
         {
@@ -654,48 +654,48 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
 
             (*p)->which = Z_SRW_scan_response;
             res = (*p)->u.scan_response = (Z_SRW_scanResponse *)
-               odr_malloc(o, sizeof(*res));
-           res->terms = 0;
-           res->num_terms = 0;
-           res->diagnostics = 0;
-           res->num_diagnostics = 0;
-           
-           for (; ptr; ptr = ptr->next)
-           {
-               if (match_xsd_string(ptr, "version", o,
-                                    &(*p)->srw_version))
-                   ;
+                odr_malloc(o, sizeof(*res));
+            res->terms = 0;
+            res->num_terms = 0;
+            res->diagnostics = 0;
+            res->num_diagnostics = 0;
+            
+            for (; ptr; ptr = ptr->next)
+            {
+                if (match_xsd_string(ptr, "version", o,
+                                     &(*p)->srw_version))
+                    ;
                 else if (match_element(ptr, "terms"))
                     yaz_srw_terms(o, ptr, &res->terms,
-                                 &res->num_terms, client_data,
-                                 ns);
-               else if (match_element(ptr, "diagnostics"))
+                                  &res->num_terms, client_data,
+                                  ns);
+                else if (match_element(ptr, "diagnostics"))
                     yaz_srw_diagnostics(o, ptr, &res->diagnostics,
                                         &res->num_diagnostics,
                                         client_data, ns);
-           }
+            }
         }
         else
-       {
-           *p = 0;
+        {
+            *p = 0;
             return -1;
-       }
+        }
     }
     else if (o->direction == ODR_ENCODE)
     {
         Z_SRW_PDU **p = handler_data;
-       xmlNsPtr ns_srw;
-       
+        xmlNsPtr ns_srw;
+        
         if ((*p)->which == Z_SRW_searchRetrieve_request)
         {
             Z_SRW_searchRetrieveRequest *req = (*p)->u.request;
             xmlNodePtr ptr = xmlNewChild(pptr, 0,
                                          "searchRetrieveRequest", 0);
-           ns_srw = xmlNewNs(ptr, ns, "zs");
-           xmlSetNs(ptr, ns_srw);
+            ns_srw = xmlNewNs(ptr, ns, "zs");
+            xmlSetNs(ptr, ns_srw);
 
-           if ((*p)->srw_version)
-               add_xsd_string(ptr, "version", (*p)->srw_version);
+            if ((*p)->srw_version)
+                add_xsd_string(ptr, "version", (*p)->srw_version);
             switch(req->query_type)
             {
             case Z_SRW_query_type_cql:
@@ -733,11 +733,11 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
             Z_SRW_searchRetrieveResponse *res = (*p)->u.response;
             xmlNodePtr ptr = xmlNewChild(pptr, 0,
                                          "searchRetrieveResponse", 0);
-           ns_srw = xmlNewNs(ptr, ns, "zs");
-           xmlSetNs(ptr, ns_srw);
+            ns_srw = xmlNewNs(ptr, ns, "zs");
+            xmlSetNs(ptr, ns_srw);
 
-           if ((*p)->srw_version)
-               add_xsd_string(ptr, "version", (*p)->srw_version);
+            if ((*p)->srw_version)
+                add_xsd_string(ptr, "version", (*p)->srw_version);
             add_xsd_integer(ptr, "numberOfRecords", res->numberOfRecords);
             add_xsd_string(ptr, "resultSetId", res->resultSetId);
             add_xsd_integer(ptr, "resultSetIdleTime", res->resultSetIdleTime);
@@ -748,7 +748,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                 client_data, ns);
             }
             add_xsd_integer(ptr, "nextRecordPosition",
-                           res->nextRecordPosition);
+                            res->nextRecordPosition);
             if (res->num_diagnostics)
             {
                 xmlNodePtr rptr = xmlNewChild(ptr, 0, "diagnostics", 0);
@@ -760,10 +760,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
         {
             Z_SRW_explainRequest *req = (*p)->u.explain_request;
             xmlNodePtr ptr = xmlNewChild(pptr, 0, "explainRequest", 0);
-           ns_srw = xmlNewNs(ptr, ns, "zs");
-           xmlSetNs(ptr, ns_srw);
+            ns_srw = xmlNewNs(ptr, ns, "zs");
+            xmlSetNs(ptr, ns_srw);
 
-           add_xsd_string(ptr, "version", (*p)->srw_version);
+            add_xsd_string(ptr, "version", (*p)->srw_version);
             add_xsd_string(ptr, "recordPacking", req->recordPacking);
             add_xsd_string(ptr, "stylesheet", req->stylesheet);
             add_xsd_string(ptr, "database", req->database);
@@ -772,19 +772,19 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
         {
             Z_SRW_explainResponse *res = (*p)->u.explain_response;
             xmlNodePtr ptr = xmlNewChild(pptr, 0, "explainResponse", 0);
-           ns_srw = xmlNewNs(ptr, ns, "zs");
-           xmlSetNs(ptr, ns_srw);
-
-           add_xsd_string(ptr, "version", (*p)->srw_version);
-           if (1)
-           {
-               xmlNodePtr ptr1 = xmlNewChild(ptr, 0, "record", 0);
-               yaz_srw_record(o, ptr1, &res->record, client_data, ns);
-           }
-           if (res->num_diagnostics)
-           {
-               xmlNodePtr rptr = xmlNewChild(ptr, 0, "diagnostics", 0);
-               yaz_srw_diagnostics(o, rptr, &res->diagnostics,
+            ns_srw = xmlNewNs(ptr, ns, "zs");
+            xmlSetNs(ptr, ns_srw);
+
+            add_xsd_string(ptr, "version", (*p)->srw_version);
+            if (1)
+            {
+                xmlNodePtr ptr1 = xmlNewChild(ptr, 0, "record", 0);
+                yaz_srw_record(o, ptr1, &res->record, client_data, ns);
+            }
+            if (res->num_diagnostics)
+            {
+                xmlNodePtr rptr = xmlNewChild(ptr, 0, "diagnostics", 0);
+                yaz_srw_diagnostics(o, rptr, &res->diagnostics,
                                     &res->num_diagnostics, client_data, ns);
             }
         }
@@ -792,43 +792,43 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
         {
             Z_SRW_scanRequest *req = (*p)->u.scan_request;
             xmlNodePtr ptr = xmlNewChild(pptr, 0, "scanRequest", 0);
-           ns_srw = xmlNewNs(ptr, ns, "zs");
-           xmlSetNs(ptr, ns_srw);
-
-           add_xsd_string(ptr, "version", (*p)->srw_version);
-           switch(req->query_type)
-           {
-           case Z_SRW_query_type_cql:
-               add_xsd_string(ptr, "scanClause", req->scanClause.cql);
-               break;
-           case Z_SRW_query_type_pqf:
-               add_xsd_string(ptr, "pScanClause", req->scanClause.pqf);
-               break;
-           }
-           add_xsd_integer(ptr, "responsePosition", req->responsePosition);
-           add_xsd_integer(ptr, "maximumTerms", req->maximumTerms);
-           add_xsd_string(ptr, "stylesheet", req->stylesheet);
+            ns_srw = xmlNewNs(ptr, ns, "zs");
+            xmlSetNs(ptr, ns_srw);
+
+            add_xsd_string(ptr, "version", (*p)->srw_version);
+            switch(req->query_type)
+            {
+            case Z_SRW_query_type_cql:
+                add_xsd_string(ptr, "scanClause", req->scanClause.cql);
+                break;
+            case Z_SRW_query_type_pqf:
+                add_xsd_string(ptr, "pScanClause", req->scanClause.pqf);
+                break;
+            }
+            add_xsd_integer(ptr, "responsePosition", req->responsePosition);
+            add_xsd_integer(ptr, "maximumTerms", req->maximumTerms);
+            add_xsd_string(ptr, "stylesheet", req->stylesheet);
             add_xsd_string(ptr, "database", req->database);
         }
         else if ((*p)->which == Z_SRW_scan_response)
         {
             Z_SRW_scanResponse *res = (*p)->u.scan_response;
             xmlNodePtr ptr = xmlNewChild(pptr, 0, "scanResponse", 0);
-           ns_srw = xmlNewNs(ptr, ns, "zs");
-           xmlSetNs(ptr, ns_srw);
+            ns_srw = xmlNewNs(ptr, ns, "zs");
+            xmlSetNs(ptr, ns_srw);
 
-           add_xsd_string(ptr, "version", (*p)->srw_version);
+            add_xsd_string(ptr, "version", (*p)->srw_version);
 
             if (res->num_terms)
             {
                 xmlNodePtr rptr = xmlNewChild(ptr, 0, "terms", 0);
                 yaz_srw_terms(o, rptr, &res->terms, &res->num_terms,
-                             client_data, ns);
+                              client_data, ns);
             }
-           if (res->num_diagnostics)
-           {
-               xmlNodePtr rptr = xmlNewChild(ptr, 0, "diagnostics", 0);
-               yaz_srw_diagnostics(o, rptr, &res->diagnostics,
+            if (res->num_diagnostics)
+            {
+                xmlNodePtr rptr = xmlNewChild(ptr, 0, "diagnostics", 0);
+                yaz_srw_diagnostics(o, rptr, &res->diagnostics,
                                     &res->num_diagnostics, client_data, ns);
             }
         }
@@ -842,3 +842,11 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
 #endif
 
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c476d11..168d7b5 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: srwutil.c,v 1.27 2005-02-01 14:43:50 adam Exp $
+ * $Id: srwutil.c,v 1.28 2005-06-25 15:46:05 adam Exp $
  */
 /**
  * \file srwutil.c
@@ -30,13 +30,13 @@ int yaz_uri_array(const char *path, ODR o, char ***name, char ***val)
     const char *cp;
     *name = 0;
     if (*path != '?')
-       return no;
+        return no;
     path++;
     cp = path;
     while ((cp = strchr(cp, '&')))
     {
-       cp++;
-       no++;
+        cp++;
+        no++;
     }
     *name = odr_malloc(o, no * sizeof(char**));
     *val = odr_malloc(o, no * sizeof(char**));
@@ -44,39 +44,39 @@ int yaz_uri_array(const char *path, ODR o, char ***name, char ***val)
     for (no = 0; *path; no++)
     {
         const char *p1 = strchr(path, '=');
-       size_t i = 0;
-       char *ret;
+        size_t i = 0;
+        char *ret;
         if (!p1)
             break;
 
-       (*name)[no] = odr_malloc(o, (p1-path)+1);
-       memcpy((*name)[no], path, p1-path);
-       (*name)[no][p1-path] = '\0';
-
-       path = p1 + 1;
-       p1 = strchr(path, '&');
-       if (!p1)
-           p1 = strlen(path) + path;
-       (*val)[no] = ret = odr_malloc(o, p1 - path + 1);
-       while (*path && *path != '&')
-       {
-           if (*path == '+')
-           {
-               ret[i++] = ' ';
-               path++;
-           }
-           else if (*path == '%' && path[1] && path[2])
-           {
-               ret[i++] = hex_digit (path[1])*16 + hex_digit (path[2]);
-               path = path + 3;
-           }
-           else
-               ret[i++] = *path++;
-       }
-       ret[i] = '\0';
-
-       if (*path)
-           path++;
+        (*name)[no] = odr_malloc(o, (p1-path)+1);
+        memcpy((*name)[no], path, p1-path);
+        (*name)[no][p1-path] = '\0';
+
+        path = p1 + 1;
+        p1 = strchr(path, '&');
+        if (!p1)
+            p1 = strlen(path) + path;
+        (*val)[no] = ret = odr_malloc(o, p1 - path + 1);
+        while (*path && *path != '&')
+        {
+            if (*path == '+')
+            {
+                ret[i++] = ' ';
+                path++;
+            }
+            else if (*path == '%' && path[1] && path[2])
+            {
+                ret[i++] = hex_digit (path[1])*16 + hex_digit (path[2]);
+                path = path + 3;
+            }
+            else
+                ret[i++] = *path++;
+        }
+        ret[i] = '\0';
+
+        if (*path)
+            path++;
     }
     (*name)[no] = 0;
     (*val)[no] = 0;
@@ -137,24 +137,24 @@ void yaz_uri_val_int(const char *path, const char *name, ODR o, int **intp)
 }
 
 void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d, 
-                          int code, const char *details)
+                           int code, const char *details)
 {
     d->uri = (char *) odr_malloc(o, 50);
     sprintf(d->uri, "info:srw/diagnostic/1/%d", code);
     d->message = 0;
     if (details)
-       d->details = odr_strdup(o, details);
+        d->details = odr_strdup(o, details);
     else
-       d->details = 0;
+        d->details = 0;
 }
 
 void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
-                           int *num, int code, const char *addinfo)
+                            int *num, int code, const char *addinfo)
 {
     Z_SRW_diagnostic *d_new;
     d_new = (Z_SRW_diagnostic *) odr_malloc (o, (*num + 1)* sizeof(**d));
     if (*num)
-       memcpy (d_new, *d, *num *sizeof(**d));
+        memcpy (d_new, *d, *num *sizeof(**d));
     *d = d_new;
 
     yaz_mk_std_diagnostic(o, *d + *num, code, addinfo);
@@ -162,21 +162,21 @@ void yaz_add_srw_diagnostic(ODR o, Z_SRW_diagnostic **d,
 }
 
 int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                  Z_SOAP **soap_package, ODR decode, char **charset)
+                   Z_SOAP **soap_package, ODR decode, char **charset)
 {
     if (!strcmp(hreq->method, "POST"))
     {
-       const char *content_type = z_HTTP_header_lookup(hreq->headers,
-                                                       "Content-Type");
-       if (content_type && 
-           (!yaz_strcmp_del("text/xml", content_type, "; ") ||
-            !yaz_strcmp_del("text/plain", content_type, "; ")))
-       {
-           char *db = "Default";
-           const char *p0 = hreq->path, *p1;
+        const char *content_type = z_HTTP_header_lookup(hreq->headers,
+                                                        "Content-Type");
+        if (content_type && 
+            (!yaz_strcmp_del("text/xml", content_type, "; ") ||
+             !yaz_strcmp_del("text/plain", content_type, "; ")))
+        {
+            char *db = "Default";
+            const char *p0 = hreq->path, *p1;
             int ret = -1;
             const char *charset_p = 0;
-           
+            
             static Z_SOAP_Handler soap_handlers[3] = {
 #if HAVE_XML2
                 {"http://www.loc.gov/zing/srw/", 0,
@@ -186,18 +186,18 @@ int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
 #endif
                 {0, 0, 0}
             };
-           
-           if (*p0 == '/')
-               p0++;
-           p1 = strchr(p0, '?');
-           if (!p1)
-               p1 = p0 + strlen(p0);
-           if (p1 != p0)
-           {
-               db = (char*) odr_malloc(decode, p1 - p0 + 1);
-               memcpy (db, p0, p1 - p0);
-               db[p1 - p0] = '\0';
-           }
+            
+            if (*p0 == '/')
+                p0++;
+            p1 = strchr(p0, '?');
+            if (!p1)
+                p1 = p0 + strlen(p0);
+            if (p1 != p0)
+            {
+                db = (char*) odr_malloc(decode, p1 - p0 + 1);
+                memcpy (db, p0, p1 - p0);
+                db[p1 - p0] = '\0';
+            }
 
             if (charset && (charset_p = strstr(content_type, "; charset=")))
             {
@@ -213,26 +213,26 @@ int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
             ret = z_soap_codec(decode, soap_package, 
                                &hreq->content_buf, &hreq->content_len,
                                soap_handlers);
-           if (ret == 0 && (*soap_package)->which == Z_SOAP_generic)
-           {
-               *srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
-               
-               if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
-                   (*srw_pdu)->u.request->database == 0)
-                   (*srw_pdu)->u.request->database = db;
-
-               if ((*srw_pdu)->which == Z_SRW_explain_request &&
-                   (*srw_pdu)->u.explain_request->database == 0)
-                   (*srw_pdu)->u.explain_request->database = db;
-
-               if ((*srw_pdu)->which == Z_SRW_scan_request &&
-                   (*srw_pdu)->u.scan_request->database == 0)
-                   (*srw_pdu)->u.scan_request->database = db;
-
-               return 0;
-           }
-           return 1;
-       }
+            if (ret == 0 && (*soap_package)->which == Z_SOAP_generic)
+            {
+                *srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
+                
+                if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
+                    (*srw_pdu)->u.request->database == 0)
+                    (*srw_pdu)->u.request->database = db;
+
+                if ((*srw_pdu)->which == Z_SRW_explain_request &&
+                    (*srw_pdu)->u.explain_request->database == 0)
+                    (*srw_pdu)->u.explain_request->database = db;
+
+                if ((*srw_pdu)->which == Z_SRW_scan_request &&
+                    (*srw_pdu)->u.scan_request->database == 0)
+                    (*srw_pdu)->u.scan_request->database = db;
+
+                return 0;
+            }
+            return 1;
+        }
     }
     return 2;
 }
@@ -241,14 +241,14 @@ int yaz_srw_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
   http://www.loc.gov/z3950/agency/zing/srw/service.html
 */ 
 int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
-                  Z_SOAP **soap_package, ODR decode, char **charset,
-                  Z_SRW_diagnostic **diag, int *num_diag)
+                   Z_SOAP **soap_package, ODR decode, char **charset,
+                   Z_SRW_diagnostic **diag, int *num_diag)
 {
 #if HAVE_XML2
     static Z_SOAP_Handler soap_handlers[2] = {
-       {"http://www.loc.gov/zing/srw/", 0,
-        (Z_SOAP_fun) yaz_srw_codec},
-       {0, 0, 0}
+        {"http://www.loc.gov/zing/srw/", 0,
+         (Z_SOAP_fun) yaz_srw_codec},
+        {0, 0, 0}
     };
 #endif
     if (!strcmp(hreq->method, "GET"))
@@ -256,28 +256,28 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
         char *db = "Default";
         const char *p0 = hreq->path, *p1;
 #if HAVE_XML2
-       const char *operation = 0;
-       char *version = 0;
-       char *query = 0;
-       char *pQuery = 0;
-       char *sortKeys = 0;
-       char *stylesheet = 0;
-       char *scanClause = 0;
-       char *pScanClause = 0;
-       char *recordXPath = 0;
-       char *recordSchema = 0;
-       char *recordPacking = "xml";  /* xml packing is default for SRU */
-       char *maximumRecords = 0;
-       char *startRecord = 0;
-       char *maximumTerms = 0;
-       char *responsePosition = 0;
-       char *extraRequestData = 0;
+        const char *operation = 0;
+        char *version = 0;
+        char *query = 0;
+        char *pQuery = 0;
+        char *sortKeys = 0;
+        char *stylesheet = 0;
+        char *scanClause = 0;
+        char *pScanClause = 0;
+        char *recordXPath = 0;
+        char *recordSchema = 0;
+        char *recordPacking = "xml";  /* xml packing is default for SRU */
+        char *maximumRecords = 0;
+        char *startRecord = 0;
+        char *maximumTerms = 0;
+        char *responsePosition = 0;
+        char *extraRequestData = 0;
 #endif
-       char **uri_name;
-       char **uri_val;
+        char **uri_name;
+        char **uri_val;
 
-       if (charset)
-           *charset = 0;
+        if (charset)
+            *charset = 0;
         if (*p0 == '/')
             p0++;
         p1 = strchr(p0, '?');
@@ -289,71 +289,71 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
             memcpy (db, p0, p1 - p0);
             db[p1 - p0] = '\0';
         }
-       yaz_uri_array(p1, decode, &uri_name, &uri_val);
+        yaz_uri_array(p1, decode, &uri_name, &uri_val);
 #if HAVE_XML2
-       if (uri_name)
-       {
-           int i;
-           for (i = 0; uri_name[i]; i++)
-           {
-               char *n = uri_name[i];
-               char *v = uri_val[i];
-               if (!strcmp(n, "query"))
-                   query = v;
-               else if (!strcmp(n, "x-pquery"))
-                   pQuery = v;
-               else if (!strcmp(n, "operation"))
-                   operation = v;
-               else if (!strcmp(n, "stylesheet"))
-                   stylesheet = v;
-               else if (!strcmp(n, "sortKeys"))
-                   sortKeys = v;
-               else if (!strcmp(n, "recordXPath"))
-                   recordXPath = v;
-               else if (!strcmp(n, "recordSchema"))
-                   recordSchema = v;
-               else if (!strcmp(n, "recordPacking"))
-                   recordPacking = v;
-               else if (!strcmp(n, "version"))
-                   version = v;
-               else if (!strcmp(n, "scanClause"))
-                   scanClause = v;
-               else if (!strcmp(n, "x-pScanClause"))
-                   pScanClause = v;
-               else if (!strcmp(n, "maximumRecords"))
-                   maximumRecords = v;
-               else if (!strcmp(n, "startRecord"))
-                   startRecord = v;
-               else if (!strcmp(n, "maximumTerms"))
-                   maximumTerms = v;
-               else if (!strcmp(n, "responsePosition"))
-                   responsePosition = v;
-               else if (!strcmp(n, "extraRequestData"))
-                   extraRequestData = v;
-               else
-                   yaz_add_srw_diagnostic(decode, diag, num_diag, 8, n);
-           }
-       }
-       if (!version)
-       {
-           if (uri_name)
-               yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "version");
-           version = "1.1";
-       }
-       if (strcmp(version, "1.1"))
-           yaz_add_srw_diagnostic(decode, diag, num_diag, 5, "1.1");
-       if (!operation)
-       {
-           if (uri_name)
-               yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "operation");
-           operation = "explain";
-       }
+        if (uri_name)
+        {
+            int i;
+            for (i = 0; uri_name[i]; i++)
+            {
+                char *n = uri_name[i];
+                char *v = uri_val[i];
+                if (!strcmp(n, "query"))
+                    query = v;
+                else if (!strcmp(n, "x-pquery"))
+                    pQuery = v;
+                else if (!strcmp(n, "operation"))
+                    operation = v;
+                else if (!strcmp(n, "stylesheet"))
+                    stylesheet = v;
+                else if (!strcmp(n, "sortKeys"))
+                    sortKeys = v;
+                else if (!strcmp(n, "recordXPath"))
+                    recordXPath = v;
+                else if (!strcmp(n, "recordSchema"))
+                    recordSchema = v;
+                else if (!strcmp(n, "recordPacking"))
+                    recordPacking = v;
+                else if (!strcmp(n, "version"))
+                    version = v;
+                else if (!strcmp(n, "scanClause"))
+                    scanClause = v;
+                else if (!strcmp(n, "x-pScanClause"))
+                    pScanClause = v;
+                else if (!strcmp(n, "maximumRecords"))
+                    maximumRecords = v;
+                else if (!strcmp(n, "startRecord"))
+                    startRecord = v;
+                else if (!strcmp(n, "maximumTerms"))
+                    maximumTerms = v;
+                else if (!strcmp(n, "responsePosition"))
+                    responsePosition = v;
+                else if (!strcmp(n, "extraRequestData"))
+                    extraRequestData = v;
+                else
+                    yaz_add_srw_diagnostic(decode, diag, num_diag, 8, n);
+            }
+        }
+        if (!version)
+        {
+            if (uri_name)
+                yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "version");
+            version = "1.1";
+        }
+        if (strcmp(version, "1.1"))
+            yaz_add_srw_diagnostic(decode, diag, num_diag, 5, "1.1");
+        if (!operation)
+        {
+            if (uri_name)
+                yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "operation");
+            operation = "explain";
+        }
         if (!strcmp(operation, "searchRetrieve"))
         {
             Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_searchRetrieve_request);
 
-           sr->srw_version = version;
-           *srw_pdu = sr;
+            sr->srw_version = version;
+            *srw_pdu = sr;
             if (query)
             {
                 sr->u.request->query_type = Z_SRW_query_type_cql;
@@ -364,8 +364,8 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
                 sr->u.request->query_type = Z_SRW_query_type_pqf;
                 sr->u.request->query.pqf = pQuery;
             }
-           else
-               yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "query");
+            else
+                yaz_add_srw_diagnostic(decode, diag, num_diag, 7, "query");
 
             if (sortKeys)
             {
@@ -377,134 +377,134 @@ int yaz_sru_decode(Z_HTTP_Request *hreq, Z_SRW_PDU **srw_pdu,
             sr->u.request->recordPacking = recordPacking;
             sr->u.request->stylesheet = stylesheet;
 
-           if (maximumRecords)
-               sr->u.request->maximumRecords =
-                   odr_intdup(decode, atoi(maximumRecords));
-           if (startRecord)
-               sr->u.request->startRecord =
-                   odr_intdup(decode, atoi(startRecord));
+            if (maximumRecords)
+                sr->u.request->maximumRecords =
+                    odr_intdup(decode, atoi(maximumRecords));
+            if (startRecord)
+                sr->u.request->startRecord =
+                    odr_intdup(decode, atoi(startRecord));
 
             sr->u.request->database = db;
 
-           (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
-           (*soap_package)->which = Z_SOAP_generic;
-           
-           (*soap_package)->u.generic =
-               odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-           
-           (*soap_package)->u.generic->p = sr;
-           (*soap_package)->u.generic->ns = soap_handlers[0].ns;
-           (*soap_package)->u.generic->no = 0;
-           
-           (*soap_package)->ns = "SRU";
-
-           return 0;
+            (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
+            (*soap_package)->which = Z_SOAP_generic;
+            
+            (*soap_package)->u.generic =
+                odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
+            
+            (*soap_package)->u.generic->p = sr;
+            (*soap_package)->u.generic->ns = soap_handlers[0].ns;
+            (*soap_package)->u.generic->no = 0;
+            
+            (*soap_package)->ns = "SRU";
+
+            return 0;
         }
-       else if (!strcmp(operation, "explain"))
-       {
-           /* Transfer SRU explain parameters to common struct */
-           /* http://www.loc.gov/z3950/agency/zing/srw/explain.html */
+        else if (!strcmp(operation, "explain"))
+        {
+            /* Transfer SRU explain parameters to common struct */
+            /* http://www.loc.gov/z3950/agency/zing/srw/explain.html */
             Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_explain_request);
 
-           sr->srw_version = version;
-           *srw_pdu = sr;
+            sr->srw_version = version;
+            *srw_pdu = sr;
             sr->u.explain_request->recordPacking = recordPacking;
-           sr->u.explain_request->database = db;
+            sr->u.explain_request->database = db;
 
             sr->u.explain_request->stylesheet = stylesheet;
 
-           (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
-           (*soap_package)->which = Z_SOAP_generic;
-           
-           (*soap_package)->u.generic =
-               odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-           
-           (*soap_package)->u.generic->p = sr;
-           (*soap_package)->u.generic->ns = soap_handlers[0].ns;
-           (*soap_package)->u.generic->no = 0;
-           
-           (*soap_package)->ns = "SRU";
-
-           return 0;
-       }
-       else if (!strcmp(operation, "scan"))
-       {
-           /* Transfer SRU scan parameters to common struct */
-           /* http://www.loc.gov/z3950/agency/zing/srw/scan.html */
+            (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
+            (*soap_package)->which = Z_SOAP_generic;
+            
+            (*soap_package)->u.generic =
+                odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
+            
+            (*soap_package)->u.generic->p = sr;
+            (*soap_package)->u.generic->ns = soap_handlers[0].ns;
+            (*soap_package)->u.generic->no = 0;
+            
+            (*soap_package)->ns = "SRU";
+
+            return 0;
+        }
+        else if (!strcmp(operation, "scan"))
+        {
+            /* Transfer SRU scan parameters to common struct */
+            /* http://www.loc.gov/z3950/agency/zing/srw/scan.html */
             Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_scan_request);
 
-           sr->srw_version = version;
-           *srw_pdu = sr;
+            sr->srw_version = version;
+            *srw_pdu = sr;
 
             if (scanClause)
             {
                 sr->u.scan_request->query_type = Z_SRW_query_type_cql;
-               sr->u.scan_request->scanClause.cql = scanClause;
+                sr->u.scan_request->scanClause.cql = scanClause;
             }
             else if (pScanClause)
             {
                 sr->u.scan_request->query_type = Z_SRW_query_type_pqf;
                 sr->u.scan_request->scanClause.pqf = pScanClause;
             }
-           else
-               yaz_add_srw_diagnostic(decode, diag, num_diag, 7,
-                                      "scanClause");
-           sr->u.scan_request->database = db;
-
-           if (maximumTerms)
-               sr->u.scan_request->maximumTerms =
-                   odr_intdup(decode, atoi(maximumTerms));
-           if (responsePosition)
-               sr->u.scan_request->responsePosition =
-                   odr_intdup(decode, atoi(responsePosition));
+            else
+                yaz_add_srw_diagnostic(decode, diag, num_diag, 7,
+                                       "scanClause");
+            sr->u.scan_request->database = db;
+
+            if (maximumTerms)
+                sr->u.scan_request->maximumTerms =
+                    odr_intdup(decode, atoi(maximumTerms));
+            if (responsePosition)
+                sr->u.scan_request->responsePosition =
+                    odr_intdup(decode, atoi(responsePosition));
 
             sr->u.scan_request->stylesheet = stylesheet;
 
-           (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
-           (*soap_package)->which = Z_SOAP_generic;
-           
-           (*soap_package)->u.generic =
-               odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-           
-           (*soap_package)->u.generic->p = sr;
-           (*soap_package)->u.generic->ns = soap_handlers[0].ns;
-           (*soap_package)->u.generic->no = 0;
-           
-           (*soap_package)->ns = "SRU";
-
-           return 0;
-       }
-       else
-       {
-           /* unsupported operation ... */
-           /* Act as if we received a explain request and throw diagnostic. */
+            (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
+            (*soap_package)->which = Z_SOAP_generic;
+            
+            (*soap_package)->u.generic =
+                odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
+            
+            (*soap_package)->u.generic->p = sr;
+            (*soap_package)->u.generic->ns = soap_handlers[0].ns;
+            (*soap_package)->u.generic->no = 0;
+            
+            (*soap_package)->ns = "SRU";
+
+            return 0;
+        }
+        else
+        {
+            /* unsupported operation ... */
+            /* Act as if we received a explain request and throw diagnostic. */
 
             Z_SRW_PDU *sr = yaz_srw_get(decode, Z_SRW_explain_request);
 
-           sr->srw_version = version;
-           *srw_pdu = sr;
+            sr->srw_version = version;
+            *srw_pdu = sr;
             sr->u.explain_request->recordPacking = recordPacking;
-           sr->u.explain_request->database = db;
+            sr->u.explain_request->database = db;
 
             sr->u.explain_request->stylesheet = stylesheet;
 
-           (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
-           (*soap_package)->which = Z_SOAP_generic;
-           
-           (*soap_package)->u.generic =
-               odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
-           
-           (*soap_package)->u.generic->p = sr;
-           (*soap_package)->u.generic->ns = soap_handlers[0].ns;
-           (*soap_package)->u.generic->no = 0;
-           
-           (*soap_package)->ns = "SRU";
-
-           yaz_add_srw_diagnostic(decode, diag, num_diag, 4, operation);
-           return 0;
-       }
+            (*soap_package) = odr_malloc(decode, sizeof(**soap_package));
+            (*soap_package)->which = Z_SOAP_generic;
+            
+            (*soap_package)->u.generic =
+                odr_malloc(decode, sizeof(*(*soap_package)->u.generic));
+            
+            (*soap_package)->u.generic->p = sr;
+            (*soap_package)->u.generic->ns = soap_handlers[0].ns;
+            (*soap_package)->u.generic->no = 0;
+            
+            (*soap_package)->ns = "SRU";
+
+            yaz_add_srw_diagnostic(decode, diag, num_diag, 4, operation);
+            return 0;
+        }
 #endif
-       return 1;
+        return 1;
     }
     return 2;
 }
@@ -529,9 +529,9 @@ Z_SRW_PDU *yaz_srw_get(ODR o, int which)
         sr->u.request->recordSchema = 0;
         sr->u.request->recordPacking = 0;
         sr->u.request->recordXPath = 0;
-       sr->u.request->database = 0;
-       sr->u.request->resultSetTTL = 0;
-       sr->u.request->stylesheet = 0;
+        sr->u.request->database = 0;
+        sr->u.request->resultSetTTL = 0;
+        sr->u.request->stylesheet = 0;
         break;
     case Z_SRW_searchRetrieve_response:
         sr->u.response = (Z_SRW_searchRetrieveResponse *)
@@ -549,38 +549,38 @@ Z_SRW_PDU *yaz_srw_get(ODR o, int which)
         sr->u.explain_request = (Z_SRW_explainRequest *)
             odr_malloc(o, sizeof(*sr->u.explain_request));
         sr->u.explain_request->recordPacking = 0;
-       sr->u.explain_request->database = 0;
-       sr->u.explain_request->stylesheet = 0;
+        sr->u.explain_request->database = 0;
+        sr->u.explain_request->stylesheet = 0;
         break;
     case Z_SRW_explain_response:
         sr->u.explain_response = (Z_SRW_explainResponse *)
             odr_malloc(o, sizeof(*sr->u.explain_response));
-       sr->u.explain_response->record.recordData_buf = 0;
-       sr->u.explain_response->record.recordData_len = 0;
-       sr->u.explain_response->record.recordSchema = 0;
-       sr->u.explain_response->record.recordPosition = 0;
-       sr->u.explain_response->record.recordPacking =
-           Z_SRW_recordPacking_string;
-       sr->u.explain_response->diagnostics = 0;
-       sr->u.explain_response->num_diagnostics = 0;
-       break;
+        sr->u.explain_response->record.recordData_buf = 0;
+        sr->u.explain_response->record.recordData_len = 0;
+        sr->u.explain_response->record.recordSchema = 0;
+        sr->u.explain_response->record.recordPosition = 0;
+        sr->u.explain_response->record.recordPacking =
+            Z_SRW_recordPacking_string;
+        sr->u.explain_response->diagnostics = 0;
+        sr->u.explain_response->num_diagnostics = 0;
+        break;
     case Z_SRW_scan_request:
         sr->u.scan_request = (Z_SRW_scanRequest *)
             odr_malloc(o, sizeof(*sr->u.scan_request));
-       sr->u.scan_request->database = 0;
-       sr->u.scan_request->stylesheet = 0;
-       sr->u.scan_request->maximumTerms = 0;
-       sr->u.scan_request->responsePosition = 0;
-       sr->u.scan_request->query_type = Z_SRW_query_type_cql;
-       sr->u.scan_request->scanClause.cql = 0;
+        sr->u.scan_request->database = 0;
+        sr->u.scan_request->stylesheet = 0;
+        sr->u.scan_request->maximumTerms = 0;
+        sr->u.scan_request->responsePosition = 0;
+        sr->u.scan_request->query_type = Z_SRW_query_type_cql;
+        sr->u.scan_request->scanClause.cql = 0;
         break;
     case Z_SRW_scan_response:
         sr->u.scan_response = (Z_SRW_scanResponse *)
             odr_malloc(o, sizeof(*sr->u.scan_response));
-       sr->u.scan_response->terms = 0;
-       sr->u.scan_response->num_terms = 0;
-       sr->u.scan_response->diagnostics = 0;
-       sr->u.scan_response->num_diagnostics = 0;
+        sr->u.scan_response->terms = 0;
+        sr->u.scan_response->num_terms = 0;
+        sr->u.scan_response->diagnostics = 0;
+        sr->u.scan_response->num_diagnostics = 0;
     }
     return sr;
 }
@@ -781,3 +781,11 @@ int yaz_diag_srw_to_bib1(int code)
     return 1;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b92aac4..968141c 100644 (file)
@@ -5,7 +5,7 @@
  * NT threaded server code by
  *   Chas Woodfield, Fretwell Downing Informatics.
  *
- * $Id: statserv.c,v 1.30 2005-05-08 07:13:57 adam Exp $
+ * $Id: statserv.c,v 1.31 2005-06-25 15:46:05 adam Exp $
  */
 
 /**
@@ -153,15 +153,15 @@ static xmlNodePtr xml_config_get_root()
     xmlNodePtr ptr = 0;
     if (xml_config_doc)
     {
-       ptr = xmlDocGetRootElement(xml_config_doc);
-       if (!ptr || ptr->type != XML_ELEMENT_NODE ||
-           strcmp((const char *) ptr->name, "yazgfs"))
-       {
-           yaz_log(YLOG_WARN, "Bad/missing root element for config %s",
-                   control_block.xml_config);
-           return 0;
-       
-       }
+        ptr = xmlDocGetRootElement(xml_config_doc);
+        if (!ptr || ptr->type != XML_ELEMENT_NODE ||
+            strcmp((const char *) ptr->name, "yazgfs"))
+        {
+            yaz_log(YLOG_WARN, "Bad/missing root element for config %s",
+                    control_block.xml_config);
+            return 0;
+        
+        }
     }
     return ptr;
 }
@@ -178,31 +178,31 @@ static char *nmem_dup_xml_content(NMEM n, xmlNodePtr ptr)
     /* determine length */
     for (p = ptr; p; p = p->next)
     {
-       if (p->type == XML_TEXT_NODE)
-           len += strlen(p->content);
+        if (p->type == XML_TEXT_NODE)
+            len += strlen(p->content);
     }
     /* now allocate for the string */
     str = nmem_malloc(n, len);
     *str = '\0'; /* so we can use strcat */
     for (p = ptr; p; p = p->next)
     {
-       if (p->type == XML_TEXT_NODE)
-       {
-           cp = p->content;
-           if (first)
-           {
-               while(*cp && isspace(*cp))
-                   cp++;
-               if (*cp)
-                   first = 0;  /* reset if we got non-whitespace out */
-           }
-           strcat(str, cp); /* append */
-       }
+        if (p->type == XML_TEXT_NODE)
+        {
+            cp = p->content;
+            if (first)
+            {
+                while(*cp && isspace(*cp))
+                    cp++;
+                if (*cp)
+                    first = 0;  /* reset if we got non-whitespace out */
+            }
+            strcat(str, cp); /* append */
+        }
     }
     /* remove trailing whitespace */
     cp = strlen(str) + str;
     while ((char*) cp != str && isspace(cp[-1]))
-       cp--;
+        cp--;
     *cp = '\0';
     /* return resulting string */
     return str;
@@ -223,13 +223,13 @@ static struct gfs_server * gfs_server_new()
 }
 
 static struct gfs_listen * gfs_listen_new(const char *id, 
-                                         const char *address)
+                                          const char *address)
 {
     struct gfs_listen *n = nmem_malloc(gfs_nmem, sizeof(*n));
     if (id)
-       n->id = nmem_strdup(gfs_nmem, id);
+        n->id = nmem_strdup(gfs_nmem, id);
     else
-       n->id = 0;
+        n->id = 0;
     n->next = 0;
     n->address = nmem_strdup(gfs_nmem, address);
     return n;
@@ -239,14 +239,14 @@ static void gfs_server_chdir(struct gfs_server *gfs)
 {
     if (gfs_root_dir[0])
     {
-       if (chdir(gfs_root_dir))
-           yaz_log(YLOG_WARN|YLOG_ERRNO, "chdir %s", gfs_root_dir);
+        if (chdir(gfs_root_dir))
+            yaz_log(YLOG_WARN|YLOG_ERRNO, "chdir %s", gfs_root_dir);
     }
     if (gfs->directory)
     {
-       if (chdir(gfs->directory))
-           yaz_log(YLOG_WARN|YLOG_ERRNO, "chdir %s",
-                   gfs->directory);
+        if (chdir(gfs->directory))
+            yaz_log(YLOG_WARN|YLOG_ERRNO, "chdir %s",
+                    gfs->directory);
     }
 }
 
@@ -255,64 +255,64 @@ int control_association(association *assoc, const char *host, int force_open)
     char vhost[128], *cp;
     if (host)
     {
-       strncpy(vhost, host, 127);
-       vhost[127] = '\0';
-       cp = strchr(vhost, ':');
-       if (cp)
-           *cp = '\0';
-       host = vhost;
+        strncpy(vhost, host, 127);
+        vhost[127] = '\0';
+        cp = strchr(vhost, ':');
+        if (cp)
+            *cp = '\0';
+        host = vhost;
     }
     if (control_block.xml_config[0])
     {
-       struct gfs_server *gfs;
-       for (gfs = gfs_server_list; gfs; gfs = gfs->next)
-       {
-           int listen_match = 0;
-           int host_match = 0;
-           if ( !gfs->host || (host && gfs->host && !strcmp(host, gfs->host)))
-               host_match = 1;
-           if (!gfs->listen_ref ||
-               gfs->listen_ref == assoc->client_chan->chan_id)
-               listen_match = 1;
-           if (listen_match && host_match)
-           {
-               if (force_open ||
-                   (assoc->last_control != &gfs->cb && assoc->backend))
-               {
-                   statserv_setcontrol(assoc->last_control);
-                   if (assoc->backend && assoc->init)
-                   {
-                       gfs_server_chdir(gfs);
-                       (assoc->last_control->bend_close)(assoc->backend);
-                   }
-                   assoc->backend = 0;
-                   xfree(assoc->init);
-                   assoc->init = 0;
-               }
-               assoc->cql_transform = gfs->cql_transform;
-               assoc->server_node_ptr = gfs->server_node_ptr;
-               assoc->last_control = &gfs->cb;
-               statserv_setcontrol(&gfs->cb);
-               gfs_server_chdir(gfs);
-               yaz_log(YLOG_DEBUG, "server select: %s", gfs->cb.configname);
-               return 1;
-           }
-       }
-       statserv_setcontrol(0);
-       assoc->last_control = 0;
-       assoc->cql_transform = 0;
-       assoc->server_node_ptr = 0;
-       yaz_log(YLOG_DEBUG, "server select: no match");
-       return 0;
+        struct gfs_server *gfs;
+        for (gfs = gfs_server_list; gfs; gfs = gfs->next)
+        {
+            int listen_match = 0;
+            int host_match = 0;
+            if ( !gfs->host || (host && gfs->host && !strcmp(host, gfs->host)))
+                host_match = 1;
+            if (!gfs->listen_ref ||
+                gfs->listen_ref == assoc->client_chan->chan_id)
+                listen_match = 1;
+            if (listen_match && host_match)
+            {
+                if (force_open ||
+                    (assoc->last_control != &gfs->cb && assoc->backend))
+                {
+                    statserv_setcontrol(assoc->last_control);
+                    if (assoc->backend && assoc->init)
+                    {
+                        gfs_server_chdir(gfs);
+                        (assoc->last_control->bend_close)(assoc->backend);
+                    }
+                    assoc->backend = 0;
+                    xfree(assoc->init);
+                    assoc->init = 0;
+                }
+                assoc->cql_transform = gfs->cql_transform;
+                assoc->server_node_ptr = gfs->server_node_ptr;
+                assoc->last_control = &gfs->cb;
+                statserv_setcontrol(&gfs->cb);
+                gfs_server_chdir(gfs);
+                yaz_log(YLOG_DEBUG, "server select: %s", gfs->cb.configname);
+                return 1;
+            }
+        }
+        statserv_setcontrol(0);
+        assoc->last_control = 0;
+        assoc->cql_transform = 0;
+        assoc->server_node_ptr = 0;
+        yaz_log(YLOG_DEBUG, "server select: no match");
+        return 0;
     }
     else
     {
-       statserv_setcontrol(&control_block);
-       assoc->last_control = &control_block;
-       assoc->cql_transform = 0;
-       assoc->server_node_ptr = 0;
-       yaz_log(YLOG_DEBUG, "server select: config=%s", control_block.configname);
-       return 1;
+        statserv_setcontrol(&control_block);
+        assoc->last_control = &control_block;
+        assoc->cql_transform = 0;
+        assoc->server_node_ptr = 0;
+        yaz_log(YLOG_DEBUG, "server select: config=%s", control_block.configname);
+        return 1;
     }
 }
 
@@ -324,93 +324,93 @@ static void xml_config_read()
     xmlNodePtr ptr = xml_config_get_root();
 
     if (!ptr)
-       return;
+        return;
     for (ptr = ptr->children; ptr; ptr = ptr->next)
     {
-       struct _xmlAttr *attr;
-       if (ptr->type != XML_ELEMENT_NODE)
-           continue;
-       attr = ptr->properties;
-       if (!strcmp((const char *) ptr->name, "listen"))
-       {
-           /*
-             <listen id="listenerid">tcp:@:9999</listen>
-           */
-           const char *id = 0;
-           const char *address =
-               nmem_dup_xml_content(gfs_nmem, ptr->children);
-           for ( ; attr; attr = attr->next)
-               if (!strcmp(attr->name, "id")
-                   && attr->children && attr->children->type == XML_TEXT_NODE)
-                   id = nmem_dup_xml_content(gfs_nmem, attr->children);
-           if (address)
-           {
-               *gfslp = gfs_listen_new(id, address);
-               gfslp = &(*gfslp)->next;
-               *gfslp = 0; /* make listener list consistent for search */
-           }
-       }
-       else if (!strcmp((const char *) ptr->name, "server"))
-       {
-           xmlNodePtr ptr_server = ptr;
-           xmlNodePtr ptr;
-           const char *listenref = 0;
-           const char *id = 0;
-
-           for ( ; attr; attr = attr->next)
-               if (!strcmp(attr->name, "listenref") && attr->children &&
-                   attr->children->type == XML_TEXT_NODE)
-                   listenref = nmem_dup_xml_content(gfs_nmem, attr->children);
-               else if (!strcmp(attr->name, "id") && attr->children &&
-                        attr->children->type == XML_TEXT_NODE)
-                   id = nmem_dup_xml_content(gfs_nmem, attr->children);
-               else
-                   yaz_log(YLOG_WARN, "Unknown attribute '%s' for server",
-                           attr->name);
-           *gfsp = gfs_server_new();
-           (*gfsp)->server_node_ptr = ptr_server;
-           if (listenref)
-           {
-               int id_no;
-               struct gfs_listen *gl = gfs_listen_list;
-               for (id_no = 1; gl; gl = gl->next, id_no++)
-                   if (gl->id && !strcmp(gl->id, listenref))
-                   {
-                       (*gfsp)->listen_ref = id_no;
-                       break;
-                   }
-               if (!gl)
-                   yaz_log(YLOG_WARN, "Non-existent listenref '%s' in server "
-                           "config element", listenref);
-           }
-           for (ptr = ptr_server->children; ptr; ptr = ptr->next)
-           {
-               if (ptr->type != XML_ELEMENT_NODE)
-                   continue;
-               if (!strcmp((const char *) ptr->name, "host"))
-               {
-                   (*gfsp)->host = nmem_dup_xml_content(gfs_nmem,
-                                                        ptr->children);
-               }
-               else if (!strcmp((const char *) ptr->name, "config"))
-               {
-                   strcpy((*gfsp)->cb.configname,
-                          nmem_dup_xml_content(gfs_nmem, ptr->children));
-               }
-               else if (!strcmp((const char *) ptr->name, "cql2rpn"))
-               {
-                   (*gfsp)->cql_transform = cql_transform_open_fname(
-                       nmem_dup_xml_content(gfs_nmem, ptr->children)
-                       );
-               }
-               else if (!strcmp((const char *) ptr->name, "directory"))
-               {
-                   (*gfsp)->directory = 
-                       nmem_dup_xml_content(gfs_nmem, ptr->children);
-               }
-           }
-           gfsp = &(*gfsp)->next;
-       }
+        struct _xmlAttr *attr;
+        if (ptr->type != XML_ELEMENT_NODE)
+            continue;
+        attr = ptr->properties;
+        if (!strcmp((const char *) ptr->name, "listen"))
+        {
+            /*
+              <listen id="listenerid">tcp:@:9999</listen>
+            */
+            const char *id = 0;
+            const char *address =
+                nmem_dup_xml_content(gfs_nmem, ptr->children);
+            for ( ; attr; attr = attr->next)
+                if (!strcmp(attr->name, "id")
+                    && attr->children && attr->children->type == XML_TEXT_NODE)
+                    id = nmem_dup_xml_content(gfs_nmem, attr->children);
+            if (address)
+            {
+                *gfslp = gfs_listen_new(id, address);
+                gfslp = &(*gfslp)->next;
+                *gfslp = 0; /* make listener list consistent for search */
+            }
+        }
+        else if (!strcmp((const char *) ptr->name, "server"))
+        {
+            xmlNodePtr ptr_server = ptr;
+            xmlNodePtr ptr;
+            const char *listenref = 0;
+            const char *id = 0;
+
+            for ( ; attr; attr = attr->next)
+                if (!strcmp(attr->name, "listenref") && attr->children &&
+                    attr->children->type == XML_TEXT_NODE)
+                    listenref = nmem_dup_xml_content(gfs_nmem, attr->children);
+                else if (!strcmp(attr->name, "id") && attr->children &&
+                         attr->children->type == XML_TEXT_NODE)
+                    id = nmem_dup_xml_content(gfs_nmem, attr->children);
+                else
+                    yaz_log(YLOG_WARN, "Unknown attribute '%s' for server",
+                            attr->name);
+            *gfsp = gfs_server_new();
+            (*gfsp)->server_node_ptr = ptr_server;
+            if (listenref)
+            {
+                int id_no;
+                struct gfs_listen *gl = gfs_listen_list;
+                for (id_no = 1; gl; gl = gl->next, id_no++)
+                    if (gl->id && !strcmp(gl->id, listenref))
+                    {
+                        (*gfsp)->listen_ref = id_no;
+                        break;
+                    }
+                if (!gl)
+                    yaz_log(YLOG_WARN, "Non-existent listenref '%s' in server "
+                            "config element", listenref);
+            }
+            for (ptr = ptr_server->children; ptr; ptr = ptr->next)
+            {
+                if (ptr->type != XML_ELEMENT_NODE)
+                    continue;
+                if (!strcmp((const char *) ptr->name, "host"))
+                {
+                    (*gfsp)->host = nmem_dup_xml_content(gfs_nmem,
+                                                         ptr->children);
+                }
+                else if (!strcmp((const char *) ptr->name, "config"))
+                {
+                    strcpy((*gfsp)->cb.configname,
+                           nmem_dup_xml_content(gfs_nmem, ptr->children));
+                }
+                else if (!strcmp((const char *) ptr->name, "cql2rpn"))
+                {
+                    (*gfsp)->cql_transform = cql_transform_open_fname(
+                        nmem_dup_xml_content(gfs_nmem, ptr->children)
+                        );
+                }
+                else if (!strcmp((const char *) ptr->name, "directory"))
+                {
+                    (*gfsp)->directory = 
+                        nmem_dup_xml_content(gfs_nmem, ptr->children);
+                }
+            }
+            gfsp = &(*gfsp)->next;
+        }
     }
 #endif
     *gfsp = 0;
@@ -420,8 +420,8 @@ static void xml_config_open()
 {
     if (!getcwd(gfs_root_dir, FILENAME_MAX))
     {
-       yaz_log(YLOG_WARN|YLOG_ERRNO, "getcwd failed");
-       gfs_root_dir[0] = '\0';
+        yaz_log(YLOG_WARN|YLOG_ERRNO, "getcwd failed");
+        gfs_root_dir[0] = '\0';
     }
 #ifdef WIN32
     init_control_tls = 1;
@@ -434,26 +434,26 @@ static void xml_config_open()
     gfs_nmem = nmem_create();
 #if HAVE_XML2
     if (control_block.xml_config[0] == '\0')
-       return;
+        return;
 
     if (!xml_config_doc)
     {
-       xml_config_doc = xmlParseFile(control_block.xml_config);
-       if (!xml_config_doc)
-       {
-           yaz_log(YLOG_FATAL, "Could not parse %s", control_block.xml_config);
-           exit(1);
-       }
-       else
-       {
-           int noSubstitutions = xmlXIncludeProcess(xml_config_doc);
-           if (noSubstitutions == -1)
-           {
-               yaz_log(YLOG_WARN, "XInclude processing failed for config %s",
-                       control_block.xml_config);
-               exit(1);
-           }
-       }
+        xml_config_doc = xmlParseFile(control_block.xml_config);
+        if (!xml_config_doc)
+        {
+            yaz_log(YLOG_FATAL, "Could not parse %s", control_block.xml_config);
+            exit(1);
+        }
+        else
+        {
+            int noSubstitutions = xmlXIncludeProcess(xml_config_doc);
+            if (noSubstitutions == -1)
+            {
+                yaz_log(YLOG_WARN, "XInclude processing failed for config %s",
+                        control_block.xml_config);
+                exit(1);
+            }
+        }
     }
     xml_config_read();
 #endif
@@ -464,15 +464,15 @@ static void xml_config_close()
 #if HAVE_XML2
     if (xml_config_doc)
     {
-       xmlFreeDoc(xml_config_doc);
-       xml_config_doc = 0;
+        xmlFreeDoc(xml_config_doc);
+        xml_config_doc = 0;
     }
 #endif
     gfs_server_list = 0;
     nmem_destroy(gfs_nmem);
 #ifdef WIN32
     if (init_control_tls)
-       TlsFree(current_control_tls);
+        TlsFree(current_control_tls);
 #elif YAZ_POSIX_THREADS
     if (init_control_tls)
         pthread_key_delete(current_control_tls);
@@ -486,8 +486,8 @@ static void xml_config_add_listeners()
 
     for (id_no = 1; gfs; gfs = gfs->next, id_no++)
     {
-       if (gfs->address)
-           add_listener(gfs->address, id_no);
+        if (gfs->address)
+            add_listener(gfs->address, id_no);
     }
 }
 
@@ -495,25 +495,25 @@ static void xml_config_bend_start()
 {
     if (control_block.xml_config[0])
     {
-       struct gfs_server *gfs = gfs_server_list;
-       for (; gfs; gfs = gfs->next)
-       {
-           yaz_log(YLOG_DEBUG, "xml_config_bend_start config=%s",
-                   gfs->cb.configname);
-           statserv_setcontrol(&gfs->cb);
-           if (control_block.bend_start)
-           {
-               gfs_server_chdir(gfs);
-               (control_block.bend_start)(&gfs->cb);
-           }
-       }
+        struct gfs_server *gfs = gfs_server_list;
+        for (; gfs; gfs = gfs->next)
+        {
+            yaz_log(YLOG_DEBUG, "xml_config_bend_start config=%s",
+                    gfs->cb.configname);
+            statserv_setcontrol(&gfs->cb);
+            if (control_block.bend_start)
+            {
+                gfs_server_chdir(gfs);
+                (control_block.bend_start)(&gfs->cb);
+            }
+        }
     }
     else
     {
-       yaz_log(YLOG_DEBUG, "xml_config_bend_start default config");
-       statserv_setcontrol(&control_block);
-       if (control_block.bend_start)
-           (*control_block.bend_start)(&control_block);
+        yaz_log(YLOG_DEBUG, "xml_config_bend_start default config");
+        statserv_setcontrol(&control_block);
+        if (control_block.bend_start)
+            (*control_block.bend_start)(&control_block);
     }
 }
 
@@ -521,22 +521,22 @@ static void xml_config_bend_stop()
 {
     if (control_block.xml_config[0])
     {
-       struct gfs_server *gfs = gfs_server_list;
-       for (; gfs; gfs = gfs->next)
-       {
-           yaz_log(YLOG_DEBUG, "xml_config_bend_stop config=%s",
-                   gfs->cb.configname);
-           statserv_setcontrol(&gfs->cb);
-           if (control_block.bend_stop)
-               (control_block.bend_stop)(&gfs->cb);
-       }
+        struct gfs_server *gfs = gfs_server_list;
+        for (; gfs; gfs = gfs->next)
+        {
+            yaz_log(YLOG_DEBUG, "xml_config_bend_stop config=%s",
+                    gfs->cb.configname);
+            statserv_setcontrol(&gfs->cb);
+            if (control_block.bend_stop)
+                (control_block.bend_stop)(&gfs->cb);
+        }
     }
     else
     {
-       yaz_log(YLOG_DEBUG, "xml_config_bend_stop default config");
-       statserv_setcontrol(&control_block);
-       if (control_block.bend_stop)
-           (*control_block.bend_stop)(&control_block);
+        yaz_log(YLOG_DEBUG, "xml_config_bend_stop default config");
+        statserv_setcontrol(&control_block);
+        if (control_block.bend_stop)
+            (*control_block.bend_stop)(&control_block);
     }
 }
 
@@ -643,7 +643,7 @@ void statserv_closedown()
         HANDLE *pThreadHandles = NULL;
 
         /* We need to stop threads adding and removing while we */
-       /* start the closedown process */
+        /* start the closedown process */
         EnterCriticalSection(&Thread_CritSect);
 
         {
@@ -697,7 +697,7 @@ void statserv_closedown()
             free(pThreadHandles);
         }
 
-       xml_config_bend_stop();
+        xml_config_bend_stop();
         /* No longer require the critical section, since all threads are dead */
         DeleteCriticalSection(&Thread_CritSect);
     }
@@ -722,8 +722,8 @@ static void listener(IOCHAN h, int event)
     {
         if ((res = cs_listen(line, 0, 0)) < 0)
         {
-           yaz_log(YLOG_FATAL, "cs_listen failed");
-           return;
+            yaz_log(YLOG_FATAL, "cs_listen failed");
+            return;
         }
         else if (res == 1)
             return;
@@ -733,52 +733,52 @@ static void listener(IOCHAN h, int event)
     }
     else if (event == EVENT_OUTPUT)
     {
-       COMSTACK new_line = cs_accept(line);
-       IOCHAN new_chan;
-       char *a = NULL;
-
-       if (!new_line)
-       {
-           yaz_log(YLOG_FATAL, "Accept failed.");
-           iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT);
-           return;
-       }
-       yaz_log(YLOG_DEBUG, "Accept ok");
-
-       if (!(new_chan = iochan_create(cs_fileno(new_line), ir_session,
-                                      EVENT_INPUT, parent_chan->chan_id)))
-       {
-           yaz_log(YLOG_FATAL, "Failed to create iochan");
+        COMSTACK new_line = cs_accept(line);
+        IOCHAN new_chan;
+        char *a = NULL;
+
+        if (!new_line)
+        {
+            yaz_log(YLOG_FATAL, "Accept failed.");
+            iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT);
+            return;
+        }
+        yaz_log(YLOG_DEBUG, "Accept ok");
+
+        if (!(new_chan = iochan_create(cs_fileno(new_line), ir_session,
+                                       EVENT_INPUT, parent_chan->chan_id)))
+        {
+            yaz_log(YLOG_FATAL, "Failed to create iochan");
             iochan_destroy(h);
             return;
-       }
+        }
 
-       yaz_log(YLOG_DEBUG, "Creating association");
-       if (!(newas = create_association(new_chan, new_line,
-                                        control_block.apdufile)))
-       {
-           yaz_log(YLOG_FATAL, "Failed to create new assoc.");
+        yaz_log(YLOG_DEBUG, "Creating association");
+        if (!(newas = create_association(new_chan, new_line,
+                                         control_block.apdufile)))
+        {
+            yaz_log(YLOG_FATAL, "Failed to create new assoc.");
             iochan_destroy(h);
             return;
-       }
-       newas->cs_get_mask = EVENT_INPUT;
-       newas->cs_put_mask = 0;
-       newas->cs_accept_mask = 0;
+        }
+        newas->cs_get_mask = EVENT_INPUT;
+        newas->cs_put_mask = 0;
+        newas->cs_accept_mask = 0;
 
-       yaz_log(YLOG_DEBUG, "Setting timeout %d", control_block.idle_timeout);
-       iochan_setdata(new_chan, newas);
-       iochan_settimeout(new_chan, 60);
+        yaz_log(YLOG_DEBUG, "Setting timeout %d", control_block.idle_timeout);
+        iochan_setdata(new_chan, newas);
+        iochan_settimeout(new_chan, 60);
 
-       /* Now what we need todo is create a new thread with this iochan as
-          the parameter */
+        /* Now what we need todo is create a new thread with this iochan as
+           the parameter */
         newHandle = (HANDLE) _beginthread(event_loop_thread, 0, new_chan);
         if (newHandle == (HANDLE) -1)
-       {
-           
-           yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create new thread.");
+        {
+            
+            yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create new thread.");
             iochan_destroy(h);
             return;
-       }
+        }
         /* We successfully created the thread, so add it to the list */
         statserv_add(newHandle, new_chan);
 
@@ -787,7 +787,7 @@ static void listener(IOCHAN h, int event)
     }
     else
     {
-       yaz_log(YLOG_FATAL, "Bad event on listener.");
+        yaz_log(YLOG_FATAL, "Bad event on listener.");
         iochan_destroy(h);
         return;
     }
@@ -841,94 +841,94 @@ static void listener(IOCHAN h, int event)
 
     if (event == EVENT_INPUT)
     {
-       COMSTACK new_line;
-       if ((res = cs_listen_check(line, 0, 0, control_block.check_ip,
-                                  control_block.daemon_name)) < 0)
-       {
-           yaz_log(YLOG_WARN|YLOG_ERRNO, "cs_listen failed");
-           return;
-       }
-       else if (res == 1)
-       {
-           yaz_log(YLOG_WARN, "cs_listen incomplete");
-           return;
-       }
-       new_line = cs_accept(line);
-       if (!new_line)
-       {
-           yaz_log(YLOG_FATAL, "Accept failed.");
-           iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
-           return;
-       }
-
-       yaz_log(log_session, "Connect from %s", cs_addrstr(new_line));
-
-       no_sessions++;
-       if (control_block.dynamic)
-       {
-           if ((res = fork()) < 0)
-           {
-               yaz_log(YLOG_FATAL|YLOG_ERRNO, "fork");
+        COMSTACK new_line;
+        if ((res = cs_listen_check(line, 0, 0, control_block.check_ip,
+                                   control_block.daemon_name)) < 0)
+        {
+            yaz_log(YLOG_WARN|YLOG_ERRNO, "cs_listen failed");
+            return;
+        }
+        else if (res == 1)
+        {
+            yaz_log(YLOG_WARN, "cs_listen incomplete");
+            return;
+        }
+        new_line = cs_accept(line);
+        if (!new_line)
+        {
+            yaz_log(YLOG_FATAL, "Accept failed.");
+            iochan_setflags(h, EVENT_INPUT | EVENT_EXCEPT); /* reset listener */
+            return;
+        }
+
+        yaz_log(log_session, "Connect from %s", cs_addrstr(new_line));
+
+        no_sessions++;
+        if (control_block.dynamic)
+        {
+            if ((res = fork()) < 0)
+            {
+                yaz_log(YLOG_FATAL|YLOG_ERRNO, "fork");
                 iochan_destroy(h);
                 return;
-           }
-           else if (res == 0) /* child */
-           {
-               char nbuf[100];
-               IOCHAN pp;
-
-               for (pp = pListener; pp; pp = iochan_getnext(pp))
-               {
-                   COMSTACK l = (COMSTACK)iochan_getdata(pp);
-                   cs_close(l);
-                   iochan_destroy(pp);
-               }
-               sprintf(nbuf, "%s(%d)", me, no_sessions);
-               yaz_log_init(control_block.loglevel, nbuf, 0);
+            }
+            else if (res == 0) /* child */
+            {
+                char nbuf[100];
+                IOCHAN pp;
+
+                for (pp = pListener; pp; pp = iochan_getnext(pp))
+                {
+                    COMSTACK l = (COMSTACK)iochan_getdata(pp);
+                    cs_close(l);
+                    iochan_destroy(pp);
+                }
+                sprintf(nbuf, "%s(%d)", me, no_sessions);
+                yaz_log_init(control_block.loglevel, nbuf, 0);
                 /* ensure that bend_stop is not called when each child exits -
                    only for the main process ..  */
                 control_block.bend_stop = 0;
-           }
-           else /* parent */
-           {
-               cs_close(new_line);
-               return;
-           }
-       }
-
-       if (control_block.threads)
-       {
+            }
+            else /* parent */
+            {
+                cs_close(new_line);
+                return;
+            }
+        }
+
+        if (control_block.threads)
+        {
 #if YAZ_POSIX_THREADS
-           pthread_t child_thread;
-           pthread_create (&child_thread, 0, new_session, new_line);
-           pthread_detach (child_thread);
+            pthread_t child_thread;
+            pthread_create (&child_thread, 0, new_session, new_line);
+            pthread_detach (child_thread);
 #elif YAZ_GNU_THREADS
-           pth_attr_t attr;
-           pth_t child_thread;
+            pth_attr_t attr;
+            pth_t child_thread;
 
             attr = pth_attr_new ();
             pth_attr_set (attr, PTH_ATTR_JOINABLE, FALSE);
             pth_attr_set (attr, PTH_ATTR_STACK_SIZE, 32*1024);
             pth_attr_set (attr, PTH_ATTR_NAME, "session");
             yaz_log (YLOG_DEBUG, "pth_spawn begin");
-           child_thread = pth_spawn (attr, new_session, new_line);
+            child_thread = pth_spawn (attr, new_session, new_line);
             yaz_log (YLOG_DEBUG, "pth_spawn finish");
             pth_attr_destroy (attr);
 #else
-           new_session(new_line);
+            new_session(new_line);
 #endif
-       }
-       else
-           new_session(new_line);
+        }
+        else
+            new_session(new_line);
     }
     else if (event == EVENT_TIMEOUT)
     {
-       yaz_log(log_server, "Shutting down listener.");
+        yaz_log(log_server, "Shutting down listener.");
         iochan_destroy(h);
     }
     else
     {
-       yaz_log(YLOG_FATAL, "Bad event on listener.");
+        yaz_log(YLOG_FATAL, "Bad event on listener.");
         iochan_destroy(h);
     }
 }
@@ -942,31 +942,31 @@ static void *new_session (void *vp)
     IOCHAN parent_chan = new_line->user;
 
     unsigned cs_get_mask, cs_accept_mask, mask =  
-       ((new_line->io_pending & CS_WANT_WRITE) ? EVENT_OUTPUT : 0) |
-       ((new_line->io_pending & CS_WANT_READ) ? EVENT_INPUT : 0);
+        ((new_line->io_pending & CS_WANT_WRITE) ? EVENT_OUTPUT : 0) |
+        ((new_line->io_pending & CS_WANT_READ) ? EVENT_INPUT : 0);
 
     if (mask)
     {
-       cs_accept_mask = mask;  /* accept didn't complete */
-       cs_get_mask = 0;
+        cs_accept_mask = mask;  /* accept didn't complete */
+        cs_get_mask = 0;
     }
     else
     {
-       cs_accept_mask = 0;     /* accept completed.  */
-       cs_get_mask = mask = EVENT_INPUT;
+        cs_accept_mask = 0;     /* accept completed.  */
+        cs_get_mask = mask = EVENT_INPUT;
     }
 
     if (!(new_chan = iochan_create(cs_fileno(new_line), ir_session, mask,
-                                  parent_chan->chan_id)))
+                                   parent_chan->chan_id)))
     {
-       yaz_log(YLOG_FATAL, "Failed to create iochan");
-       return 0;
+        yaz_log(YLOG_FATAL, "Failed to create iochan");
+        return 0;
     }
     if (!(newas = create_association(new_chan, new_line,
-                                    control_block.apdufile)))
+                                     control_block.apdufile)))
     {
-       yaz_log(YLOG_FATAL, "Failed to create new assoc.");
-       return 0;
+        yaz_log(YLOG_FATAL, "Failed to create new assoc.");
+        return 0;
     }
     newas->cs_accept_mask = cs_accept_mask;
     newas->cs_get_mask = cs_get_mask;
@@ -979,17 +979,17 @@ static void *new_session (void *vp)
     a = 0;
 #endif
     yaz_log(log_session, "Starting session %d from %s (pid=%ld)",
-           no_sessions, a ? a : "[Unknown]", (long) getpid());
+            no_sessions, a ? a : "[Unknown]", (long) getpid());
     if (max_sessions && no_sessions >= max_sessions)
         control_block.one_shot = 1;
     if (control_block.threads)
     {
-       event_loop(&new_chan);
+        event_loop(&new_chan);
     }
     else
     {
-       new_chan->next = pListener;
-       pListener = new_chan;
+        new_chan->next = pListener;
+        pListener = new_chan;
     }
     return 0;
 }
@@ -1007,21 +1007,21 @@ static void inetd_connection(int what)
     if ((line = cs_createbysocket(0, tcpip_type, 0, what)))
     {
         if ((chan = iochan_create(cs_fileno(line), ir_session, EVENT_INPUT,
-                                 0)))
+                                  0)))
         {
             if ((assoc = create_association(chan, line,
-                                           control_block.apdufile)))
+                                            control_block.apdufile)))
             {
                 iochan_setdata(chan, assoc);
                 iochan_settimeout(chan, 60);
                 addr = cs_addrstr(line);
                 yaz_log(log_session, "Inetd association from %s",
                         addr ? addr : "[UNKNOWN]");
-               assoc->cs_get_mask = EVENT_INPUT;
+                assoc->cs_get_mask = EVENT_INPUT;
             }
             else
             {
-               yaz_log(YLOG_FATAL, "Failed to create association structure");
+                yaz_log(YLOG_FATAL, "Failed to create association structure");
             }
             chan->next = pListener;
             pListener = chan;
@@ -1033,7 +1033,7 @@ static void inetd_connection(int what)
     }
     else
     {
-       yaz_log(YLOG_ERRNO|YLOG_FATAL, "Failed to create comstack on socket 0");
+        yaz_log(YLOG_ERRNO|YLOG_FATAL, "Failed to create comstack on socket 0");
     }
 }
 
@@ -1048,36 +1048,36 @@ static int add_listener(char *where, int listen_id)
     const char *mode;
 
     if (control_block.dynamic)
-       mode = "dynamic";
+        mode = "dynamic";
     else if (control_block.threads)
-       mode = "threaded";
+        mode = "threaded";
     else
-       mode = "static";
+        mode = "static";
 
     yaz_log(log_server, "Adding %s listener on %s id=%d", mode, where,
-           listen_id);
+            listen_id);
 
     l = cs_create_host(where, 2, &ap);
     if (!l)
     {
-       yaz_log(YLOG_FATAL, "Failed to listen on %s", where);
-       return -1;
+        yaz_log(YLOG_FATAL, "Failed to listen on %s", where);
+        return -1;
     }
     if (*control_block.cert_fname)
-       cs_set_ssl_certificate_file(l, control_block.cert_fname);
+        cs_set_ssl_certificate_file(l, control_block.cert_fname);
 
     if (cs_bind(l, ap, CS_SERVER) < 0)
     {
-       yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to bind to %s", where);
-       cs_close (l);
-       return -1;
+        yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to bind to %s", where);
+        cs_close (l);
+        return -1;
     }
     if (!(lst = iochan_create(cs_fileno(l), listener, EVENT_INPUT |
-        EVENT_EXCEPT, listen_id)))
+         EVENT_EXCEPT, listen_id)))
     {
-       yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create IOCHAN-type");
-       cs_close (l);
-       return -1;
+        yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create IOCHAN-type");
+        cs_close (l);
+        return -1;
     }
     iochan_setdata(lst, l); /* user-defined data for listener is COMSTACK */
     l->user = lst;  /* user-defined data for COMSTACK is listener chan */
@@ -1093,7 +1093,7 @@ static int add_listener(char *where, int listen_id)
 static void catchchld(int num)
 {
     while (waitpid(-1, 0, WNOHANG) > 0)
-       ;
+        ;
     signal(SIGCHLD, catchchld);
 }
 #endif
@@ -1102,14 +1102,14 @@ statserv_options_block *statserv_getcontrol(void)
 {
 #ifdef WIN32
     if (init_control_tls)
-       return (statserv_options_block *) TlsGetValue(current_control_tls);
+        return (statserv_options_block *) TlsGetValue(current_control_tls);
     else
-       return &control_block;
+        return &control_block;
 #elif YAZ_POSIX_THREADS
     if (init_control_tls)
-       return pthread_getspecific(current_control_tls);
+        return pthread_getspecific(current_control_tls);
     else
-       return &control_block;
+        return &control_block;
 #else
     if (current_control_block)
         return current_control_block;
@@ -1122,10 +1122,10 @@ void statserv_setcontrol(statserv_options_block *block)
     chdir(gfs_root_dir);
 #ifdef WIN32
     if (init_control_tls)
-       TlsSetValue(current_control_tls, block);
+        TlsSetValue(current_control_tls, block);
 #elif YAZ_POSIX_THREADS
     if (init_control_tls)
-       pthread_setspecific(current_control_tls, block);
+        pthread_setspecific(current_control_tls, block);
 #else
     current_control_block = block;
 #endif
@@ -1151,9 +1151,9 @@ int statserv_start(int argc, char **argv)
     sep = '/';
 #endif
     if ((me = strrchr (argv[0], sep)))
-       me++; /* get the basename */
+        me++; /* get the basename */
     else
-       me = argv[0];
+        me = argv[0];
     programname = argv[0];
 
     if (control_block.options_func(argc, argv))
@@ -1168,116 +1168,116 @@ int statserv_start(int argc, char **argv)
 
     yaz_log (log_server, "Starting server %s", me);
     if (!pListener && *control_block.default_listen)
-       add_listener(control_block.default_listen, 0);
+        add_listener(control_block.default_listen, 0);
 #else
 /* UNIX */
     if (control_block.inetd)
-       inetd_connection(control_block.default_proto);
+        inetd_connection(control_block.default_proto);
     else
     {
-       static int hand[2];
-       if (control_block.background)
-       {
-           /* create pipe so that parent waits until child has created
-              PID (or failed) */
-           if (pipe(hand) < 0)
-           {
-               yaz_log(YLOG_FATAL|YLOG_ERRNO, "pipe");
-               return 1;
-           }
-           switch (fork())
-           {
-           case 0: 
-               break;
-           case -1:
-               return 1;
-           default:
-               close(hand[1]);
-               while(1)
-               {
-                   char dummy[1];
-                   int res = read(hand[0], dummy, 1);
-                   if (res < 0 && yaz_errno() != EINTR)
-                   {
-                       yaz_log(YLOG_FATAL|YLOG_ERRNO, "read fork handshake");
-                       break;
-                   }
-                   else if (res >= 0)
-                       break;
-               }
-               close(hand[0]);
-               _exit(0);
-           }
-           /* child */
-           close(hand[0]);
-           if (setsid() < 0)
-               return 1;
-           
-           close(0);
-           close(1);
-           close(2);
-           open("/dev/null", O_RDWR);
-           dup(0); dup(0);
-       }
-       xml_config_add_listeners();
-
-       if (!pListener && *control_block.default_listen)
-           add_listener(control_block.default_listen, 0);
-       
-       if (!pListener)
-           return 1;
-
-       if (*control_block.pid_fname)
-       {
-           FILE *f = fopen(control_block.pid_fname, "w");
-           if (!f)
-           {
-               yaz_log(YLOG_FATAL|YLOG_ERRNO, "Couldn't create %s", 
-                       control_block.pid_fname);
-               exit(0);
-           }
-           fprintf(f, "%ld", (long) getpid());
-           fclose(f);
-       }
-       
-       if (control_block.background)
-           close(hand[1]);
-
-
-       yaz_log (log_server, "Starting server %s pid=%ld", programname, 
-                (long) getpid());
+        static int hand[2];
+        if (control_block.background)
+        {
+            /* create pipe so that parent waits until child has created
+               PID (or failed) */
+            if (pipe(hand) < 0)
+            {
+                yaz_log(YLOG_FATAL|YLOG_ERRNO, "pipe");
+                return 1;
+            }
+            switch (fork())
+            {
+            case 0: 
+                break;
+            case -1:
+                return 1;
+            default:
+                close(hand[1]);
+                while(1)
+                {
+                    char dummy[1];
+                    int res = read(hand[0], dummy, 1);
+                    if (res < 0 && yaz_errno() != EINTR)
+                    {
+                        yaz_log(YLOG_FATAL|YLOG_ERRNO, "read fork handshake");
+                        break;
+                    }
+                    else if (res >= 0)
+                        break;
+                }
+                close(hand[0]);
+                _exit(0);
+            }
+            /* child */
+            close(hand[0]);
+            if (setsid() < 0)
+                return 1;
+            
+            close(0);
+            close(1);
+            close(2);
+            open("/dev/null", O_RDWR);
+            dup(0); dup(0);
+        }
+        xml_config_add_listeners();
+
+        if (!pListener && *control_block.default_listen)
+            add_listener(control_block.default_listen, 0);
+        
+        if (!pListener)
+            return 1;
+
+        if (*control_block.pid_fname)
+        {
+            FILE *f = fopen(control_block.pid_fname, "w");
+            if (!f)
+            {
+                yaz_log(YLOG_FATAL|YLOG_ERRNO, "Couldn't create %s", 
+                        control_block.pid_fname);
+                exit(0);
+            }
+            fprintf(f, "%ld", (long) getpid());
+            fclose(f);
+        }
+        
+        if (control_block.background)
+            close(hand[1]);
+
+
+        yaz_log (log_server, "Starting server %s pid=%ld", programname, 
+                 (long) getpid());
 #if 0
-       sigset_t sigs_to_block;
-       
-       sigemptyset(&sigs_to_block);
-       sigaddset (&sigs_to_block, SIGTERM);
-       pthread_sigmask (SIG_BLOCK, &sigs_to_block, 0);
-       /* missing... */
+        sigset_t sigs_to_block;
+        
+        sigemptyset(&sigs_to_block);
+        sigaddset (&sigs_to_block, SIGTERM);
+        pthread_sigmask (SIG_BLOCK, &sigs_to_block, 0);
+        /* missing... */
 #endif
-       if (control_block.dynamic)
-           signal(SIGCHLD, catchchld);
+        if (control_block.dynamic)
+            signal(SIGCHLD, catchchld);
     }
     signal (SIGPIPE, SIG_IGN);
     signal (SIGTERM, sigterm);
     if (*control_block.setuid)
     {
-       struct passwd *pw;
-       
-       if (!(pw = getpwnam(control_block.setuid)))
-       {
-           yaz_log(YLOG_FATAL, "%s: Unknown user", control_block.setuid);
-           return(1);
-       }
-       if (setuid(pw->pw_uid) < 0)
-       {
-           yaz_log(YLOG_FATAL|YLOG_ERRNO, "setuid");
-           exit(1);
-       }
+        struct passwd *pw;
+        
+        if (!(pw = getpwnam(control_block.setuid)))
+        {
+            yaz_log(YLOG_FATAL, "%s: Unknown user", control_block.setuid);
+            return(1);
+        }
+        if (setuid(pw->pw_uid) < 0)
+        {
+            yaz_log(YLOG_FATAL|YLOG_ERRNO, "setuid");
+            exit(1);
+        }
     }
 /* UNIX */
 #endif
     if (pListener == NULL)
-       return 1;
+        return 1;
     yaz_log(YLOG_DEBUG, "Entering event loop.");
     return event_loop(&pListener);
 }
@@ -1299,114 +1299,114 @@ int check_options(int argc, char **argv)
 
     get_logbits(1); 
     while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:A:p:DC:f:",
-                         argv, argc, &arg)) != -2)
+                          argv, argc, &arg)) != -2)
     {
-       switch (ret)
-       {
-       case 0:
-           if (add_listener(arg, 0))
+        switch (ret)
+        {
+        case 0:
+            if (add_listener(arg, 0))
                 return 1;  /* failed to create listener */
-           break;
-       case '1':        
-           control_block.one_shot = 1;
-           control_block.dynamic = 0;
-           break;
-       case 'z':
-           control_block.default_proto = PROTO_Z3950;
-           break;
-       case 's':
+            break;
+        case '1':        
+            control_block.one_shot = 1;
+            control_block.dynamic = 0;
+            break;
+        case 'z':
+            control_block.default_proto = PROTO_Z3950;
+            break;
+        case 's':
             fprintf (stderr, "%s: SR protocol no longer supported\n", me);
             exit (1);
-           break;
-       case 'S':
-           control_block.dynamic = 0;
-           break;
-       case 'T':
+            break;
+        case 'S':
+            control_block.dynamic = 0;
+            break;
+        case 'T':
 #if YAZ_POSIX_THREADS
-           control_block.dynamic = 0;
-           control_block.threads = 1;
+            control_block.dynamic = 0;
+            control_block.threads = 1;
 #elif YAZ_GNU_THREADS
-           control_block.dynamic = 0;
-           control_block.threads = 1;
+            control_block.dynamic = 0;
+            control_block.threads = 1;
 #else
-           fprintf(stderr, "%s: Threaded mode not available.\n", me);
-           return 1;
+            fprintf(stderr, "%s: Threaded mode not available.\n", me);
+            return 1;
 #endif
-           break;
-       case 'l':
-           option_copy(control_block.logfile, arg);
-           yaz_log_init(control_block.loglevel, me, control_block.logfile);
-           break;
-       case 'v':
-           control_block.loglevel =
-               yaz_log_mask_str_x(arg,control_block.loglevel);
-           yaz_log_init(control_block.loglevel, me, control_block.logfile);
-           get_logbits(1); 
-           break;
-       case 'a':
-           option_copy(control_block.apdufile, arg);
-           break;
-       case 'u':
-           option_copy(control_block.setuid, arg);
-           break;
-       case 'c':
-           option_copy(control_block.configname, arg);
-           break;
-       case 'C':
-           option_copy(control_block.cert_fname, arg);
-           break;
-       case 'd':
-           option_copy(control_block.daemon_name, arg);
-           break;
-       case 't':
-           if (!arg || !(r = atoi(arg)))
-           {
-               fprintf(stderr, "%s: Specify positive timeout for -t.\n", me);
-               return(1);
-           }
-           control_block.idle_timeout = r;
-           break;
-       case  'k':
-           if (!arg || !(r = atoi(arg)))
-           {
-               fprintf(stderr, "%s: Specify positive size for -k.\n", me);
-               return(1);
-           }
-           control_block.maxrecordsize = r * 1024;
-           break;
-       case 'i':
-           control_block.inetd = 1;
-           break;
-       case 'w':
-           if (chdir(arg))
-           {
-               perror(arg);            
-               return 1;
-           }
-           break;
+            break;
+        case 'l':
+            option_copy(control_block.logfile, arg);
+            yaz_log_init(control_block.loglevel, me, control_block.logfile);
+            break;
+        case 'v':
+            control_block.loglevel =
+                yaz_log_mask_str_x(arg,control_block.loglevel);
+            yaz_log_init(control_block.loglevel, me, control_block.logfile);
+            get_logbits(1); 
+            break;
+        case 'a':
+            option_copy(control_block.apdufile, arg);
+            break;
+        case 'u':
+            option_copy(control_block.setuid, arg);
+            break;
+        case 'c':
+            option_copy(control_block.configname, arg);
+            break;
+        case 'C':
+            option_copy(control_block.cert_fname, arg);
+            break;
+        case 'd':
+            option_copy(control_block.daemon_name, arg);
+            break;
+        case 't':
+            if (!arg || !(r = atoi(arg)))
+            {
+                fprintf(stderr, "%s: Specify positive timeout for -t.\n", me);
+                return(1);
+            }
+            control_block.idle_timeout = r;
+            break;
+        case  'k':
+            if (!arg || !(r = atoi(arg)))
+            {
+                fprintf(stderr, "%s: Specify positive size for -k.\n", me);
+                return(1);
+            }
+            control_block.maxrecordsize = r * 1024;
+            break;
+        case 'i':
+            control_block.inetd = 1;
+            break;
+        case 'w':
+            if (chdir(arg))
+            {
+                perror(arg);            
+                return 1;
+            }
+            break;
         case 'A':
             max_sessions = atoi(arg);
             break;
-       case 'p':
-           option_copy(control_block.pid_fname, arg);
-           break;
-       case 'f':
+        case 'p':
+            option_copy(control_block.pid_fname, arg);
+            break;
+        case 'f':
 #if HAVE_XML2
-           option_copy(control_block.xml_config, arg);
+            option_copy(control_block.xml_config, arg);
 #else
-           fprintf(stderr, "%s: Option -f unsupported since YAZ is compiled without Libxml2 support\n", me);
-           exit(1);
+            fprintf(stderr, "%s: Option -f unsupported since YAZ is compiled without Libxml2 support\n", me);
+            exit(1);
 #endif
-           break;
-       case 'D':
-           control_block.background = 1;
-           break;
-       default:
-           fprintf(stderr, "Usage: %s [ -a <pdufile> -v <loglevel>"
-                   " -l <logfile> -u <user> -c <config> -t <minutes>"
-                   " -k <kilobytes> -d <daemon> -p <pidfile> -C certfile"
+            break;
+        case 'D':
+            control_block.background = 1;
+            break;
+        default:
+            fprintf(stderr, "Usage: %s [ -a <pdufile> -v <loglevel>"
+                    " -l <logfile> -u <user> -c <config> -t <minutes>"
+                    " -k <kilobytes> -d <daemon> -p <pidfile> -C certfile"
                         " -ziDST1 -w <directory> <listener-addr>... ]\n", me);
-           return 1;
+            return 1;
         }
     }
     return 0;
@@ -1428,8 +1428,8 @@ static Args ArgDetails;
 #define SZDEPENDENCIES       ""
 
 int statserv_main(int argc, char **argv,
-                 bend_initresult *(*bend_init)(bend_initrequest *r),
-                 void (*bend_close)(void *handle))
+                  bend_initresult *(*bend_init)(bend_initrequest *r),
+                  void (*bend_close)(void *handle))
 {
     struct statserv_options_block *cb = &control_block;
     cb->bend_init = bend_init;
@@ -1441,9 +1441,9 @@ int statserv_main(int argc, char **argv,
     
     /* Now setup the service with the service controller */
     SetupService(argc, argv, &ArgDetails, SZAPPNAME,
-                cb->service_name, /* internal service name */
-                cb->service_display_name, /* displayed name */
-                SZDEPENDENCIES);
+                 cb->service_name, /* internal service name */
+                 cb->service_display_name, /* displayed name */
+                 SZDEPENDENCIES);
     return 0;
 }
 
@@ -1471,8 +1471,8 @@ void StopAppService(void *pHandle)
 #else
 /* UNIX */
 int statserv_main(int argc, char **argv,
-                 bend_initresult *(*bend_init)(bend_initrequest *r),
-                 void (*bend_close)(void *handle))
+                  bend_initresult *(*bend_init)(bend_initrequest *r),
+                  void (*bend_close)(void *handle))
 {
     int ret;
 
@@ -1485,3 +1485,11 @@ int statserv_main(int argc, char **argv,
     return ret;
 }
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 96ef8bc..a2d1f4d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tcpdchk.c,v 1.7 2005-01-17 10:29:25 adam Exp $
+ * $Id: tcpdchk.c,v 1.8 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file tcpdchk.c
@@ -57,44 +57,52 @@ int check_ip_tcpd(void *cd, const char *addr, int len, int type)
 
     if (type == AF_INET)
     {
-       if (daemon_name && *daemon_name)
-       {
+        if (daemon_name && *daemon_name)
+        {
 #if HAVE_TCPD_H
-           struct request_info request_info;
-           int i;
+            struct request_info request_info;
+            int i;
 #endif
-           char *host_name = 0, *host_addr = 0;
-           struct hostent *host;
+            char *host_name = 0, *host_addr = 0;
+            struct hostent *host;
 
-           struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
-           
-           if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
-                                     sizeof(addr_in->sin_addr),
-                                     AF_INET)))
-               host_name = (char*) host->h_name;
-           host_addr = inet_ntoa(addr_in->sin_addr);
+            struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
+            
+            if ((host = gethostbyaddr((char*)&addr_in->sin_addr,
+                                      sizeof(addr_in->sin_addr),
+                                      AF_INET)))
+                host_name = (char*) host->h_name;
+            host_addr = inet_ntoa(addr_in->sin_addr);
 #if HAVE_TCPD_H
-           if (host_addr)
-               request_init(&request_info, RQ_DAEMON, daemon_name,
-                            RQ_CLIENT_NAME, host_name,
-                            RQ_CLIENT_SIN, addr_in,
-                            RQ_CLIENT_ADDR, host_addr, 0);
-           else
-               request_init(&request_info, RQ_DAEMON, daemon_name,
-                            RQ_CLIENT_SIN, addr_in,
-                            RQ_CLIENT_ADDR, host_addr, 0);
-           i = hosts_access(&request_info);
-           if (!i)
-           {
-               yaz_log (YLOG_DEBUG, "access denied from %s",
-                        host_name ? host_name : host_addr);
-               return 1;
-           }
-           yaz_log (YLOG_DEBUG, "access granted from %s",
-                    host_name ? host_name : host_addr);
+            if (host_addr)
+                request_init(&request_info, RQ_DAEMON, daemon_name,
+                             RQ_CLIENT_NAME, host_name,
+                             RQ_CLIENT_SIN, addr_in,
+                             RQ_CLIENT_ADDR, host_addr, 0);
+            else
+                request_init(&request_info, RQ_DAEMON, daemon_name,
+                             RQ_CLIENT_SIN, addr_in,
+                             RQ_CLIENT_ADDR, host_addr, 0);
+            i = hosts_access(&request_info);
+            if (!i)
+            {
+                yaz_log (YLOG_DEBUG, "access denied from %s",
+                         host_name ? host_name : host_addr);
+                return 1;
+            }
+            yaz_log (YLOG_DEBUG, "access granted from %s",
+                     host_name ? host_name : host_addr);
 #endif
-       }
+        }
     }
     return 0;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 97449bf..db0e834 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tcpip.c,v 1.15 2005-02-01 14:37:47 adam Exp $
+ * $Id: tcpip.c,v 1.16 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file tcpip.c
@@ -61,8 +61,8 @@ static int tcpip_more(COMSTACK h);
 static int tcpip_rcvconnect(COMSTACK h);
 static int tcpip_bind(COMSTACK h, void *address, int mode);
 static int tcpip_listen(COMSTACK h, char *raddr, int *addrlen,
-                int (*check_ip)(void *cd, const char *a, int len, int type),
-                void *cd);
+                 int (*check_ip)(void *cd, const char *a, int len, int type),
+                 void *cd);
 static int tcpip_set_blocking(COMSTACK p, int blocking);
 
 #if HAVE_OPENSSL_SSL_H
@@ -144,17 +144,17 @@ COMSTACK tcpip_type(int s, int blocking, int protocol, void *vp)
         return 0;
     if (s < 0)
     {
-       if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
-           return 0;
-       new_socket = 1;
+        if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+            return 0;
+        new_socket = 1;
     }
     else
-       new_socket = 0;
+        new_socket = 0;
     if (!(p = (struct comstack *)xmalloc(sizeof(struct comstack))))
-       return 0;
+        return 0;
     if (!(sp = (struct tcpip_state *)(p->cprivate =
                                          xmalloc(sizeof(tcpip_state)))))
-       return 0;
+        return 0;
 
     if (!((p->blocking = blocking)&1))
     {
@@ -204,9 +204,9 @@ COMSTACK tcpip_type(int s, int blocking, int protocol, void *vp)
     sp->altsize = sp->altlen = 0;
     sp->towrite = sp->written = -1;
     if (protocol == PROTO_WAIS)
-       sp->complete = completeWAIS;
+        sp->complete = completeWAIS;
     else
-       sp->complete = cs_complete_auto;
+        sp->complete = cs_complete_auto;
 
     p->timeout = COMSTACK_DEFAULT_TIMEOUT;
     TRC(fprintf(stderr, "Created new TCPIP comstack\n"));
@@ -223,7 +223,7 @@ COMSTACK ssl_type(int s, int blocking, int protocol, void *vp)
 
     p = tcpip_type (s, blocking, protocol, 0);
     if (!p)
-       return 0;
+        return 0;
     p->f_get = ssl_get;
     p->f_put = ssl_put;
     p->type = ssl_type;
@@ -262,7 +262,7 @@ int tcpip_strtoaddr_ex(const char *str, struct sockaddr_in *add,
         add->sin_addr.s_addr = INADDR_ANY;
     else if ((hp = gethostbyname(buf)))
         memcpy(&add->sin_addr.s_addr, *hp->h_addr_list,
-              sizeof(struct in_addr));
+               sizeof(struct in_addr));
     else if ((tmpadd = (unsigned) inet_addr(buf)) != 0)
         memcpy(&add->sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
     else
@@ -279,7 +279,7 @@ void *tcpip_straddr(COMSTACK h, const char *str)
         port = 80;
 
     if (!tcpip_strtoaddr_ex (str, &sp->addr, port))
-       return 0;
+        return 0;
     return &sp->addr;
 }
 
@@ -288,7 +288,7 @@ struct sockaddr_in *tcpip_strtoaddr(const char *str)
     static struct sockaddr_in add;
     
     if (!tcpip_strtoaddr_ex (str, &add, 210))
-       return 0;
+        return 0;
     return &add;
 }
 
@@ -297,7 +297,7 @@ int tcpip_more(COMSTACK h)
     tcpip_state *sp = (tcpip_state *)h->cprivate;
     
     return sp->altlen && (*sp->complete)((unsigned char *) sp->altbuf,
-       sp->altlen);
+        sp->altlen);
 }
 
 /*
@@ -318,7 +318,7 @@ int tcpip_connect(COMSTACK h, void *address)
     if (h->state != CS_ST_UNBND)
     {
         h->cerrno = CSOUTSTATE;
-       return -1;
+        return -1;
     }
 #ifdef __sun__
     /* On Suns, you must set a bigger Receive Buffer BEFORE a call to connect
@@ -331,7 +331,7 @@ int tcpip_connect(COMSTACK h, void *address)
         return -1;
     }
     TRC(fprintf( stderr, "Current Size of TCP Receive Buffer= %d\n",
-                recbuflen ));
+                 recbuflen ));
     recbuflen *= 10; /* lets be optimistic */
     if ( setsockopt(h->iofile, SOL_SOCKET, SO_RCVBUF, (void *)&recbuflen, rbufsize ) < 0 )
     {
@@ -344,7 +344,7 @@ int tcpip_connect(COMSTACK h, void *address)
         return -1;
     }
     TRC(fprintf( stderr, "New Size of TCP Receive Buffer = %d\n",
-                recbuflen ));
+                 recbuflen ));
 #endif
     r = connect(h->iofile, (struct sockaddr *) add, sizeof(*add));
     if (r < 0)
@@ -390,47 +390,47 @@ int tcpip_rcvconnect(COMSTACK h)
     if (h->state != CS_ST_CONNECTING)
     {
         h->cerrno = CSOUTSTATE;
-       return -1;
+        return -1;
     }
 #if HAVE_OPENSSL_SSL_H
     if (h->type == ssl_type && !sp->ctx)
     {
-       SSL_load_error_strings();
-       SSLeay_add_all_algorithms();
-
-       sp->ctx = sp->ctx_alloc = SSL_CTX_new (SSLv23_method());
-       if (!sp->ctx)
-       {
-           h->cerrno = CSERRORSSL;
-           return -1;
-       }
+        SSL_load_error_strings();
+        SSLeay_add_all_algorithms();
+
+        sp->ctx = sp->ctx_alloc = SSL_CTX_new (SSLv23_method());
+        if (!sp->ctx)
+        {
+            h->cerrno = CSERRORSSL;
+            return -1;
+        }
     }
     if (sp->ctx)
     {
-       int res;
-
-       if (!sp->ssl)
-       {
-           sp->ssl = SSL_new (sp->ctx);
-           SSL_set_fd (sp->ssl, h->iofile);
-       }
-       res = SSL_connect (sp->ssl);
-       if (res <= 0)
-       {
-           int err = SSL_get_error(sp->ssl, res);
-           if (err == SSL_ERROR_WANT_READ)
-           {
-               h->io_pending = CS_WANT_READ;
-               return 1;
-           }
-           if (err == SSL_ERROR_WANT_WRITE)
-           {
-               h->io_pending = CS_WANT_WRITE;
-               return 1;
-           }
-           h->cerrno = CSERRORSSL;
-           return -1;
-       }
+        int res;
+
+        if (!sp->ssl)
+        {
+            sp->ssl = SSL_new (sp->ctx);
+            SSL_set_fd (sp->ssl, h->iofile);
+        }
+        res = SSL_connect (sp->ssl);
+        if (res <= 0)
+        {
+            int err = SSL_get_error(sp->ssl, res);
+            if (err == SSL_ERROR_WANT_READ)
+            {
+                h->io_pending = CS_WANT_READ;
+                return 1;
+            }
+            if (err == SSL_ERROR_WANT_WRITE)
+            {
+                h->io_pending = CS_WANT_WRITE;
+                return 1;
+            }
+            h->cerrno = CSERRORSSL;
+            return -1;
+        }
     }
 #endif
     h->event = CS_DATA;
@@ -475,54 +475,54 @@ static int tcpip_bind(COMSTACK h, void *address, int mode)
     tcpip_state *sp = (tcpip_state *)h->cprivate;
     if (h->type == ssl_type && !sp->ctx)
     {
-       SSL_load_error_strings();
-       SSLeay_add_all_algorithms();
-
-       sp->ctx = sp->ctx_alloc = SSL_CTX_new (SSLv23_method());
-       if (!sp->ctx)
-       {
-           h->cerrno = CSERRORSSL;
-           return -1;
-       }
+        SSL_load_error_strings();
+        SSLeay_add_all_algorithms();
+
+        sp->ctx = sp->ctx_alloc = SSL_CTX_new (SSLv23_method());
+        if (!sp->ctx)
+        {
+            h->cerrno = CSERRORSSL;
+            return -1;
+        }
     }
     if (sp->ctx)
     {
-       if (sp->ctx_alloc)
-       {
-           int res;
-           res = SSL_CTX_use_certificate_file (sp->ctx, sp->cert_fname,
-                                               SSL_FILETYPE_PEM);
-           if (res <= 0)
-           {
-               ERR_print_errors_fp(stderr);
-               exit (2);
-           }
-           res = SSL_CTX_use_PrivateKey_file (sp->ctx, sp->cert_fname,
-                                              SSL_FILETYPE_PEM);
-           if (res <= 0)
-           {
-               ERR_print_errors_fp(stderr);
-               exit (3);
-           }
-           res = SSL_CTX_check_private_key (sp->ctx);
-           if (res <= 0)
-           {
-               ERR_print_errors_fp(stderr);
-               exit(5);
-           }
-       }
-       TRC (fprintf (stderr, "ssl_bind\n"));
+        if (sp->ctx_alloc)
+        {
+            int res;
+            res = SSL_CTX_use_certificate_file (sp->ctx, sp->cert_fname,
+                                                SSL_FILETYPE_PEM);
+            if (res <= 0)
+            {
+                ERR_print_errors_fp(stderr);
+                exit (2);
+            }
+            res = SSL_CTX_use_PrivateKey_file (sp->ctx, sp->cert_fname,
+                                               SSL_FILETYPE_PEM);
+            if (res <= 0)
+            {
+                ERR_print_errors_fp(stderr);
+                exit (3);
+            }
+            res = SSL_CTX_check_private_key (sp->ctx);
+            if (res <= 0)
+            {
+                ERR_print_errors_fp(stderr);
+                exit(5);
+            }
+        }
+        TRC (fprintf (stderr, "ssl_bind\n"));
     }
     else
     {
-       TRC (fprintf (stderr, "tcpip_bind\n"));
+        TRC (fprintf (stderr, "tcpip_bind\n"));
     }
 #else
     TRC (fprintf (stderr, "tcpip_bind\n"));
 #endif
 #ifndef WIN32
     if (setsockopt(h->iofile, SOL_SOCKET, SO_REUSEADDR, (char*) 
-       &one, sizeof(one)) < 0)
+        &one, sizeof(one)) < 0)
     {
         h->cerrno = CSYSERR;
         return -1;
@@ -545,8 +545,8 @@ static int tcpip_bind(COMSTACK h, void *address, int mode)
 }
 
 int tcpip_listen(COMSTACK h, char *raddr, int *addrlen,
-                int (*check_ip)(void *cd, const char *a, int len, int t),
-                void *cd)
+                 int (*check_ip)(void *cd, const char *a, int len, int t),
+                 void *cd)
 {
     struct sockaddr_in addr;
     YAZ_SOCKLEN_T len = sizeof(addr);
@@ -560,21 +560,21 @@ int tcpip_listen(COMSTACK h, char *raddr, int *addrlen,
     h->newfd = accept(h->iofile, (struct sockaddr*)&addr, &len);
     if (h->newfd < 0)
     {
-       if (
+        if (
 #ifdef WIN32
-           WSAGetLastError() == WSAEWOULDBLOCK
+            WSAGetLastError() == WSAEWOULDBLOCK
 #else
-           yaz_errno() == EWOULDBLOCK 
+            yaz_errno() == EWOULDBLOCK 
 #ifdef EAGAIN
 #if EAGAIN != EWOULDBLOCK
             || yaz_errno() == EAGAIN
 #endif
 #endif
 #endif
-           )
-           h->cerrno = CSNODATA;
-       else
-           h->cerrno = CSYSERR;
+            )
+            h->cerrno = CSNODATA;
+        else
+            h->cerrno = CSYSERR;
         return -1;
     }
     if (addrlen && (size_t) (*addrlen) >= sizeof(struct sockaddr_in))
@@ -584,14 +584,14 @@ int tcpip_listen(COMSTACK h, char *raddr, int *addrlen,
     if (check_ip && (*check_ip)(cd, (const char *) &addr,
         sizeof(addr), AF_INET))
     {
-       h->cerrno = CSDENY;
+        h->cerrno = CSDENY;
 #ifdef WIN32
         closesocket(h->newfd);
 #else
         close(h->newfd);
 #endif
-       h->newfd = -1;
-       return -1;
+        h->newfd = -1;
+        return -1;
     }
     h->state = CS_ST_INCON;
     tcpip_setsockopt (h->newfd);
@@ -609,102 +609,102 @@ COMSTACK tcpip_accept(COMSTACK h)
     TRC(fprintf(stderr, "tcpip_accept\n"));
     if (h->state == CS_ST_INCON)
     {
-       if (!(cnew = (COMSTACK)xmalloc(sizeof(*cnew))))
-       {
-           h->cerrno = CSYSERR;
+        if (!(cnew = (COMSTACK)xmalloc(sizeof(*cnew))))
+        {
+            h->cerrno = CSYSERR;
 #ifdef WIN32
-           closesocket(h->newfd);
+            closesocket(h->newfd);
 #else
-           close(h->newfd);
+            close(h->newfd);
 #endif
-           h->newfd = -1;
-           return 0;
-       }
-       memcpy(cnew, h, sizeof(*h));
-       cnew->iofile = h->newfd;
-       cnew->io_pending = 0;
-       if (!(state = (tcpip_state *)
-             (cnew->cprivate = xmalloc(sizeof(tcpip_state)))))
-       {
-           h->cerrno = CSYSERR;
-           if (h->newfd != -1)
-           {
+            h->newfd = -1;
+            return 0;
+        }
+        memcpy(cnew, h, sizeof(*h));
+        cnew->iofile = h->newfd;
+        cnew->io_pending = 0;
+        if (!(state = (tcpip_state *)
+              (cnew->cprivate = xmalloc(sizeof(tcpip_state)))))
+        {
+            h->cerrno = CSYSERR;
+            if (h->newfd != -1)
+            {
 #ifdef WIN32
-               closesocket(h->newfd);
+                closesocket(h->newfd);
 #else
-               close(h->newfd);
+                close(h->newfd);
 #endif
-               h->newfd = -1;
-           }
-           return 0;
-       }
-       if (!(cnew->blocking&1) && 
+                h->newfd = -1;
+            }
+            return 0;
+        }
+        if (!(cnew->blocking&1) && 
 #ifdef WIN32
-           (ioctlsocket(cnew->iofile, FIONBIO, &tru) < 0)
+            (ioctlsocket(cnew->iofile, FIONBIO, &tru) < 0)
 #else
-           (fcntl(cnew->iofile, F_SETFL, O_NONBLOCK) < 0)
+            (fcntl(cnew->iofile, F_SETFL, O_NONBLOCK) < 0)
 #endif
-           )
-       {
-           h->cerrno = CSYSERR;
-           if (h->newfd != -1)
-           {
+            )
+        {
+            h->cerrno = CSYSERR;
+            if (h->newfd != -1)
+            {
 #ifdef WIN32
-               closesocket(h->newfd);
+                closesocket(h->newfd);
 #else
-               close(h->newfd);
+                close(h->newfd);
 #endif
-               h->newfd = -1;
-           }
-           xfree (cnew);
-           xfree (state);
-           return 0;
-       }
-       h->newfd = -1;
-       state->altbuf = 0;
-       state->altsize = state->altlen = 0;
-       state->towrite = state->written = -1;
-       state->complete = st->complete;
-       cnew->state = CS_ST_ACCEPT;
-       h->state = CS_ST_IDLE;
-       
+                h->newfd = -1;
+            }
+            xfree (cnew);
+            xfree (state);
+            return 0;
+        }
+        h->newfd = -1;
+        state->altbuf = 0;
+        state->altsize = state->altlen = 0;
+        state->towrite = state->written = -1;
+        state->complete = st->complete;
+        cnew->state = CS_ST_ACCEPT;
+        h->state = CS_ST_IDLE;
+        
 #if HAVE_OPENSSL_SSL_H
-       state->ctx = st->ctx;
-       state->ctx_alloc = 0;
-       state->ssl = st->ssl;
-       if (state->ctx)
-       {
-           state->ssl = SSL_new (state->ctx);
-           SSL_set_fd (state->ssl, cnew->iofile);
-       }
+        state->ctx = st->ctx;
+        state->ctx_alloc = 0;
+        state->ssl = st->ssl;
+        if (state->ctx)
+        {
+            state->ssl = SSL_new (state->ctx);
+            SSL_set_fd (state->ssl, cnew->iofile);
+        }
 #endif
-       h = cnew;
+        h = cnew;
     }
     if (h->state == CS_ST_ACCEPT)
     {
 #if HAVE_OPENSSL_SSL_H
-       tcpip_state *state = (tcpip_state *)h->cprivate;
-       if (state->ctx)
-       {
-           int res = SSL_accept (state->ssl);
-           TRC(fprintf(stderr, "SSL_accept\n"));
-           if (res <= 0)
-           {
-               int err = SSL_get_error(state->ssl, res);
-               if (err == SSL_ERROR_WANT_READ)
-               {
-                   h->io_pending = CS_WANT_READ;
-                   return h;
-               }
-               if (err == SSL_ERROR_WANT_WRITE)
-               {
-                   h->io_pending = CS_WANT_WRITE;
-                   return h;
-               }
-               cs_close (h);
-               return 0;
-           }
-       }
+        tcpip_state *state = (tcpip_state *)h->cprivate;
+        if (state->ctx)
+        {
+            int res = SSL_accept (state->ssl);
+            TRC(fprintf(stderr, "SSL_accept\n"));
+            if (res <= 0)
+            {
+                int err = SSL_get_error(state->ssl, res);
+                if (err == SSL_ERROR_WANT_READ)
+                {
+                    h->io_pending = CS_WANT_READ;
+                    return h;
+                }
+                if (err == SSL_ERROR_WANT_WRITE)
+                {
+                    h->io_pending = CS_WANT_WRITE;
+                    return h;
+                }
+                cs_close (h);
+                return 0;
+            }
+        }
 #endif
     }
     else
@@ -757,52 +757,52 @@ int tcpip_get(COMSTACK h, char **buf, int *bufsize)
             if (!(*buf =(char *)xrealloc(*buf, *bufsize *= 2)))
                 return -1;
 #ifdef __sun__
-       yaz_set_errno( 0 );
-       /* unfortunatly, sun sometimes forgets to set errno in recv
-          when EWOULDBLOCK etc. would be required (res = -1) */
+        yaz_set_errno( 0 );
+        /* unfortunatly, sun sometimes forgets to set errno in recv
+           when EWOULDBLOCK etc. would be required (res = -1) */
 #endif
-       res = recv(h->iofile, *buf + hasread, CS_TCPIP_BUFCHUNK, 0);
-       TRC(fprintf(stderr, "  recv res=%d, hasread=%d\n", res, hasread));
-       if (res < 0)
-       {
-         TRC(fprintf(stderr, "  recv errno=%d, (%s)\n", yaz_errno(), 
-                     strerror(yaz_errno())));
+        res = recv(h->iofile, *buf + hasread, CS_TCPIP_BUFCHUNK, 0);
+        TRC(fprintf(stderr, "  recv res=%d, hasread=%d\n", res, hasread));
+        if (res < 0)
+        {
+          TRC(fprintf(stderr, "  recv errno=%d, (%s)\n", yaz_errno(), 
+                      strerror(yaz_errno())));
 #ifdef WIN32
-           if (WSAGetLastError() == WSAEWOULDBLOCK)
-           {
-               h->io_pending = CS_WANT_READ;
-               break;
-           }
-           else
-               return -1;
+            if (WSAGetLastError() == WSAEWOULDBLOCK)
+            {
+                h->io_pending = CS_WANT_READ;
+                break;
+            }
+            else
+                return -1;
 #else
-           if (yaz_errno() == EWOULDBLOCK 
+            if (yaz_errno() == EWOULDBLOCK 
 #ifdef EAGAIN   
 #if EAGAIN != EWOULDBLOCK
                 || yaz_errno() == EAGAIN
 #endif
 #endif
-               || yaz_errno() == EINPROGRESS
+                || yaz_errno() == EINPROGRESS
 #ifdef __sun__
-               || yaz_errno() == ENOENT /* Sun's sometimes set errno to this */
+                || yaz_errno() == ENOENT /* Sun's sometimes set errno to this */
 #endif
-               )
-           {
-               h->io_pending = CS_WANT_READ;
-               break;
-           }
-           else if (yaz_errno() == 0)
-               continue;
-           else
-               return -1;
+                )
+            {
+                h->io_pending = CS_WANT_READ;
+                break;
+            }
+            else if (yaz_errno() == 0)
+                continue;
+            else
+                return -1;
 #endif
-       }
-       else if (!res)
-           return hasread;
+        }
+        else if (!res)
+            return hasread;
         hasread += res;
     }
     TRC (fprintf (stderr, "  Out of read loop with hasread=%d, berlen=%d\n",
-                 hasread, berlen));
+                  hasread, berlen));
     /* move surplus buffer (or everything if we didn't get a BER rec.) */
     if (hasread > berlen)
     {
@@ -864,27 +864,27 @@ int ssl_get(COMSTACK h, char **buf, int *bufsize)
         else if (*bufsize - hasread < CS_TCPIP_BUFCHUNK)
             if (!(*buf =(char *)xrealloc(*buf, *bufsize *= 2)))
                 return -1;
-       res = SSL_read (sp->ssl, *buf + hasread, CS_TCPIP_BUFCHUNK);
-       TRC(fprintf(stderr, "  SSL_read res=%d, hasread=%d\n", res, hasread));
-       if (res <= 0)
-       {
-           int ssl_err = SSL_get_error(sp->ssl, res);
-           if (ssl_err == SSL_ERROR_WANT_READ)
-           {
-               h->io_pending = CS_WANT_READ;
-               break;
-           }
-           if (ssl_err == SSL_ERROR_WANT_WRITE)
-           {
-               h->io_pending = CS_WANT_WRITE;
-               break;
-           }
-           if (res == 0)
-               return 0;
-           h->cerrno = CSERRORSSL;
-           return -1;
-       }
-       hasread += res;
+        res = SSL_read (sp->ssl, *buf + hasread, CS_TCPIP_BUFCHUNK);
+        TRC(fprintf(stderr, "  SSL_read res=%d, hasread=%d\n", res, hasread));
+        if (res <= 0)
+        {
+            int ssl_err = SSL_get_error(sp->ssl, res);
+            if (ssl_err == SSL_ERROR_WANT_READ)
+            {
+                h->io_pending = CS_WANT_READ;
+                break;
+            }
+            if (ssl_err == SSL_ERROR_WANT_WRITE)
+            {
+                h->io_pending = CS_WANT_WRITE;
+                break;
+            }
+            if (res == 0)
+                return 0;
+            h->cerrno = CSERRORSSL;
+            return -1;
+        }
+        hasread += res;
     }
     TRC (fprintf (stderr, "  Out of read loop with hasread=%d, berlen=%d\n",
         hasread, berlen));
@@ -937,21 +937,21 @@ int tcpip_put(COMSTACK h, char *buf, int size)
     }
     while (state->towrite > state->written)
     {
-       if ((res =
-            send(h->iofile, buf + state->written, size -
-                 state->written, 
+        if ((res =
+             send(h->iofile, buf + state->written, size -
+                  state->written, 
 #ifdef MSG_NOSIGNAL
-                 MSG_NOSIGNAL
+                  MSG_NOSIGNAL
 #else
-                 0
+                  0
 #endif
-                )) < 0)
-       {
-           if (
+                 )) < 0)
+        {
+            if (
 #ifdef WIN32
-               WSAGetLastError() == WSAEWOULDBLOCK
+                WSAGetLastError() == WSAEWOULDBLOCK
 #else
-               yaz_errno() == EWOULDBLOCK 
+                yaz_errno() == EWOULDBLOCK 
 #ifdef EAGAIN
 #if EAGAIN != EWOULDBLOCK
              || yaz_errno() == EAGAIN
@@ -960,20 +960,20 @@ int tcpip_put(COMSTACK h, char *buf, int size)
 #ifdef __sun__
                 || yaz_errno() == ENOENT /* Sun's sometimes set errno to this value! */
 #endif
-               || yaz_errno() == EINPROGRESS
+                || yaz_errno() == EINPROGRESS
 #endif
-               )
-           {
-               TRC(fprintf(stderr, "  Flow control stop\n"));
-               h->io_pending = CS_WANT_WRITE;
-               return 1;
-           }
-           h->cerrno = CSYSERR;
-           return -1;
-       }
-       state->written += res;
-       TRC(fprintf(stderr, "  Wrote %d, written=%d, nbytes=%d\n",
-                   res, state->written, size));
+                )
+            {
+                TRC(fprintf(stderr, "  Flow control stop\n"));
+                h->io_pending = CS_WANT_WRITE;
+                return 1;
+            }
+            h->cerrno = CSYSERR;
+            return -1;
+        }
+        state->written += res;
+        TRC(fprintf(stderr, "  Wrote %d, written=%d, nbytes=%d\n",
+                    res, state->written, size));
     }
     state->towrite = state->written = -1;
     TRC(fprintf(stderr, "  Ok\n"));
@@ -1007,27 +1007,27 @@ int ssl_put(COMSTACK h, char *buf, int size)
     }
     while (state->towrite > state->written)
     {
-       res = SSL_write (state->ssl, buf + state->written,
-                        size - state->written);
-       if (res <= 0)
-       {
-           int ssl_err = SSL_get_error(state->ssl, res);
-           if (ssl_err == SSL_ERROR_WANT_READ)
-           {
-               h->io_pending = CS_WANT_READ;
-               return 1;
-           }
-           if (ssl_err == SSL_ERROR_WANT_WRITE)
-           {
-               h->io_pending = CS_WANT_WRITE;
-               return 1;
-           }
-           h->cerrno = CSERRORSSL;
-           return -1;
-       }
-       state->written += res;
-       TRC(fprintf(stderr, "  Wrote %d, written=%d, nbytes=%d\n",
-                   res, state->written, size));
+        res = SSL_write (state->ssl, buf + state->written,
+                         size - state->written);
+        if (res <= 0)
+        {
+            int ssl_err = SSL_get_error(state->ssl, res);
+            if (ssl_err == SSL_ERROR_WANT_READ)
+            {
+                h->io_pending = CS_WANT_READ;
+                return 1;
+            }
+            if (ssl_err == SSL_ERROR_WANT_WRITE)
+            {
+                h->io_pending = CS_WANT_WRITE;
+                return 1;
+            }
+            h->cerrno = CSERRORSSL;
+            return -1;
+        }
+        state->written += res;
+        TRC(fprintf(stderr, "  Wrote %d, written=%d, nbytes=%d\n",
+                    res, state->written, size));
     }
     state->towrite = state->written = -1;
     TRC(fprintf(stderr, "  Ok\n"));
@@ -1043,10 +1043,10 @@ int tcpip_close(COMSTACK h)
     if (h->iofile != -1)
     {
 #if HAVE_OPENSSL_SSL_H
-       if (sp->ssl)
-       {
-           SSL_shutdown (sp->ssl);
-       }
+        if (sp->ssl)
+        {
+            SSL_shutdown (sp->ssl);
+        }
 #endif
 #ifdef WIN32
         closesocket(h->iofile);
@@ -1059,12 +1059,12 @@ int tcpip_close(COMSTACK h)
 #if HAVE_OPENSSL_SSL_H
     if (sp->ssl)
     {
-       TRC (fprintf(stderr, "SSL_free\n"));
-       SSL_free (sp->ssl);
+        TRC (fprintf(stderr, "SSL_free\n"));
+        SSL_free (sp->ssl);
     }
     sp->ssl = 0;
     if (sp->ctx_alloc)
-       SSL_CTX_free (sp->ctx_alloc);
+        SSL_CTX_free (sp->ctx_alloc);
 #endif
     xfree(sp);
     xfree(h);
@@ -1082,16 +1082,16 @@ char *tcpip_addrstr(COMSTACK h)
     len = sizeof(addr);
     if (getpeername(h->iofile, (struct sockaddr*) &addr, &len) < 0)
     {
-       h->cerrno = CSYSERR;
-       return 0;
+        h->cerrno = CSYSERR;
+        return 0;
     }
     if (!(h->blocking&2)) {
         if ((host = gethostbyaddr((char*)&addr.sin_addr, sizeof(addr.sin_addr),
-                             AF_INET)))
-           r = (char*) host->h_name;
+                              AF_INET)))
+            r = (char*) host->h_name;
     }
     if (!r)
-       r = inet_ntoa(addr.sin_addr);
+        r = inet_ntoa(addr.sin_addr);
     if (h->protocol == PROTO_HTTP)
         sprintf(buf, "http:%s", r);
     else
@@ -1113,19 +1113,19 @@ int static tcpip_set_blocking(COMSTACK p, int blocking)
     unsigned long flag;
     
     if (p->blocking == blocking)
-       return 1;
+        return 1;
 #ifdef WIN32
     flag = 1;
     if (ioctlsocket(p->iofile, FIONBIO, &flag) < 0)
-       return 0;
+        return 0;
 #else
     flag = fcntl(p->iofile, F_GETFL, 0);
     if(!(blocking&1))
-       flag = flag & ~O_NONBLOCK;
+        flag = flag & ~O_NONBLOCK;
     else
         flag = flag | O_NONBLOCK;
     if (fcntl(p->iofile, F_SETFL, flag) < 0)
-       return 0;
+        return 0;
 #endif
     p->blocking = blocking;
     return 1;
@@ -1139,7 +1139,7 @@ int cs_set_ssl_ctx(COMSTACK cs, void *ctx)
         return 0;
     sp = (struct tcpip_state *) cs->cprivate;
     if (sp->ctx_alloc)
-       return 0;
+        return 0;
     sp->ctx = (SSL_CTX *) ctx;
     return 1;
 }
@@ -1157,7 +1157,7 @@ int cs_set_ssl_certificate_file(COMSTACK cs, const char *fname)
 {
     struct tcpip_state *sp;
     if (!cs || cs->type != ssl_type)
-       return 0;
+        return 0;
     sp = (struct tcpip_state *) cs->cprivate;
     strncpy(sp->cert_fname, fname, sizeof(sp->cert_fname)-1);
     sp->cert_fname[sizeof(sp->cert_fname)-1] = '\0';
@@ -1169,19 +1169,19 @@ int cs_get_peer_certificate_x509(COMSTACK cs, char **buf, int *len)
     SSL *ssl = (SSL *) cs_get_ssl(cs);
     if (ssl)
     {
-       X509 *server_cert = SSL_get_peer_certificate (ssl);
-       if (server_cert)
-       {
-           BIO *bio = BIO_new(BIO_s_mem());
-           char *pem_buf;
-           /* get PEM buffer in memory */
-           PEM_write_bio_X509(bio, server_cert);
-           *len = BIO_get_mem_data(bio, &pem_buf);
-           *buf = (char *) xmalloc(*len);
-           memcpy(*buf, pem_buf, *len);
-           BIO_free(bio);
-           return 1;
-       }
+        X509 *server_cert = SSL_get_peer_certificate (ssl);
+        if (server_cert)
+        {
+            BIO *bio = BIO_new(BIO_s_mem());
+            char *pem_buf;
+            /* get PEM buffer in memory */
+            PEM_write_bio_X509(bio, server_cert);
+            *len = BIO_get_mem_data(bio, &pem_buf);
+            *buf = (char *) xmalloc(*len);
+            memcpy(*buf, pem_buf, *len);
+            BIO_free(bio);
+            return 1;
+        }
     }
     return 0;
 }
@@ -1207,3 +1207,11 @@ int cs_set_ssl_certificate_file(COMSTACK cs, const char *fname)
 }
 #endif
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index e57b093..38d66ef 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tpath.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: tpath.c,v 1.6 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file tpath.c
@@ -37,7 +37,7 @@ FILE *yaz_fopen(const char *path, const char *name, const char *mode,
 
     for(;;)
     {
-       FILE *f;
+        FILE *f;
 
         const char *path_sep = 0;
         size_t len = 0;
@@ -71,8 +71,8 @@ FILE *yaz_fopen(const char *path, const char *name, const char *mode,
                 spath[slen++] = '/';
         }
         strcpy (spath+slen, name);
-       if ((f = fopen(spath, mode)))
-           return f;
+        if ((f = fopen(spath, mode)))
+            return f;
         
         if (!path_sep)
             break;
@@ -93,3 +93,11 @@ int yaz_is_abspath (const char *p)
 #endif
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 3449001..71f9d4f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: unix.c,v 1.14 2005-02-09 09:18:27 adam Exp $
+ * $Id: unix.c,v 1.15 2005-06-25 15:46:06 adam Exp $
  * UNIX socket COMSTACK. By Morten Bøgeskov.
  */
 /**
@@ -55,8 +55,8 @@ static int unix_more(COMSTACK h);
 static int unix_rcvconnect(COMSTACK h);
 static int unix_bind(COMSTACK h, void *address, int mode);
 static int unix_listen(COMSTACK h, char *raddr, int *addrlen,
-               int (*check_ip)(void *cd, const char *a, int len, int type),
-               void *cd);
+                int (*check_ip)(void *cd, const char *a, int len, int type),
+                void *cd);
 static int unix_set_blocking(COMSTACK p, int blocking);
 
 static COMSTACK unix_accept(COMSTACK h);
@@ -65,7 +65,7 @@ static void *unix_straddr(COMSTACK h, const char *str);
 
 #ifndef SUN_LEN
 #define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
-                     + strlen ((ptr)->sun_path))
+                      + strlen ((ptr)->sun_path))
 #endif
 #if 0
 #define TRC(x) x
@@ -106,27 +106,27 @@ COMSTACK unix_type(int s, int blocking, int protocol, void *vp)
     int new_socket;
 
     if (!unix_init ())
-       return 0;
+        return 0;
     if (s < 0)
     {
-       if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
-           return 0;
-       new_socket = 1;
+        if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+            return 0;
+        new_socket = 1;
     }
     else
-       new_socket = 0;
+        new_socket = 0;
     if (!(p = (struct comstack *)xmalloc(sizeof(struct comstack))))
-       return 0;
+        return 0;
     if (!(state = (struct unix_state *)(p->cprivate =
-                                       xmalloc(sizeof(unix_state)))))
-       return 0;
+                                        xmalloc(sizeof(unix_state)))))
+        return 0;
 
     if (!((p->blocking = blocking)&1))
     {
-       if (fcntl(s, F_SETFL, O_NONBLOCK) < 0)
-           return 0;
+        if (fcntl(s, F_SETFL, O_NONBLOCK) < 0)
+            return 0;
 #ifndef MSG_NOSIGNAL
-       signal (SIGPIPE, SIG_IGN);
+        signal (SIGPIPE, SIG_IGN);
 #endif
     }
 
@@ -158,9 +158,9 @@ COMSTACK unix_type(int s, int blocking, int protocol, void *vp)
     state->altsize = state->altlen = 0;
     state->towrite = state->written = -1;
     if (protocol == PROTO_WAIS)
-       state->complete = completeWAIS;
+        state->complete = completeWAIS;
     else
-       state->complete = cs_complete_auto;
+        state->complete = cs_complete_auto;
 
     p->timeout = COMSTACK_DEFAULT_TIMEOUT;
     TRC(fprintf(stderr, "Created new UNIX comstack\n"));
@@ -173,13 +173,13 @@ static int unix_strtoaddr_ex(const char *str, struct sockaddr_un *add)
 {
     char *cp;
     if (!unix_init ())
-       return 0;
+        return 0;
     TRC(fprintf(stderr, "unix_strtoaddress: %s\n", str ? str : "NULL"));
     add->sun_family = AF_UNIX;
     strncpy(add->sun_path, str, sizeof(add->sun_path));
     cp = strchr (add->sun_path, ':');
     if (cp)
-       *cp = '\0';
+        *cp = '\0';
     return 1;
 }
 
@@ -195,91 +195,91 @@ static void *unix_straddr(COMSTACK h, const char *str)
 
     if ((eol = strchr(s, ',')))
     {
-       do
-       {
-           if ((eol = strchr(s, ',')))
-               *eol++ = '\0';
-           if (sp->uid  == -1 && strncmp(s, "user=",  5) == 0)
-           {
-               char * arg = s + 5;
-               if (strspn(arg, "0123456789") == strlen(arg))
-               {
-                   sp->uid = atoi(arg);
-               }
-               else
-               {
-                   struct passwd * pw = getpwnam(arg);
-                   if(pw == NULL)
-                   {
-                       printf("No such user\n");
-                       free(f);
-                       return 0;
-                   }
-                   sp->uid = pw->pw_uid;
-               }
-           }
-           else if (sp->gid == -1 && strncmp(s, "group=", 6) == 0)
-           {
-               char * arg = s + 6;
-               if (strspn(arg, "0123456789") == strlen(arg))
-               {
-                   sp->gid = atoi(arg);
-               }
-               else
-               {
-                   struct group * gr = getgrnam(arg);
-                   if (gr == NULL)
-                   {
-                       printf("No such group\n");
-                       free(f);
-                       return 0;
-                   }
-                   sp->gid = gr->gr_gid;
-               }
-           }
-           else if (sp->umask == -1 && strncmp(s, "umask=", 6) == 0)
-           {
-               char * end;
-               char * arg = s + 6;
-               
-               sp->umask = strtol(arg, &end, 8);
-               if (errno == EINVAL ||
-                   *end)
-               {
-                   printf("Invalid umask\n");
-                   free(f);
-                   return 0;
-               }
-           }
-           else if (file == NULL && strncmp(s, "file=", 5) == 0)
-           {
-               char * arg = s + 5;
-               file = arg;
-           }
-           else
-           {
-               printf("invalid or double argument: %s\n", s);
-               free(f);
-               return 0;
-           }
-       } while((s = eol));
+        do
+        {
+            if ((eol = strchr(s, ',')))
+                *eol++ = '\0';
+            if (sp->uid  == -1 && strncmp(s, "user=",  5) == 0)
+            {
+                char * arg = s + 5;
+                if (strspn(arg, "0123456789") == strlen(arg))
+                {
+                    sp->uid = atoi(arg);
+                }
+                else
+                {
+                    struct passwd * pw = getpwnam(arg);
+                    if(pw == NULL)
+                    {
+                        printf("No such user\n");
+                        free(f);
+                        return 0;
+                    }
+                    sp->uid = pw->pw_uid;
+                }
+            }
+            else if (sp->gid == -1 && strncmp(s, "group=", 6) == 0)
+            {
+                char * arg = s + 6;
+                if (strspn(arg, "0123456789") == strlen(arg))
+                {
+                    sp->gid = atoi(arg);
+                }
+                else
+                {
+                    struct group * gr = getgrnam(arg);
+                    if (gr == NULL)
+                    {
+                        printf("No such group\n");
+                        free(f);
+                        return 0;
+                    }
+                    sp->gid = gr->gr_gid;
+                }
+            }
+            else if (sp->umask == -1 && strncmp(s, "umask=", 6) == 0)
+            {
+                char * end;
+                char * arg = s + 6;
+                
+                sp->umask = strtol(arg, &end, 8);
+                if (errno == EINVAL ||
+                    *end)
+                {
+                    printf("Invalid umask\n");
+                    free(f);
+                    return 0;
+                }
+            }
+            else if (file == NULL && strncmp(s, "file=", 5) == 0)
+            {
+                char * arg = s + 5;
+                file = arg;
+            }
+            else
+            {
+                printf("invalid or double argument: %s\n", s);
+                free(f);
+                return 0;
+            }
+        } while((s = eol));
     }
     else
     {
-       file = str;
+        file = str;
     }
     if(! file)
     {
-       errno = EINVAL;
-       return 0;
+        errno = EINVAL;
+        return 0;
     }
 
     TRC(fprintf(stderr, "unix_straddr: %s\n", str ? str : "NULL"));
 
     if (!unix_strtoaddr_ex (file, &sp->addr))
     {
-       free(f);
-       return 0;
+        free(f);
+        return 0;
     }
     free(f);
     return &sp->addr;
@@ -292,7 +292,7 @@ struct sockaddr_un *unix_strtoaddr(const char *str)
     TRC(fprintf(stderr, "unix_strtoaddr: %s\n", str ? str : "NULL"));
 
     if (!unix_strtoaddr_ex (str, &add))
-       return 0;
+        return 0;
     return &add;
 }
 
@@ -301,7 +301,7 @@ static int unix_more(COMSTACK h)
     unix_state *sp = (unix_state *)h->cprivate;
 
     return sp->altlen && (*sp->complete)((unsigned char *) sp->altbuf,
-                                        sp->altlen);
+                                         sp->altlen);
 }
 
 /*
@@ -319,35 +319,35 @@ static int unix_connect(COMSTACK h, void *address)
     h->io_pending = 0;
     if (h->state != CS_ST_UNBND)
     {
-       h->cerrno = CSOUTSTATE;
-       return -1;
+        h->cerrno = CSOUTSTATE;
+        return -1;
     }
     for (i = 0; i<3; i++)
     {
-       r = connect(h->iofile, (struct sockaddr *) add, SUN_LEN(add));
-       if (r < 0 && yaz_errno() == EAGAIN)
-       {
+        r = connect(h->iofile, (struct sockaddr *) add, SUN_LEN(add));
+        if (r < 0 && yaz_errno() == EAGAIN)
+        {
 #if HAVE_USLEEP
-           usleep(i*10000+1000); /* 1ms, 11ms, 21ms */
+            usleep(i*10000+1000); /* 1ms, 11ms, 21ms */
 #else
-           sleep(1);
+            sleep(1);
 #endif
-           continue;
-       }
-       else
-           break;
+            continue;
+        }
+        else
+            break;
     }
     if (r < 0)
     {
-       if (yaz_errno() == EINPROGRESS)
-       {
-           h->event = CS_CONNECT;
-           h->state = CS_ST_CONNECTING;
-           h->io_pending = CS_WANT_WRITE;
-           return 1;
-       }
-       h->cerrno = CSYSERR;
-       return -1;
+        if (yaz_errno() == EINPROGRESS)
+        {
+            h->event = CS_CONNECT;
+            h->state = CS_ST_CONNECTING;
+            h->io_pending = CS_WANT_WRITE;
+            return 1;
+        }
+        h->cerrno = CSYSERR;
+        return -1;
     }
     h->event = CS_CONNECT;
     h->state = CS_ST_CONNECTING;
@@ -363,11 +363,11 @@ static int unix_rcvconnect(COMSTACK h)
     TRC(fprintf(stderr, "unix_rcvconnect\n"));
 
     if (h->state == CS_ST_DATAXFER)
-       return 0;
+        return 0;
     if (h->state != CS_ST_CONNECTING)
     {
-       h->cerrno = CSOUTSTATE;
-       return -1;
+        h->cerrno = CSOUTSTATE;
+        return -1;
     }
     h->event = CS_DATA;
     h->state = CS_ST_DATAXFER;
@@ -384,46 +384,46 @@ static int unix_bind(COMSTACK h, void *address, int mode)
     TRC (fprintf (stderr, "unix_bind\n"));
 
     if(stat(path, &stat_buf) != -1) {
-       struct sockaddr_un socket_unix;
-       int socket_out = -1;
-       if(! S_ISSOCK(stat_buf.st_mode)) {
-           h->cerrno = CSYSERR;
-           yaz_set_errno(EEXIST); /* Not a socket (File exists) */
-           return -1;
-       }
-       if((socket_out = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
-           h->cerrno = CSYSERR;
-           return -1;
-       }
-       socket_unix.sun_family = AF_UNIX;
-       strncpy(socket_unix.sun_path, path, sizeof(socket_unix.sun_path));
-       if(connect(socket_out, (struct sockaddr *) &socket_unix, SUN_LEN(&socket_unix)) < 0) {
-           if(yaz_errno() == ECONNREFUSED) {
-               TRC (fprintf (stderr, "Socket exists but nobody is listening\n"));
-           } else {
-               h->cerrno = CSYSERR;
-               return -1;
-           }
-       } else {
-           close(socket_out);
-           h->cerrno = CSYSERR;
-           yaz_set_errno(EADDRINUSE);
-           return -1;
-       }
-       unlink(path);
+        struct sockaddr_un socket_unix;
+        int socket_out = -1;
+        if(! S_ISSOCK(stat_buf.st_mode)) {
+            h->cerrno = CSYSERR;
+            yaz_set_errno(EEXIST); /* Not a socket (File exists) */
+            return -1;
+        }
+        if((socket_out = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+            h->cerrno = CSYSERR;
+            return -1;
+        }
+        socket_unix.sun_family = AF_UNIX;
+        strncpy(socket_unix.sun_path, path, sizeof(socket_unix.sun_path));
+        if(connect(socket_out, (struct sockaddr *) &socket_unix, SUN_LEN(&socket_unix)) < 0) {
+            if(yaz_errno() == ECONNREFUSED) {
+                TRC (fprintf (stderr, "Socket exists but nobody is listening\n"));
+            } else {
+                h->cerrno = CSYSERR;
+                return -1;
+            }
+        } else {
+            close(socket_out);
+            h->cerrno = CSYSERR;
+            yaz_set_errno(EADDRINUSE);
+            return -1;
+        }
+        unlink(path);
     }
 
     if (bind(h->iofile, (struct sockaddr *) addr, SUN_LEN((struct sockaddr_un *)addr)))
     {
-       h->cerrno = CSYSERR;
-       return -1;
+        h->cerrno = CSYSERR;
+        return -1;
     }
     chown(path, sp->uid, sp->gid);
     chmod(path, sp->umask != -1 ? sp->umask : 0666);
     if (mode == CS_SERVER && listen(h->iofile, 100) < 0)
     {
-       h->cerrno = CSYSERR;
-       return -1;
+        h->cerrno = CSYSERR;
+        return -1;
     }
     h->state = CS_ST_IDLE;
     h->event = CS_LISTEN;
@@ -432,7 +432,7 @@ static int unix_bind(COMSTACK h, void *address, int mode)
 
 static int unix_listen(COMSTACK h, char *raddr, int *addrlen,
                     int (*check_ip)(void *cd, const char *a, int len, int t),
-                   void *cd)
+                    void *cd)
 {
     struct sockaddr_un addr;
     YAZ_SOCKLEN_T len = sizeof(addr);
@@ -440,29 +440,29 @@ static int unix_listen(COMSTACK h, char *raddr, int *addrlen,
     TRC(fprintf(stderr, "unix_listen pid=%d\n", getpid()));
     if (h->state != CS_ST_IDLE)
     {
-       h->cerrno = CSOUTSTATE;
-       return -1;
+        h->cerrno = CSOUTSTATE;
+        return -1;
     }
     h->newfd = accept(h->iofile, (struct sockaddr*)&addr, &len);
     if (h->newfd < 0)
     {
-       if (
-           yaz_errno() == EWOULDBLOCK
+        if (
+            yaz_errno() == EWOULDBLOCK
 #ifdef EAGAIN
 #if EAGAIN != EWOULDBLOCK
-           || yaz_errno() == EAGAIN
+            || yaz_errno() == EAGAIN
 #endif
 #endif
-           )
-           h->cerrno = CSNODATA;
-       else
-           h->cerrno = CSYSERR;
-       return -1;
+            )
+            h->cerrno = CSNODATA;
+        else
+            h->cerrno = CSYSERR;
+        return -1;
     }
     if (addrlen && (size_t) (*addrlen) >= sizeof(struct sockaddr_un))
-       memcpy(raddr, &addr, *addrlen = sizeof(struct sockaddr_un));
+        memcpy(raddr, &addr, *addrlen = sizeof(struct sockaddr_un));
     else if (addrlen)
-       *addrlen = 0;
+        *addrlen = 0;
     h->state = CS_ST_INCON;
     return 0;
 }
@@ -475,60 +475,60 @@ static COMSTACK unix_accept(COMSTACK h)
     TRC(fprintf(stderr, "unix_accept\n"));
     if (h->state == CS_ST_INCON)
     {
-       if (!(cnew = (COMSTACK)xmalloc(sizeof(*cnew))))
-       {
-           h->cerrno = CSYSERR;
-           close(h->newfd);
-           h->newfd = -1;
-           return 0;
-       }
-       memcpy(cnew, h, sizeof(*h));
-       cnew->iofile = h->newfd;
-       cnew->io_pending = 0;
-       if (!(state = (unix_state *)
-             (cnew->cprivate = xmalloc(sizeof(unix_state)))))
-       {
-           h->cerrno = CSYSERR;
-           if (h->newfd != -1)
-           {
-               close(h->newfd);
-               h->newfd = -1;
-           }
-           return 0;
-       }
-       if (!(cnew->blocking&1) && 
+        if (!(cnew = (COMSTACK)xmalloc(sizeof(*cnew))))
+        {
+            h->cerrno = CSYSERR;
+            close(h->newfd);
+            h->newfd = -1;
+            return 0;
+        }
+        memcpy(cnew, h, sizeof(*h));
+        cnew->iofile = h->newfd;
+        cnew->io_pending = 0;
+        if (!(state = (unix_state *)
+              (cnew->cprivate = xmalloc(sizeof(unix_state)))))
+        {
+            h->cerrno = CSYSERR;
+            if (h->newfd != -1)
+            {
+                close(h->newfd);
+                h->newfd = -1;
+            }
+            return 0;
+        }
+        if (!(cnew->blocking&1) && 
             (fcntl(cnew->iofile, F_SETFL, O_NONBLOCK) < 0)
-           )
-       {
-           h->cerrno = CSYSERR;
-           if (h->newfd != -1)
-           {
-               close(h->newfd);
-               h->newfd = -1;
-           }
-           xfree (cnew);
-           xfree (state);
-           return 0;
-       }
-       h->newfd = -1;
-       state->altbuf = 0;
-       state->altsize = state->altlen = 0;
-       state->towrite = state->written = -1;
-       state->complete = st->complete;
-       memcpy(&state->addr, &st->addr, sizeof(state->addr));
-       cnew->state = CS_ST_ACCEPT;
-       cnew->event = CS_NONE;
-       h->state = CS_ST_IDLE;
-
-       h = cnew;
+            )
+        {
+            h->cerrno = CSYSERR;
+            if (h->newfd != -1)
+            {
+                close(h->newfd);
+                h->newfd = -1;
+            }
+            xfree (cnew);
+            xfree (state);
+            return 0;
+        }
+        h->newfd = -1;
+        state->altbuf = 0;
+        state->altsize = state->altlen = 0;
+        state->towrite = state->written = -1;
+        state->complete = st->complete;
+        memcpy(&state->addr, &st->addr, sizeof(state->addr));
+        cnew->state = CS_ST_ACCEPT;
+        cnew->event = CS_NONE;
+        h->state = CS_ST_IDLE;
+
+        h = cnew;
     }
     if (h->state == CS_ST_ACCEPT)
     {
     }
     else
     {
-       h->cerrno = CSOUTSTATE;
-       return 0;
+        h->cerrno = CSOUTSTATE;
+        return 0;
     }
     h->io_pending = 0;
     h->state = CS_ST_DATAXFER;
@@ -552,75 +552,75 @@ static int unix_get(COMSTACK h, char **buf, int *bufsize)
     TRC(fprintf(stderr, "unix_get: bufsize=%d\n", *bufsize));
     if (sp->altlen) /* switch buffers */
     {
-       TRC(fprintf(stderr, "  %d bytes in altbuf (0x%x)\n", sp->altlen,
-                   (unsigned) sp->altbuf));
-       tmpc = *buf;
-       tmpi = *bufsize;
-       *buf = sp->altbuf;
-       *bufsize = sp->altsize;
-       hasread = sp->altlen;
-       sp->altlen = 0;
-       sp->altbuf = tmpc;
-       sp->altsize = tmpi;
+        TRC(fprintf(stderr, "  %d bytes in altbuf (0x%x)\n", sp->altlen,
+                    (unsigned) sp->altbuf));
+        tmpc = *buf;
+        tmpi = *bufsize;
+        *buf = sp->altbuf;
+        *bufsize = sp->altsize;
+        hasread = sp->altlen;
+        sp->altlen = 0;
+        sp->altbuf = tmpc;
+        sp->altsize = tmpi;
     }
     h->io_pending = 0;
     while (!(berlen = (*sp->complete)((unsigned char *)*buf, hasread)))
     {
-       if (!*bufsize)
-       {
-           if (!(*buf = (char *)xmalloc(*bufsize = CS_UNIX_BUFCHUNK)))
-               return -1;
-       }
-       else if (*bufsize - hasread < CS_UNIX_BUFCHUNK)
-           if (!(*buf =(char *)xrealloc(*buf, *bufsize *= 2)))
-               return -1;
-       res = recv(h->iofile, *buf + hasread, CS_UNIX_BUFCHUNK, 0);
-       TRC(fprintf(stderr, "  recv res=%d, hasread=%d\n", res, hasread));
-       if (res < 0)
-       {
-           if (yaz_errno() == EWOULDBLOCK
+        if (!*bufsize)
+        {
+            if (!(*buf = (char *)xmalloc(*bufsize = CS_UNIX_BUFCHUNK)))
+                return -1;
+        }
+        else if (*bufsize - hasread < CS_UNIX_BUFCHUNK)
+            if (!(*buf =(char *)xrealloc(*buf, *bufsize *= 2)))
+                return -1;
+        res = recv(h->iofile, *buf + hasread, CS_UNIX_BUFCHUNK, 0);
+        TRC(fprintf(stderr, "  recv res=%d, hasread=%d\n", res, hasread));
+        if (res < 0)
+        {
+            if (yaz_errno() == EWOULDBLOCK
 #ifdef EAGAIN
 #if EAGAIN != EWOULDBLOCK
-               || yaz_errno() == EAGAIN
+                || yaz_errno() == EAGAIN
 #endif
 #endif
-               || yaz_errno() == EINPROGRESS
-               )
-           {
-               h->io_pending = CS_WANT_READ;
-               break;
-           }
-           else if (yaz_errno() == 0)
-               continue;
-           else
-               return -1;
-       }
-       else if (!res)
-           return hasread;
-       hasread += res;
+                || yaz_errno() == EINPROGRESS
+                )
+            {
+                h->io_pending = CS_WANT_READ;
+                break;
+            }
+            else if (yaz_errno() == 0)
+                continue;
+            else
+                return -1;
+        }
+        else if (!res)
+            return hasread;
+        hasread += res;
     }
     TRC (fprintf (stderr, "  Out of read loop with hasread=%d, berlen=%d\n",
-                 hasread, berlen));
+                  hasread, berlen));
     /* move surplus buffer (or everything if we didn't get a BER rec.) */
     if (hasread > berlen)
     {
-       tomove = req = hasread - berlen;
-       rest = tomove % CS_UNIX_BUFCHUNK;
-       if (rest)
-           req += CS_UNIX_BUFCHUNK - rest;
-       if (!sp->altbuf)
-       {
-           if (!(sp->altbuf = (char *)xmalloc(sp->altsize = req)))
-               return -1;
-       } else if (sp->altsize < req)
-           if (!(sp->altbuf =(char *)xrealloc(sp->altbuf, sp->altsize = req)))
-               return -1;
-       TRC(fprintf(stderr, "  Moving %d bytes to altbuf(0x%x)\n", tomove,
-                   (unsigned) sp->altbuf));
-       memcpy(sp->altbuf, *buf + berlen, sp->altlen = tomove);
+        tomove = req = hasread - berlen;
+        rest = tomove % CS_UNIX_BUFCHUNK;
+        if (rest)
+            req += CS_UNIX_BUFCHUNK - rest;
+        if (!sp->altbuf)
+        {
+            if (!(sp->altbuf = (char *)xmalloc(sp->altsize = req)))
+                return -1;
+        } else if (sp->altsize < req)
+            if (!(sp->altbuf =(char *)xrealloc(sp->altbuf, sp->altsize = req)))
+                return -1;
+        TRC(fprintf(stderr, "  Moving %d bytes to altbuf(0x%x)\n", tomove,
+                    (unsigned) sp->altbuf));
+        memcpy(sp->altbuf, *buf + berlen, sp->altlen = tomove);
     }
     if (berlen < CS_UNIX_BUFCHUNK - 1)
-       *(*buf + berlen) = '\0';
+        *(*buf + berlen) = '\0';
     return berlen ? berlen : 1;
 }
 
@@ -641,45 +641,45 @@ static int unix_put(COMSTACK h, char *buf, int size)
     h->event = CS_DATA;
     if (state->towrite < 0)
     {
-       state->towrite = size;
-       state->written = 0;
+        state->towrite = size;
+        state->written = 0;
     }
     else if (state->towrite != size)
     {
-       h->cerrno = CSWRONGBUF;
-       return -1;
+        h->cerrno = CSWRONGBUF;
+        return -1;
     }
     while (state->towrite > state->written)
     {
-       if ((res =
-            send(h->iofile, buf + state->written, size -
-                 state->written,
+        if ((res =
+             send(h->iofile, buf + state->written, size -
+                  state->written,
 #ifdef MSG_NOSIGNAL
-                 MSG_NOSIGNAL
+                  MSG_NOSIGNAL
 #else
-                 0
+                  0
 #endif
-                )) < 0)
-       {
-           if (
-               yaz_errno() == EWOULDBLOCK
+                 )) < 0)
+        {
+            if (
+                yaz_errno() == EWOULDBLOCK
 #ifdef EAGAIN
 #if EAGAIN != EWOULDBLOCK
-               || yaz_errno() == EAGAIN
+                || yaz_errno() == EAGAIN
 #endif
 #endif
-               )
-           {
-               TRC(fprintf(stderr, "  Flow control stop\n"));
-               h->io_pending = CS_WANT_WRITE;
-               return 1;
-           }
-           h->cerrno = CSYSERR;
-           return -1;
-       }
-       state->written += res;
-       TRC(fprintf(stderr, "  Wrote %d, written=%d, nbytes=%d\n",
-                   res, state->written, size));
+                )
+            {
+                TRC(fprintf(stderr, "  Flow control stop\n"));
+                h->io_pending = CS_WANT_WRITE;
+                return 1;
+            }
+            h->cerrno = CSYSERR;
+            return -1;
+        }
+        state->written += res;
+        TRC(fprintf(stderr, "  Wrote %d, written=%d, nbytes=%d\n",
+                    res, state->written, size));
     }
     state->towrite = state->written = -1;
     TRC(fprintf(stderr, "  Ok\n"));
@@ -693,10 +693,10 @@ static int unix_close(COMSTACK h)
     TRC(fprintf(stderr, "unix_close\n"));
     if (h->iofile != -1)
     {
-       close(h->iofile);
+        close(h->iofile);
     }
     if (sp->altbuf)
-       xfree(sp->altbuf);
+        xfree(sp->altbuf);
     xfree(sp);
     xfree(h);
     return 0;
@@ -715,15 +715,23 @@ static int unix_set_blocking(COMSTACK p, int blocking)
     unsigned long flag;
 
     if (p->blocking == blocking)
-       return 1;
+        return 1;
     flag = fcntl(p->iofile, F_GETFL, 0);
     if(!blocking)
-       flag = flag & ~O_NONBLOCK;
+        flag = flag & ~O_NONBLOCK;
     else
-       flag = flag | O_NONBLOCK;
+        flag = flag | O_NONBLOCK;
     if (fcntl(p->iofile, F_SETFL, flag) < 0)
-       return 0;
+        return 0;
     p->blocking = blocking;
     return 1;
 }
 #endif /* WIN32 */
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index d93e326..c52a0af 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: version.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: version.c,v 1.4 2005-06-25 15:46:06 adam Exp $
  */
 
 /**
@@ -29,3 +29,11 @@ unsigned long yaz_version(char *version_str, char *sys_str)
         strcpy(sys_str, "");
     return YAZ_VERSIONL;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 71c81d7..fa7ee5f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: waislen.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: waislen.c,v 1.4 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file waislen.c
@@ -20,14 +20,22 @@ int completeWAIS(const unsigned char *buf, int len)
     int i, lval = 0;
 
     if (len < 25)
-       return 0;
+        return 0;
     if (*buf != '0')
-       return 0;
+        return 0;
     /* calculate length */
     for (i = 0; i < 10; i++)
-       lval = lval * 10 + (buf[i] - '0');
+        lval = lval * 10 + (buf[i] - '0');
     lval += 25;
     if (len >= lval)
-       return lval;
+        return lval;
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index bca1636..9470477 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: wrbuf.c,v 1.7 2005-01-15 19:47:14 adam Exp $
+ * $Id: wrbuf.c,v 1.8 2005-06-25 15:46:06 adam Exp $
  */
 
 /**
@@ -27,7 +27,7 @@ WRBUF wrbuf_alloc(void)
     WRBUF n;
 
     if (!(n = (WRBUF)xmalloc(sizeof(*n))))
-       abort();
+        abort();
     n->buf = 0;
     n->size = 0;
     n->pos = 0;
@@ -37,7 +37,7 @@ WRBUF wrbuf_alloc(void)
 void wrbuf_free(WRBUF b, int free_buf)
 {
     if (free_buf && b->buf)
-       xfree(b->buf);
+        xfree(b->buf);
     xfree(b);
 }
 
@@ -51,15 +51,15 @@ int wrbuf_grow(WRBUF b, int minsize)
     int togrow;
 
     if (!b->size)
-       togrow = 1024;
+        togrow = 1024;
     else
-       togrow = b->size;
+        togrow = b->size;
     if (togrow < minsize)
-       togrow = minsize;
+        togrow = minsize;
     if (b->size && !(b->buf =(char *)xrealloc(b->buf, b->size += togrow)))
-       abort();
+        abort();
     else if (!b->size && !(b->buf = (char *)xmalloc(b->size = togrow)))
-       abort();
+        abort();
     return 0;
 }
 
@@ -68,7 +68,7 @@ int wrbuf_write(WRBUF b, const char *buf, int size)
     if (size <= 0)
         return 0;
     if (b->pos + size >= b->size)
-       wrbuf_grow(b, size);
+        wrbuf_grow(b, size);
     memcpy(b->buf + b->pos, buf, size);
     b->pos += size;
     return 0;
@@ -90,34 +90,34 @@ int wrbuf_xmlputs_n(WRBUF b, const char *cp, int size)
 {
     while (--size >= 0)
     {
-       /* only TAB,CR,LF of ASCII CTRL are allowed in XML 1.0! */
-       if (*cp >= 0 && *cp <= 31)
-           if (*cp != 9 && *cp != 10 && *cp != 13)
-           {
-               cp++;  /* we silently ignore (delete) these.. */
-               continue;
-           }
-       switch(*cp)
-       {
-       case '<':
-           wrbuf_puts(b, "&lt;");
-           break;
-       case '>':
-           wrbuf_puts(b, "&gt;");
-           break;
-       case '&':
-           wrbuf_puts(b, "&amp;");
-           break;
-       case '"':
-           wrbuf_puts(b, "&quot;");
-           break;
-       case '\'':
-           wrbuf_puts(b, "&apos;");
-           break;
-       default:
-           wrbuf_putc(b, *cp);
-       }
-       cp++;
+        /* only TAB,CR,LF of ASCII CTRL are allowed in XML 1.0! */
+        if (*cp >= 0 && *cp <= 31)
+            if (*cp != 9 && *cp != 10 && *cp != 13)
+            {
+                cp++;  /* we silently ignore (delete) these.. */
+                continue;
+            }
+        switch(*cp)
+        {
+        case '<':
+            wrbuf_puts(b, "&lt;");
+            break;
+        case '>':
+            wrbuf_puts(b, "&gt;");
+            break;
+        case '&':
+            wrbuf_puts(b, "&amp;");
+            break;
+        case '"':
+            wrbuf_puts(b, "&quot;");
+            break;
+        case '\'':
+            wrbuf_puts(b, "&apos;");
+            break;
+        default:
+            wrbuf_putc(b, *cp);
+        }
+        cp++;
     }
     wrbuf_putc(b, 0);
     (b->pos)--;
@@ -146,37 +146,37 @@ void wrbuf_printf(WRBUF b, const char *fmt, ...)
 }
 
 static int wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
-                              int size, int cdata)
+                               int size, int cdata)
 {
     if (cd)
     {
-       char outbuf[12];
-       size_t inbytesleft = size;
-       const char *inp = buf;
-       while (inbytesleft)
-       {
-           size_t outbytesleft = sizeof(outbuf);
-           char *outp = outbuf;
-           size_t r = yaz_iconv(cd, (char**) &inp,  &inbytesleft,
-                                &outp, &outbytesleft);
-           if (r == (size_t) (-1))
-           {
-               int e = yaz_iconv_error(cd);
-               if (e != YAZ_ICONV_E2BIG)
-                   break;
-           }
-           if (cdata)
-               wrbuf_xmlputs_n(b, outbuf, outp - outbuf);
-           else
-               wrbuf_write(b, outbuf, outp - outbuf);
-       }
+        char outbuf[12];
+        size_t inbytesleft = size;
+        const char *inp = buf;
+        while (inbytesleft)
+        {
+            size_t outbytesleft = sizeof(outbuf);
+            char *outp = outbuf;
+            size_t r = yaz_iconv(cd, (char**) &inp,  &inbytesleft,
+                                 &outp, &outbytesleft);
+            if (r == (size_t) (-1))
+            {
+                int e = yaz_iconv_error(cd);
+                if (e != YAZ_ICONV_E2BIG)
+                    break;
+            }
+            if (cdata)
+                wrbuf_xmlputs_n(b, outbuf, outp - outbuf);
+            else
+                wrbuf_write(b, outbuf, outp - outbuf);
+        }
     }
     else
     {
-       if (cdata)
-           wrbuf_xmlputs_n(b, buf, size);
-       else
-           wrbuf_write(b, buf, size);
+        if (cdata)
+            wrbuf_xmlputs_n(b, buf, size);
+        else
+            wrbuf_write(b, buf, size);
     }
     return wrbuf_len(b);
 }
@@ -191,3 +191,11 @@ int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd, const char *buf, int size)
     return wrbuf_iconv_write_x(b, cd, buf, size, 1);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index b430a28..70ecbde 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xcqlutil.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+/* $Id: xcqlutil.c,v 1.6 2005-06-25 15:46:06 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -64,59 +64,59 @@ static void prefixes(struct cql_node *cn,
     if (cn->u.st.index_uri)
     {
         pr_n("<prefixes>\n", pr, client_data, level);
-       head = 1;
+        head = 1;
 
-       pr_n("<prefix>\n", pr, client_data, level+2);
-       pr_n("<identifier>", pr, client_data, level+4);
-       pr_cdata(cn->u.st.index_uri, pr, client_data);
-       pr_n("</identifier>\n", pr, client_data, 0);
-       pr_n("</prefix>\n", pr, client_data, level+2);
+        pr_n("<prefix>\n", pr, client_data, level+2);
+        pr_n("<identifier>", pr, client_data, level+4);
+        pr_cdata(cn->u.st.index_uri, pr, client_data);
+        pr_n("</identifier>\n", pr, client_data, 0);
+        pr_n("</prefix>\n", pr, client_data, level+2);
     }
     if (cn->u.st.relation_uri && cn->u.st.relation)
     {
-       if (!head)
-           pr_n("<prefixes>\n", pr, client_data, level);
-       pr_n("<prefix>\n", pr, client_data, level+2);
-       pr_n("<name>", pr, client_data, level+4);
-       pr_cdata("rel", pr, client_data);
-       pr_n("</name>\n", pr, client_data, 0);
-       pr_n("<identifier>", pr, client_data, level+4);
-       pr_cdata(cn->u.st.relation_uri, pr, client_data);
-       pr_n("</identifier>\n", pr, client_data, 0);
-       pr_n("</prefix>\n", pr, client_data, level+2);
+        if (!head)
+            pr_n("<prefixes>\n", pr, client_data, level);
+        pr_n("<prefix>\n", pr, client_data, level+2);
+        pr_n("<name>", pr, client_data, level+4);
+        pr_cdata("rel", pr, client_data);
+        pr_n("</name>\n", pr, client_data, 0);
+        pr_n("<identifier>", pr, client_data, level+4);
+        pr_cdata(cn->u.st.relation_uri, pr, client_data);
+        pr_n("</identifier>\n", pr, client_data, 0);
+        pr_n("</prefix>\n", pr, client_data, level+2);
     }
     if (head)
         pr_n("</prefixes>\n", pr, client_data, level);
 }
                      
 static void cql_to_xml_mod(struct cql_node *m,
-                          void (*pr)(const char *buf, void *client_data),
-                          void *client_data, int level)
+                           void (*pr)(const char *buf, void *client_data),
+                           void *client_data, int level)
 {
     if (m)
     {
-       pr_n("<modifiers>\n", pr, client_data, level);
-       for (; m; m = m->u.st.modifiers)
-       {
-           pr_n("<modifier>\n", pr, client_data, level+2);
-           pr_n("<type>", pr, client_data, level+4);
-           pr_cdata(m->u.st.index, pr, client_data);
-           pr_n("</type>\n", pr, client_data, 0);
-           if (m->u.st.relation)
-           {
-               pr_n("<relation>", pr, client_data, level+4);
-               pr_cdata(m->u.st.relation, pr, client_data);
-               pr_n("</relation>\n", pr, client_data, 0);
-           }
-           if (m->u.st.term)
-           {
-               pr_n("<value>", pr, client_data, level+4);
-               pr_cdata(m->u.st.term, pr, client_data);
-               pr_n("</value>\n", pr, client_data, 0);
-           }
-           pr_n("</modifier>\n", pr, client_data, level+2);
-       }
-       pr_n("</modifiers>\n", pr, client_data, level);
+        pr_n("<modifiers>\n", pr, client_data, level);
+        for (; m; m = m->u.st.modifiers)
+        {
+            pr_n("<modifier>\n", pr, client_data, level+2);
+            pr_n("<type>", pr, client_data, level+4);
+            pr_cdata(m->u.st.index, pr, client_data);
+            pr_n("</type>\n", pr, client_data, 0);
+            if (m->u.st.relation)
+            {
+                pr_n("<relation>", pr, client_data, level+4);
+                pr_cdata(m->u.st.relation, pr, client_data);
+                pr_n("</relation>\n", pr, client_data, 0);
+            }
+            if (m->u.st.term)
+            {
+                pr_n("<value>", pr, client_data, level+4);
+                pr_cdata(m->u.st.term, pr, client_data);
+                pr_n("</value>\n", pr, client_data, 0);
+            }
+            pr_n("</modifier>\n", pr, client_data, level+2);
+        }
+        pr_n("</modifiers>\n", pr, client_data, level);
     }
 }
 
@@ -141,19 +141,19 @@ static void cql_to_xml_r(struct cql_node *cn,
         {
             pr_n("<relation>\n", pr, client_data, level+2);
             pr_n("<value>", pr, client_data, level+4);
-           if (cn->u.st.relation_uri)
-               pr_cdata("rel.", pr, client_data);
+            if (cn->u.st.relation_uri)
+                pr_cdata("rel.", pr, client_data);
             pr_cdata(cn->u.st.relation, pr, client_data);
             pr_n("</value>\n", pr, client_data, 0);
 
-           if (cn->u.st.relation_uri)
-           {
-               pr_n("<identifier>", pr, client_data, level+4);
-               pr_cdata(cn->u.st.relation_uri, pr, client_data);
-               pr_n("</identifier>\n", pr, client_data, 0);
-           }
-           cql_to_xml_mod(cn->u.st.modifiers,
-                          pr, client_data, level+4);
+            if (cn->u.st.relation_uri)
+            {
+                pr_n("<identifier>", pr, client_data, level+4);
+                pr_cdata(cn->u.st.relation_uri, pr, client_data);
+                pr_n("</identifier>\n", pr, client_data, 0);
+            }
+            cql_to_xml_mod(cn->u.st.modifiers,
+                           pr, client_data, level+4);
 
             pr_n("</relation>\n", pr, client_data, level+2);
         }
@@ -175,8 +175,8 @@ static void cql_to_xml_r(struct cql_node *cn,
             pr_cdata(cn->u.boolean.value, pr, client_data);
             pr_n("</value>\n", pr, client_data, 0);
 
-           cql_to_xml_mod(cn->u.boolean.modifiers,
-                          pr, client_data, level+4);
+            cql_to_xml_mod(cn->u.boolean.modifiers,
+                           pr, client_data, level+4);
 
             pr_n("</boolean>\n", pr, client_data, level+2);
         }
@@ -233,3 +233,11 @@ int cql_to_xml_buf(struct cql_node *cn, char *out, int max)
     return info.off;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 34554f8..6ff7b4a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * All rights reserved.
  *
- * $Id: xmalloc.c,v 1.5 2005-01-15 19:47:14 adam Exp $
+ * $Id: xmalloc.c,v 1.6 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file xmalloc.c
@@ -56,7 +56,7 @@ void *xmalloc_d(size_t nbytes, const char *file, int line)
     }
 
     if (!(res = (char*) malloc(nbytes + sizeof(*dinfo)+16*sizeof(char))))
-       return 0;
+        return 0;
     dinfo = (struct dmalloc_info *) res;
     strncpy (dinfo->file, file, sizeof(dinfo->file)-1);
     dinfo->file[sizeof(dinfo->file)-1] = '\0';
@@ -66,7 +66,7 @@ void *xmalloc_d(size_t nbytes, const char *file, int line)
     dinfo->prev = 0;
     dinfo->next = dmalloc_list;
     if (dinfo->next)
-       dinfo->next->prev = dinfo;
+        dinfo->next->prev = dinfo;
     dmalloc_list = dinfo;
     
     memcpy(res + sizeof(*dinfo), head, 8*sizeof(char));
@@ -80,25 +80,25 @@ void xfree_d(void *ptr, const char *file, int line)
     struct dmalloc_info *dinfo;
 
     if (!ptr)
-       return;
+        return;
     dinfo = (struct dmalloc_info *)
-       ((char*)ptr - 8*sizeof(char) - sizeof(*dinfo));
+        ((char*)ptr - 8*sizeof(char) - sizeof(*dinfo));
     if (memcmp(head, (char*) ptr - 8*sizeof(char), 8*sizeof(char)))
     {
-       yaz_log(YLOG_FATAL, "xfree_d bad head, %s:%d, %p", file, line, ptr);
+        yaz_log(YLOG_FATAL, "xfree_d bad head, %s:%d, %p", file, line, ptr);
         abort();
     }
     if (memcmp((char*) ptr + dinfo->len, tail, 8*sizeof(char)))
     {
-       yaz_log(YLOG_FATAL, "xfree_d bad tail, %s:%d, %p", file, line, ptr);
+        yaz_log(YLOG_FATAL, "xfree_d bad tail, %s:%d, %p", file, line, ptr);
         abort();
     }
     if (dinfo->prev)
-       dinfo->prev->next = dinfo->next;
+        dinfo->prev->next = dinfo->next;
     else
-       dmalloc_list = dinfo->next;
+        dmalloc_list = dinfo->next;
     if (dinfo->next)
-       dinfo->next->prev = dinfo->prev;
+        dinfo->next->prev = dinfo->prev;
     memcpy ((char*) ptr - 8*sizeof(char), freed, 8*sizeof(char));
     free(dinfo);
     return;
@@ -118,42 +118,42 @@ void *xrealloc_d(void *p, size_t nbytes, const char *file, int line)
 
     if (!ptr)
     {
-       if (!nbytes)
-           return 0;
-       res = (char *) malloc(nbytes + sizeof(*dinfo) + 16*sizeof(char));
+        if (!nbytes)
+            return 0;
+        res = (char *) malloc(nbytes + sizeof(*dinfo) + 16*sizeof(char));
     }
     else
     {
-       if (memcmp(head, ptr - 8*sizeof(char), 8*sizeof(char)))
-       {
-           yaz_log(YLOG_FATAL, "xrealloc_d bad head, %s:%d, %p",
-                   file, line, ptr);
-           abort();
-       }
-       dinfo = (struct dmalloc_info *) (ptr-8*sizeof(char) - sizeof(*dinfo));
-       if (memcmp(ptr + dinfo->len, tail, 8*sizeof(char)))
-       {
-           yaz_log(YLOG_FATAL, "xrealloc_d bad tail, %s:%d, %p",
-                   file, line, ptr);
-           abort();
-       }
-       if (dinfo->prev)
-           dinfo->prev->next = dinfo->next;
-       else
-           dmalloc_list = dinfo->next;
-       if (dinfo->next)
-           dinfo->next->prev = dinfo->prev;
-       
-       if (!nbytes)
-       {
-           free (dinfo);
-           return 0;
-       }
-       res = (char *)
-           realloc(dinfo, nbytes + sizeof(*dinfo) + 16*sizeof(char));
+        if (memcmp(head, ptr - 8*sizeof(char), 8*sizeof(char)))
+        {
+            yaz_log(YLOG_FATAL, "xrealloc_d bad head, %s:%d, %p",
+                    file, line, ptr);
+            abort();
+        }
+        dinfo = (struct dmalloc_info *) (ptr-8*sizeof(char) - sizeof(*dinfo));
+        if (memcmp(ptr + dinfo->len, tail, 8*sizeof(char)))
+        {
+            yaz_log(YLOG_FATAL, "xrealloc_d bad tail, %s:%d, %p",
+                    file, line, ptr);
+            abort();
+        }
+        if (dinfo->prev)
+            dinfo->prev->next = dinfo->next;
+        else
+            dmalloc_list = dinfo->next;
+        if (dinfo->next)
+            dinfo->next->prev = dinfo->prev;
+        
+        if (!nbytes)
+        {
+            free (dinfo);
+            return 0;
+        }
+        res = (char *)
+            realloc(dinfo, nbytes + sizeof(*dinfo) + 16*sizeof(char));
     }
     if (!res)
-       return 0;
+        return 0;
     dinfo = (struct dmalloc_info *) res;
     strncpy (dinfo->file, file, sizeof(dinfo->file)-1);
     dinfo->file[sizeof(dinfo->file)-1] = '\0';
@@ -163,7 +163,7 @@ void *xrealloc_d(void *p, size_t nbytes, const char *file, int line)
     dinfo->prev = 0;
     dinfo->next = dmalloc_list;
     if (dmalloc_list)
-       dmalloc_list->prev = dinfo;
+        dmalloc_list->prev = dinfo;
     dmalloc_list = dinfo;
     
     memcpy(res + sizeof(*dinfo), head, 8*sizeof(char));
@@ -185,7 +185,7 @@ void *xcalloc_d(size_t nmemb, size_t size, const char *file, int line)
     }
 
     if (!(res = (char*) calloc(1, nbytes+sizeof(*dinfo)+16*sizeof(char))))
-       return 0;
+        return 0;
     dinfo = (struct dmalloc_info *) res;
     strncpy (dinfo->file, file, sizeof(dinfo->file)-1);
     dinfo->file[sizeof(dinfo->file)-1] = '\0';
@@ -195,7 +195,7 @@ void *xcalloc_d(size_t nmemb, size_t size, const char *file, int line)
     dinfo->prev = 0;
     dinfo->next = dmalloc_list;
     if (dinfo->next)
-       dinfo->next->prev = dinfo;
+        dinfo->next->prev = dinfo;
     dmalloc_list = dinfo;
     
     memcpy(res + sizeof(*dinfo), head, 8*sizeof(char));
@@ -218,10 +218,10 @@ void xmalloc_trav_d(const char *file, int line)
     yaz_log (log_level, "malloc_trav %s:%d", file, line);
     while (dinfo)
     {
-       yaz_log (log_level, " %20s:%d p=%p size=%d", dinfo->file, dinfo->line,
-             ((char*) dinfo)+sizeof(*dinfo)+8*sizeof(char), dinfo->len);
-       size += dinfo->len;
-       dinfo = dinfo->next;
+        yaz_log (log_level, " %20s:%d p=%p size=%d", dinfo->file, dinfo->line,
+              ((char*) dinfo)+sizeof(*dinfo)+8*sizeof(char), dinfo->len);
+        size += dinfo->len;
+        dinfo = dinfo->next;
     }
     yaz_log (log_level, "total bytes %ld", (long) size);
 }
@@ -261,9 +261,9 @@ void *xrealloc_f (void *o, size_t size, const char *file, int line)
             "%s:%d: xrealloc(s=%d) %p -> %p", file, line, size, o, p);
     if (!p)
     {
-       yaz_log (YLOG_FATAL|YLOG_ERRNO, "Out of memory, realloc (%d bytes)",
-                size);
-       exit(1);
+        yaz_log (YLOG_FATAL|YLOG_ERRNO, "Out of memory, realloc (%d bytes)",
+                 size);
+        exit(1);
     }
     return p;
 }
@@ -333,3 +333,11 @@ void xfree_f(void *p, const char *file, int line)
         yaz_log (log_level, "%s:%d: xfree %p", file, line, p);
     xfree_d(p, file, line);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 739b8de..a74dd9d 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: yaz-ccl.c,v 1.3 2005-01-15 19:47:14 adam Exp $
+ * $Id: yaz-ccl.c,v 1.4 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file yaz-ccl.c
@@ -48,3 +48,11 @@ Z_AttributesPlusTerm *ccl_scan_query (ODR o, struct ccl_rpn_node *p)
     return q;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index db55135..435ed4e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: z3950oid.c,v 1.3 2005-06-24 19:56:52 adam Exp $
+ * $Id: z3950oid.c,v 1.4 2005-06-25 15:46:06 adam Exp $
  */
 
 #if HAVE_CONFIG_H
@@ -21,7 +21,7 @@ Odr_oid *yaz_oidval_to_z3950oid (ODR o, int oid_class, int oid_value)
     ident.value = (enum oid_value) oid_value;
 
     if (ident.value == VAL_NONE)
-       return 0;
+        return 0;
 
     return odr_oiddup(o, oid_ent_to_oid(&ident, oid));
 }
@@ -36,7 +36,7 @@ Odr_oid *yaz_str_to_z3950oid (ODR o, int oid_class, const char *str)
     ident.value = oid_getvalbyname(str);
 
     if (ident.value == VAL_NONE)
-       return 0;
+        return 0;
 
     return odr_oiddup(o, oid_ent_to_oid(&ident, oid));
 }
@@ -46,7 +46,7 @@ const char *yaz_z3950oid_to_str (Odr_oid *oid, int *oid_class)
     struct oident *ident = oid_getentbyoid(oid);
 
     if (!ident || ident->value == VAL_NONE)
-       return 0;
+        return 0;
     *oid_class = ident->oclass;
     return ident->desc;
 }
@@ -70,3 +70,11 @@ const char* yaz_z3950_oid_value_to_str(oid_value ov, oid_class oc)
         return "";
     }
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 293c2e6..88c92a5 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zgdu.c,v 1.12 2005-01-15 19:47:14 adam Exp $
+ * $Id: zgdu.c,v 1.13 2005-06-25 15:46:06 adam Exp $
  */
 
 /**
@@ -37,8 +37,8 @@ static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
             o->error = OHTTP;
             return 0;
         }
-       i++;
-       if (o->buf[i] == '\r')
+        i++;
+        if (o->buf[i] == '\r')
             break;
         for (po = i; ; i++)
         {
@@ -58,16 +58,16 @@ static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
         while (i < o->size-1 && o->buf[i] == ' ')
             i++;
         for (po = i; i < o->size-1 && o->buf[i] != '\r' ; i++)
-           ;
+            ;
         
         (*headers)->value = (char*) odr_malloc(o, i - po + 1);
         memcpy ((*headers)->value, o->buf + po, i - po);
         (*headers)->value[i - po] = '\0';
         
-       if (!strcasecmp((*headers)->name, "Transfer-Encoding")
-           &&
-           !strcasecmp((*headers)->value, "chunked"))
-           chunked = 1;
+        if (!strcasecmp((*headers)->name, "Transfer-Encoding")
+            &&
+            !strcasecmp((*headers)->value, "chunked"))
+            chunked = 1;
         headers = &(*headers)->next;
     }
     *headers = 0;
@@ -81,73 +81,73 @@ static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
 
     if (chunked)
     {
-       int off = 0;
-       
-       /* we know buffer will be smaller than o->size - i*/
-       *content_buf = (char*) odr_malloc(o, o->size - i);  
-       
-       while (1)
-       {
-           /* chunk length .. */
-           int chunk_len = 0;
-           for (; i  < o->size-2; i++)
-               if (isdigit(o->buf[i]))
-                   chunk_len = chunk_len * 16 + 
-                       (o->buf[i] - '0');
-               else if (isupper(o->buf[i]))
-                   chunk_len = chunk_len * 16 + 
-                       (o->buf[i] - ('A'-10));
-               else if (islower(o->buf[i]))
-                   chunk_len = chunk_len * 16 + 
-                       (o->buf[i] - ('a'-10));
-               else
-                   break;
-           /* chunk extension ... */
-           while (o->buf[i] != '\r' && o->buf[i+1] != '\n')
-           {
-               if (i >= o->size-2)
-               {
-                   o->error = OHTTP;
-                   return 0;
-               }
-               i++;
-           }
-           i += 2;  /* skip CRLF */
-           if (chunk_len == 0)
-               break;
-           if (chunk_len < 0 || off + chunk_len > o->size)
-           {
-               o->error = OHTTP;
-               return 0;
-           }
-           /* copy chunk .. */
-           memcpy (*content_buf + off, o->buf + i, chunk_len);
-           i += chunk_len + 2; /* skip chunk+CRLF */
-           off += chunk_len;
-       }
-       if (!off)
-           *content_buf = 0;
-       *content_len = off;
+        int off = 0;
+        
+        /* we know buffer will be smaller than o->size - i*/
+        *content_buf = (char*) odr_malloc(o, o->size - i);  
+        
+        while (1)
+        {
+            /* chunk length .. */
+            int chunk_len = 0;
+            for (; i  < o->size-2; i++)
+                if (isdigit(o->buf[i]))
+                    chunk_len = chunk_len * 16 + 
+                        (o->buf[i] - '0');
+                else if (isupper(o->buf[i]))
+                    chunk_len = chunk_len * 16 + 
+                        (o->buf[i] - ('A'-10));
+                else if (islower(o->buf[i]))
+                    chunk_len = chunk_len * 16 + 
+                        (o->buf[i] - ('a'-10));
+                else
+                    break;
+            /* chunk extension ... */
+            while (o->buf[i] != '\r' && o->buf[i+1] != '\n')
+            {
+                if (i >= o->size-2)
+                {
+                    o->error = OHTTP;
+                    return 0;
+                }
+                i++;
+            }
+            i += 2;  /* skip CRLF */
+            if (chunk_len == 0)
+                break;
+            if (chunk_len < 0 || off + chunk_len > o->size)
+            {
+                o->error = OHTTP;
+                return 0;
+            }
+            /* copy chunk .. */
+            memcpy (*content_buf + off, o->buf + i, chunk_len);
+            i += chunk_len + 2; /* skip chunk+CRLF */
+            off += chunk_len;
+        }
+        if (!off)
+            *content_buf = 0;
+        *content_len = off;
     }
     else
     {
-       if (i > o->size)
-       {
-           o->error = OHTTP;
-           return 0;
-       }
-       else if (i == o->size)
-       {
-           *content_buf = 0;
-           *content_len = 0;
-       }
-       else 
-       {
-           *content_len = o->size - i;
-           *content_buf = (char*) odr_malloc(o, *content_len + 1);
-           memcpy(*content_buf, o->buf + i, *content_len);
-           (*content_buf)[*content_len] = '\0';
-       }
+        if (i > o->size)
+        {
+            o->error = OHTTP;
+            return 0;
+        }
+        else if (i == o->size)
+        {
+            *content_buf = 0;
+            *content_len = 0;
+        }
+        else 
+        {
+            *content_len = o->size - i;
+            *content_buf = (char*) odr_malloc(o, *content_len + 1);
+            memcpy(*content_buf, o->buf + i, *content_len);
+            (*content_buf)[*content_len] = '\0';
+        }
     }
     return 1;
 }
@@ -253,12 +253,12 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
         {
             int i, po;
             Z_HTTP_Response *hr;
-           (*p)->which = Z_GDU_HTTP_Response;
+            (*p)->which = Z_GDU_HTTP_Response;
 
             hr = (*p)->u.HTTP_Response = (Z_HTTP_Response *)
                 odr_malloc(o, sizeof(*hr));
             hr->content_buf = 0;
-           hr->content_len = 0;
+            hr->content_len = 0;
 
             po = i = 5;
             while (i < o->size-2 && o->buf[i] != ' ' && o->buf[i] != '\r')
@@ -293,7 +293,7 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
             int i, po;
             Z_HTTP_Request *hr;
 
-           (*p)->which = Z_GDU_HTTP_Request;
+            (*p)->which = Z_GDU_HTTP_Request;
             hr = (*p)->u.HTTP_Request = 
                 (Z_HTTP_Request *) odr_malloc(o, sizeof(*hr));
 
@@ -346,7 +346,7 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
         }
         else
         {
-           (*p)->which = Z_GDU_Z3950;
+            (*p)->which = Z_GDU_Z3950;
             return z_APDU(o, &(*p)->u.z3950, opt, 0);
         }
     }
@@ -368,7 +368,7 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
             {
                 char lstr[60];
                 sprintf(lstr, "Content-Length: %d\r\n",
-                       (*p)->u.HTTP_Response->content_len);
+                        (*p)->u.HTTP_Response->content_len);
                 odr_write(o, (unsigned char *) lstr, strlen(lstr));
             }
             for (h = (*p)->u.HTTP_Response->headers; h; h = h->next)
@@ -386,7 +386,7 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
             if (o->direction == ODR_PRINT)
             {
                 odr_printf(o, "-- HTTP response:\n%.*s\n", o->top - top0,
-                          o->buf + top0);
+                           o->buf + top0);
                 odr_printf(o, "-- \n");
             }
             break;
@@ -406,7 +406,7 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
             {
                 char lstr[60];
                 sprintf(lstr, "Content-Length: %d\r\n",
-                       (*p)->u.HTTP_Request->content_len);
+                        (*p)->u.HTTP_Request->content_len);
                 odr_write(o, (unsigned char *) lstr, strlen(lstr));
             }
             for (h = (*p)->u.HTTP_Request->headers; h; h = h->next)
@@ -435,3 +435,11 @@ int z_GDU (ODR o, Z_GDU **p, int opt, const char *name)
     return 1;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 01a6330..27d243a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zget.c,v 1.10 2005-01-27 09:06:12 adam Exp $
+ * $Id: zget.c,v 1.11 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file zget.c
@@ -19,7 +19,7 @@ Z_InitRequest *zget_InitRequest(ODR o)
     r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options));
     ODR_MASK_ZERO(r->options);
     r->protocolVersion = (Odr_bitmask *)
-       odr_malloc(o, sizeof(*r->protocolVersion));
+        odr_malloc(o, sizeof(*r->protocolVersion));
 
     ODR_MASK_SET(r->options, Z_Options_search);
     ODR_MASK_SET(r->options, Z_Options_present);
@@ -41,7 +41,7 @@ Z_InitRequest *zget_InitRequest(ODR o)
 #ifdef YAZ_OS
     " " YAZ_OS
 #endif
-       ;
+        ;
     r->userInformationField = 0;
     r->otherInfo = 0;
     return r;
@@ -68,7 +68,7 @@ Z_InitResponse *zget_InitResponse(ODR o)
 #ifdef YAZ_OS
     " " YAZ_OS
 #endif
-       ;
+        ;
     r->userInformationField = 0;
     r->otherInfo = 0;
     return r;
@@ -147,7 +147,7 @@ Z_PresentResponse *zget_PresentResponse(ODR o)
 Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o)
 {
     Z_DeleteResultSetRequest *r = (Z_DeleteResultSetRequest *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->deleteFunction = odr_intdup(o, Z_DeleteResultSetRequest_list);
@@ -160,7 +160,7 @@ Z_DeleteResultSetRequest *zget_DeleteResultSetRequest(ODR o)
 Z_DeleteResultSetResponse *zget_DeleteResultSetResponse(ODR o)
 {
     Z_DeleteResultSetResponse *r = (Z_DeleteResultSetResponse *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
     
     r->referenceId = 0;
     r->deleteOperationStatus = odr_intdup(o, Z_DeleteStatus_success);
@@ -206,7 +206,7 @@ Z_ScanResponse *zget_ScanResponse(ODR o)
 Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o)
 {
     Z_TriggerResourceControlRequest *r = (Z_TriggerResourceControlRequest *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
     
     r->referenceId = 0;
     r->requestedAction = odr_intdup(o, Z_TriggerResourceControlRequest_resourceReport);
@@ -219,7 +219,7 @@ Z_TriggerResourceControlRequest *zget_TriggerResourceControlRequest(ODR o)
 Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o)
 {
     Z_ResourceControlRequest *r = (Z_ResourceControlRequest *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->suspendedFlag = 0;
@@ -234,7 +234,7 @@ Z_ResourceControlRequest *zget_ResourceControlRequest(ODR o)
 Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o)
 {
     Z_ResourceControlResponse *r = (Z_ResourceControlResponse *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->continueFlag = odr_intdup(o, 1);
@@ -246,7 +246,7 @@ Z_ResourceControlResponse *zget_ResourceControlResponse(ODR o)
 Z_AccessControlRequest *zget_AccessControlRequest(ODR o)
 {
     Z_AccessControlRequest *r = (Z_AccessControlRequest *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->which = Z_AccessControlRequest_simpleForm;
@@ -258,7 +258,7 @@ Z_AccessControlRequest *zget_AccessControlRequest(ODR o)
 Z_AccessControlResponse *zget_AccessControlResponse(ODR o)
 {
     Z_AccessControlResponse *r = (Z_AccessControlResponse *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->which = Z_AccessControlResponse_simpleForm;
@@ -296,7 +296,7 @@ Z_Close *zget_Close(ODR o)
 Z_ResourceReportRequest *zget_ResourceReportRequest(ODR o)
 {
     Z_ResourceReportRequest *r = (Z_ResourceReportRequest *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->opId = 0;
@@ -308,7 +308,7 @@ Z_ResourceReportRequest *zget_ResourceReportRequest(ODR o)
 Z_ResourceReportResponse *zget_ResourceReportResponse(ODR o)
 {
     Z_ResourceReportResponse *r = (Z_ResourceReportResponse *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->resourceReportStatus = odr_intdup(o, Z_ResourceReportResponse_success);
@@ -345,7 +345,7 @@ Z_SortResponse *zget_SortResponse(ODR o)
 Z_ExtendedServicesRequest *zget_ExtendedServicesRequest(ODR o)
 {
     Z_ExtendedServicesRequest *r = (Z_ExtendedServicesRequest *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->function = odr_intdup(o, Z_ExtendedServicesRequest_create);
@@ -365,7 +365,7 @@ Z_ExtendedServicesRequest *zget_ExtendedServicesRequest(ODR o)
 Z_ExtendedServicesResponse *zget_ExtendedServicesResponse(ODR o)
 {
     Z_ExtendedServicesResponse *r = (Z_ExtendedServicesResponse *)
-       odr_malloc(o, sizeof(*r));
+        odr_malloc(o, sizeof(*r));
 
     r->referenceId = 0;
     r->operationStatus = odr_intdup(o, Z_ExtendedServicesResponse_done);
@@ -486,7 +486,7 @@ Z_APDU *zget_APDU(ODR o, int which)
         break;
     case Z_APDU_extendedServicesResponse:
         r->u.extendedServicesResponse = zget_ExtendedServicesResponse(o);
-       break;
+        break;
     case Z_APDU_duplicateDetectionRequest:
         r->u.duplicateDetectionRequest = zget_DuplicateDetectionRequest(o);
         break;
@@ -494,16 +494,16 @@ Z_APDU *zget_APDU(ODR o, int which)
         r->u.duplicateDetectionResponse = zget_DuplicateDetectionResponse(o);
         break;
     default:
-       return 0;
+        return 0;
     }
     return r;
 }
 
 Z_DefaultDiagFormat *zget_DefaultDiagFormat(ODR o, int error,
-                                           const char *addinfo)
+                                            const char *addinfo)
 {
     Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) 
-       odr_malloc (o, sizeof(*dr));
+        odr_malloc (o, sizeof(*dr));
     
     dr->diagnosticSetId = yaz_oidval_to_z3950oid (o, CLASS_DIAGSET, VAL_BIB1);
     dr->condition = odr_intdup(o, error);
@@ -531,15 +531,15 @@ Z_DiagRecs *zget_DiagRecs(ODR o, int error, const char *addinfo)
 }
 
 Z_NamePlusRecord *zget_surrogateDiagRec(ODR o, const char *dbname,
-                                       int error, const char *addinfo)
+                                        int error, const char *addinfo)
 {
     Z_NamePlusRecord *rec = (Z_NamePlusRecord *) odr_malloc (o, sizeof(*rec));
     Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (o, sizeof(*drec));
     
     if (dbname)
-       rec->databaseName = odr_strdup(o, dbname);
+        rec->databaseName = odr_strdup(o, dbname);
     else
-       rec->databaseName = 0;
+        rec->databaseName = 0;
     rec->which = Z_NamePlusRecord_surrogateDiagnostic;
     rec->u.surrogateDiagnostic = drec;
     drec->which = Z_DiagRec_defaultFormat;
@@ -597,7 +597,7 @@ Z_External *zget_init_diagnostics(ODR odr, int error, const char *addinfo)
 }
 
 Z_External *zget_init_diagnostics_octet(ODR odr, int error,
-                                       const char *addinfo)
+                                        const char *addinfo)
 {
     Z_External *x, *x2;
     oident oid;
@@ -663,3 +663,11 @@ Z_External *zget_init_diagnostics_octet(ODR odr, int error,
     return x;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index bd86ed6..3547e0b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-c.c,v 1.44 2005-06-21 07:33:09 adam Exp $
+ * $Id: zoom-c.c,v 1.45 2005-06-25 15:46:06 adam Exp $
  */
 /**
  * \file zoom-c.c
@@ -57,8 +57,8 @@ static void initlog()
     if (!log_level_initialized)
     {
         log_api = yaz_log_module_level("zoom");
-       log_details = yaz_log_module_level("zoomdetails");
-       log_level_initialized = 1;
+        log_details = yaz_log_module_level("zoomdetails");
+        log_level_initialized = 1;
     }
 }
 
@@ -80,13 +80,13 @@ static void ZOOM_connection_put_event (ZOOM_connection c, ZOOM_Event event)
 {
     if (c->m_queue_back)
     {
-       c->m_queue_back->prev = event;
-       assert (c->m_queue_front);
+        c->m_queue_back->prev = event;
+        assert (c->m_queue_front);
     }
     else
     {
-       assert (!c->m_queue_front);
-       c->m_queue_front = event;
+        assert (!c->m_queue_front);
+        c->m_queue_front = event;
     }
     event->next = c->m_queue_back;
     event->prev = 0;
@@ -99,17 +99,17 @@ static ZOOM_Event ZOOM_connection_get_event(ZOOM_connection c)
     if (!event)
     {
         c->last_event = ZOOM_EVENT_NONE;
-       return 0;
+        return 0;
     }
     assert (c->m_queue_back);
     c->m_queue_front = event->prev;
     if (c->m_queue_front)
     {
-       assert (c->m_queue_back);
-       c->m_queue_front->next = 0;
+        assert (c->m_queue_back);
+        c->m_queue_front->next = 0;
     }
     else
-       c->m_queue_back = 0;
+        c->m_queue_back = 0;
     c->last_event = event->kind;
     return event;
 }
@@ -128,9 +128,9 @@ static void set_dset_error (ZOOM_connection c, int error,
     {
         xfree(c->diagset);
         c->diagset = xstrdup(dset);
-       /* remove integer part from SRW diagset .. */
+        /* remove integer part from SRW diagset .. */
         if ((cp = strrchr(c->diagset, '/')))
-          *cp = '\0';
+           *cp = '\0';
     }
     if (addinfo && addinfo2)
     {
@@ -156,7 +156,7 @@ static void set_HTTP_error (ZOOM_connection c, int error,
 #endif
 
 static void set_ZOOM_error (ZOOM_connection c, int error,
-                           const char *addinfo)
+                            const char *addinfo)
 {
     set_dset_error(c, error, "ZOOM", addinfo, 0);
 }
@@ -183,7 +183,7 @@ ZOOM_task ZOOM_connection_add_task (ZOOM_connection c, int which)
 {
     ZOOM_task *taskp = &c->tasks;
     while (*taskp)
-       taskp = &(*taskp)->next;
+        taskp = &(*taskp)->next;
     *taskp = (ZOOM_task) xmalloc (sizeof(**taskp));
     (*taskp)->running = 0;
     (*taskp)->which = which;
@@ -211,15 +211,15 @@ void ZOOM_connection_remove_task (ZOOM_connection c)
 
     if (task)
     {
-       c->tasks = task->next;
-       switch (task->which)
-       {
-       case ZOOM_TASK_SEARCH:
-           ZOOM_resultset_destroy (task->u.search.resultset);
-           break;
-       case ZOOM_TASK_RETRIEVE:
-           ZOOM_resultset_destroy (task->u.retrieve.resultset);
-           break;
+        c->tasks = task->next;
+        switch (task->which)
+        {
+        case ZOOM_TASK_SEARCH:
+            ZOOM_resultset_destroy (task->u.search.resultset);
+            break;
+        case ZOOM_TASK_RETRIEVE:
+            ZOOM_resultset_destroy (task->u.retrieve.resultset);
+            break;
         case ZOOM_TASK_CONNECT:
             break;
         case ZOOM_TASK_SCAN:
@@ -228,14 +228,14 @@ void ZOOM_connection_remove_task (ZOOM_connection c)
         case ZOOM_TASK_PACKAGE:
             ZOOM_package_destroy (task->u.package);
             break;
-       case ZOOM_TASK_SORT:
-           ZOOM_resultset_destroy (task->u.sort.resultset);
-           ZOOM_query_destroy(task->u.sort.q);
-           break;
-       default:
-           assert (0);
-       }
-       xfree (task);
+        case ZOOM_TASK_SORT:
+            ZOOM_resultset_destroy (task->u.sort.resultset);
+            ZOOM_query_destroy(task->u.sort.q);
+            break;
+        default:
+            assert (0);
+        }
+        xfree (task);
     }
 }
 
@@ -244,7 +244,7 @@ static int ZOOM_connection_exec_task (ZOOM_connection c);
 void ZOOM_connection_remove_tasks (ZOOM_connection c)
 {
     while (c->tasks)
-       ZOOM_connection_remove_task(c);
+        ZOOM_connection_remove_task(c);
 }
 
 static ZOOM_record record_cache_lookup (ZOOM_resultset r, int pos);
@@ -308,14 +308,14 @@ static char **set_DatabaseNames (ZOOM_connection con, ZOOM_options options,
     if (!cp || !*cp)
     {
         if (strncmp (con->host_port, "unix:", 5) == 0)
-           cp = strchr(con->host_port+5, ':');
-       else
-           cp = strchr(con->host_port, '/');
-       if (cp)
-           cp++;
+            cp = strchr(con->host_port+5, ':');
+        else
+            cp = strchr(con->host_port, '/');
+        if (cp)
+            cp++;
     }
     if (!cp)
-       cp = "Default";
+        cp = "Default";
     nmem_strsplit(con->odr_out->mem, "+", cp,  &databaseNames, num);
     return databaseNames;
 }
@@ -339,7 +339,7 @@ ZOOM_connection_connect(ZOOM_connection c,
     initlog();
 
     yaz_log(log_api, "%p ZOOM_connection_connect host=%s portnum=%d",
-           c, host, portnum);
+            c, host, portnum);
 
     if (c->cs)
     {
@@ -352,56 +352,56 @@ ZOOM_connection_connect(ZOOM_connection c,
     val = ZOOM_options_get (c->options, "proxy");
     if (val && *val)
     {
-       yaz_log(log_details, "%p ZOOM_connection_connect proxy=%s", c, val);
-       c->proxy = xstrdup (val);
+        yaz_log(log_details, "%p ZOOM_connection_connect proxy=%s", c, val);
+        c->proxy = xstrdup (val);
     }
     else
-       c->proxy = 0;
+        c->proxy = 0;
 
     xfree (c->charset);
     val = ZOOM_options_get (c->options, "charset");
     if (val && *val)
     {
-       yaz_log(log_details, "%p ZOOM_connection_connect charset=%s", c, val);
-       c->charset = xstrdup (val);
+        yaz_log(log_details, "%p ZOOM_connection_connect charset=%s", c, val);
+        c->charset = xstrdup (val);
     }
     else
-       c->charset = 0;
+        c->charset = 0;
 
     xfree (c->lang);
     val = ZOOM_options_get (c->options, "lang");
     if (val && *val)
     {
-       yaz_log(log_details, "%p ZOOM_connection_connect lang=%s", c, val);
-       c->lang = xstrdup (val);
+        yaz_log(log_details, "%p ZOOM_connection_connect lang=%s", c, val);
+        c->lang = xstrdup (val);
     }
     else
-       c->lang = 0;
+        c->lang = 0;
 
     xfree (c->host_port);
     if (portnum)
     {
-       char hostn[128];
-       sprintf (hostn, "%.80s:%d", host, portnum);
-       c->host_port = xstrdup(hostn);
+        char hostn[128];
+        sprintf (hostn, "%.80s:%d", host, portnum);
+        c->host_port = xstrdup(hostn);
     }
     else
-       c->host_port = xstrdup(host);
+        c->host_port = xstrdup(host);
 
     ZOOM_options_set(c->options, "host", c->host_port);
 
     val = ZOOM_options_get (c->options, "cookie");
     if (val && *val)
     { 
-       yaz_log(log_details, "%p ZOOM_connection_connect cookie=%s", c, val);
-       c->cookie_out = xstrdup (val);
+        yaz_log(log_details, "%p ZOOM_connection_connect cookie=%s", c, val);
+        c->cookie_out = xstrdup (val);
     }
 
     val = ZOOM_options_get (c->options, "clientIP");
     if (val && *val)
     {
-       yaz_log(log_details, "%p ZOOM_connection_connect clientIP=%s",
-               c, val);
+        yaz_log(log_details, "%p ZOOM_connection_connect clientIP=%s",
+                c, val);
         c->client_IP = xstrdup (val);
     }
 
@@ -414,8 +414,8 @@ ZOOM_connection_connect(ZOOM_connection c,
 
     if (!c->async)
     {
-       while (ZOOM_event (1, &c))
-           ;
+        while (ZOOM_event (1, &c))
+            ;
     }
 }
 
@@ -438,14 +438,14 @@ ZOOM_API(void)
 ZOOM_query_destroy(ZOOM_query s)
 {
     if (!s)
-       return;
+        return;
 
     (s->refcount)--;
     yaz_log(log_details, "%p ZOOM_query_destroy count=%d", s, s->refcount);
     if (s->refcount == 0)
     {
-       odr_destroy (s->odr);
-       xfree (s);
+        odr_destroy (s->odr);
+        xfree (s);
     }
 }
 
@@ -458,9 +458,9 @@ ZOOM_query_prefix(ZOOM_query s, const char *str)
     s->z_query->u.type_1 =  p_query_rpn(s->odr, PROTO_Z3950, str);
     if (!s->z_query->u.type_1)
     {
-       yaz_log(log_details, "%p ZOOM_query_prefix str=%s failed", s, str);
-       s->z_query = 0;
-       return -1;
+        yaz_log(log_details, "%p ZOOM_query_prefix str=%s failed", s, str);
+        s->z_query = 0;
+        return -1;
     }
     yaz_log(log_details, "%p ZOOM_query_prefix str=%s", s, str);
     return 0;
@@ -495,9 +495,9 @@ ZOOM_query_sortby(ZOOM_query s, const char *criteria)
     s->sort_spec = yaz_sort_spec (s->odr, criteria);
     if (!s->sort_spec)
     {
-       yaz_log(log_details, "%p ZOOM_query_sortby criteria=%s failed",
-               s, criteria);
-       return -1;
+        yaz_log(log_details, "%p ZOOM_query_sortby criteria=%s failed",
+                s, criteria);
+        return -1;
     }
     yaz_log(log_details, "%p ZOOM_query_sortby criteria=%s", s, criteria);
     return 0;
@@ -510,12 +510,12 @@ ZOOM_connection_destroy(ZOOM_connection c)
 {
     ZOOM_resultset r;
     if (!c)
-       return;
+        return;
     yaz_log(log_api, "%p ZOOM_connection_destroy", c);
     if (c->cs)
-       cs_close (c->cs);
+        cs_close (c->cs);
     for (r = c->resultsets; r; r = r->next)
-       r->connection = 0;
+        r->connection = 0;
 
     xfree (c->buf_in);
     xfree (c->addinfo);
@@ -539,9 +539,9 @@ void ZOOM_resultset_addref (ZOOM_resultset r)
 {
     if (r)
     {
-       (r->refcount)++;
+        (r->refcount)++;
         yaz_log(log_details, "%p ZOOM_resultset_addref count=%d",
-               r, r->refcount);
+                r, r->refcount);
     }
 }
 
@@ -598,10 +598,10 @@ ZOOM_connection_search(ZOOM_connection c, ZOOM_query q)
     r->start = ZOOM_options_get_int(r->options, "start", 0);
     r->count = ZOOM_options_get_int(r->options, "count", 0);
     {
-       /* If "presentChunk" is defined use that; otherwise "step" */
-       const char *cp = ZOOM_options_get (r->options, "presentChunk");
-       r->step = ZOOM_options_get_int(r->options,
-                                      (cp != 0 ? "presentChunk": "step"), 0);
+        /* If "presentChunk" is defined use that; otherwise "step" */
+        const char *cp = ZOOM_options_get (r->options, "presentChunk");
+        r->step = ZOOM_options_get_int(r->options,
+                                       (cp != 0 ? "presentChunk": "step"), 0);
     }
     r->piggyback = ZOOM_options_get_bool (r->options, "piggyback", 1);
     cp = ZOOM_options_get (r->options, "setname");
@@ -638,23 +638,23 @@ ZOOM_connection_search(ZOOM_connection c, ZOOM_query q)
 
     if (!c->async)
     {
-       while (ZOOM_event (1, &c))
-           ;
+        while (ZOOM_event (1, &c))
+            ;
     }
     return r;
 }
 
 ZOOM_API(void)
     ZOOM_resultset_sort(ZOOM_resultset r,
-                       const char *sort_type, const char *sort_spec)
+                        const char *sort_type, const char *sort_spec)
 {
     ZOOM_connection c = r->connection;
     ZOOM_task task;
 
     yaz_log(log_api, "%p ZOOM_resultset_sort r=%p sort_type=%s sort_spec=%s",
-           r, r, sort_type, sort_spec);
+            r, r, sort_type, sort_spec);
     if (!c)
-       return;
+        return;
 
     if (c->host_port && c->proto == PROTO_HTTP)
     {
@@ -666,7 +666,7 @@ ZOOM_API(void)
         else
         {
             yaz_log(log_details, "%p ZOOM_resultset_sort: prepare reconnect",
-                   r);
+                    r);
             c->reconnect_ok = 1;
         }
     }
@@ -681,8 +681,8 @@ ZOOM_API(void)
 
     if (!c->async)
     {
-       while (ZOOM_event (1, &c))
-           ;
+        while (ZOOM_event (1, &c))
+            ;
     }
 }
 
@@ -693,12 +693,12 @@ ZOOM_API(void)
     
     for (rc = r->record_cache; rc; rc = rc->next)
     {
-       if (rc->rec.wrbuf_marc)
-           wrbuf_free (rc->rec.wrbuf_marc, 1);
-       if (rc->rec.wrbuf_iconv)
-           wrbuf_free (rc->rec.wrbuf_iconv, 1);
-       if (rc->rec.wrbuf_opac)
-           wrbuf_free (rc->rec.wrbuf_opac, 1);
+        if (rc->rec.wrbuf_marc)
+            wrbuf_free (rc->rec.wrbuf_marc, 1);
+        if (rc->rec.wrbuf_iconv)
+            wrbuf_free (rc->rec.wrbuf_iconv, 1);
+        if (rc->rec.wrbuf_opac)
+            wrbuf_free (rc->rec.wrbuf_opac, 1);
     }
     r->record_cache = 0;
 }
@@ -710,32 +710,32 @@ ZOOM_resultset_destroy(ZOOM_resultset r)
         return;
     (r->refcount)--;
     yaz_log(log_details, "%p ZOOM_resultset_destroy r=%p count=%d",
-           r, r, r->refcount);
+            r, r, r->refcount);
     if (r->refcount == 0)
     {
-       ZOOM_resultset_cache_reset(r);
-
-       if (r->connection)
-       {
-           /* remove ourselves from the resultsets in connection */
-           ZOOM_resultset *rp = &r->connection->resultsets;
-           while (1)
-           {
-               assert (*rp);   /* we must be in this list!! */
-               if (*rp == r)
-               {   /* OK, we're here - take us out of it */
-                   *rp = (*rp)->next;
-                   break;
-               }
-               rp = &(*rp)->next;
-           }
-       }
-       ZOOM_query_destroy (r->query);
-       ZOOM_options_destroy (r->options);
-       odr_destroy (r->odr);
+        ZOOM_resultset_cache_reset(r);
+
+        if (r->connection)
+        {
+            /* remove ourselves from the resultsets in connection */
+            ZOOM_resultset *rp = &r->connection->resultsets;
+            while (1)
+            {
+                assert (*rp);   /* we must be in this list!! */
+                if (*rp == r)
+                {   /* OK, we're here - take us out of it */
+                    *rp = (*rp)->next;
+                    break;
+                }
+                rp = &(*rp)->next;
+            }
+        }
+        ZOOM_query_destroy (r->query);
+        ZOOM_options_destroy (r->options);
+        odr_destroy (r->odr);
         xfree (r->setname);
         xfree (r->schema);
-       xfree (r);
+        xfree (r);
     }
 }
 
@@ -748,7 +748,7 @@ ZOOM_resultset_size (ZOOM_resultset r)
 static void do_close (ZOOM_connection c)
 {
     if (c->cs)
-       cs_close(c->cs);
+        cs_close(c->cs);
     c->cs = 0;
     c->mask = 0;
     c->state = STATE_IDLE;
@@ -762,12 +762,12 @@ static void ZOOM_resultset_retrieve (ZOOM_resultset r,
     const char *cp;
 
     if (!r)
-       return;
+        return;
     yaz_log(log_details, "%p ZOOM_resultset_retrieve force_sync=%d start=%d"
-           " count=%d", r, force_sync, start, count);
+            " count=%d", r, force_sync, start, count);
     c = r->connection;
     if (!c)
-       return;
+        return;
 
     if (c->host_port && c->proto == PROTO_HTTP)
     {
@@ -779,7 +779,7 @@ static void ZOOM_resultset_retrieve (ZOOM_resultset r,
         else
         {
             yaz_log(log_details, "%p ZOOM_resultset_retrieve: prepare "
-                   "reconnect", r);
+                    "reconnect", r);
             c->reconnect_ok = 1;
         }
     }
@@ -801,8 +801,8 @@ static void ZOOM_resultset_retrieve (ZOOM_resultset r,
     ZOOM_resultset_addref (r);
 
     if (!r->connection->async || force_sync)
-       while (r->connection && ZOOM_event (1, &r->connection))
-           ;
+        while (r->connection && ZOOM_event (1, &r->connection))
+            ;
 }
 
 ZOOM_API(void)
@@ -812,9 +812,9 @@ ZOOM_resultset_records (ZOOM_resultset r, ZOOM_record *recs,
     int force_present = 0;
 
     if (!r)
-       return ;
+        return ;
     yaz_log(log_api, "%p ZOOM_resultset_records r=%p start=%d count=%d",
-           r, r, start, count);
+            r, r, start, count);
     if (count && recs)
         force_present = 1;
     ZOOM_resultset_retrieve (r, force_present, start, count);
@@ -834,8 +834,8 @@ static void get_cert(ZOOM_connection c)
     if (cs_get_peer_certificate_x509(c->cs, &cert_buf, &cert_len))
     {
         ZOOM_connection_option_setl(c, "sslPeerCert",
-                                   cert_buf, cert_len);
-       xfree(cert_buf);
+                                    cert_buf, cert_len);
+        xfree(cert_buf);
     }
 }
 
@@ -845,14 +845,14 @@ static zoom_ret do_connect (ZOOM_connection c)
     const char *effective_host;
 
     if (c->proxy)
-       effective_host = c->proxy;
+        effective_host = c->proxy;
     else
-       effective_host = c->host_port;
+        effective_host = c->host_port;
 
     yaz_log(log_details, "%p do_connect effective_host=%s", c, effective_host);
 
     if (c->cs)
-       cs_close(c->cs);
+        cs_close(c->cs);
     c->cs = cs_create_host (effective_host, 0, &add);
 
     if (c->cs && c->cs->protocol == PROTO_HTTP)
@@ -879,7 +879,7 @@ static zoom_ret do_connect (ZOOM_connection c)
         {
             ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_CONNECT);
             ZOOM_connection_put_event(c, event);
-           get_cert(c);
+            get_cert(c);
             if (c->proto == PROTO_Z3950)
                 ZOOM_connection_send_init(c);
             else
@@ -912,14 +912,14 @@ static zoom_ret do_connect (ZOOM_connection c)
 int z3950_connection_socket(ZOOM_connection c)
 {
     if (c->cs)
-       return cs_fileno(c->cs);
+        return cs_fileno(c->cs);
     return -1;
 }
 
 int z3950_connection_mask(ZOOM_connection c)
 {
     if (c->cs)
-       return c->mask;
+        return c->mask;
     return 0;
 }
 
@@ -929,7 +929,7 @@ static void otherInfo_attach (ZOOM_connection c, Z_APDU *a, ODR out)
     for (i = 0; i<200; i++)
     {
         size_t len;
-       Z_OtherInformation **oi;
+        Z_OtherInformation **oi;
         char buf[80];
         const char *val;
         const char *cp;
@@ -951,8 +951,8 @@ static void otherInfo_attach (ZOOM_connection c, Z_APDU *a, ODR out)
         if (oidval == VAL_NONE)
             continue;
         
-       yaz_oi_APDU(a, &oi);
-       yaz_oi_set_string_oidval(oi, out, oidval, 1, cp+1);
+        yaz_oi_APDU(a, &oi);
+        yaz_oi_set_string_oidval(oi, out, oidval, 1, cp+1);
     }
 }
 
@@ -961,32 +961,32 @@ static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out)
     assert (a);
     if (c->cookie_out)
     {
-       Z_OtherInformation **oi;
-       yaz_oi_APDU(a, &oi);
-       yaz_oi_set_string_oidval(oi, out, VAL_COOKIE, 1, c->cookie_out);
+        Z_OtherInformation **oi;
+        yaz_oi_APDU(a, &oi);
+        yaz_oi_set_string_oidval(oi, out, VAL_COOKIE, 1, c->cookie_out);
     }
     if (c->client_IP)
     {
-       Z_OtherInformation **oi;
-       yaz_oi_APDU(a, &oi);
-       yaz_oi_set_string_oidval(oi, out, VAL_CLIENT_IP, 1, c->client_IP);
+        Z_OtherInformation **oi;
+        yaz_oi_APDU(a, &oi);
+        yaz_oi_set_string_oidval(oi, out, VAL_CLIENT_IP, 1, c->client_IP);
     }
     otherInfo_attach (c, a, out);
     if (!z_APDU(out, &a, 0, 0))
     {
-       FILE *outf = fopen("/tmp/apdu.txt", "a");
-       if (a && outf)
-       {
-           ODR odr_pr = odr_createmem(ODR_PRINT);
-           fprintf (outf, "a=%p\n", a);
-           odr_setprint(odr_pr, outf);
-           z_APDU(odr_pr, &a, 0, 0);
-           odr_destroy(odr_pr);
-       }
+        FILE *outf = fopen("/tmp/apdu.txt", "a");
+        if (a && outf)
+        {
+            ODR odr_pr = odr_createmem(ODR_PRINT);
+            fprintf (outf, "a=%p\n", a);
+            odr_setprint(odr_pr, outf);
+            z_APDU(odr_pr, &a, 0, 0);
+            odr_destroy(odr_pr);
+        }
         yaz_log(log_api, "%p encoding_APDU: encoding failed", c);
         set_ZOOM_error(c, ZOOM_ERROR_ENCODE, 0);
-       odr_reset(out);
-       return -1;
+        odr_reset(out);
+        return -1;
     }
     yaz_log(log_details, "%p encoding_APDU encoding OK", c);
     return 0;
@@ -997,7 +997,7 @@ static zoom_ret send_APDU (ZOOM_connection c, Z_APDU *a)
     ZOOM_Event event;
     assert (a);
     if (encode_APDU(c, a, c->odr_out))
-       return zoom_complete;
+        return zoom_complete;
     yaz_log(log_details, "%p send APDU type=%d", c, a->which);
     c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
     event = ZOOM_Event_create (ZOOM_EVENT_SEND_APDU);
@@ -1023,8 +1023,8 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c)
 
     /* support the pass for backwards compatibility */
     if (!auth_password)
-       auth_password = ZOOM_options_get (c->options, "pass");
-       
+        auth_password = ZOOM_options_get (c->options, "pass");
+        
     ODR_MASK_SET(ireq->options, Z_Options_search);
     ODR_MASK_SET(ireq->options, Z_Options_present);
     ODR_MASK_SET(ireq->options, Z_Options_scan);
@@ -1038,101 +1038,101 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c)
 
     /* Index Data's Z39.50 Implementor Id is 81 */
     ireq->implementationId = odr_prepend(c->odr_out,
-       ZOOM_options_get(c->options, "implementationId"),
-       odr_prepend(c->odr_out, "81", ireq->implementationId));
+        ZOOM_options_get(c->options, "implementationId"),
+        odr_prepend(c->odr_out, "81", ireq->implementationId));
 
     ireq->implementationName = odr_prepend(c->odr_out,
-       ZOOM_options_get(c->options, "implementationName"),
-       odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
+        ZOOM_options_get(c->options, "implementationName"),
+        odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
 
-    version = odr_strdup(c->odr_out, "$Revision: 1.44 $");
-    if (strlen(version) > 10)  /* check for unexpanded CVS strings */
-       version[strlen(version)-2] = '\0';
+    version = odr_strdup(c->odr_out, "$Revision: 1.45 $");
+    if (strlen(version) > 10)   /* check for unexpanded CVS strings */
+        version[strlen(version)-2] = '\0';
     ireq->implementationVersion = odr_prepend(c->odr_out,
-       ZOOM_options_get(c->options, "implementationVersion"),
-       odr_prepend(c->odr_out, &version[11], ireq->implementationVersion));
+        ZOOM_options_get(c->options, "implementationVersion"),
+        odr_prepend(c->odr_out, &version[11], ireq->implementationVersion));
 
     *ireq->maximumRecordSize =
-       ZOOM_options_get_int (c->options, "maximumRecordSize", 1024*1024);
+        ZOOM_options_get_int (c->options, "maximumRecordSize", 1024*1024);
     *ireq->preferredMessageSize =
-       ZOOM_options_get_int (c->options, "preferredMessageSize", 1024*1024);
+        ZOOM_options_get_int (c->options, "preferredMessageSize", 1024*1024);
     
     if (auth_groupId || auth_password)
     {
-       Z_IdPass *pass = (Z_IdPass *) odr_malloc(c->odr_out, sizeof(*pass));
-       int i = 0;
-       pass->groupId = 0;
-       if (auth_groupId && *auth_groupId)
-       {
-           pass->groupId = (char *)
+        Z_IdPass *pass = (Z_IdPass *) odr_malloc(c->odr_out, sizeof(*pass));
+        int i = 0;
+        pass->groupId = 0;
+        if (auth_groupId && *auth_groupId)
+        {
+            pass->groupId = (char *)
                 odr_malloc(c->odr_out, strlen(auth_groupId)+1);
-           strcpy(pass->groupId, auth_groupId);
-           i++;
-       }
-       pass->userId = 0;
-       if (auth_userId && *auth_userId)
-       {
-           pass->userId = (char *)
+            strcpy(pass->groupId, auth_groupId);
+            i++;
+        }
+        pass->userId = 0;
+        if (auth_userId && *auth_userId)
+        {
+            pass->userId = (char *)
                 odr_malloc(c->odr_out, strlen(auth_userId)+1);
-           strcpy(pass->userId, auth_userId);
-           i++;
-       }
-       pass->password = 0;
-       if (auth_password && *auth_password)
-       {
-           pass->password = (char *)
+            strcpy(pass->userId, auth_userId);
+            i++;
+        }
+        pass->password = 0;
+        if (auth_password && *auth_password)
+        {
+            pass->password = (char *)
                 odr_malloc(c->odr_out, strlen(auth_password)+1);
-           strcpy(pass->password, auth_password);
-           i++;
-       }
-       if (i)
-       {
-           auth->which = Z_IdAuthentication_idPass;
-           auth->u.idPass = pass;
-           ireq->idAuthentication = auth;
-       }
+            strcpy(pass->password, auth_password);
+            i++;
+        }
+        if (i)
+        {
+            auth->which = Z_IdAuthentication_idPass;
+            auth->u.idPass = pass;
+            ireq->idAuthentication = auth;
+        }
     }
     else if (auth_userId)
     {
-       auth->which = Z_IdAuthentication_open;
-       auth->u.open = (char *)
+        auth->which = Z_IdAuthentication_open;
+        auth->u.open = (char *)
             odr_malloc(c->odr_out, strlen(auth_userId)+1);
-       strcpy(auth->u.open, auth_userId);
-       ireq->idAuthentication = auth;
+        strcpy(auth->u.open, auth_userId);
+        ireq->idAuthentication = auth;
     }
     if (c->proxy)
-       yaz_oi_set_string_oidval(&ireq->otherInfo, c->odr_out,
-                                VAL_PROXY, 1, c->host_port);
+        yaz_oi_set_string_oidval(&ireq->otherInfo, c->odr_out,
+                                 VAL_PROXY, 1, c->host_port);
     if (c->charset || c->lang)
     {
-       Z_OtherInformation **oi;
-       Z_OtherInformationUnit *oi_unit;
-       
-       yaz_oi_APDU(apdu, &oi);
-       
-       if ((oi_unit = yaz_oi_update(oi, c->odr_out, NULL, 0, 0)))
-       {
+        Z_OtherInformation **oi;
+        Z_OtherInformationUnit *oi_unit;
+        
+        yaz_oi_APDU(apdu, &oi);
+        
+        if ((oi_unit = yaz_oi_update(oi, c->odr_out, NULL, 0, 0)))
+        {
             char **charsets_addresses = 0;
             char **langs_addresses = 0;
             int charsets_count = 0;
             int langs_count = 0;
-          
+           
             if (c->charset)
-               nmem_strsplit_blank(c->odr_out->mem, c->charset,
-                                   &charsets_addresses, &charsets_count);
+                nmem_strsplit_blank(c->odr_out->mem, c->charset,
+                                    &charsets_addresses, &charsets_count);
             if (c->lang)
-               nmem_strsplit_blank(c->odr_out->mem, c->lang,
-                                   &langs_addresses, &langs_count);
+                nmem_strsplit_blank(c->odr_out->mem, c->lang,
+                                    &langs_addresses, &langs_count);
             ODR_MASK_SET(ireq->options, Z_Options_negotiationModel);
             oi_unit->which = Z_OtherInfo_externallyDefinedInfo;
             oi_unit->information.externallyDefinedInfo =
                 yaz_set_proposal_charneg(c->odr_out,
-                                        (const char **) charsets_addresses,
-                                        charsets_count,
-                                        (const char **) langs_addresses,
-                                        langs_count, 
-                                        1);
-       }
+                                         (const char **) charsets_addresses,
+                                         charsets_count,
+                                         (const char **) langs_addresses,
+                                         langs_count, 
+                                         1);
+        }
     }
     assert (apdu);
     return send_APDU (c, apdu);
@@ -1222,7 +1222,7 @@ static zoom_ret ZOOM_connection_srw_send_search(ZOOM_connection c)
     const char *recordPacking = 0;
 
     if (c->error)                  /* don't continue on error */
-       return zoom_complete;
+        return zoom_complete;
     assert (c->tasks);
     if (c->tasks->which == ZOOM_TASK_SEARCH)
     {
@@ -1312,17 +1312,17 @@ static zoom_ret ZOOM_connection_send_search (ZOOM_connection c)
     yaz_log(log_details, "%p ZOOM_connection_send_search set=%p", c, r);
 
     elementSetName =
-       ZOOM_options_get (r->options, "elementSetName");
+        ZOOM_options_get (r->options, "elementSetName");
     smallSetElementSetName  =
-       ZOOM_options_get (r->options, "smallSetElementSetName");
+        ZOOM_options_get (r->options, "smallSetElementSetName");
     mediumSetElementSetName =
-       ZOOM_options_get (r->options, "mediumSetElementSetName");
+        ZOOM_options_get (r->options, "mediumSetElementSetName");
 
     if (!smallSetElementSetName)
-       smallSetElementSetName = elementSetName;
+        smallSetElementSetName = elementSetName;
 
     if (!mediumSetElementSetName)
-       mediumSetElementSetName = elementSetName;
+        mediumSetElementSetName = elementSetName;
 
     assert (r);
     assert (r->query);
@@ -1332,11 +1332,11 @@ static zoom_ret ZOOM_connection_send_search (ZOOM_connection c)
     if (!search_req->query)
     {
         set_ZOOM_error(c, ZOOM_ERROR_INVALID_QUERY, 0);
-       return zoom_complete;
+        return zoom_complete;
     }
 
     search_req->databaseNames =
-       set_DatabaseNames (c, r->options, &search_req->num_databaseNames);
+        set_DatabaseNames (c, r->options, &search_req->num_databaseNames);
 
     /* get syntax (no need to provide unless piggyback is in effect) */
     syntax = ZOOM_options_get (r->options, "preferredRecordSyntax");
@@ -1346,47 +1346,47 @@ static zoom_ret ZOOM_connection_send_search (ZOOM_connection c)
     mspn = ZOOM_options_get_int (r->options, "mediumSetPresentNumber", -1);
     if (lslb != -1 && ssub != -1 && mspn != -1)
     {
-       /* So're a Z39.50 expert? Let's hope you don't do sort */
-       *search_req->largeSetLowerBound = lslb;
-       *search_req->smallSetUpperBound = ssub;
-       *search_req->mediumSetPresentNumber = mspn;
+        /* So're a Z39.50 expert? Let's hope you don't do sort */
+        *search_req->largeSetLowerBound = lslb;
+        *search_req->smallSetUpperBound = ssub;
+        *search_req->mediumSetPresentNumber = mspn;
     }
     else if (r->start == 0 && r->count > 0
-            && r->piggyback && !r->r_sort_spec && !r->schema)
+             && r->piggyback && !r->r_sort_spec && !r->schema)
     {
-       /* Regular piggyback - do it unless we're going to do sort */
-       *search_req->largeSetLowerBound = 2000000000;
-       *search_req->smallSetUpperBound = 1;
-       *search_req->mediumSetPresentNumber = r->step>0 ? r->step : r->count;
+        /* Regular piggyback - do it unless we're going to do sort */
+        *search_req->largeSetLowerBound = 2000000000;
+        *search_req->smallSetUpperBound = 1;
+        *search_req->mediumSetPresentNumber = r->step>0 ? r->step : r->count;
     }
     else
     {
-       /* non-piggyback. Need not provide elementsets or syntaxes .. */
-       smallSetElementSetName = 0;
-       mediumSetElementSetName = 0;
-       syntax = 0;
+        /* non-piggyback. Need not provide elementsets or syntaxes .. */
+        smallSetElementSetName = 0;
+        mediumSetElementSetName = 0;
+        syntax = 0;
     }
     if (smallSetElementSetName && *smallSetElementSetName)
     {
-       Z_ElementSetNames *esn = (Z_ElementSetNames *)
+        Z_ElementSetNames *esn = (Z_ElementSetNames *)
             odr_malloc (c->odr_out, sizeof(*esn));
-       
-       esn->which = Z_ElementSetNames_generic;
-       esn->u.generic = odr_strdup (c->odr_out, smallSetElementSetName);
-       search_req->smallSetElementSetNames = esn;
+        
+        esn->which = Z_ElementSetNames_generic;
+        esn->u.generic = odr_strdup (c->odr_out, smallSetElementSetName);
+        search_req->smallSetElementSetNames = esn;
     }
     if (mediumSetElementSetName && *mediumSetElementSetName)
     {
-       Z_ElementSetNames *esn = (Z_ElementSetNames *)
+        Z_ElementSetNames *esn = (Z_ElementSetNames *)
             odr_malloc (c->odr_out, sizeof(*esn));
-       
-       esn->which = Z_ElementSetNames_generic;
-       esn->u.generic = odr_strdup (c->odr_out, mediumSetElementSetName);
-       search_req->mediumSetElementSetNames = esn;
+        
+        esn->which = Z_ElementSetNames_generic;
+        esn->u.generic = odr_strdup (c->odr_out, mediumSetElementSetName);
+        search_req->mediumSetElementSetNames = esn;
     }
     if (syntax)
-       search_req->preferredRecordSyntax =
-           yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, syntax);
+        search_req->preferredRecordSyntax =
+            yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, syntax);
     
     if (!r->setname)
     {
@@ -1408,14 +1408,14 @@ static zoom_ret ZOOM_connection_send_search (ZOOM_connection c)
             }
             r->setname = xstrdup (setname);
             yaz_log(log_details, "%p ZOOM_connection_send_search: allocating "
-                   "set %s", c, r->setname);
+                    "set %s", c, r->setname);
         }
         else
-       {
+        {
             yaz_log(log_details, "%p ZOOM_connection_send_search: using "
-                   "default set", c);
+                    "default set", c);
             r->setname = xstrdup ("default");
-       }
+        }
         ZOOM_options_set (r->options, "setname", r->setname);
     }
     search_req->resultSetName = odr_strdup(c->odr_out, r->setname);
@@ -1430,11 +1430,11 @@ static void response_default_diag(ZOOM_connection c, Z_DefaultDiagFormat *r)
     switch (r->which)
     {
     case Z_DefaultDiagFormat_v2Addinfo:
-       addinfo = r->u.v2Addinfo;
-       break;
+        addinfo = r->u.v2Addinfo;
+        break;
     case Z_DefaultDiagFormat_v3Addinfo:
-       addinfo = r->u.v3Addinfo;
-       break;
+        addinfo = r->u.v3Addinfo;
+        break;
     }
     xfree (c->addinfo);
     c->addinfo = 0;
@@ -1448,7 +1448,7 @@ static void response_diag(ZOOM_connection c, Z_DiagRec *p)
     if (p->which != Z_DiagRec_defaultFormat)
         set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
     else
-       response_default_diag(c, p->u.defaultFormat);
+        response_default_diag(c, p->u.defaultFormat);
 }
 
 ZOOM_API(ZOOM_record)
@@ -1461,7 +1461,7 @@ ZOOM_record_clone (ZOOM_record srec)
 
     odr_enc = odr_createmem(ODR_ENCODE);
     if (!z_NamePlusRecord (odr_enc, &srec->npr, 0, 0))
-       return 0;
+        return 0;
     buf = odr_getbuf (odr_enc, &size, 0);
     
     nrec = (ZOOM_record) xmalloc (sizeof(*nrec));
@@ -1499,21 +1499,21 @@ ZOOM_API(void)
 ZOOM_record_destroy (ZOOM_record rec)
 {
     if (!rec)
-       return;
+        return;
     if (rec->wrbuf_marc)
-       wrbuf_free (rec->wrbuf_marc, 1);
+        wrbuf_free (rec->wrbuf_marc, 1);
     if (rec->wrbuf_iconv)
-       wrbuf_free (rec->wrbuf_iconv, 1);
+        wrbuf_free (rec->wrbuf_iconv, 1);
     if (rec->wrbuf_opac)
-       wrbuf_free (rec->wrbuf_opac, 1);
+        wrbuf_free (rec->wrbuf_opac, 1);
     odr_destroy (rec->odr);
     xfree (rec);
 }
 
 static const char *marc_iconv_return(ZOOM_record rec, int marc_type,
-                                    int *len,
-                                    const char *buf, int sz,
-                                    const char *record_charset)
+                                     int *len,
+                                     const char *buf, int sz,
+                                     const char *record_charset)
 {
     char to[40];
     char from[40];
@@ -1524,51 +1524,51 @@ static const char *marc_iconv_return(ZOOM_record rec, int marc_type,
     strcpy(to, "UTF-8");
     if (record_charset && *record_charset)
     {
-       /* Use "from,to" or just "from" */
-       const char *cp = strchr(record_charset, ',');
-       int clen = strlen(record_charset);
-       if (cp && cp[1])
-       {
-           strncpy( to, cp+1, sizeof(to)-1);
-           to[sizeof(to)-1] = '\0';
-           clen = cp - record_charset;
-       }
-       if (clen > sizeof(from)-1)
-           clen = sizeof(from)-1;
-       
-       if (clen)
-           strncpy(from, record_charset, clen);
-       from[clen] = '\0';
+        /* Use "from,to" or just "from" */
+        const char *cp = strchr(record_charset, ',');
+        int clen = strlen(record_charset);
+        if (cp && cp[1])
+        {
+            strncpy( to, cp+1, sizeof(to)-1);
+            to[sizeof(to)-1] = '\0';
+            clen = cp - record_charset;
+        }
+        if (clen > sizeof(from)-1)
+            clen = sizeof(from)-1;
+        
+        if (clen)
+            strncpy(from, record_charset, clen);
+        from[clen] = '\0';
     }
 
     if (*from && *to)
     {
-       cd = yaz_iconv_open(to, from);
-       yaz_marc_iconv(mt, cd);
+        cd = yaz_iconv_open(to, from);
+        yaz_marc_iconv(mt, cd);
     }
 
     yaz_marc_xml(mt, marc_type);
     if (!rec->wrbuf_marc)
-       rec->wrbuf_marc = wrbuf_alloc();
+        rec->wrbuf_marc = wrbuf_alloc();
     wrbuf_rewind (rec->wrbuf_marc);
     if (yaz_marc_decode_wrbuf (mt, buf, sz, rec->wrbuf_marc) > 0)
     {
-       yaz_marc_destroy(mt);
-       if (cd)
-           yaz_iconv_close(cd);
-       if (len)
-           *len = wrbuf_len(rec->wrbuf_marc);
-       return wrbuf_buf(rec->wrbuf_marc);
+        yaz_marc_destroy(mt);
+        if (cd)
+            yaz_iconv_close(cd);
+        if (len)
+            *len = wrbuf_len(rec->wrbuf_marc);
+        return wrbuf_buf(rec->wrbuf_marc);
     }
     yaz_marc_destroy(mt);
     if (cd)
-       yaz_iconv_close(cd);
+        yaz_iconv_close(cd);
     return 0;
 }
 
 static const char *record_iconv_return(ZOOM_record rec, int *len,
-                                      const char *buf, int sz,
-                                      const char *record_charset)
+                                       const char *buf, int sz,
+                                       const char *record_charset)
 {
     char to[40];
     char from[40];
@@ -1578,56 +1578,56 @@ static const char *record_iconv_return(ZOOM_record rec, int *len,
     strcpy(to, "UTF-8");
     if (record_charset && *record_charset)
     {
-       /* Use "from,to" or just "from" */
-       const char *cp = strchr(record_charset, ',');
-       int clen = strlen(record_charset);
-       if (cp && cp[1])
-       {
-           strncpy( to, cp+1, sizeof(to)-1);
-           to[sizeof(to)-1] = '\0';
-           clen = cp - record_charset;
-       }
-       if (clen > sizeof(from)-1)
-           clen = sizeof(from)-1;
-       
-       if (clen)
-           strncpy(from, record_charset, clen);
-       from[clen] = '\0';
+        /* Use "from,to" or just "from" */
+        const char *cp = strchr(record_charset, ',');
+        int clen = strlen(record_charset);
+        if (cp && cp[1])
+        {
+            strncpy( to, cp+1, sizeof(to)-1);
+            to[sizeof(to)-1] = '\0';
+            clen = cp - record_charset;
+        }
+        if (clen > sizeof(from)-1)
+            clen = sizeof(from)-1;
+        
+        if (clen)
+            strncpy(from, record_charset, clen);
+        from[clen] = '\0';
     }
 
     if (*from && *to && (cd = yaz_iconv_open(to, from)))
     {
-       char outbuf[12];
-       size_t inbytesleft = sz;
-       const char *inp = buf;
-       
-       if (!rec->wrbuf_iconv)
-           rec->wrbuf_iconv = wrbuf_alloc();
-
-       wrbuf_rewind(rec->wrbuf_iconv);
-
-       while (inbytesleft)
-       {
-           size_t outbytesleft = sizeof(outbuf);
-           char *outp = outbuf;
-           size_t r = yaz_iconv (cd, (char**) &inp,
-                                 &inbytesleft, 
-                                 &outp, &outbytesleft);
-           if (r == (size_t) (-1))
-           {
-               int e = yaz_iconv_error(cd);
-               if (e != YAZ_ICONV_E2BIG)
-                   break;
-           }
-           wrbuf_write(rec->wrbuf_iconv, outbuf, outp - outbuf);
-       }
-       wrbuf_puts(rec->wrbuf_iconv, "");
-       buf = wrbuf_buf(rec->wrbuf_iconv);
-       sz = wrbuf_len(rec->wrbuf_iconv);
-       yaz_iconv_close(cd);
+        char outbuf[12];
+        size_t inbytesleft = sz;
+        const char *inp = buf;
+        
+        if (!rec->wrbuf_iconv)
+            rec->wrbuf_iconv = wrbuf_alloc();
+
+        wrbuf_rewind(rec->wrbuf_iconv);
+
+        while (inbytesleft)
+        {
+            size_t outbytesleft = sizeof(outbuf);
+            char *outp = outbuf;
+            size_t r = yaz_iconv (cd, (char**) &inp,
+                                  &inbytesleft, 
+                                  &outp, &outbytesleft);
+            if (r == (size_t) (-1))
+            {
+                int e = yaz_iconv_error(cd);
+                if (e != YAZ_ICONV_E2BIG)
+                    break;
+            }
+            wrbuf_write(rec->wrbuf_iconv, outbuf, outp - outbuf);
+        }
+        wrbuf_puts(rec->wrbuf_iconv, "");
+        buf = wrbuf_buf(rec->wrbuf_iconv);
+        sz = wrbuf_len(rec->wrbuf_iconv);
+        yaz_iconv_close(cd);
     }
     if (len)
-       *len = sz;
+        *len = sz;
     return buf;
 }
 
@@ -1642,75 +1642,75 @@ ZOOM_record_get (ZOOM_record rec, const char *type_spec, int *len)
     Z_NamePlusRecord *npr;
     
     if (len)
-       *len = 0; /* default return */
-       
+        *len = 0; /* default return */
+        
     if (!rec)
-       return 0;
+        return 0;
     npr = rec->npr;
     if (!npr)
-       return 0;
+        return 0;
 
     cp = type_spec;
     for (i = 0; cp[i] && i < sizeof(type)-1; i++)
     {
-       if (cp[i] == ';' || cp[i] == ' ')
-           break;
-       type[i] = cp[i];
+        if (cp[i] == ';' || cp[i] == ' ')
+            break;
+        type[i] = cp[i];
     }
     type[i] = '\0';
     charset[0] = '\0';
     while (type_spec[i] == ';')
     {
-       i++;
-       while (type_spec[i] == ' ')
-           i++;
-       if (!strncmp(type_spec+i, "charset=", 8))
-       {
-           int j = 0;
-           i = i + 8; /* skip charset= */
-           for (j = 0; type_spec[i]  && j < sizeof(charset)-1; i++, j++)
-           {
-               if (type_spec[i] == ';' || type_spec[i] == ' ')
-                   break;
-               charset[j] = cp[i];
-           }
-           charset[j] = '\0';
-       }
-       else if (!strncmp(type_spec+i, "xpath=", 6))
-       {
-           int j = 0; 
-           i = i + 6;
-           for (j = 0; type_spec[i] && j < sizeof(xpath)-1; i++, j++)
-               xpath[j] = cp[i];
-           xpath[j] = '\0';
-       } 
-       while (type_spec[i] == ' ')
-           i++;
+        i++;
+        while (type_spec[i] == ' ')
+            i++;
+        if (!strncmp(type_spec+i, "charset=", 8))
+        {
+            int j = 0;
+            i = i + 8; /* skip charset= */
+            for (j = 0; type_spec[i]  && j < sizeof(charset)-1; i++, j++)
+            {
+                if (type_spec[i] == ';' || type_spec[i] == ' ')
+                    break;
+                charset[j] = cp[i];
+            }
+            charset[j] = '\0';
+        }
+        else if (!strncmp(type_spec+i, "xpath=", 6))
+        {
+            int j = 0; 
+            i = i + 6;
+            for (j = 0; type_spec[i] && j < sizeof(xpath)-1; i++, j++)
+                xpath[j] = cp[i];
+            xpath[j] = '\0';
+        } 
+        while (type_spec[i] == ' ')
+            i++;
     }
     if (!strcmp (type, "database"))
     {
-       if (len)
+        if (len)
             *len = (npr->databaseName ? strlen(npr->databaseName) : 0);
-       return npr->databaseName;
+        return npr->databaseName;
     }
     else if (!strcmp (type, "syntax"))
     {
-        const char *desc = 0;  
-       if (npr->which == Z_NamePlusRecord_databaseRecord)
-       {
-           Z_External *r = (Z_External *) npr->u.databaseRecord;
-           oident *ent = oid_getentbyoid(r->direct_reference);
-           if (ent)
-               desc = ent->desc;
-       }
-       if (!desc)
+        const char *desc = 0;   
+        if (npr->which == Z_NamePlusRecord_databaseRecord)
+        {
+            Z_External *r = (Z_External *) npr->u.databaseRecord;
+            oident *ent = oid_getentbyoid(r->direct_reference);
+            if (ent)
+                desc = ent->desc;
+        }
+        if (!desc)
             desc = "none";
-       if (len)
+        if (len)
             *len = strlen(desc);
-       return desc;
+        return desc;
     }
     if (npr->which != Z_NamePlusRecord_databaseRecord)
-       return 0;
+        return 0;
 
     /* from now on - we have a database record .. */
     if (!strcmp (type, "render"))
@@ -1718,22 +1718,22 @@ ZOOM_record_get (ZOOM_record rec, const char *type_spec, int *len)
         Z_External *r = (Z_External *) npr->u.databaseRecord;
         oident *ent = oid_getentbyoid(r->direct_reference);
 
-       /* render bibliographic record .. */
-       if (r->which == Z_External_OPAC)
-       {
-           r = r->u.opac->bibliographicRecord;
-           if (!r)
-               return 0;
-           ent = oid_getentbyoid(r->direct_reference);
-       }
+        /* render bibliographic record .. */
+        if (r->which == Z_External_OPAC)
+        {
+            r = r->u.opac->bibliographicRecord;
+            if (!r)
+                return 0;
+            ent = oid_getentbyoid(r->direct_reference);
+        }
         if (r->which == Z_External_sutrs)
-           return record_iconv_return(rec, len,
-                                      (char*) r->u.sutrs->buf,
-                                      r->u.sutrs->len,
-                                      charset);
+            return record_iconv_return(rec, len,
+                                       (char*) r->u.sutrs->buf,
+                                       r->u.sutrs->len,
+                                       charset);
         else if (r->which == Z_External_octet)
         {
-           const char *ret_buf;
+            const char *ret_buf;
             switch (ent->value)
             {
             case VAL_SOIF:
@@ -1744,18 +1744,18 @@ ZOOM_record_get (ZOOM_record rec, const char *type_spec, int *len)
             case VAL_APPLICATION_XML:
                 break;
             default:
-               ret_buf = marc_iconv_return(
-                   rec, YAZ_MARC_LINE, len,
-                   (const char *) r->u.octet_aligned->buf,
-                   r->u.octet_aligned->len,
-                   charset);
-               if (ret_buf)
-                   return ret_buf;
+                ret_buf = marc_iconv_return(
+                    rec, YAZ_MARC_LINE, len,
+                    (const char *) r->u.octet_aligned->buf,
+                    r->u.octet_aligned->len,
+                    charset);
+                if (ret_buf)
+                    return ret_buf;
             }
-           return record_iconv_return(rec, len,
-                                      (const char *) r->u.octet_aligned->buf,
-                                      r->u.octet_aligned->len,
-                                      charset);
+            return record_iconv_return(rec, len,
+                                       (const char *) r->u.octet_aligned->buf,
+                                       r->u.octet_aligned->len,
+                                       charset);
         }
         else if (r->which == Z_External_grs1)
         {
@@ -1763,35 +1763,35 @@ ZOOM_record_get (ZOOM_record rec, const char *type_spec, int *len)
                 rec->wrbuf_marc = wrbuf_alloc();
             wrbuf_rewind (rec->wrbuf_marc);
             yaz_display_grs1(rec->wrbuf_marc, r->u.grs1, 0);
-           return record_iconv_return(rec, len,
-                                      wrbuf_buf(rec->wrbuf_marc),
-                                      wrbuf_len(rec->wrbuf_marc),
-                                      charset);
+            return record_iconv_return(rec, len,
+                                       wrbuf_buf(rec->wrbuf_marc),
+                                       wrbuf_len(rec->wrbuf_marc),
+                                       charset);
         }
-       return 0;
+        return 0;
     }
     else if (!strcmp (type, "xml") || !strcmp(type, "oai"))
     {
         Z_External *r = (Z_External *) npr->u.databaseRecord;
         oident *ent = oid_getentbyoid(r->direct_reference);
 
-       /* render bibliographic record .. */
-       if (r->which == Z_External_OPAC)
-       {
-           r = r->u.opac->bibliographicRecord;
-           if (!r)
-               return 0;
-           ent = oid_getentbyoid(r->direct_reference);
-       }
+        /* render bibliographic record .. */
+        if (r->which == Z_External_OPAC)
+        {
+            r = r->u.opac->bibliographicRecord;
+            if (!r)
+                return 0;
+            ent = oid_getentbyoid(r->direct_reference);
+        }
         
         if (r->which == Z_External_sutrs)
-           return record_iconv_return(rec, len,
-                                      (const char *) r->u.sutrs->buf,
-                                      r->u.sutrs->len,
-                                      charset);
+            return record_iconv_return(rec, len,
+                                       (const char *) r->u.sutrs->buf,
+                                       r->u.sutrs->len,
+                                       charset);
         else if (r->which == Z_External_octet)
         {
-           const char *ret_buf;
+            const char *ret_buf;
             int marc_decode_type = YAZ_MARC_MARCXML;
 
             if (!strcmp(type, "oai"))
@@ -1806,67 +1806,67 @@ ZOOM_record_get (ZOOM_record rec, const char *type_spec, int *len)
             case VAL_APPLICATION_XML:
                 break;
             default:
-               ret_buf = marc_iconv_return(
-                   rec, marc_decode_type, len,
-                   (const char *) r->u.octet_aligned->buf,
-                   r->u.octet_aligned->len,
-                   charset);
-               if (ret_buf)
-                   return ret_buf;
+                ret_buf = marc_iconv_return(
+                    rec, marc_decode_type, len,
+                    (const char *) r->u.octet_aligned->buf,
+                    r->u.octet_aligned->len,
+                    charset);
+                if (ret_buf)
+                    return ret_buf;
             }
-           return record_iconv_return(rec, len,
-                                      (const char *) r->u.octet_aligned->buf,
-                                      r->u.octet_aligned->len,
-                                      charset);
+            return record_iconv_return(rec, len,
+                                       (const char *) r->u.octet_aligned->buf,
+                                       r->u.octet_aligned->len,
+                                       charset);
         }
         else if (r->which == Z_External_grs1)
         {
             if (len) *len = 5;
             return "GRS-1";
         }
-       return 0;
+        return 0;
     }
     else if (!strcmp (type, "raw"))
     {
-       Z_External *r = (Z_External *) npr->u.databaseRecord;
-       
-       if (r->which == Z_External_sutrs)
-       {
-           if (len) *len = r->u.sutrs->len;
-           return (const char *) r->u.sutrs->buf;
-       }
-       else if (r->which == Z_External_octet)
-       {
-           if (len) *len = r->u.octet_aligned->len;
-           return (const char *) r->u.octet_aligned->buf;
-       }
-       else /* grs-1, explain, OPAC, ... */
-       {
-           if (len) *len = -1;
-           return (const char *) npr->u.databaseRecord;
-       }
-       return 0;
+        Z_External *r = (Z_External *) npr->u.databaseRecord;
+        
+        if (r->which == Z_External_sutrs)
+        {
+            if (len) *len = r->u.sutrs->len;
+            return (const char *) r->u.sutrs->buf;
+        }
+        else if (r->which == Z_External_octet)
+        {
+            if (len) *len = r->u.octet_aligned->len;
+            return (const char *) r->u.octet_aligned->buf;
+        }
+        else /* grs-1, explain, OPAC, ... */
+        {
+            if (len) *len = -1;
+            return (const char *) npr->u.databaseRecord;
+        }
+        return 0;
     }
     else if (!strcmp (type, "ext"))
     {
-       if (len) *len = -1;
-       return (const char *) npr->u.databaseRecord;
+        if (len) *len = -1;
+        return (const char *) npr->u.databaseRecord;
     }
     else if (!strcmp (type, "opac"))
-            
-    {
-       Z_External *r = (Z_External *) npr->u.databaseRecord;
-       if (r->which == Z_External_OPAC)
-       {
-           if (!rec->wrbuf_opac)
-               rec->wrbuf_opac = wrbuf_alloc();
-           wrbuf_rewind (rec->wrbuf_opac);
-           yaz_display_OPAC(rec->wrbuf_opac, r->u.opac, 0);
-           return record_iconv_return(rec, len,
-                                      wrbuf_buf(rec->wrbuf_opac),
-                                      wrbuf_len(rec->wrbuf_opac),
-                                      charset);
-       }
+             
+    {
+        Z_External *r = (Z_External *) npr->u.databaseRecord;
+        if (r->which == Z_External_OPAC)
+        {
+            if (!rec->wrbuf_opac)
+                rec->wrbuf_opac = wrbuf_alloc();
+            wrbuf_rewind (rec->wrbuf_opac);
+            yaz_display_OPAC(rec->wrbuf_opac, r->u.opac, 0);
+            return record_iconv_return(rec, len,
+                                       wrbuf_buf(rec->wrbuf_opac),
+                                       wrbuf_len(rec->wrbuf_opac),
+                                       charset);
+        }
     }
     return 0;
 }
@@ -1894,11 +1894,11 @@ static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr,
 
     for (rc = r->record_cache; rc; rc = rc->next)
     {
-       if (pos == rc->pos)
-       {
-           if (strcmp_null(r->schema, rc->schema))
+        if (pos == rc->pos)
+        {
+            if (strcmp_null(r->schema, rc->schema))
                 continue;
-           if (strcmp_null(elementSetName,rc->elementSetName))
+            if (strcmp_null(elementSetName,rc->elementSetName))
                 continue;
             if (strcmp_null(syntax, rc->syntax))
                 continue;
@@ -1906,7 +1906,7 @@ static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr,
             rc->rec.npr = npr;
             /* keeping wrbuf_marc too */
             return;
-       }
+        }
     }
     rc = (ZOOM_record_cache) odr_malloc (r->odr, sizeof(*rc));
     rc->rec.npr = npr; 
@@ -1915,19 +1915,19 @@ static void record_cache_add (ZOOM_resultset r, Z_NamePlusRecord *npr,
     rc->rec.wrbuf_iconv = 0;
     rc->rec.wrbuf_opac = 0;
     if (elementSetName)
-       rc->elementSetName = odr_strdup (r->odr, elementSetName);
+        rc->elementSetName = odr_strdup (r->odr, elementSetName);
     else
-       rc->elementSetName = 0;
+        rc->elementSetName = 0;
 
     if (syntax)
-       rc->syntax = odr_strdup (r->odr, syntax);
+        rc->syntax = odr_strdup (r->odr, syntax);
     else
-       rc->syntax = 0;
+        rc->syntax = 0;
 
     if (r->schema)
-       rc->schema = odr_strdup (r->odr, r->schema);
+        rc->schema = odr_strdup (r->odr, r->schema);
     else
-       rc->schema = 0;
+        rc->schema = 0;
 
     rc->pos = pos;
     rc->next = r->record_cache;
@@ -1944,27 +1944,27 @@ static ZOOM_record record_cache_lookup (ZOOM_resultset r, int pos)
     
     for (rc = r->record_cache; rc; rc = rc->next)
     {
-       if (pos == rc->pos)
-       {
-           if (strcmp_null(r->schema, rc->schema))
+        if (pos == rc->pos)
+        {
+            if (strcmp_null(r->schema, rc->schema))
                 continue;
-           if (strcmp_null(elementSetName,rc->elementSetName))
+            if (strcmp_null(elementSetName,rc->elementSetName))
                 continue;
             if (strcmp_null(syntax, rc->syntax))
                 continue;
             return &rc->rec;
-       }
+        }
     }
     return 0;
 }
-                                            
+                                             
 static void handle_records (ZOOM_connection c, Z_Records *sr,
-                           int present_phase)
+                            int present_phase)
 {
     ZOOM_resultset resultset;
 
     if (!c->tasks)
-       return ;
+        return ;
     switch (c->tasks->which)
     {
     case ZOOM_TASK_SEARCH:
@@ -1972,54 +1972,54 @@ static void handle_records (ZOOM_connection c, Z_Records *sr,
         break;
     case ZOOM_TASK_RETRIEVE:
         resultset = c->tasks->u.retrieve.resultset;        
-       break;
+        break;
     default:
         return;
     }
     if (sr && sr->which == Z_Records_NSD)
-       response_default_diag(c, sr->u.nonSurrogateDiagnostic);
+        response_default_diag(c, sr->u.nonSurrogateDiagnostic);
     else if (sr && sr->which == Z_Records_multipleNSD)
     {
-       if (sr->u.multipleNonSurDiagnostics->num_diagRecs >= 1)
-           response_diag(c, sr->u.multipleNonSurDiagnostics->diagRecs[0]);
-       else
+        if (sr->u.multipleNonSurDiagnostics->num_diagRecs >= 1)
+            response_diag(c, sr->u.multipleNonSurDiagnostics->diagRecs[0]);
+        else
             set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
     }
     else 
     {
-       if (resultset->count + resultset->start > resultset->size)
-           resultset->count = resultset->size - resultset->start;
-       if (resultset->count < 0)
-           resultset->count = 0;
-       if (sr && sr->which == Z_Records_DBOSD)
-       {
-           int i;
-           NMEM nmem = odr_extract_mem (c->odr_in);
-           Z_NamePlusRecordList *p =
-               sr->u.databaseOrSurDiagnostics;
-           for (i = 0; i<p->num_records; i++)
-           {
-               record_cache_add (resultset, p->records[i],
+        if (resultset->count + resultset->start > resultset->size)
+            resultset->count = resultset->size - resultset->start;
+        if (resultset->count < 0)
+            resultset->count = 0;
+        if (sr && sr->which == Z_Records_DBOSD)
+        {
+            int i;
+            NMEM nmem = odr_extract_mem (c->odr_in);
+            Z_NamePlusRecordList *p =
+                sr->u.databaseOrSurDiagnostics;
+            for (i = 0; i<p->num_records; i++)
+            {
+                record_cache_add (resultset, p->records[i],
                                   i+ resultset->start);
-           }
-           /* transfer our response to search_nmem .. we need it later */
-           nmem_transfer (resultset->odr->mem, nmem);
-           nmem_destroy (nmem);
-           if (present_phase && p->num_records == 0)
-           {
-               /* present response and we didn't get any records! */
-               Z_NamePlusRecord *myrec = 
-                   zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
-               record_cache_add(resultset, myrec, resultset->start);
-           }
-       }
-       else if (present_phase)
-       {
-           /* present response and we didn't get any records! */
-           Z_NamePlusRecord *myrec = 
-               zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
-           record_cache_add(resultset, myrec, resultset->start);
-       }
+            }
+            /* transfer our response to search_nmem .. we need it later */
+            nmem_transfer (resultset->odr->mem, nmem);
+            nmem_destroy (nmem);
+            if (present_phase && p->num_records == 0)
+            {
+                /* present response and we didn't get any records! */
+                Z_NamePlusRecord *myrec = 
+                    zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
+                record_cache_add(resultset, myrec, resultset->start);
+            }
+        }
+        else if (present_phase)
+        {
+            /* present response and we didn't get any records! */
+            Z_NamePlusRecord *myrec = 
+                zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
+            record_cache_add(resultset, myrec, resultset->start);
+        }
     }
 }
 
@@ -2034,7 +2034,7 @@ static void handle_search_response (ZOOM_connection c, Z_SearchResponse *sr)
     ZOOM_Event event;
 
     if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH)
-       return ;
+        return ;
     
     event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH);
     ZOOM_connection_put_event(c, event);
@@ -2048,7 +2048,7 @@ static void handle_search_response (ZOOM_connection c, Z_SearchResponse *sr)
 static void sort_response (ZOOM_connection c, Z_SortResponse *res)
 {
     if (res->diagnostics && res->num_diagnostics > 0)
-       response_diag (c, res->diagnostics[0]);
+        response_diag (c, res->diagnostics[0]);
 }
 
 static int scan_response (ZOOM_connection c, Z_ScanResponse *res)
@@ -2078,24 +2078,24 @@ static int scan_response (ZOOM_connection c, Z_ScanResponse *res)
 }
 
 static zoom_ret send_sort (ZOOM_connection c,
-                          ZOOM_resultset resultset)
+                           ZOOM_resultset resultset)
 {
     if (c->error)
-       resultset->r_sort_spec = 0;
+        resultset->r_sort_spec = 0;
     if (resultset->r_sort_spec)
     {
-       Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_sortRequest);
-       Z_SortRequest *req = apdu->u.sortRequest;
-       
-       req->num_inputResultSetNames = 1;
-       req->inputResultSetNames = (Z_InternationalString **)
-           odr_malloc (c->odr_out, sizeof(*req->inputResultSetNames));
-       req->inputResultSetNames[0] =
+        Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_sortRequest);
+        Z_SortRequest *req = apdu->u.sortRequest;
+        
+        req->num_inputResultSetNames = 1;
+        req->inputResultSetNames = (Z_InternationalString **)
+            odr_malloc (c->odr_out, sizeof(*req->inputResultSetNames));
+        req->inputResultSetNames[0] =
             odr_strdup (c->odr_out, resultset->setname);
-       req->sortedResultSetName = odr_strdup (c->odr_out, resultset->setname);
-       req->sortSequence = resultset->r_sort_spec;
-       resultset->r_sort_spec = 0;
-       return send_APDU (c, apdu);
+        req->sortedResultSetName = odr_strdup (c->odr_out, resultset->setname);
+        req->sortSequence = resultset->r_sort_spec;
+        resultset->r_sort_spec = 0;
+        return send_APDU (c, apdu);
     }
     return zoom_complete;
 }
@@ -2111,8 +2111,8 @@ static zoom_ret send_present(ZOOM_connection c)
 
     if (!c->tasks)
     {
-       yaz_log(log_details, "%p send_present no tasks", c);
-       return zoom_complete;
+        yaz_log(log_details, "%p send_present no tasks", c);
+        return zoom_complete;
     }
     switch (c->tasks->which)
     {
@@ -2125,38 +2125,38 @@ static zoom_ret send_present(ZOOM_connection c)
         resultset->count = c->tasks->u.retrieve.count;
 
         if (resultset->start >= resultset->size)
-       {
-           yaz_log(log_details, "%p send_present start=%d >= size=%d",
-                   c, resultset->start, resultset->size);
+        {
+            yaz_log(log_details, "%p send_present start=%d >= size=%d",
+                    c, resultset->start, resultset->size);
             return zoom_complete;
-       }
+        }
         if (resultset->start + resultset->count > resultset->size)
             resultset->count = resultset->size - resultset->start;
-       break;
+        break;
     default:
         return zoom_complete;
     }
     yaz_log(log_details, "%p send_present start=%d count=%d",
-           c, resultset->start, resultset->count);
+            c, resultset->start, resultset->count);
 
     syntax = ZOOM_resultset_option_get (resultset, "preferredRecordSyntax");
     elementSetName = ZOOM_resultset_option_get (resultset, "elementSetName");
 
     if (c->error)                  /* don't continue on error */
-       return zoom_complete;
+        return zoom_complete;
     if (resultset->start < 0)
-       return zoom_complete;
+        return zoom_complete;
     for (i = 0; i<resultset->count; i++)
     {
-       ZOOM_record rec =
-           record_cache_lookup (resultset, i + resultset->start);
-       if (!rec)
-           break;
+        ZOOM_record rec =
+            record_cache_lookup (resultset, i + resultset->start);
+        if (!rec)
+            break;
     }
     if (i == resultset->count)
     {
-       yaz_log(log_details, "%p send_present skip=%d no more to fetch", c, i);
-       return zoom_complete;
+        yaz_log(log_details, "%p send_present skip=%d no more to fetch", c, i);
+        return zoom_complete;
     }
 
     apdu = zget_APDU(c->odr_out, Z_APDU_presentRequest);
@@ -2166,7 +2166,7 @@ static zoom_ret send_present(ZOOM_connection c)
     resultset->count -= i;
 
     if (i)
-       yaz_log(log_details, "%p send_present skip=%d", c, i);
+        yaz_log(log_details, "%p send_present skip=%d", c, i);
 
     *req->resultSetStartPoint = resultset->start + 1;
     *req->numberOfRecordsRequested = resultset->step>0 ?
@@ -2175,12 +2175,12 @@ static zoom_ret send_present(ZOOM_connection c)
 
 
     if (syntax && *syntax)
-       req->preferredRecordSyntax =
-           yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, syntax);
+        req->preferredRecordSyntax =
+            yaz_str_to_z3950oid (c->odr_out, CLASS_RECSYN, syntax);
 
     if (resultset->schema && *resultset->schema)
     {
-       Z_RecordComposition *compo = (Z_RecordComposition *)
+        Z_RecordComposition *compo = (Z_RecordComposition *)
             odr_malloc (c->odr_out, sizeof(*compo));
 
         req->recordComposition = compo;
@@ -2223,16 +2223,16 @@ static zoom_ret send_present(ZOOM_connection c)
     }
     else if (elementSetName && *elementSetName)
     {
-       Z_ElementSetNames *esn = (Z_ElementSetNames *)
+        Z_ElementSetNames *esn = (Z_ElementSetNames *)
             odr_malloc (c->odr_out, sizeof(*esn));
-       Z_RecordComposition *compo = (Z_RecordComposition *)
+        Z_RecordComposition *compo = (Z_RecordComposition *)
             odr_malloc (c->odr_out, sizeof(*compo));
-       
-       esn->which = Z_ElementSetNames_generic;
-       esn->u.generic = odr_strdup (c->odr_out, elementSetName);
-       compo->which = Z_RecordComp_simple;
-       compo->u.simple = esn;
-       req->recordComposition = compo;
+        
+        esn->which = Z_ElementSetNames_generic;
+        esn->u.generic = odr_strdup (c->odr_out, elementSetName);
+        compo->which = Z_RecordComp_simple;
+        compo->u.simple = esn;
+        req->recordComposition = compo;
     }
     req->resultSetId = odr_strdup(c->odr_out, resultset->setname);
     return send_APDU (c, apdu);
@@ -2339,7 +2339,7 @@ ZOOM_scanset_size (ZOOM_scanset scan)
 
 ZOOM_API(const char *)
 ZOOM_scanset_term (ZOOM_scanset scan, size_t pos,
-                  int *occ, int *len)
+                   int *occ, int *len)
 {
     const char *term = 0;
     size_t noent = ZOOM_scanset_size (scan);
@@ -2365,7 +2365,7 @@ ZOOM_scanset_term (ZOOM_scanset scan, size_t pos,
 
 ZOOM_API(const char *)
 ZOOM_scanset_display_term (ZOOM_scanset scan, size_t pos,
-                          int *occ, int *len)
+                           int *occ, int *len)
 {
     const char *term = 0;
     size_t noent = ZOOM_scanset_size (scan);
@@ -2380,11 +2380,11 @@ ZOOM_scanset_display_term (ZOOM_scanset scan, size_t pos,
         Z_TermInfo *t = res->entries->entries[pos]->u.termInfo;
 
         if (t->displayTerm)
-       {
-           term = t->displayTerm;
-           *len = strlen(term);
-       }
-       else if (t->term->which == Z_Term_general)
+        {
+            term = t->displayTerm;
+            *len = strlen(term);
+        }
+        else if (t->term->which == Z_Term_general)
         {
             term = (const char *) t->term->u.general->buf;
             *len = t->term->u.general->len;
@@ -2451,13 +2451,13 @@ static Z_External *encode_ill_request (ZOOM_package p)
     ILL_Request *req;
     Z_External *r = 0;
     struct ill_get_ctl ctl;
-       
+        
     ctl.odr = p->odr_out;
     ctl.clientData = p;
     ctl.f = ill_array_lookup;
-       
+        
     req = ill_get_ILLRequest(&ctl, "ill", 0);
-       
+        
     if (!ill_Request (out, &req, 0, 0))
     {
         int ill_request_size;
@@ -2471,17 +2471,17 @@ static Z_External *encode_ill_request (ZOOM_package p)
         oident oid;
         int illRequest_size = 0;
         char *illRequest_buf = odr_getbuf (out, &illRequest_size, 0);
-               
+                
         oid.proto = PROTO_GENERAL;
         oid.oclass = CLASS_GENERAL;
         oid.value = VAL_ISO_ILL_1;
-               
+                
         r = (Z_External *) odr_malloc (out, sizeof(*r));
         r->direct_reference = odr_oiddup(out,oid_getoidbyent(&oid)); 
         r->indirect_reference = 0;
         r->descriptor = 0;
         r->which = Z_External_single;
-               
+                
         r->u.single_ASN1_type = (Odr_oct *)
             odr_malloc (out, sizeof(*r->u.single_ASN1_type));
         r->u.single_ASN1_type->buf = (unsigned char*)
@@ -2504,29 +2504,29 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p)
 
     /* to keep part ... */
     req->u.esRequest->toKeep = (Z_IOOriginPartToKeep *)
-       odr_malloc(p->odr_out,sizeof(Z_IOOriginPartToKeep));
+        odr_malloc(p->odr_out,sizeof(Z_IOOriginPartToKeep));
     req->u.esRequest->toKeep->supplDescription = 0;
     req->u.esRequest->toKeep->contact = (Z_IOContact *)
         odr_malloc (p->odr_out, sizeof(*req->u.esRequest->toKeep->contact));
-       
+        
     str = ZOOM_options_get(p->options, "contact-name");
     req->u.esRequest->toKeep->contact->name = str ?
         nmem_strdup (p->odr_out->mem, str) : 0;
-       
+        
     str = ZOOM_options_get(p->options, "contact-phone");
     req->u.esRequest->toKeep->contact->phone = str ?
         nmem_strdup (p->odr_out->mem, str) : 0;
-       
+        
     str = ZOOM_options_get(p->options, "contact-email");
     req->u.esRequest->toKeep->contact->email = str ?
         nmem_strdup (p->odr_out->mem, str) : 0;
-       
+        
     req->u.esRequest->toKeep->addlBilling = 0;
-       
+        
     /* not to keep part ... */
     req->u.esRequest->notToKeep = (Z_IOOriginPartNotToKeep *)
         odr_malloc(p->odr_out,sizeof(Z_IOOriginPartNotToKeep));
-       
+        
     str = ZOOM_options_get(p->options, "itemorder-setname");
     if (!str)
         str = "default";
@@ -2542,7 +2542,7 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p)
            nmem_strdup (p->odr_out->mem, str);
         req->u.esRequest->notToKeep->resultSetItem->item =
             (int *) odr_malloc(p->odr_out, sizeof(int));
-       
+        
         str = ZOOM_options_get(p->options, "itemorder-item");
         *req->u.esRequest->notToKeep->resultSetItem->item =
             (str ? atoi(str) : 1);
@@ -2553,52 +2553,52 @@ static Z_ItemOrder *encode_item_order(ZOOM_package p)
 }
 
 Z_APDU *create_admin_package(ZOOM_package p, int type, 
-                            Z_ESAdminOriginPartToKeep **toKeepP,
-                            Z_ESAdminOriginPartNotToKeep **notToKeepP)
+                             Z_ESAdminOriginPartToKeep **toKeepP,
+                             Z_ESAdminOriginPartNotToKeep **notToKeepP)
 {
     Z_APDU *apdu = create_es_package (p, VAL_ADMINSERVICE);
     if (apdu)
     {
-       Z_ESAdminOriginPartToKeep  *toKeep;
-       Z_ESAdminOriginPartNotToKeep  *notToKeep;
-       Z_External *r = (Z_External *) odr_malloc (p->odr_out, sizeof(*r));
-       const char *first_db = "Default";
-       int num_db;
-       char **db = set_DatabaseNames(p->connection, p->options, &num_db);
-       if (num_db > 0)
-           first_db = db[0];
-           
-       r->direct_reference =
-           yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
-                                  VAL_ADMINSERVICE);
-       r->descriptor = 0;
-       r->indirect_reference = 0;
-       r->which = Z_External_ESAdmin;
-       
-       r->u.adminService = (Z_Admin *)
-           odr_malloc(p->odr_out, sizeof(*r->u.adminService));
-       r->u.adminService->which = Z_Admin_esRequest;
-       r->u.adminService->u.esRequest = (Z_AdminEsRequest *)
-           odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest));
-       
-       toKeep = r->u.adminService->u.esRequest->toKeep =
-           (Z_ESAdminOriginPartToKeep *) 
-           odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest->toKeep));
-       toKeep->which = type;
-       toKeep->databaseName = odr_strdup(p->odr_out, first_db);
-       toKeep->u.create = odr_nullval();
-       apdu->u.extendedServicesRequest->taskSpecificParameters = r;
-       
-       r->u.adminService->u.esRequest->notToKeep = notToKeep =
-           (Z_ESAdminOriginPartNotToKeep *)
-           odr_malloc(p->odr_out,
-                      sizeof(*r->u.adminService->u.esRequest->notToKeep));
-       notToKeep->which = Z_ESAdminOriginPartNotToKeep_recordsWillFollow;
-       notToKeep->u.recordsWillFollow = odr_nullval();
-       if (toKeepP)
-           *toKeepP = toKeep;
-       if (notToKeepP)
-           *notToKeepP = notToKeep;
+        Z_ESAdminOriginPartToKeep  *toKeep;
+        Z_ESAdminOriginPartNotToKeep  *notToKeep;
+        Z_External *r = (Z_External *) odr_malloc (p->odr_out, sizeof(*r));
+        const char *first_db = "Default";
+        int num_db;
+        char **db = set_DatabaseNames(p->connection, p->options, &num_db);
+        if (num_db > 0)
+            first_db = db[0];
+            
+        r->direct_reference =
+            yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
+                                   VAL_ADMINSERVICE);
+        r->descriptor = 0;
+        r->indirect_reference = 0;
+        r->which = Z_External_ESAdmin;
+        
+        r->u.adminService = (Z_Admin *)
+            odr_malloc(p->odr_out, sizeof(*r->u.adminService));
+        r->u.adminService->which = Z_Admin_esRequest;
+        r->u.adminService->u.esRequest = (Z_AdminEsRequest *)
+            odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest));
+        
+        toKeep = r->u.adminService->u.esRequest->toKeep =
+            (Z_ESAdminOriginPartToKeep *) 
+            odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest->toKeep));
+        toKeep->which = type;
+        toKeep->databaseName = odr_strdup(p->odr_out, first_db);
+        toKeep->u.create = odr_nullval();
+        apdu->u.extendedServicesRequest->taskSpecificParameters = r;
+        
+        r->u.adminService->u.esRequest->notToKeep = notToKeep =
+            (Z_ESAdminOriginPartNotToKeep *)
+            odr_malloc(p->odr_out,
+                       sizeof(*r->u.adminService->u.esRequest->notToKeep));
+        notToKeep->which = Z_ESAdminOriginPartNotToKeep_recordsWillFollow;
+        notToKeep->u.recordsWillFollow = odr_nullval();
+        if (toKeepP)
+            *toKeepP = toKeep;
+        if (notToKeepP)
+            *notToKeepP = notToKeep;
     }
     return apdu;
 }
@@ -2617,12 +2617,12 @@ static Z_APDU *create_xmlupdate_package(ZOOM_package p)
     
     ext->which = Z_External_octet;
     ext->u.single_ASN1_type = (Odr_oct *)
-       odr_malloc (p->odr_out, sizeof(Odr_oct));
+        odr_malloc (p->odr_out, sizeof(Odr_oct));
 
     if (!doc)
-       doc = "";
+        doc = "";
     ext->u.single_ASN1_type->buf = (unsigned char*)
-       odr_strdup(p->odr_out, doc);
+        odr_strdup(p->odr_out, doc);
     ext->u.single_ASN1_type->size = ext->u.single_ASN1_type->len = strlen(doc);
     return apdu;
 }
@@ -2642,98 +2642,98 @@ static Z_APDU *create_update_package(ZOOM_package p)
     int action_no = -1;
     
     if (syntax_str)
-       syntax_oid = oid_getvalbyname(syntax_str);
+        syntax_oid = oid_getvalbyname(syntax_str);
     if (!record_buf)
     {
-       record_buf = "void";
-       syntax_oid = VAL_SUTRS;
+        record_buf = "void";
+        syntax_oid = VAL_SUTRS;
     }
     if (syntax_oid != VAL_NONE)
-       syntax_oid = VAL_TEXT_XML;
+        syntax_oid = VAL_TEXT_XML;
     
     if (num_db > 0)
-       first_db = db[0];
+        first_db = db[0];
     
     if (!action)
-       action = "specialUpdate";
+        action = "specialUpdate";
     
     if (!strcmp(action, "recordInsert"))
-       action_no = Z_IUOriginPartToKeep_recordInsert;
+        action_no = Z_IUOriginPartToKeep_recordInsert;
     else if (!strcmp(action, "recordReplace"))
-       action_no = Z_IUOriginPartToKeep_recordReplace;
+        action_no = Z_IUOriginPartToKeep_recordReplace;
     else if (!strcmp(action, "recordDelete"))
-       action_no = Z_IUOriginPartToKeep_recordDelete;
+        action_no = Z_IUOriginPartToKeep_recordDelete;
     else if (!strcmp(action, "elementUpdate"))
-       action_no = Z_IUOriginPartToKeep_elementUpdate;
+        action_no = Z_IUOriginPartToKeep_elementUpdate;
     else if (!strcmp(action, "specialUpdate"))
-       action_no = Z_IUOriginPartToKeep_specialUpdate;
+        action_no = Z_IUOriginPartToKeep_specialUpdate;
     else
-       return 0;
+        return 0;
 
     apdu = create_es_package (p, VAL_DBUPDATE);
     if (apdu)
     {
-       Z_IUOriginPartToKeep *toKeep;
-       Z_IUSuppliedRecords *notToKeep;
-       Z_External *r = (Z_External *)
-           odr_malloc (p->odr_out, sizeof(*r));
-       
-       apdu->u.extendedServicesRequest->taskSpecificParameters = r;
-       
-       r->direct_reference =
-           yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
-                                  VAL_DBUPDATE);
-       r->descriptor = 0;
-       r->which = Z_External_update;
-       r->indirect_reference = 0;
-       r->u.update = (Z_IUUpdate *)
-           odr_malloc(p->odr_out, sizeof(*r->u.update));
-       
-       r->u.update->which = Z_IUUpdate_esRequest;
-       r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
-           odr_malloc(p->odr_out, sizeof(*r->u.update->u.esRequest));
-       toKeep = r->u.update->u.esRequest->toKeep = 
-           (Z_IUOriginPartToKeep *)
-           odr_malloc(p->odr_out, sizeof(*toKeep));
-       
-       toKeep->databaseName = odr_strdup(p->odr_out, first_db);
-       toKeep->schema = 0;
-       toKeep->elementSetName = 0;
-       toKeep->actionQualifier = 0;
-       toKeep->action = odr_intdup(p->odr_out, action_no);
-       
-       notToKeep = r->u.update->u.esRequest->notToKeep = 
-           (Z_IUSuppliedRecords *)
-           odr_malloc(p->odr_out, sizeof(*notToKeep));
-       notToKeep->num = 1;
-       notToKeep->elements = (Z_IUSuppliedRecords_elem **)
-           odr_malloc(p->odr_out, sizeof(*notToKeep->elements));
-       notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
-           odr_malloc(p->odr_out, sizeof(**notToKeep->elements));
-       notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
-       if (recordIdOpaque)
-       {
-           notToKeep->elements[0]->u.opaque = (Odr_oct *)
-               odr_malloc (p->odr_out, sizeof(Odr_oct));
-           notToKeep->elements[0]->u.opaque->size =
-               notToKeep->elements[0]->u.opaque->len = strlen(recordIdOpaque);
-           notToKeep->elements[0]->u.opaque->buf = (unsigned char*)
-               odr_strdup(p->odr_out, recordIdOpaque);
-       }
-       else if (recordIdNumber)
-       {
-           notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_number;
-           
-           notToKeep->elements[0]->u.number =
-               odr_intdup(p->odr_out, atoi(recordIdNumber));
-       }
-       else
-           notToKeep->elements[0]->u.opaque = 0;
-       notToKeep->elements[0]->supplementalId = 0;
-       notToKeep->elements[0]->correlationInfo = 0;
-       notToKeep->elements[0]->record =
-           z_ext_record(p->odr_out, syntax_oid,
-                        record_buf, strlen(record_buf));
+        Z_IUOriginPartToKeep *toKeep;
+        Z_IUSuppliedRecords *notToKeep;
+        Z_External *r = (Z_External *)
+            odr_malloc (p->odr_out, sizeof(*r));
+        
+        apdu->u.extendedServicesRequest->taskSpecificParameters = r;
+        
+        r->direct_reference =
+            yaz_oidval_to_z3950oid(p->odr_out, CLASS_EXTSERV,
+                                   VAL_DBUPDATE);
+        r->descriptor = 0;
+        r->which = Z_External_update;
+        r->indirect_reference = 0;
+        r->u.update = (Z_IUUpdate *)
+            odr_malloc(p->odr_out, sizeof(*r->u.update));
+        
+        r->u.update->which = Z_IUUpdate_esRequest;
+        r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
+            odr_malloc(p->odr_out, sizeof(*r->u.update->u.esRequest));
+        toKeep = r->u.update->u.esRequest->toKeep = 
+            (Z_IUOriginPartToKeep *)
+            odr_malloc(p->odr_out, sizeof(*toKeep));
+        
+        toKeep->databaseName = odr_strdup(p->odr_out, first_db);
+        toKeep->schema = 0;
+        toKeep->elementSetName = 0;
+        toKeep->actionQualifier = 0;
+        toKeep->action = odr_intdup(p->odr_out, action_no);
+        
+        notToKeep = r->u.update->u.esRequest->notToKeep = 
+            (Z_IUSuppliedRecords *)
+            odr_malloc(p->odr_out, sizeof(*notToKeep));
+        notToKeep->num = 1;
+        notToKeep->elements = (Z_IUSuppliedRecords_elem **)
+            odr_malloc(p->odr_out, sizeof(*notToKeep->elements));
+        notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
+            odr_malloc(p->odr_out, sizeof(**notToKeep->elements));
+        notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
+        if (recordIdOpaque)
+        {
+            notToKeep->elements[0]->u.opaque = (Odr_oct *)
+                odr_malloc (p->odr_out, sizeof(Odr_oct));
+            notToKeep->elements[0]->u.opaque->size =
+                notToKeep->elements[0]->u.opaque->len = strlen(recordIdOpaque);
+            notToKeep->elements[0]->u.opaque->buf = (unsigned char*)
+                odr_strdup(p->odr_out, recordIdOpaque);
+        }
+        else if (recordIdNumber)
+        {
+            notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_number;
+            
+            notToKeep->elements[0]->u.number =
+                odr_intdup(p->odr_out, atoi(recordIdNumber));
+        }
+        else
+            notToKeep->elements[0]->u.opaque = 0;
+        notToKeep->elements[0]->supplementalId = 0;
+        notToKeep->elements[0]->correlationInfo = 0;
+        notToKeep->elements[0]->record =
+            z_ext_record(p->odr_out, syntax_oid,
+                         record_buf, strlen(record_buf));
     }
     if (0 && apdu)
     {
@@ -2776,26 +2776,26 @@ ZOOM_API(void)
     }
     else if (!strcmp(type, "create"))  /* create database */
     {
-       apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_create,
-                                   0, 0);
-    }  
+        apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_create,
+                                    0, 0);
+    }   
     else if (!strcmp(type, "drop"))  /* drop database */
     {
-       apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_drop,
-                                   0, 0);
+        apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_drop,
+                                    0, 0);
     }
     else if (!strcmp(type, "commit"))  /* commit changes */
     {
-       apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_commit,
-                                   0, 0);
+        apdu = create_admin_package(p, Z_ESAdminOriginPartToKeep_commit,
+                                    0, 0);
     }
     else if (!strcmp(type, "update")) /* update record(s) */
     {
-       apdu = create_update_package(p);
+        apdu = create_update_package(p);
     }
     else if (!strcmp(type, "xmlupdate"))
     {
-       apdu = create_xmlupdate_package(p);
+        apdu = create_xmlupdate_package(p);
     }
     if (apdu)
     {
@@ -2869,21 +2869,21 @@ static int ZOOM_connection_exec_task (ZOOM_connection c)
     zoom_ret ret = zoom_complete;
 
     if (!task)
-       return 0;
+        return 0;
     yaz_log(log_details, "%p ZOOM_connection_exec_task type=%d run=%d",
              c, task->which, task->running);
     if (c->error != ZOOM_ERROR_NONE)
     {
         yaz_log(log_details, "%p ZOOM_connection_exec_task "
-               "removing tasks because of error = %d", c, c->error);
+                "removing tasks because of error = %d", c, c->error);
         ZOOM_connection_remove_tasks (c);
         return 0;
     }
     if (task->running)
     {
         yaz_log(log_details, "%p ZOOM_connection_exec_task "
-                "task already running", c);
-       return 0;
+                 "task already running", c);
+        return 0;
     }
     task->running = 1;
     ret = zoom_complete;
@@ -2911,29 +2911,29 @@ static int ZOOM_connection_exec_task (ZOOM_connection c)
             break;
         case ZOOM_TASK_PACKAGE:
             ret = send_package(c);
-           break;
-       case ZOOM_TASK_SORT:
-           c->tasks->u.sort.resultset->r_sort_spec = 
-               c->tasks->u.sort.q->sort_spec;
-           ret = send_sort(c, c->tasks->u.sort.resultset);
+            break;
+        case ZOOM_TASK_SORT:
+            c->tasks->u.sort.resultset->r_sort_spec = 
+                c->tasks->u.sort.q->sort_spec;
+            ret = send_sort(c, c->tasks->u.sort.resultset);
             break;
         }
     }
     else
     {
         yaz_log(log_details, "%p ZOOM_connection_exec_task "
-               "remove tasks because no connection exist", c);
+                "remove tasks because no connection exist", c);
         ZOOM_connection_remove_tasks (c);
     }
     if (ret == zoom_complete)
     {
         yaz_log(log_details, "%p ZOOM_connection_exec_task "
-                "task removed (complete)", c);
+                 "task removed (complete)", c);
         ZOOM_connection_remove_task (c);
         return 0;
     }
     yaz_log(log_details, "%p ZOOM_connection_exec_task "
-           "task pending", c);
+            "task pending", c);
     return 1;
 }
 
@@ -2942,9 +2942,9 @@ static zoom_ret send_sort_present (ZOOM_connection c)
     zoom_ret r = zoom_complete;
 
     if (c->tasks && c->tasks->which == ZOOM_TASK_SEARCH)
-       r = send_sort (c, c->tasks->u.search.resultset);
+        r = send_sort (c, c->tasks->u.search.resultset);
     if (r == zoom_complete)
-       r = send_present (c);
+        r = send_present (c);
     return r;
 }
 
@@ -2966,41 +2966,41 @@ static int es_response (ZOOM_connection c,
                                "targetReference", (char*) id->buf, id->len);
     }
     if (res->taskPackage && 
-       res->taskPackage->which == Z_External_octet)
+        res->taskPackage->which == Z_External_octet)
     {
-       Odr_oct *doc = res->taskPackage->u.octet_aligned;
-       ZOOM_options_setl (c->tasks->u.package->options,
-                          "xmlUpdateDoc", (char*) doc->buf, doc->len);
+        Odr_oct *doc = res->taskPackage->u.octet_aligned;
+        ZOOM_options_setl (c->tasks->u.package->options,
+                           "xmlUpdateDoc", (char*) doc->buf, doc->len);
     }
     return 1;
 }
 
 static void interpret_init_diag(ZOOM_connection c,
-                               Z_DiagnosticFormat *diag)
+                                Z_DiagnosticFormat *diag)
 {
     if (diag->num > 0)
     {
-       Z_DiagnosticFormat_s *ds = diag->elements[0];
-       if (ds->which == Z_DiagnosticFormat_s_defaultDiagRec)
-           response_default_diag(c, ds->u.defaultDiagRec);
+        Z_DiagnosticFormat_s *ds = diag->elements[0];
+        if (ds->which == Z_DiagnosticFormat_s_defaultDiagRec)
+            response_default_diag(c, ds->u.defaultDiagRec);
     }
 }
 
 
 static void interpret_otherinformation_field(ZOOM_connection c,
-                                            Z_OtherInformation *ui)
+                                             Z_OtherInformation *ui)
 {
     int i;
     for (i = 0; i < ui->num_elements; i++)
     {
-       Z_OtherInformationUnit *unit = ui->list[i];
-       if (unit->which == Z_OtherInfo_externallyDefinedInfo &&
-           unit->information.externallyDefinedInfo &&
-           unit->information.externallyDefinedInfo->which ==
-           Z_External_diag1) 
-       {
-           interpret_init_diag(c, unit->information.externallyDefinedInfo->u.diag1);
-       } 
+        Z_OtherInformationUnit *unit = ui->list[i];
+        if (unit->which == Z_OtherInfo_externallyDefinedInfo &&
+            unit->information.externallyDefinedInfo &&
+            unit->information.externallyDefinedInfo->which ==
+            Z_External_diag1) 
+        {
+            interpret_init_diag(c, unit->information.externallyDefinedInfo->u.diag1);
+        } 
     }
 }
 
@@ -3013,8 +3013,8 @@ static void recv_apdu (ZOOM_connection c, Z_APDU *apdu)
     switch(apdu->which)
     {
     case Z_APDU_initResponse:
-       yaz_log(log_api, "%p recv_apd: Received Init response", c);
-       initrs = apdu->u.initResponse;
+        yaz_log(log_api, "%p recv_apd: Received Init response", c);
+        initrs = apdu->u.initResponse;
         ZOOM_connection_option_set(c, "serverImplementationId",
                                    initrs->implementationId ?
                                    initrs->implementationId : "");
@@ -3024,7 +3024,7 @@ static void recv_apdu (ZOOM_connection c, Z_APDU *apdu)
         ZOOM_connection_option_set(c, "serverImplementationVersion",
                                    initrs->implementationVersion ?
                                    initrs->implementationVersion : "");
-       /* Set the three old options too, for old applications */
+        /* Set the three old options too, for old applications */
         ZOOM_connection_option_set(c, "targetImplementationId",
                                    initrs->implementationId ?
                                    initrs->implementationId : "");
@@ -3034,24 +3034,24 @@ static void recv_apdu (ZOOM_connection c, Z_APDU *apdu)
         ZOOM_connection_option_set(c, "targetImplementationVersion",
                                    initrs->implementationVersion ?
                                    initrs->implementationVersion : "");
-       if (!*initrs->result)
-       {
-           Z_External *uif = initrs->userInformationField;
-
-           set_ZOOM_error(c, ZOOM_ERROR_INIT, 0); /* default error */
-
-           if (uif && uif->which == Z_External_userInfo1)
-               interpret_otherinformation_field(c, uif->u.userInfo1);
-       }
-       else
-       {
-           char *cookie =
-               yaz_oi_get_string_oidval (&apdu->u.initResponse->otherInfo,
-                                         VAL_COOKIE, 1, 0);
-           xfree (c->cookie_in);
-           c->cookie_in = 0;
-           if (cookie)
-               c->cookie_in = xstrdup(cookie);
+        if (!*initrs->result)
+        {
+            Z_External *uif = initrs->userInformationField;
+
+            set_ZOOM_error(c, ZOOM_ERROR_INIT, 0); /* default error */
+
+            if (uif && uif->which == Z_External_userInfo1)
+                interpret_otherinformation_field(c, uif->u.userInfo1);
+        }
+        else
+        {
+            char *cookie =
+                yaz_oi_get_string_oidval (&apdu->u.initResponse->otherInfo,
+                                          VAL_COOKIE, 1, 0);
+            xfree (c->cookie_in);
+            c->cookie_in = 0;
+            if (cookie)
+                c->cookie_in = xstrdup(cookie);
             if (ODR_MASK_GET(initrs->options, Z_Options_namedResultSets) &&
                 ODR_MASK_GET(initrs->protocolVersion, Z_ProtocolVersion_3))
                 c->support_named_resultsets = 1;
@@ -3060,10 +3060,10 @@ static void recv_apdu (ZOOM_connection c, Z_APDU *apdu)
                 assert (c->tasks->which == ZOOM_TASK_CONNECT);
                 ZOOM_connection_remove_task (c);
             }
-           ZOOM_connection_exec_task (c);
-       }
-       if (ODR_MASK_GET(initrs->options, Z_Options_negotiationModel))
-       {
+            ZOOM_connection_exec_task (c);
+        }
+        if (ODR_MASK_GET(initrs->options, Z_Options_negotiationModel))
+        {
             NMEM tmpmem = nmem_create();
             Z_CharSetandLanguageNegotiation *p =
                 yaz_get_charneg_record(initrs->otherInfo);
@@ -3075,8 +3075,8 @@ static void recv_apdu (ZOOM_connection c, Z_APDU *apdu)
                 
                 yaz_get_response_charneg(tmpmem, p, &charset, &lang, &sel);
                 yaz_log(log_details, "%p recv_apdu target accepted: "
-                       "charset %s, language %s, select %d",
-                       c,
+                        "charset %s, language %s, select %d",
+                        c,
                         charset ? charset : "none", lang ? lang : "none", sel);
                 if (charset)
                     ZOOM_connection_option_set (c, "negotiation-charset",
@@ -3086,42 +3086,42 @@ static void recv_apdu (ZOOM_connection c, Z_APDU *apdu)
                                                 lang);
 
                 ZOOM_connection_option_set (
-                   c,  "negotiation-charset-in-effect-for-records",
-                   (sel != 0) ? "1" : "0");
+                    c,  "negotiation-charset-in-effect-for-records",
+                    (sel != 0) ? "1" : "0");
                 nmem_destroy(tmpmem);
             }
-       }       
-       break;
+        }       
+        break;
     case Z_APDU_searchResponse:
-       yaz_log(log_api, "%p recv_apdu Search response", c);
-       handle_search_response (c, apdu->u.searchResponse);
-       if (send_sort_present (c) == zoom_complete)
-           ZOOM_connection_remove_task (c);
-       break;
+        yaz_log(log_api, "%p recv_apdu Search response", c);
+        handle_search_response (c, apdu->u.searchResponse);
+        if (send_sort_present (c) == zoom_complete)
+            ZOOM_connection_remove_task (c);
+        break;
     case Z_APDU_presentResponse:
-       yaz_log(log_api, "%p recv_apdu Present response", c);
-       handle_present_response (c, apdu->u.presentResponse);
-       if (send_present (c) == zoom_complete)
-           ZOOM_connection_remove_task (c);
-       break;
+        yaz_log(log_api, "%p recv_apdu Present response", c);
+        handle_present_response (c, apdu->u.presentResponse);
+        if (send_present (c) == zoom_complete)
+            ZOOM_connection_remove_task (c);
+        break;
     case Z_APDU_sortResponse:
-       yaz_log(log_api, "%p recv_apdu Sort response", c);
-       sort_response (c, apdu->u.sortResponse);
-       if (send_present (c) == zoom_complete)
-           ZOOM_connection_remove_task (c);
+        yaz_log(log_api, "%p recv_apdu Sort response", c);
+        sort_response (c, apdu->u.sortResponse);
+        if (send_present (c) == zoom_complete)
+            ZOOM_connection_remove_task (c);
         break;
     case Z_APDU_scanResponse:
-       yaz_log(log_api, "%p recv_apdu Scan response", c);
+        yaz_log(log_api, "%p recv_apdu Scan response", c);
         scan_response (c, apdu->u.scanResponse);
         ZOOM_connection_remove_task (c);
         break;
     case Z_APDU_extendedServicesResponse:
-       yaz_log(log_api, "%p recv_apdu Extended Services response", c);
+        yaz_log(log_api, "%p recv_apdu Extended Services response", c);
         es_response (c, apdu->u.extendedServicesResponse);
         ZOOM_connection_remove_task (c);
         break;
     case Z_APDU_close:
-       yaz_log(log_api, "%p recv_apdu Close PDU", c);
+        yaz_log(log_api, "%p recv_apdu Close PDU", c);
         if (c->reconnect_ok)
         {
             do_close(c);
@@ -3135,7 +3135,7 @@ static void recv_apdu (ZOOM_connection c, Z_APDU *apdu)
         }
         break;
     default:
-       yaz_log(log_api, "%p Received unknown PDU", c);
+        yaz_log(log_api, "%p Received unknown PDU", c);
         set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
         do_close(c);
     }
@@ -3158,7 +3158,7 @@ static void handle_srw_response(ZOOM_connection c,
     else if (c->tasks->which == ZOOM_TASK_RETRIEVE)
         resultset = c->tasks->u.retrieve.resultset;
     else
-       return ;
+        return ;
 
     event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH);
     ZOOM_connection_put_event(c, event);
@@ -3202,16 +3202,16 @@ static void handle_srw_response(ZOOM_connection c,
     }
     if (res->num_diagnostics > 0)
     {
-       const char *uri = res->diagnostics[0].uri;
-       if (uri)
-       {
-           int code = 0;       
-           const char *cp;
-           if ((cp = strrchr(uri, '/')))
-               code = atoi(cp+1);
-           set_dset_error(c, code, uri,
-                          res->diagnostics[0].details, 0);
-       }
+        const char *uri = res->diagnostics[0].uri;
+        if (uri)
+        {
+            int code = 0;       
+            const char *cp;
+            if ((cp = strrchr(uri, '/')))
+                code = atoi(cp+1);
+            set_dset_error(c, code, uri,
+                           res->diagnostics[0].details, 0);
+        }
     }
     nmem = odr_extract_mem(c->odr_in);
     nmem_transfer(resultset->odr->mem, nmem);
@@ -3297,7 +3297,7 @@ static int do_read (ZOOM_connection c)
     more = cs_more(c->cs);
     yaz_log(log_details, "%p do_read len=%d more=%d", c, r, more);
     if (r == 1)
-       return 0;
+        return 0;
     if (r <= 0)
     {
         if (c->reconnect_ok)
@@ -3319,31 +3319,31 @@ static int do_read (ZOOM_connection c)
         Z_GDU *gdu;
         ZOOM_Event event;
 
-       odr_reset (c->odr_in);
-       odr_setbuf (c->odr_in, c->buf_in, r, 0);
+        odr_reset (c->odr_in);
+        odr_setbuf (c->odr_in, c->buf_in, r, 0);
         event = ZOOM_Event_create (ZOOM_EVENT_RECV_APDU);
         ZOOM_connection_put_event (c, event);
 
-       if (!z_GDU (c->odr_in, &gdu, 0, 0))
-       {
-           int x;
-           int err = odr_geterrorx(c->odr_in, &x);
-           char msg[60];
-           const char *element = odr_getelement(c->odr_in);
-           sprintf (msg, "ODR code %d:%d element=%-20s",
-                    err, x, element ? element : "<unknown>");
-           set_ZOOM_error(c, ZOOM_ERROR_DECODE, msg);
-           do_close (c);
-       }
-       else if (gdu->which == Z_GDU_Z3950)
-           recv_apdu (c, gdu->u.z3950);
+        if (!z_GDU (c->odr_in, &gdu, 0, 0))
+        {
+            int x;
+            int err = odr_geterrorx(c->odr_in, &x);
+            char msg[60];
+            const char *element = odr_getelement(c->odr_in);
+            sprintf (msg, "ODR code %d:%d element=%-20s",
+                     err, x, element ? element : "<unknown>");
+            set_ZOOM_error(c, ZOOM_ERROR_DECODE, msg);
+            do_close (c);
+        }
+        else if (gdu->which == Z_GDU_Z3950)
+            recv_apdu (c, gdu->u.z3950);
         else if (gdu->which == Z_GDU_HTTP_Response)
         {
 #if HAVE_XML2
             handle_http (c, gdu->u.HTTP_Response);
 #else
             set_ZOOM_error(c, ZOOM_ERROR_DECODE, 0);
-           do_close (c);
+            do_close (c);
 #endif
         }
         c->reconnect_ok = 0;
@@ -3372,12 +3372,12 @@ static zoom_ret do_write_ex (ZOOM_connection c, char *buf_out, int len_out)
             ZOOM_connection_insert_task (c, ZOOM_TASK_CONNECT);
             return zoom_pending;
         }
-       if (c->state == STATE_CONNECTING)
-           set_ZOOM_error(c, ZOOM_ERROR_CONNECT, 0);
-       else
+        if (c->state == STATE_CONNECTING)
+            set_ZOOM_error(c, ZOOM_ERROR_CONNECT, 0);
+        else
             set_ZOOM_error(c, ZOOM_ERROR_CONNECTION_LOST, 0);
-       do_close (c);
-       return zoom_complete;
+        do_close (c);
+        return zoom_complete;
     }
     else if (r == 1)
     {    
@@ -3387,13 +3387,13 @@ static zoom_ret do_write_ex (ZOOM_connection c, char *buf_out, int len_out)
         if (c->cs->io_pending & CS_WANT_READ)
             c->mask += ZOOM_SELECT_READ;
         yaz_log(log_details, "%p do_write_ex write incomplete mask=%d",
-               c, c->mask);
+                c, c->mask);
     }
     else
     {
         c->mask = ZOOM_SELECT_READ|ZOOM_SELECT_EXCEPT;
         yaz_log(log_details, "%p do_write_ex write complete mask=%d",
-               c, c->mask);
+                c, c->mask);
     }
     return zoom_pending;
 }
@@ -3412,14 +3412,14 @@ ZOOM_connection_option_get (ZOOM_connection c, const char *key)
 
 ZOOM_API(void)
 ZOOM_connection_option_set (ZOOM_connection c, const char *key,
-                           const char *val)
+                            const char *val)
 {
     ZOOM_options_set (c->options, key, val);
 }
 
 ZOOM_API(void)
 ZOOM_connection_option_setl (ZOOM_connection c, const char *key,
-                            const char *val, int len)
+                             const char *val, int len)
 {
     ZOOM_options_setl (c->options, key, val, len);
 }
@@ -3466,31 +3466,31 @@ ZOOM_diag_str (int error)
     switch (error)
     {
     case ZOOM_ERROR_NONE:
-       return "No error";
+        return "No error";
     case ZOOM_ERROR_CONNECT:
-       return "Connect failed";
+        return "Connect failed";
     case ZOOM_ERROR_MEMORY:
-       return "Out of memory";
+        return "Out of memory";
     case ZOOM_ERROR_ENCODE:
-       return "Encoding failed";
+        return "Encoding failed";
     case ZOOM_ERROR_DECODE:
-       return "Decoding failed";
+        return "Decoding failed";
     case ZOOM_ERROR_CONNECTION_LOST:
-       return "Connection lost";
+        return "Connection lost";
     case ZOOM_ERROR_INIT:
-       return "Init rejected";
+        return "Init rejected";
     case ZOOM_ERROR_INTERNAL:
-       return "Internal failure";
+        return "Internal failure";
     case ZOOM_ERROR_TIMEOUT:
-       return "Timeout";
+        return "Timeout";
     case ZOOM_ERROR_UNSUPPORTED_PROTOCOL:
-       return "Unsupported protocol";
+        return "Unsupported protocol";
     case ZOOM_ERROR_UNSUPPORTED_QUERY:
-       return "Unsupported query type";
+        return "Unsupported query type";
     case ZOOM_ERROR_INVALID_QUERY:
-       return "Invalid query";
+        return "Invalid query";
     default:
-       return diagbib1_str (error);
+        return diagbib1_str (error);
     }
 }
 
@@ -3531,13 +3531,13 @@ static int ZOOM_connection_do_io(ZOOM_connection c, int mask)
     ZOOM_Event event = 0;
     int r = cs_look(c->cs);
     yaz_log(log_details, "%p ZOOM_connection_do_io mask=%d cs_look=%d",
-            c, mask, r);
+             c, mask, r);
     
     if (r == CS_NONE)
     {
         event = ZOOM_Event_create (ZOOM_EVENT_CONNECT);
-       set_ZOOM_error(c, ZOOM_ERROR_CONNECT, 0);
-       do_close (c);
+        set_ZOOM_error(c, ZOOM_ERROR_CONNECT, 0);
+        do_close (c);
         ZOOM_connection_put_event (c, event);
     }
     else if (r == CS_CONNECT)
@@ -3547,7 +3547,7 @@ static int ZOOM_connection_do_io(ZOOM_connection c, int mask)
 
         ret = cs_rcvconnect (c->cs);
         yaz_log(log_details, "%p ZOOM_connection_do_io "
-               "cs_rcvconnect returned %d", c, ret);
+                "cs_rcvconnect returned %d", c, ret);
         if (ret == 1)
         {
             c->mask = ZOOM_SELECT_EXCEPT;
@@ -3560,7 +3560,7 @@ static int ZOOM_connection_do_io(ZOOM_connection c, int mask)
         else if (ret == 0)
         {
             ZOOM_connection_put_event (c, event);
-           get_cert(c);
+            get_cert(c);
             if (c->proto == PROTO_Z3950)
                 ZOOM_connection_send_init(c);
             else
@@ -3615,12 +3615,12 @@ ZOOM_event (int no, ZOOM_connection *cs)
 
     for (i = 0; i<no; i++)
     {
-       ZOOM_connection c = cs[i];
+        ZOOM_connection c = cs[i];
         ZOOM_Event event;
-       if (c && (event = ZOOM_connection_get_event(c)))
+        if (c && (event = ZOOM_connection_get_event(c)))
         {
             ZOOM_Event_destroy (event);
-           return i+1;
+            return i+1;
         }
     }
     for (i = 0; i<no; i++)
@@ -3646,31 +3646,31 @@ ZOOM_event (int no, ZOOM_connection *cs)
     nfds = 0;
     for (i = 0; i<no; i++)
     {
-       ZOOM_connection c = cs[i];
-       int fd, mask;
+        ZOOM_connection c = cs[i];
+        int fd, mask;
         int this_timeout;
-       
-       if (!c)
-           continue;
-       fd = z3950_connection_socket(c);
-       mask = z3950_connection_mask(c);
-
-       if (fd == -1)
-           continue;
-       if (max_fd < fd)
-           max_fd = fd;
-       
-       /* -1 is used for indefinite timeout (no timeout), so -2 here. */
+        
+        if (!c)
+            continue;
+        fd = z3950_connection_socket(c);
+        mask = z3950_connection_mask(c);
+
+        if (fd == -1)
+            continue;
+        if (max_fd < fd)
+            max_fd = fd;
+        
+        /* -1 is used for indefinite timeout (no timeout), so -2 here. */
         this_timeout = ZOOM_options_get_int (c->options, "timeout", -2);
-       if (this_timeout != -2)
-       {
-           /* ensure the minimum timeout is used */
-           if (!timeout_set)
-               timeout = this_timeout;
-           else if (this_timeout != -1 && this_timeout < timeout)
-               timeout = this_timeout;
-           timeout_set = 1;
-       }               
+        if (this_timeout != -2)
+        {
+            /* ensure the minimum timeout is used */
+            if (!timeout_set)
+                timeout = this_timeout;
+            else if (this_timeout != -1 && this_timeout < timeout)
+                timeout = this_timeout;
+            timeout_set = 1;
+        }               
 #if HAVE_SYS_POLL_H
         if (mask)
         {
@@ -3689,21 +3689,21 @@ ZOOM_event (int no, ZOOM_connection *cs)
             nfds++;
         }
 #else
-       if (mask & ZOOM_SELECT_READ)
-       {
-           FD_SET (fd, &input);
-           nfds++;
-       }
-       if (mask & ZOOM_SELECT_WRITE)
-       {
-           FD_SET (fd, &output);
-           nfds++;
-       }
-       if (mask & ZOOM_SELECT_EXCEPT)
-       {
-           FD_SET (fd, &except);
-           nfds++;
-       }
+        if (mask & ZOOM_SELECT_READ)
+        {
+            FD_SET (fd, &input);
+            nfds++;
+        }
+        if (mask & ZOOM_SELECT_WRITE)
+        {
+            FD_SET (fd, &output);
+            nfds++;
+        }
+        if (mask & ZOOM_SELECT_EXCEPT)
+        {
+            FD_SET (fd, &except);
+            nfds++;
+        }
 #endif
     }
     if (!nfds)
@@ -3729,8 +3729,8 @@ ZOOM_event (int no, ZOOM_connection *cs)
         else if (r == 0 && c->mask)
         {
             ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_TIMEOUT);
-           /* timeout and this connection was waiting */
-           set_ZOOM_error(c, ZOOM_ERROR_TIMEOUT, 0);
+            /* timeout and this connection was waiting */
+            set_ZOOM_error(c, ZOOM_ERROR_TIMEOUT, 0);
             do_close (c);
             ZOOM_connection_put_event(c, event);
         }
@@ -3741,44 +3741,52 @@ ZOOM_event (int no, ZOOM_connection *cs)
     r = select (max_fd+1, &input, &output, &except, (timeout == -1 ? 0 : &tv));
     for (i = 0; i<no; i++)
     {
-       ZOOM_connection c = cs[i];
-       int fd, mask;
-
-       if (!c)
-           continue;
-       fd = z3950_connection_socket(c);
-       mask = 0;
-       if (r && c->mask)
-       {
-           /* no timeout and real socket */
-           if (FD_ISSET(fd, &input))
-               mask += ZOOM_SELECT_READ;
-           if (FD_ISSET(fd, &output))
-               mask += ZOOM_SELECT_WRITE;
-           if (FD_ISSET(fd, &except))
-               mask += ZOOM_SELECT_EXCEPT;
-           if (mask)
-               ZOOM_connection_do_io(c, mask);
-       }
-       if (r == 0 && c->mask)
-       {
+        ZOOM_connection c = cs[i];
+        int fd, mask;
+
+        if (!c)
+            continue;
+        fd = z3950_connection_socket(c);
+        mask = 0;
+        if (r && c->mask)
+        {
+            /* no timeout and real socket */
+            if (FD_ISSET(fd, &input))
+                mask += ZOOM_SELECT_READ;
+            if (FD_ISSET(fd, &output))
+                mask += ZOOM_SELECT_WRITE;
+            if (FD_ISSET(fd, &except))
+                mask += ZOOM_SELECT_EXCEPT;
+            if (mask)
+                ZOOM_connection_do_io(c, mask);
+        }
+        if (r == 0 && c->mask)
+        {
             ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_TIMEOUT);
-           /* timeout and this connection was waiting */
-           set_ZOOM_error(c, ZOOM_ERROR_TIMEOUT, 0);
+            /* timeout and this connection was waiting */
+            set_ZOOM_error(c, ZOOM_ERROR_TIMEOUT, 0);
             do_close (c);
             ZOOM_connection_put_event(c, event);
-       }
+        }
     }
 #endif
     for (i = 0; i<no; i++)
     {
-       ZOOM_connection c = cs[i];
+        ZOOM_connection c = cs[i];
         ZOOM_Event event;
-       if (c && (event = ZOOM_connection_get_event(c)))
+        if (c && (event = ZOOM_connection_get_event(c)))
         {
             ZOOM_Event_destroy (event);
-           return i+1;
+            return i+1;
         }
     }
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index f628a1e..fe1362b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-opt.c,v 1.3 2005-01-15 19:47:15 adam Exp $
+ * $Id: zoom-opt.c,v 1.4 2005-06-25 15:46:07 adam Exp $
  */
 /**
  * \file zoom-opt.c
@@ -37,10 +37,10 @@ ZOOM_options_create_with_parent2 (ZOOM_options parent1, ZOOM_options parent2)
     opt->entries = 0;
     opt->parent1= parent1;
     if (parent1)
-       (parent1->refcount)++;
+        (parent1->refcount)++;
     opt->parent2= parent2;
     if (parent2)
-       (parent2->refcount)++;
+        (parent2->refcount)++;
     return opt;
 }
 
@@ -69,24 +69,24 @@ ZOOM_API(void)
 ZOOM_options_destroy (ZOOM_options opt)
 {
     if (!opt)
-       return;
+        return;
     (opt->refcount)--;
     if (opt->refcount == 0)
     {
-       struct ZOOM_options_entry *e;
-       
-       ZOOM_options_destroy (opt->parent1);
-       ZOOM_options_destroy (opt->parent2);
-       e = opt->entries;
-       while (e)
-       {
-           struct ZOOM_options_entry *e0 = e;
-           xfree (e->name);
-           xfree (e->value);
-           e = e->next;
-           xfree (e0);
-       }
-       xfree (opt);
+        struct ZOOM_options_entry *e;
+        
+        ZOOM_options_destroy (opt->parent1);
+        ZOOM_options_destroy (opt->parent2);
+        e = opt->entries;
+        while (e)
+        {
+            struct ZOOM_options_entry *e0 = e;
+            xfree (e->name);
+            xfree (e->value);
+            e = e->next;
+            xfree (e0);
+        }
+        xfree (opt);
     }
 }
 
@@ -99,9 +99,9 @@ ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value,
     e = &opt->entries;
     while (*e)
     {
-       if (!strcmp((*e)->name, name))
-       {
-           xfree ((*e)->value);
+        if (!strcmp((*e)->name, name))
+        {
+            xfree ((*e)->value);
             (*e)->value = 0;
             if (value)
             {
@@ -109,9 +109,9 @@ ZOOM_options_setl (ZOOM_options opt, const char *name, const char *value,
                 memcpy ((*e)->value, value, len);
                 (*e)->value[len] = '\0';
             }
-           return;
-       }
-       e = &(*e)->next;
+            return;
+        }
+        e = &(*e)->next;
     }
     *e = (struct ZOOM_options_entry *) xmalloc (sizeof(**e));
     (*e)->name = xstrdup (name);
@@ -136,23 +136,23 @@ ZOOM_options_get (ZOOM_options opt, const char *name)
 {
     const char *v = 0;
     if (!opt)
-       return 0;
+        return 0;
     if (opt->callback_func)
-       v = (*opt->callback_func)(opt->callback_handle, name);
+        v = (*opt->callback_func)(opt->callback_handle, name);
     if (!v)
     {
-       struct ZOOM_options_entry *e;
-       for (e = opt->entries; e; e = e->next)
-           if (!strcmp(e->name, name))
-           {
-               v = e->value;
-               break;
-           }
+        struct ZOOM_options_entry *e;
+        for (e = opt->entries; e; e = e->next)
+            if (!strcmp(e->name, name))
+            {
+                v = e->value;
+                break;
+            }
     }
     if (!v)
-       v = ZOOM_options_get(opt->parent1, name);
+        v = ZOOM_options_get(opt->parent1, name);
     if (!v)
-       v = ZOOM_options_get(opt->parent2, name);
+        v = ZOOM_options_get(opt->parent2, name);
     return v;
 }
 
@@ -162,9 +162,9 @@ ZOOM_options_get_bool (ZOOM_options opt, const char *name, int defa)
     const char *v = ZOOM_options_get (opt, name);
 
     if (!v)
-       return defa;
+        return defa;
     if (!strcmp (v, "1") || !strcmp(v, "T"))
-       return 1;
+        return 1;
     return 0;
 }
 
@@ -174,7 +174,7 @@ ZOOM_options_get_int (ZOOM_options opt, const char *name, int defa)
     const char *v = ZOOM_options_get (opt, name);
 
     if (!v || !*v)
-       return defa;
+        return defa;
     return atoi(v);
 }
 
@@ -186,3 +186,11 @@ ZOOM_options_set_int(ZOOM_options opt, const char *name, int value)
     sprintf (s, "%d", value);
     ZOOM_options_set (opt, name, s);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 72cbf9f..a1ef953 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoom-p.h,v 1.6 2005-01-15 19:47:15 adam Exp $
+ * $Id: zoom-p.h,v 1.7 2005-06-25 15:46:07 adam Exp $
  */
 /**
  * \file zoom-p.h
@@ -158,10 +158,10 @@ struct ZOOM_task_p {
 #define ZOOM_TASK_PACKAGE 5
         ZOOM_package package;
 #define ZOOM_TASK_SORT 6
-       struct {
-           ZOOM_resultset resultset;
-           ZOOM_query q;
-       } sort;
+        struct {
+            ZOOM_resultset resultset;
+            ZOOM_query q;
+        } sort;
     } u;
     ZOOM_task next;
 };
@@ -173,3 +173,11 @@ struct ZOOM_Event_p {
 };
 
 void ZOOM_options_addref (ZOOM_options opt);
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c816601..0ab7517 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstccl.c,v 1.8 2005-04-15 21:47:56 adam Exp $
+ * $Id: tstccl.c,v 1.9 2005-06-25 15:46:07 adam Exp $
  */
 
 /* CCL test */
@@ -59,9 +59,9 @@ void tst1(int pass, int *number_of_errors)
         ccl_qual_fitem(bibset, "1=/my/title",         "dc.title");
         ccl_qual_fitem(bibset, "r=r",         "date");
         ccl_qual_fitem(bibset, "r=o",         "x");
-       break;
+        break;
     case 1:
-       strcpy(tstline, "ti u=4    s=pw t=l,r");
+        strcpy(tstline, "ti u=4    s=pw t=l,r");
         ccl_qual_line(bibset, tstline);
 
         strcpy(tstline, "term 1=1016 s=al,pw   # default term");
@@ -75,60 +75,60 @@ void tst1(int pass, int *number_of_errors)
 
         strcpy(tstline, "x r=o # ordered relation");
         ccl_qual_line(bibset, tstline);
-       break;
+        break;
     case 2:
         ccl_qual_buf(bibset, "ti u=4    s=pw t=l,r\n"
-                    "term 1=1016 s=al,pw\r\n"
-                    "\n"
-                    "dc.title 1=/my/title\n"
-                    "date r=r\n" 
-                    "x r=o\n"
-           );
-       break;
+                     "term 1=1016 s=al,pw\r\n"
+                     "\n"
+                     "dc.title 1=/my/title\n"
+                     "date r=r\n" 
+                     "x r=o\n"
+            );
+        break;
     default:
-       exit(23);
+        exit(23);
     }
 
     parser->bibset = bibset;
 
     for (i = 0; query_str[i].query; i++)
     {
-       struct ccl_token *token_list;
-       struct ccl_rpn_node *rpn;
-
-       token_list = ccl_parser_tokenize(parser, query_str[i].query);
-       rpn = ccl_parser_find(parser, token_list);
-       ccl_token_del (token_list);
-       if (rpn)
-       {
-           WRBUF wrbuf = wrbuf_alloc();
-           ccl_pquery(wrbuf, rpn);
-
-           if (!query_str[i].result)
-           {
-               printf ("Failed %s\n", query_str[i].query);
-               printf (" got:     %s:\n", wrbuf_buf(wrbuf));
-               printf (" expected failure\n");
-               (*number_of_errors)++;
-           }
-           else if (strcmp(wrbuf_buf(wrbuf), query_str[i].result))
-           {
-               printf ("Failed %s\n", query_str[i].query);
-               printf (" got:     %s:\n", wrbuf_buf(wrbuf));
-               printf (" expected:%s:\n", query_str[i].result);
-               (*number_of_errors)++;
-           }
-           ccl_rpn_delete(rpn);
-           wrbuf_free(wrbuf, 1);
-       }
-       else if (query_str[i].result)
-       {
-           printf ("Failed %s\n", query_str[i].query);
-           printf (" got failure\n");
-           printf (" expected:%s:\n", query_str[i].result);
-           (*number_of_errors)++;
-       }
-    }  
+        struct ccl_token *token_list;
+        struct ccl_rpn_node *rpn;
+
+        token_list = ccl_parser_tokenize(parser, query_str[i].query);
+        rpn = ccl_parser_find(parser, token_list);
+        ccl_token_del (token_list);
+        if (rpn)
+        {
+            WRBUF wrbuf = wrbuf_alloc();
+            ccl_pquery(wrbuf, rpn);
+
+            if (!query_str[i].result)
+            {
+                printf ("Failed %s\n", query_str[i].query);
+                printf (" got:     %s:\n", wrbuf_buf(wrbuf));
+                printf (" expected failure\n");
+                (*number_of_errors)++;
+            }
+            else if (strcmp(wrbuf_buf(wrbuf), query_str[i].result))
+            {
+                printf ("Failed %s\n", query_str[i].query);
+                printf (" got:     %s:\n", wrbuf_buf(wrbuf));
+                printf (" expected:%s:\n", query_str[i].result);
+                (*number_of_errors)++;
+            }
+            ccl_rpn_delete(rpn);
+            wrbuf_free(wrbuf, 1);
+        }
+        else if (query_str[i].result)
+        {
+            printf ("Failed %s\n", query_str[i].query);
+            printf (" got failure\n");
+            printf (" expected:%s:\n", query_str[i].result);
+            (*number_of_errors)++;
+        }
+    }   
     ccl_parser_destroy (parser);
     ccl_qual_rm(&bibset);
 }
@@ -138,12 +138,20 @@ int main(int argc, char **argv)
     int number_of_errors = 0;
     tst1(0, &number_of_errors);
     if (number_of_errors)
-       exit(1);
+        exit(1);
     tst1(1, &number_of_errors);
     if (number_of_errors)
-       exit(1);
+        exit(1);
     tst1(2, &number_of_errors);
     if (number_of_errors)
-       exit(1);
+        exit(1);
     exit(0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 6f230c1..b7e9704 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tsticonv.c,v 1.9 2005-05-08 07:35:23 adam Exp $
+ * $Id: tsticonv.c,v 1.10 2005-06-25 15:46:07 adam Exp $
  */
 
 #if HAVE_CONFIG_H
 #include <yaz/yaz-util.h>
 
 static int compare_buffers(char *msg, int no,
-                          int expect_len, const unsigned char *expect_buf,
-                          int got_len, const unsigned char *got_buf)
+                           int expect_len, const unsigned char *expect_buf,
+                           int got_len, const unsigned char *got_buf)
 {
     int i;
     if (expect_len == got_len
-       && !memcmp(expect_buf, got_buf, expect_len))
-       return 1;
+        && !memcmp(expect_buf, got_buf, expect_len))
+        return 1;
     printf("tsticonv test=%s i=%d failed\n", msg, no);
     printf("off got exp\n");
     for (i = 0; i<got_len || i<expect_len; i++)
     {
-       char got_char[10];
-       char expect_char[10];
+        char got_char[10];
+        char expect_char[10];
 
-       if (i < got_len)
-           sprintf(got_char, "%02X", got_buf[i]);
-       else
-           sprintf(got_char, "?  ");
+        if (i < got_len)
+            sprintf(got_char, "%02X", got_buf[i]);
+        else
+            sprintf(got_char, "?  ");
 
-       if (i < expect_len)
-           sprintf(expect_char, "%02X", expect_buf[i]);
-       else
-           sprintf(expect_char, "?  ");
-       
-       printf("%02d  %s  %s %c\n",
-              i, got_char, expect_char, got_buf[i] == expect_buf[i] ?
-              ' ' : '*');
+        if (i < expect_len)
+            sprintf(expect_char, "%02X", expect_buf[i]);
+        else
+            sprintf(expect_char, "?  ");
+        
+        printf("%02d  %s  %s %c\n",
+               i, got_char, expect_char, got_buf[i] == expect_buf[i] ?
+               ' ' : '*');
 
     }
     exit(1);
@@ -78,8 +78,8 @@ static void tst_marc8_to_iso_8859_1()
     cd = yaz_iconv_open("ISO-8859-1", "MARC8");
     if (!cd)
     {
-       printf("tsticonv 10 yaz_iconv_open failed\n");
-       exit(10);
+        printf("tsticonv 10 yaz_iconv_open failed\n");
+        exit(10);
     }
     for (i = 0; iso_8859_1_a[i]; i++)
     {
@@ -96,11 +96,11 @@ static void tst_marc8_to_iso_8859_1()
             int e = yaz_iconv_error(cd);
 
             printf ("tsticonv 11 i=%d e=%d\n", i, e);
-           exit(11);
+            exit(11);
         }
-       compare_buffers("tsticonv 11", i,
-                       strlen(iso_8859_1_a[i]), iso_8859_1_a[i],
-                       outbuf - outbuf0, outbuf0);
+        compare_buffers("tsticonv 11", i,
+                        strlen(iso_8859_1_a[i]), iso_8859_1_a[i],
+                        outbuf - outbuf0, outbuf0);
     }
     yaz_iconv_close(cd);
 }
@@ -108,59 +108,59 @@ static void tst_marc8_to_iso_8859_1()
 static void tst_marc8_to_ucs4b()
 {
     static struct {
-       const unsigned char *marc8_b;
-       int len;
-       const unsigned char *ucs4_b;
+        const unsigned char *marc8_b;
+        int len;
+        const unsigned char *ucs4_b;
     } ar[] = {
     { 
         "\033$1" "\x21\x2B\x3B" /* FF1F */ "\033(B" "o",
-       8, "\x00\x00\xFF\x1F" "\x00\x00\x00o"
+        8, "\x00\x00\xFF\x1F" "\x00\x00\x00o"
     }, {
-       "\033$1" "\x6F\x77\x29" /* AE0E */ "\x6F\x52\x7C" /* c0F4 */ "\033(B",
-       8, "\x00\x00\xAE\x0E" "\x00\x00\xC0\xF4",
+        "\033$1" "\x6F\x77\x29" /* AE0E */ "\x6F\x52\x7C" /* c0F4 */ "\033(B",
+        8, "\x00\x00\xAE\x0E" "\x00\x00\xC0\xF4",
     }, {
-       "\033$1"
-       "\x21\x50\x6E"  /* UCS 7CFB */
-       "\x21\x51\x31"  /* UCS 7D71 */
-       "\x21\x3A\x67"  /* UCS 5B89 */
-       "\x21\x33\x22"  /* UCS 5168 */
-       "\x21\x33\x53"  /* UCS 5206 */
-       "\x21\x44\x2B"  /* UCS 6790 */
-       "\033(B",
-       24, "\x00\x00\x7C\xFB"
-       "\x00\x00\x7D\x71"
-       "\x00\x00\x5B\x89"
-       "\x00\x00\x51\x68"
-       "\x00\x00\x52\x06"
-       "\x00\x00\x67\x90"
+        "\033$1"
+        "\x21\x50\x6E"  /* UCS 7CFB */
+        "\x21\x51\x31"  /* UCS 7D71 */
+        "\x21\x3A\x67"  /* UCS 5B89 */
+        "\x21\x33\x22"  /* UCS 5168 */
+        "\x21\x33\x53"  /* UCS 5206 */
+        "\x21\x44\x2B"  /* UCS 6790 */
+        "\033(B",
+        24, "\x00\x00\x7C\xFB"
+        "\x00\x00\x7D\x71"
+        "\x00\x00\x5B\x89"
+        "\x00\x00\x51\x68"
+        "\x00\x00\x52\x06"
+        "\x00\x00\x67\x90"
     }, {
-       "\xB0\xB2",     /* AYN and oSLASH */
-       8, "\x00\x00\x02\xBB"  "\x00\x00\x00\xF8"
+        "\xB0\xB2",     /* AYN and oSLASH */
+        8, "\x00\x00\x02\xBB"  "\x00\x00\x00\xF8"
     }, {
-       "\xF6\x61",     /* a underscore */
-       8, "\x00\x00\x00\x61"  "\x00\x00\x03\x32"
+        "\xF6\x61",     /* a underscore */
+        8, "\x00\x00\x00\x61"  "\x00\x00\x03\x32"
     }, {
-       "\x61\xC2",     /* a, phonorecord mark */
-       8, "\x00\x00\x00\x61"  "\x00\x00\x21\x17"
+        "\x61\xC2",     /* a, phonorecord mark */
+        8, "\x00\x00\x00\x61"  "\x00\x00\x21\x17"
     },
     {  /* bug #258 */
-       "el" "\xe8" "am\xe8" "an", /* elaman where a is a" */
-       32,
-       "\x00\x00\x00" "e"
-       "\x00\x00\x00" "l"
-       "\x00\x00\x00" "a"
-       "\x00\x00\x03\x08"
-       "\x00\x00\x00" "m"
-       "\x00\x00\x00" "a"
-       "\x00\x00\x03\x08"
-       "\x00\x00\x00" "n"
+        "el" "\xe8" "am\xe8" "an", /* elaman where a is a" */
+        32,
+        "\x00\x00\x00" "e"
+        "\x00\x00\x00" "l"
+        "\x00\x00\x00" "a"
+        "\x00\x00\x03\x08"
+        "\x00\x00\x00" "m"
+        "\x00\x00\x00" "a"
+        "\x00\x00\x03\x08"
+        "\x00\x00\x00" "n"
     }, 
     { /* bug #260 */
-       "\xe5\xe8\x41",
-       12, "\x00\x00\x00\x41" "\x00\x00\x03\x04" "\x00\x00\x03\x08"
+        "\xe5\xe8\x41",
+        12, "\x00\x00\x00\x41" "\x00\x00\x03\x04" "\x00\x00\x03\x08"
     }, 
     {
-       0, 0, 0
+        0, 0, 0
     }
     };
     int i;
@@ -169,39 +169,39 @@ static void tst_marc8_to_ucs4b()
     cd = yaz_iconv_open("UCS4", "MARC8");
     if (!cd)
     {
-       printf ("tsticonv 20 yaz_iconv_open failed\n");
-       exit(20);
+        printf ("tsticonv 20 yaz_iconv_open failed\n");
+        exit(20);
     }
     for (i = 0; ar[i].len; i++)
     {
         size_t r;
-       size_t expect_len = ar[i].len;
+        size_t expect_len = ar[i].len;
         char *inbuf= (char*) ar[i].marc8_b;
         size_t inbytesleft = strlen(inbuf);
         char outbuf0[64];
         char *outbuf = outbuf0;
 
-       while (inbytesleft)
-       {
-           size_t outbytesleft = outbuf0 + sizeof(outbuf0) - outbuf;
-           if (outbytesleft > 12)
-               outbytesleft = 12;
+        while (inbytesleft)
+        {
+            size_t outbytesleft = outbuf0 + sizeof(outbuf0) - outbuf;
+            if (outbytesleft > 12)
+                outbytesleft = 12;
             r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
             if (r == (size_t) (-1))
             {
                 int e = yaz_iconv_error(cd);
-               if (e != YAZ_ICONV_E2BIG)
-               {
+                if (e != YAZ_ICONV_E2BIG)
+                {
                     printf ("tsticonv 21 i=%d e=%d\n", i, e);
-                   exit(21);
-               }
-           }
-           else
-               break;
+                    exit(21);
+                }
+            }
+            else
+                break;
         }
-       compare_buffers("tsticonv 22", i,
-                       expect_len, ar[i].ucs4_b,
-                       outbuf - outbuf0, outbuf0);
+        compare_buffers("tsticonv 22", i,
+                        expect_len, ar[i].ucs4_b,
+                        outbuf - outbuf0, outbuf0);
     }
     yaz_iconv_close(cd);
 }
@@ -209,14 +209,14 @@ static void tst_marc8_to_ucs4b()
 static void tst_ucs4b_to_utf8()
 {
     static const char *ucs4_c[] = {
-       "\x00\x00\xFF\x1F\x00\x00\x00o",
-       "\x00\x00\xAE\x0E\x00\x00\xC0\xF4",
-       0
+        "\x00\x00\xFF\x1F\x00\x00\x00o",
+        "\x00\x00\xAE\x0E\x00\x00\xC0\xF4",
+        0
     };
     static const char *utf8_c[] = {
-       "\xEF\xBC\x9F\x6F",
-       "\xEA\xB8\x8E\xEC\x83\xB4",
-       0
+        "\xEF\xBC\x9F\x6F",
+        "\xEA\xB8\x8E\xEC\x83\xB4",
+        0
     };
     
     int i;
@@ -225,8 +225,8 @@ static void tst_ucs4b_to_utf8()
     cd = yaz_iconv_open("UTF8", "UCS4");
     if (!cd)
     {
-       printf ("tsticonv 30 yaz_iconv_open failed\n");
-       exit(30);
+        printf ("tsticonv 30 yaz_iconv_open failed\n");
+        exit(30);
     }
     for (i = 0; ucs4_c[i]; i++)
     {
@@ -243,11 +243,11 @@ static void tst_ucs4b_to_utf8()
             int e = yaz_iconv_error(cd);
 
             printf ("tsticonv 31 i=%d e=%d\n", i, e);
-           exit(31);
+            exit(31);
         }
-       compare_buffers("tsticonv 32", i,
-                       strlen(utf8_c[i]), utf8_c[i],
-                       outbuf - outbuf0, outbuf0);
+        compare_buffers("tsticonv 32", i,
+                        strlen(utf8_c[i]), utf8_c[i],
+                        outbuf - outbuf0, outbuf0);
     }
     yaz_iconv_close(cd);
 }
@@ -259,58 +259,58 @@ static void dconvert(int mandatory, const char *tmpcode)
     for (i = 0; iso_8859_1_a[i]; i++)
     {
         size_t r;
-       char *inbuf = (char*) iso_8859_1_a[i];
-       size_t inbytesleft = strlen(inbuf);
-       char outbuf0[24];
-       char outbuf1[10];
-       char *outbuf = outbuf0;
-       size_t outbytesleft = sizeof(outbuf0);
+        char *inbuf = (char*) iso_8859_1_a[i];
+        size_t inbytesleft = strlen(inbuf);
+        char outbuf0[24];
+        char outbuf1[10];
+        char *outbuf = outbuf0;
+        size_t outbytesleft = sizeof(outbuf0);
 
         cd = yaz_iconv_open(tmpcode, "ISO-8859-1");
-       if (!cd)
+        if (!cd)
         {
             if (!mandatory)
                 return;
             printf ("tsticonv code=%s i=%d 1\n", tmpcode, i);
-           exit(1);
+            exit(1);
         }
-       r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
-       if (r == (size_t)(-1))
+        r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+        if (r == (size_t)(-1))
         {
             int e = yaz_iconv_error(cd);
 
             printf ("tsticonv code=%s i=%d 2 e=%d\n", tmpcode, i, e);
-           exit(2);
+            exit(2);
         }
-       yaz_iconv_close(cd);
+        yaz_iconv_close(cd);
         
-       cd = yaz_iconv_open("ISO-8859-1", tmpcode);
-       if (!cd)
+        cd = yaz_iconv_open("ISO-8859-1", tmpcode);
+        if (!cd)
         {
             if (!mandatory)
                 return;
             printf ("tsticonv code=%s i=%d 3\n", tmpcode, i);
-           exit(3);
+            exit(3);
         }
-       inbuf = outbuf0;
-       inbytesleft = sizeof(outbuf0) - outbytesleft;
+        inbuf = outbuf0;
+        inbytesleft = sizeof(outbuf0) - outbytesleft;
 
-       outbuf = outbuf1;
-       outbytesleft = sizeof(outbuf1);
-       r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
-       if (r == (size_t)(-1)) {
+        outbuf = outbuf1;
+        outbytesleft = sizeof(outbuf1);
+        r = yaz_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+        if (r == (size_t)(-1)) {
             int e = yaz_iconv_error(cd);
 
             printf ("tsticonv code=%s i=%d 4 e=%d\n", tmpcode, i, e);
-           exit(4);
-       }
-       compare_buffers("dconvert", i,
-                       strlen(iso_8859_1_a[i]), iso_8859_1_a[i],
-                       sizeof(outbuf1) - outbytesleft, outbuf1);
-       yaz_iconv_close(cd);
+            exit(4);
+        }
+        compare_buffers("dconvert", i,
+                        strlen(iso_8859_1_a[i]), iso_8859_1_a[i],
+                        sizeof(outbuf1) - outbytesleft, outbuf1);
+        yaz_iconv_close(cd);
     }
 }
-       
+        
 int main (int argc, char **argv)
 {
     dconvert(1, "UTF-8");
@@ -323,3 +323,11 @@ int main (int argc, char **argv)
     tst_ucs4b_to_utf8();
     exit(0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 743da7f..8bce12f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstlog.c,v 1.4 2005-01-15 19:47:15 adam Exp $
+ * $Id: tstlog.c,v 1.5 2005-06-25 15:46:07 adam Exp $
  *
  */
 #include <stdio.h>
@@ -18,29 +18,37 @@ int main(int argc, char **argv)
 
     while ((ret = options("f:v:l:m:", argv, argc, &arg)) != -2)
     {
-       switch (ret)
-       {
-       case 'f':
-           yaz_log_time_format(arg);
-           break;
-       case 'v':
-           yaz_log_init_level(yaz_log_mask_str(arg));
-           break;
-       case 'l':
-           yaz_log_init_file(arg);
-           break;
-       case 'm':        
-           level = yaz_log_module_level(arg);
-           break;
-       case 0:
-           yaz_log(level, "%s", arg);
-           break;
-       default:
-           fprintf(stderr, "tstlog. Bad option\n");
-           fprintf(stderr, "tstlog [-f logformat] [-v level] [-l file] "
-                   "[-m module] msg ..\n");
-           exit(1);
-       }
+        switch (ret)
+        {
+        case 'f':
+            yaz_log_time_format(arg);
+            break;
+        case 'v':
+            yaz_log_init_level(yaz_log_mask_str(arg));
+            break;
+        case 'l':
+            yaz_log_init_file(arg);
+            break;
+        case 'm':        
+            level = yaz_log_module_level(arg);
+            break;
+        case 0:
+            yaz_log(level, "%s", arg);
+            break;
+        default:
+            fprintf(stderr, "tstlog. Bad option\n");
+            fprintf(stderr, "tstlog [-f logformat] [-v level] [-l file] "
+                    "[-m module] msg ..\n");
+            exit(1);
+        }
     }
     exit(0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 757763c..e20cce8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstmatchstr.c,v 1.3 2005-01-15 19:47:15 adam Exp $
+ * $Id: tstmatchstr.c,v 1.4 2005-06-25 15:46:07 adam Exp $
  */
 
 #include <stdio.h>
@@ -52,3 +52,11 @@ int main (int argc, char **argv)
     exit(0);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2ed2e56..0949749 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstnmem.c,v 1.4 2005-01-15 19:47:15 adam Exp $
+ * $Id: tstnmem.c,v 1.5 2005-06-25 15:46:07 adam Exp $
  */
 
 #if HAVE_CONFIG_H
@@ -31,14 +31,14 @@ int main (int argc, char **argv)
         cp = nmem_malloc(n, j);
         if (!cp)
             exit(2);
-       if (sizeof(long) >= j)
-           *(long*) cp = 123L;
+        if (sizeof(long) >= j)
+            *(long*) cp = 123L;
 #if HAVE_LONG_LONG
-       if (sizeof(long long) >= j)
-           *(long long*) cp = 123L;
+        if (sizeof(long long) >= j)
+            *(long long*) cp = 123L;
 #endif
-       if (sizeof(double) >= j)
-           *(double*) cp = 12.2;
+        if (sizeof(double) >= j)
+            *(double*) cp = 12.2;
     }
     
     for (j = 2000; j<20000; j+= 2000)
@@ -51,3 +51,11 @@ int main (int argc, char **argv)
     nmem_exit();
     exit(0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 5b26a16..33d366b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstodr.c,v 1.5 2005-05-26 21:47:16 adam Exp $
+ * $Id: tstodr.c,v 1.6 2005-06-25 15:46:07 adam Exp $
  *
  */
 #include <stdlib.h>
@@ -53,15 +53,15 @@ void tst_MySequence1(ODR encode, ODR decode)
     if (!t->fifth || *t->fifth != YC_MySequence_enum1)
         exit(8);
     if (!t->myoid)
-       exit(9);
+        exit(9);
     else
     {
-       int *myoid = odr_getoidbystr(decode, MYOID);
-       struct oident *oident;
+        int *myoid = odr_getoidbystr(decode, MYOID);
+        struct oident *oident;
 
-       if (oid_oidcmp(myoid, t->myoid))
-           exit(10);
-       oident = oid_getentbyoid(t->myoid);
+        if (oid_oidcmp(myoid, t->myoid))
+            exit(10);
+        oident = oid_getentbyoid(t->myoid);
     }
 }
 
@@ -128,3 +128,11 @@ int main(int argc, char **argv)
     odr_destroy(odr_decode);
     exit(0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a748840..5018678 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstsoap1.c,v 1.2 2005-05-08 07:33:12 adam Exp $
+ * $Id: tstsoap1.c,v 1.3 2005-06-25 15:46:07 adam Exp $
  */
 
 #include <stdlib.h>
@@ -17,22 +17,22 @@ int main(int argc, char **argv)
 
     if (argc <= 1)
     {
-       xmlChar *buf_out;
-       int len_out;
-       xmlDocPtr doc = xmlNewDoc("1.0");
+        xmlChar *buf_out;
+        int len_out;
+        xmlDocPtr doc = xmlNewDoc("1.0");
 #if 0
-       const char *val = "jordbær"; /* makes xmlDocDumpMemory hang .. */
+        const char *val = "jordbær"; /* makes xmlDocDumpMemory hang .. */
 #else
-       const char *val = "jordbaer"; /* OK */
+        const char *val = "jordbaer"; /* OK */
 #endif
-       xmlNodePtr top = xmlNewNode(0, "top");
-       
-       xmlNewTextChild(top, 0, "sub", val);
-       xmlDocSetRootElement(doc, top);
-       
-       xmlDocDumpMemory(doc, &buf_out, &len_out);
+        xmlNodePtr top = xmlNewNode(0, "top");
+        
+        xmlNewTextChild(top, 0, "sub", val);
+        xmlDocSetRootElement(doc, top);
+        
+        xmlDocDumpMemory(doc, &buf_out, &len_out);
 #if 0
-       printf("%*s", len_out, buf_out);
+        printf("%*s", len_out, buf_out);
 #endif
     }
 #endif
@@ -40,3 +40,11 @@ int main(int argc, char **argv)
 }
 
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 0fd766e..1b952b7 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstsoap2.c,v 1.1 2005-05-06 11:11:37 adam Exp $
+ * $Id: tstsoap2.c,v 1.2 2005-06-25 15:46:07 adam Exp $
  */
 
 #include <stdlib.h>
@@ -43,8 +43,8 @@ static void tst_srw(void)
     odr_destroy(o);
     if (ret)
     {
-       printf("z_soap_codec_enc failed\n");
-       exit(1);
+        printf("z_soap_codec_enc failed\n");
+        exit(1);
     }
 }
 #endif
@@ -55,8 +55,16 @@ int main(int argc, char **argv)
     LIBXML_TEST_VERSION
     if (argc <= 1)
     {
-       tst_srw();
+        tst_srw();
     }
 #endif
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index bab2004..a31115e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: tstwrbuf.c,v 1.3 2005-02-01 17:23:36 adam Exp $
+ * $Id: tstwrbuf.c,v 1.4 2005-06-25 15:46:07 adam Exp $
  */
 
 #include <stdlib.h>
@@ -57,3 +57,11 @@ int main (int argc, char **argv)
     exit(0);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 95ca053..bf855f2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: benchmark.c,v 1.7 2005-01-15 19:47:15 adam Exp $
+/* $Id: benchmark.c,v 1.8 2005-06-25 15:46:07 adam Exp $
  * Copyright (C) 1995-2005, Index Data ApS
  *
  * This file is part of the YAZ toolkit.
 
 
 struct options {
-    int nconnect;              /* number of connections to make */
-    int nsearch;               /* number of searches on each connection */
-    int npresent;              /* number of presents for each search */
-    int full;                  /* 1 = fetch full records, 0 = brief */
-    int delay;                 /* number of ms to delay between ops */
-    int random;                        /* if true, delay is random 0-specified */
-    int verbosity;             /* 0 = quiet, higher => more verbose */
+    int nconnect;               /* number of connections to make */
+    int nsearch;                /* number of searches on each connection */
+    int npresent;               /* number of presents for each search */
+    int full;                   /* 1 = fetch full records, 0 = brief */
+    int delay;                  /* number of ms to delay between ops */
+    int random;                 /* if true, delay is random 0-specified */
+    int verbosity;              /* 0 = quiet, higher => more verbose */
 } options = {
     3,
     3,
@@ -51,47 +51,47 @@ int main(int argc, char **argv)
     int nok = 0;
 
     while ((c = getopt(argc, argv, "c:s:p:fbd:rv:")) != -1) {
-       switch (c) {
-       case 'c': options.nconnect = atoi(optarg); break;
-       case 's': options.nsearch = atoi(optarg); break;
-       case 'p': options.npresent = atoi(optarg); break;
-       case 'f': options.full = 1; break;
-       case 'b': options.full = 0; break;
-       case 'd': options.delay = atoi(optarg); break;
-       case 'r': options.random = 1; break;
-       case 'v': options.verbosity = atoi(optarg); break;
-       default: goto USAGE;
-       }
+        switch (c) {
+        case 'c': options.nconnect = atoi(optarg); break;
+        case 's': options.nsearch = atoi(optarg); break;
+        case 'p': options.npresent = atoi(optarg); break;
+        case 'f': options.full = 1; break;
+        case 'b': options.full = 0; break;
+        case 'd': options.delay = atoi(optarg); break;
+        case 'r': options.random = 1; break;
+        case 'v': options.verbosity = atoi(optarg); break;
+        default: goto USAGE;
+        }
     }
 
     if (argc-optind != 2) {
     USAGE:
-       fprintf(stderr, "Usage: %s [options] <host> <port>\n"
-"      -c <n>  Make <n> connection to the server [default: 3]\n"
-"      -s <n>  Perform <n> searches on each connection [3]\n"
-"      -p <n>  Make <n> present requests after each search [3]\n"
-"      -f      Fetch full records [default: brief]\n"
-"      -b      Fetch brief records\n"
-"      -d <n>  Delay <n> ms after each operation\n"
-"      -r      Delays are random between 0 and the specified number of ms\n"
-"      -v <n>  Set verbosity level to <n> [0, silent on success]\n"
+        fprintf(stderr, "Usage: %s [options] <host> <port>\n"
+"       -c <n>  Make <n> connection to the server [default: 3]\n"
+"       -s <n>  Perform <n> searches on each connection [3]\n"
+"       -p <n>  Make <n> present requests after each search [3]\n"
+"       -f      Fetch full records [default: brief]\n"
+"       -b      Fetch brief records\n"
+"       -d <n>  Delay <n> ms after each operation\n"
+"       -r      Delays are random between 0 and the specified number of ms\n"
+"       -v <n>  Set verbosity level to <n> [0, silent on success]\n"
 , argv[0]);
-       return 1;
+        return 1;
     }
 
     host = argv[optind];
     port = atoi(argv[optind+1]);
 
     for (i = 0; i < options.nconnect; i++) {
-       db_printf(2, "iteration %d of %d", i+1, options.nconnect);
-       ok = test(host, port);
-       if (ok) nok++;
+        db_printf(2, "iteration %d of %d", i+1, options.nconnect);
+        ok = test(host, port);
+        if (ok) nok++;
     }
 
     db_printf(1, "passed %d of %d tests", nok, options.nconnect);
     if (nok < options.nconnect)
-       printf("Failed %d of %d tests\n",
-              options.nconnect-nok, options.nconnect);
+        printf("Failed %d of %d tests\n",
+               options.nconnect-nok, options.nconnect);
 
 
     return 0;
@@ -106,8 +106,8 @@ static int test(char *host, int port)
 
     conn = ZOOM_connection_new(host, port);
     if ((error = ZOOM_connection_error(conn, &errmsg, &addinfo))) {
-       fprintf(stderr, "ZOOM error: %s (%d): %s\n", errmsg, error, addinfo);
-       return 0;
+        fprintf(stderr, "ZOOM error: %s (%d): %s\n", errmsg, error, addinfo);
+        return 0;
     }
 
     ZOOM_connection_destroy(conn);
@@ -119,7 +119,7 @@ static void db_printf(int level, char *fmt, ...)
     va_list ap;
 
     if (level > options.verbosity)
-       return;
+        return;
 
     fprintf(stderr, "DEBUG(%d): ", level);
     va_start(ap, fmt);
@@ -127,3 +127,11 @@ static void db_printf(int level, char *fmt, ...)
     fputc('\n', stderr);
     va_end(ap);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 25d7649..fcb3e86 100644 (file)
@@ -44,7 +44,7 @@
 /* CCL shell.
  * Europagate 1995
  *
- * $Id: cclsh.c,v 1.1 2003-10-27 12:21:38 adam Exp $
+ * $Id: cclsh.c,v 1.2 2005-06-25 15:46:07 adam Exp $
  *
  * Old Europagate Log:
  *
@@ -148,7 +148,7 @@ int main (int argc, char **argv)
                 fclose (bib_inf);
                 break;
             default:
-               usage(prog);
+                usage(prog);
             }
         }
         else
@@ -172,31 +172,31 @@ int main (int argc, char **argv)
             if (*line_in)
                 add_history(line_in);
 #endif
-           if (strlen(line_in) > 999) {
+            if (strlen(line_in) > 999) {
                 fprintf(stderr,"Input line to long\n");
                 break;
-           }
+            }
             strcpy(buf,line_in);
             free (line_in);
 #else    
-       printf ("CCLSH>"); fflush (stdout);
-       if (!fgets (buf, 999, stdin))
-           break;
+        printf ("CCLSH>"); fflush (stdout);
+        if (!fgets (buf, 999, stdin))
+            break;
 #endif 
 
         for (i = 0; i<1; i++)
         {
-           CCL_parser cclp = ccl_parser_create ();
-           struct ccl_token *list;
-           
-           cclp->bibset = bibset;
-           
-           list = ccl_parser_tokenize (cclp, buf);
-           rpn = ccl_parser_find (cclp, list);
-           
-           error = cclp->error_code;
-           if (error)
-               pos = cclp->error_pos - buf;
+            CCL_parser cclp = ccl_parser_create ();
+            struct ccl_token *list;
+            
+            cclp->bibset = bibset;
+            
+            list = ccl_parser_tokenize (cclp, buf);
+            rpn = ccl_parser_find (cclp, list);
+            
+            error = cclp->error_code;
+            if (error)
+                pos = cclp->error_pos - buf;
 
             if (error)
             {
@@ -205,20 +205,20 @@ int main (int argc, char **argv)
             }
             else
             {
-               if (rpn && i == 0)
-               {
-                   ccl_pr_tree (rpn, stdout);
-                   printf ("\n");
-               }
+                if (rpn && i == 0)
+                {
+                    ccl_pr_tree (rpn, stdout);
+                    printf ("\n");
+                }
             }
-           if (debug)
-           {
-               struct ccl_token *lp;
-               for (lp = list; lp; lp = lp->next)
-                   printf ("%d %.*s\n", lp->kind, (int) (lp->len), lp->name);
-           }
-           ccl_token_del (list);
-           ccl_parser_destroy (cclp);
+            if (debug)
+            {
+                struct ccl_token *lp;
+                for (lp = list; lp; lp = lp->next)
+                    printf ("%d %.*s\n", lp->kind, (int) (lp->len), lp->name);
+            }
+            ccl_token_del (list);
+            ccl_parser_destroy (cclp);
             if (rpn)
                 ccl_rpn_delete(rpn);
         }
@@ -226,3 +226,11 @@ int main (int argc, char **argv)
     printf ("\n");
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 086d4bf..3c5df41 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cql2pqf.c,v 1.6 2005-01-15 19:47:15 adam Exp $
+/* $Id: cql2pqf.c,v 1.7 2005-06-25 15:46:07 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -36,20 +36,20 @@ int main(int argc, char **argv)
         switch (ret)
         {
         case 0:
-           if (!fname)
-               fname = arg;
-           else
-               query = arg;
+            if (!fname)
+                fname = arg;
+            else
+                query = arg;
             break;
-       case 'n':
-           iterations = atoi(arg);
-           break;
-       default:
-           usage();
-       }
+        case 'n':
+            iterations = atoi(arg);
+            break;
+        default:
+            usage();
+        }
     }
     if (!fname)
-       usage();
+        usage();
     ct = cql_transform_open_fname(fname);
     if (!ct)
     {
@@ -59,33 +59,41 @@ int main(int argc, char **argv)
 
     if (query)
     {
-       for (i = 0; i<iterations; i++)
-           r = cql_parser_string(cp, query);
+        for (i = 0; i<iterations; i++)
+            r = cql_parser_string(cp, query);
     }
     else
-       r = cql_parser_stdio(cp, stdin);
+        r = cql_parser_stdio(cp, stdin);
 
     if (r)
         fprintf (stderr, "Syntax error\n");
     else
     {
         r = cql_transform_FILE(ct, cql_parser_result(cp), stdout);
-       printf("\n");
+        printf("\n");
         if (r)
         {
             const char *addinfo;
             cql_transform_error(ct, &addinfo);
             printf ("Transform error %d %s\n", r, addinfo ? addinfo : "");
         }
-       else
-       {
-           FILE *null = fopen("/dev/null", "w");
-           for (i = 1; i<iterations; i++)
-               cql_transform_FILE(ct, cql_parser_result(cp), null);
-           fclose(null);
-       }
+        else
+        {
+            FILE *null = fopen("/dev/null", "w");
+            for (i = 1; i<iterations; i++)
+                cql_transform_FILE(ct, cql_parser_result(cp), null);
+            fclose(null);
+        }
     }
     cql_transform_close(ct);
     cql_parser_destroy(cp);
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 138afad..191b8c9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cql2xcql.c,v 1.6 2005-01-15 19:47:15 adam Exp $
+/* $Id: cql2xcql.c,v 1.7 2005-06-25 15:46:07 adam Exp $
    Copyright (C) 1995-2005, Index Data ApS
    Index Data Aps
 
@@ -27,20 +27,20 @@ int main(int argc, char **argv)
         switch (ret)
         {
         case 0:
-           fname = arg;
+            fname = arg;
             break;
-       case 'n':
-           iterations = atoi(arg);
-           break;
-       }
+        case 'n':
+            iterations = atoi(arg);
+            break;
+        }
     }
 
     cp = cql_parser_create();
     if (fname)
     {
-       int i;
-       for (i = 0; i<iterations; i++)
-           r = cql_parser_string(cp, fname);
+        int i;
+        for (i = 0; i<iterations; i++)
+            r = cql_parser_string(cp, fname);
     }
     else
         r = cql_parser_stdio(cp, stdin);
@@ -51,3 +51,11 @@ int main(int argc, char **argv)
     cql_parser_destroy(cp);
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 0108bc6..0c38835 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: marcdump.c,v 1.31 2005-06-09 18:47:07 adam Exp $
+ * $Id: marcdump.c,v 1.32 2005-06-25 15:46:07 adam Exp $
  */
 
 #define _FILE_OFFSET_BITS 64
@@ -62,40 +62,40 @@ void print_xpath_nodes(xmlNodeSetPtr nodes, FILE* output) {
     
     fprintf(output, "Result (%d nodes):\n", size);
     for(i = 0; i < size; ++i) {
-       assert(nodes->nodeTab[i]);
-       
-       if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL)
-       {
-           xmlNsPtr ns;
-           
-           ns = (xmlNsPtr)nodes->nodeTab[i];
-           cur = (xmlNodePtr)ns->next;
-           if(cur->ns) { 
-               fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n", 
-                   ns->prefix, ns->href, cur->ns->href, cur->name);
-           } else {
-               fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n", 
-                   ns->prefix, ns->href, cur->name);
-           }
-       } 
-       else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE)
-       {
-           cur = nodes->nodeTab[i];        
-           if(cur->ns) { 
-               fprintf(output, "= element node \"%s:%s\"\n", 
-                   cur->ns->href, cur->name);
-           } 
-           else
-           {
-               fprintf(output, "= element node \"%s\"\n", 
-                   cur->name);
-           }
-       }
-       else
-       {
-           cur = nodes->nodeTab[i];    
-           fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type);
-       }
+        assert(nodes->nodeTab[i]);
+        
+        if(nodes->nodeTab[i]->type == XML_NAMESPACE_DECL)
+        {
+            xmlNsPtr ns;
+            
+            ns = (xmlNsPtr)nodes->nodeTab[i];
+            cur = (xmlNodePtr)ns->next;
+            if(cur->ns) { 
+                fprintf(output, "= namespace \"%s\"=\"%s\" for node %s:%s\n", 
+                    ns->prefix, ns->href, cur->ns->href, cur->name);
+            } else {
+                fprintf(output, "= namespace \"%s\"=\"%s\" for node %s\n", 
+                    ns->prefix, ns->href, cur->name);
+            }
+        } 
+        else if(nodes->nodeTab[i]->type == XML_ELEMENT_NODE)
+        {
+            cur = nodes->nodeTab[i];        
+            if(cur->ns) { 
+                fprintf(output, "= element node \"%s:%s\"\n", 
+                    cur->ns->href, cur->name);
+            } 
+            else
+            {
+                fprintf(output, "= element node \"%s\"\n", 
+                    cur->name);
+            }
+        }
+        else
+        {
+            cur = nodes->nodeTab[i];    
+            fprintf(output, "= node \"%s\": type %d\n", cur->name, cur->type);
+        }
     }
 }
 #endif
@@ -127,8 +127,8 @@ int main (int argc, char **argv)
 
     while ((r = options("pvc:xOeXIf:t:2", argv, argc, &arg)) != -2)
     {
-       int count;
-       no++;
+        int count;
+        no++;
         switch (r)
         {
         case 'f':
@@ -137,43 +137,43 @@ int main (int argc, char **argv)
         case 't':
             to = arg;
             break;
-       case 'c':
-           if (cfile)
-               fclose (cfile);
-           cfile = fopen(arg, "w");
-           break;
+        case 'c':
+            if (cfile)
+                fclose (cfile);
+            cfile = fopen(arg, "w");
+            break;
         case 'x':
             xml = YAZ_MARC_SIMPLEXML;
             break;
         case 'O':
             xml = YAZ_MARC_OAIMARC;
             break;
-       case 'e':
-           xml = YAZ_MARC_XCHANGE;
-           break;
+        case 'e':
+            xml = YAZ_MARC_XCHANGE;
+            break;
         case 'X':
             xml = YAZ_MARC_MARCXML;
             break;
-       case 'I':
-           xml = YAZ_MARC_ISO2709;
-           break;
-       case 'p':
-           print_offset = 1;
-           break;
-       case '2':
-           libxml_dom_test = 1;
-           break;
+        case 'I':
+            xml = YAZ_MARC_ISO2709;
+            break;
+        case 'p':
+            print_offset = 1;
+            break;
+        case '2':
+            libxml_dom_test = 1;
+            break;
         case 0:
-           inf = fopen(arg, "rb");
-           count = 0;
-           if (!inf)
-           {
-               fprintf (stderr, "%s: cannot open %s:%s\n",
-                        prog, arg, strerror (errno));
-               exit(1);
-           }
-           if (cfile)
-               fprintf (cfile, "char *marc_records[] = {\n");
+            inf = fopen(arg, "rb");
+            count = 0;
+            if (!inf)
+            {
+                fprintf (stderr, "%s: cannot open %s:%s\n",
+                         prog, arg, strerror (errno));
+                exit(1);
+            }
+            if (cfile)
+                fprintf (cfile, "char *marc_records[] = {\n");
             if (1)
             {
                 yaz_marc_t mt = yaz_marc_create();
@@ -188,7 +188,7 @@ int main (int argc, char **argv)
                                 "unsupported\n", from, to);
                         exit(2);
                     }
-                   yaz_marc_iconv(mt, cd);
+                    yaz_marc_iconv(mt, cd);
                 }
                 yaz_marc_xml(mt, xml);
                 yaz_marc_debug(mt, verbose);
@@ -200,89 +200,89 @@ int main (int argc, char **argv)
                     
                     r = fread (buf, 1, 5, inf);
                     if (r < 5)
-                   {
-                       if (r && print_offset && verbose)
-                           printf ("<!-- Extra %d bytes at end of file -->\n", r);
+                    {
+                        if (r && print_offset && verbose)
+                            printf ("<!-- Extra %d bytes at end of file -->\n", r);
                         break;
-                   }
-                   while (*buf < '0' || *buf > '9')
-                   {
-                       int i;
-                       long off = ftell(inf) - 5;
-                       if (verbose || print_offset)
-                           printf("<!-- Skipping bad byte %d (0x%02X) at offset "
-                                  "%ld (0x%lx) -->\n", 
-                                  *buf & 0xff, *buf & 0xff,
-                                  off, off);
-                       for (i = 0; i<4; i++)
-                           buf[i] = buf[i+1];
-                       r = fread(buf+4, 1, 1, inf);
-                       if (r < 1)
-                           break;
-                   }
-                   if (r < 1)
-                   {
-                       if (verbose || print_offset)
-                           printf ("<!-- End of file with data -->\n");
-                       break;
-                   }
-                   if (print_offset)
-                   {
-                       long off = ftell(inf) - 5;
-                       printf ("<!-- Record %d offset %ld (0x%lx) -->\n",
-                               num, off, off);
-                   }
+                    }
+                    while (*buf < '0' || *buf > '9')
+                    {
+                        int i;
+                        long off = ftell(inf) - 5;
+                        if (verbose || print_offset)
+                            printf("<!-- Skipping bad byte %d (0x%02X) at offset "
+                                   "%ld (0x%lx) -->\n", 
+                                   *buf & 0xff, *buf & 0xff,
+                                   off, off);
+                        for (i = 0; i<4; i++)
+                            buf[i] = buf[i+1];
+                        r = fread(buf+4, 1, 1, inf);
+                        if (r < 1)
+                            break;
+                    }
+                    if (r < 1)
+                    {
+                        if (verbose || print_offset)
+                            printf ("<!-- End of file with data -->\n");
+                        break;
+                    }
+                    if (print_offset)
+                    {
+                        long off = ftell(inf) - 5;
+                        printf ("<!-- Record %d offset %ld (0x%lx) -->\n",
+                                num, off, off);
+                    }
                     len = atoi_n(buf, 5);
                     if (len < 25 || len > 100000)
-                   {
-                       long off = ftell(inf) - 5;
-                       printf("Bad Length %d read at offset %ld (%lx)\n",
-                              len, (long) off, (long) off);
+                    {
+                        long off = ftell(inf) - 5;
+                        printf("Bad Length %d read at offset %ld (%lx)\n",
+                               len, (long) off, (long) off);
                         break;
-                   }
+                    }
                     len = len - 5;
                     r = fread (buf + 5, 1, len, inf);
                     if (r < len)
                         break;
                     r = yaz_marc_decode_buf (mt, buf, -1, &result, &rlen);
-                   if (result)
-                       fwrite (result, rlen, 1, stdout);
+                    if (result)
+                        fwrite (result, rlen, 1, stdout);
 #if HAVE_XML2
-                   if (r > 0 && libxml_dom_test)
-                   {
-                       xmlDocPtr doc = xmlParseMemory(result, rlen);
-                       if (!doc)
-                           fprintf(stderr, "xmLParseMemory failed\n");
-                       else
-                       {
-                           int i;
-                           xmlXPathContextPtr xpathCtx; 
-                           xmlXPathObjectPtr xpathObj; 
-                           static const char *xpathExpr[] = {
-                               "/record/datafield[@tag='245']/subfield[@code='a']",
-                               "/record/datafield[@tag='100']/subfield",
-                               "/record/datafield[@tag='245']/subfield[@code='a']",
-                               "/record/datafield[@tag='650']/subfield",
-                               "/record/datafield[@tag='650']",
-                               0};
-                           
-                           xpathCtx = xmlXPathNewContext(doc);
+                    if (r > 0 && libxml_dom_test)
+                    {
+                        xmlDocPtr doc = xmlParseMemory(result, rlen);
+                        if (!doc)
+                            fprintf(stderr, "xmLParseMemory failed\n");
+                        else
+                        {
+                            int i;
+                            xmlXPathContextPtr xpathCtx; 
+                            xmlXPathObjectPtr xpathObj; 
+                            static const char *xpathExpr[] = {
+                                "/record/datafield[@tag='245']/subfield[@code='a']",
+                                "/record/datafield[@tag='100']/subfield",
+                                "/record/datafield[@tag='245']/subfield[@code='a']",
+                                "/record/datafield[@tag='650']/subfield",
+                                "/record/datafield[@tag='650']",
+                                0};
+                            
+                            xpathCtx = xmlXPathNewContext(doc);
 
-                           for (i = 0; xpathExpr[i]; i++) {
-                               xpathObj = xmlXPathEvalExpression(xpathExpr[i], xpathCtx);
-                               if(xpathObj == NULL) {
-                                   fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr[i]);
-                               }
-                               else
-                               {
-                                   print_xpath_nodes(xpathObj->nodesetval, stdout);
-                                   xmlXPathFreeObject(xpathObj);
-                               }
-                           }
-                           xmlXPathFreeContext(xpathCtx); 
-                           xmlFreeDoc(doc);
-                       }
-                   }
+                            for (i = 0; xpathExpr[i]; i++) {
+                                xpathObj = xmlXPathEvalExpression(xpathExpr[i], xpathCtx);
+                                if(xpathObj == NULL) {
+                                    fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr[i]);
+                                }
+                                else
+                                {
+                                    print_xpath_nodes(xpathObj->nodesetval, stdout);
+                                    xmlXPathFreeObject(xpathObj);
+                                }
+                            }
+                            xmlXPathFreeContext(xpathCtx); 
+                            xmlFreeDoc(doc);
+                        }
+                    }
 #endif
                     if (r > 0 && cfile)
                     {
@@ -300,24 +300,24 @@ int main (int argc, char **argv)
                             if (i < r - 1 && (i & 15) == 15)
                                 fprintf (cfile, "\"\n");
                             
-                       }
+                        }
                         fprintf (cfile, "\"\n");
                     }
-                   num++;
-                   if (verbose)
-                       printf("\n");
+                    num++;
+                    if (verbose)
+                        printf("\n");
                 }
                 count++;
                 if (cd)
                     yaz_iconv_close(cd);
                 yaz_marc_destroy(mt);
-           }
-           if (cfile)
-               fprintf (cfile, "};\n");
-           fclose(inf);
+            }
+            if (cfile)
+                fprintf (cfile, "};\n");
+            fclose(inf);
             break;
         case 'v':
-           verbose++;
+            verbose++;
             break;
         default:
             usage(prog);
@@ -325,11 +325,19 @@ int main (int argc, char **argv)
         }
     }
     if (cfile)
-       fclose (cfile);
+        fclose (cfile);
     if (!no)
     {
         usage(prog);
-       exit (1);
+        exit (1);
     }
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 096b2c5..1524abc 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: srwtst.c,v 1.3 2005-01-17 13:09:43 adam Exp $
+ * $Id: srwtst.c,v 1.4 2005-06-25 15:46:07 adam Exp $
  */
 
 #include <stdlib.h>
@@ -106,3 +106,11 @@ int main(int argc, char **argv)
     exit(1);
 }
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 4547614..3cf8afe 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: yaziconv.c,v 1.3 2005-01-17 13:09:43 adam Exp $
+ * $Id: yaziconv.c,v 1.4 2005-06-25 15:46:07 adam Exp $
  */
 
 #if HAVE_CONFIG_H
@@ -180,3 +180,11 @@ int main (int argc, char **argv)
     yaz_iconv_close (cd);
     return 0;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 3006cea..e42ae8f 100644 (file)
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 6d9fce2..111f629 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: zoomsh.c,v 1.36 2005-06-25 15:42:19 adam Exp $
+ * $Id: zoomsh.c,v 1.37 2005-06-25 15:46:08 adam Exp $
  */
 
 /* ZOOM-C Shell */
@@ -35,7 +35,7 @@ static int next_token (const char **cpp, const char **t_start)
     int len = 0;
     const char *cp = *cpp;
     while (*cp == ' ')
-       cp++;
+        cp++;
     if (*cp == '"')
     {
         cp++;
@@ -69,11 +69,11 @@ static int next_token_copy (const char **cpp, char *buf_out, int buf_max)
     int len = next_token (cpp, &start);
     if (len < 0)
     {
-       *buf_out = 0;
-       return len;
+        *buf_out = 0;
+        return len;
     }
     if (len >= buf_max)
-       len = buf_max-1;
+        len = buf_max-1;
     memcpy (buf_out, start, len);
     buf_out[len] = '\0';
     return len;
@@ -83,37 +83,37 @@ static int is_command (const char *cmd_str, const char *this_str, int this_len)
 {
     int cmd_len = strlen(cmd_str);
     if (cmd_len != this_len)
-       return 0;
+        return 0;
     if (memcmp (cmd_str, this_str, cmd_len))
-       return 0;
+        return 0;
     return 1;
 }
 
 static void cmd_set (ZOOM_connection *c, ZOOM_resultset *r,
-                    ZOOM_options options,
-                    const char **args)
+                     ZOOM_options options,
+                     const char **args)
 {
     char key[40], val[80];
 
     if (next_token_copy (args, key, sizeof(key)) < 0)
     {
-       printf ("missing argument for set\n");
-       return ;
+        printf ("missing argument for set\n");
+        return ;
     }
     if (next_token_copy (args, val, sizeof(val)) < 0)
-       ZOOM_options_set(options, key, 0);
+        ZOOM_options_set(options, key, 0);
     else
-       ZOOM_options_set(options, key, val);
+        ZOOM_options_set(options, key, val);
 }
 
 static void cmd_get (ZOOM_connection *c, ZOOM_resultset *r,
-                    ZOOM_options options,
-                    const char **args)
+                     ZOOM_options options,
+                     const char **args)
 {
     char key[40];
     if (next_token_copy (args, key, sizeof(key)) < 0)
     {
-       printf ("missing argument for get\n");
+        printf ("missing argument for get\n");
     }
     else
     {
@@ -123,98 +123,98 @@ static void cmd_get (ZOOM_connection *c, ZOOM_resultset *r,
 }
 
 static void cmd_close (ZOOM_connection *c, ZOOM_resultset *r,
-                      ZOOM_options options,
-                      const char **args)
+                       ZOOM_options options,
+                       const char **args)
 {
     char host[60];
     int i;
     next_token_copy (args, host, sizeof(host));
     for (i = 0; i<MAX_CON; i++)
     {
-       const char *h;
-       if (!c[i])
-           continue;
-       if ((h = ZOOM_connection_option_get(c[i], "host"))
+        const char *h;
+        if (!c[i])
+            continue;
+        if ((h = ZOOM_connection_option_get(c[i], "host"))
             && !strcmp (h, host))
-       {
-           ZOOM_connection_destroy (c[i]);
-           c[i] = 0;
-       }
-       else if (*host == '\0')
-       {
-           ZOOM_connection_destroy (c[i]);
-           c[i] = 0;
-       }
+        {
+            ZOOM_connection_destroy (c[i]);
+            c[i] = 0;
+        }
+        else if (*host == '\0')
+        {
+            ZOOM_connection_destroy (c[i]);
+            c[i] = 0;
+        }
     }
 }
 
 static void display_records (ZOOM_connection c,
-                            ZOOM_resultset r,
-                            int start, int count)
+                             ZOOM_resultset r,
+                             int start, int count)
 {
     int i;
     for (i = 0; i<count; i++)
     {
-       int pos = i + start;
+        int pos = i + start;
         ZOOM_record rec = ZOOM_resultset_record (r, pos);
-       const char *db = ZOOM_record_get (rec, "database", 0);
-       int len, opac_len;
-       const char *render = ZOOM_record_get (rec, "render", &len);
-       const char *opac_render = ZOOM_record_get (rec, "opac", &opac_len);
-       const char *syntax = ZOOM_record_get (rec, "syntax", 0);
-       /* if rec is non-null, we got a record for display */
-       if (rec)
-       {
-           char oidbuf[100];
-           (void) oid_name_to_dotstring(CLASS_RECSYN, syntax, oidbuf);
-           printf ("%d %s %s (%s)\n",
-                   pos+1, (db ? db : "unknown"), syntax, oidbuf);
-           if (render)
-               fwrite (render, 1, len, stdout);
-           printf ("\n");
-           if (opac_render)
-               fwrite (opac_render, 1, opac_len, stdout);
-       }
-           
+        const char *db = ZOOM_record_get (rec, "database", 0);
+        int len, opac_len;
+        const char *render = ZOOM_record_get (rec, "render", &len);
+        const char *opac_render = ZOOM_record_get (rec, "opac", &opac_len);
+        const char *syntax = ZOOM_record_get (rec, "syntax", 0);
+        /* if rec is non-null, we got a record for display */
+        if (rec)
+        {
+            char oidbuf[100];
+            (void) oid_name_to_dotstring(CLASS_RECSYN, syntax, oidbuf);
+            printf ("%d %s %s (%s)\n",
+                    pos+1, (db ? db : "unknown"), syntax, oidbuf);
+            if (render)
+                fwrite (render, 1, len, stdout);
+            printf ("\n");
+            if (opac_render)
+                fwrite (opac_render, 1, opac_len, stdout);
+        }
+            
     }
 }
 
 static void cmd_show (ZOOM_connection *c, ZOOM_resultset *r,
-                     ZOOM_options options,
-                     const char **args)
+                      ZOOM_options options,
+                      const char **args)
 {
     int i;
     char start_str[10], count_str[10];
 
     if (next_token_copy (args, start_str, sizeof(start_str)) >= 0)
-       ZOOM_options_set (options, "start", start_str);
+        ZOOM_options_set (options, "start", start_str);
 
     if (next_token_copy (args, count_str, sizeof(count_str)) >= 0)
-       ZOOM_options_set (options, "count", count_str);
+        ZOOM_options_set (options, "count", count_str);
 
     for (i = 0; i<MAX_CON; i++)
-       ZOOM_resultset_records (r[i], 0, atoi(start_str), atoi(count_str));
+        ZOOM_resultset_records (r[i], 0, atoi(start_str), atoi(count_str));
     while (ZOOM_event (MAX_CON, c))
-       ;
+        ;
 
     for (i = 0; i<MAX_CON; i++)
     {
-       int error;
-       const char *errmsg, *addinfo, *dset;
-       /* display errors if any */
-       if (!c[i])
-           continue;
-       if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
-           printf ("%s error: %s (%s:%d) %s\n",
-                    ZOOM_connection_option_get(c[i], "host"), errmsg,
-                    dset, error, addinfo);
-       else if (r[i])
-       {
-           /* OK, no major errors. Display records... */
-           int start = ZOOM_options_get_int (options, "start", 0);
-           int count = ZOOM_options_get_int (options, "count", 0);
-           display_records (c[i], r[i], start, count);
-       }
+        int error;
+        const char *errmsg, *addinfo, *dset;
+        /* display errors if any */
+        if (!c[i])
+            continue;
+        if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
+            printf ("%s error: %s (%s:%d) %s\n",
+                     ZOOM_connection_option_get(c[i], "host"), errmsg,
+                     dset, error, addinfo);
+        else if (r[i])
+        {
+            /* OK, no major errors. Display records... */
+            int start = ZOOM_options_get_int (options, "start", 0);
+            int count = ZOOM_options_get_int (options, "count", 0);
+            display_records (c[i], r[i], start, count);
+        }
     }
     ZOOM_options_set (options, "count", "0");
     ZOOM_options_set (options, "start", "0");
@@ -230,11 +230,11 @@ static void cmd_ext (ZOOM_connection *c, ZOOM_resultset *r,
     int i;
 
     if (next_token_copy (args, ext_type_str, sizeof(ext_type_str)) < 0)
-       return;
+        return;
     
     for (i = 0; i<MAX_CON; i++)
     {
-       if (c[i])
+        if (c[i])
         {
             p[i] = ZOOM_connection_package (c[i], 0);
             ZOOM_package_send(p[i], ext_type_str);
@@ -244,30 +244,30 @@ static void cmd_ext (ZOOM_connection *c, ZOOM_resultset *r,
     }
 
     while (ZOOM_event (MAX_CON, c))
-       ;
+        ;
 
     for (i = 0; i<MAX_CON; i++)
     {
-       int error;
-       const char *errmsg, *addinfo, *dset;
-       /* display errors if any */
-       if (!p[i])
-           continue;
-       if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
-           printf ("%s error: %s (%s:%d) %s\n",
-                    ZOOM_connection_option_get(c[i], "host"), errmsg,
-                    dset, error, addinfo);
-       else if (p[i])
-       {
-           const char *v;
+        int error;
+        const char *errmsg, *addinfo, *dset;
+        /* display errors if any */
+        if (!p[i])
+            continue;
+        if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
+            printf ("%s error: %s (%s:%d) %s\n",
+                     ZOOM_connection_option_get(c[i], "host"), errmsg,
+                     dset, error, addinfo);
+        else if (p[i])
+        {
+            const char *v;
             printf ("ok\n");
-           v = ZOOM_package_option_get (p[i], "targetReference");
-           if (v)
-               printf("targetReference: %s\n", v);
-           v = ZOOM_package_option_get (p[i], "xmlUpdateDoc");
-           if (v)
-               printf("xmlUpdateDoc: %s\n", v);
-       }
+            v = ZOOM_package_option_get (p[i], "targetReference");
+            if (v)
+                printf("targetReference: %s\n", v);
+            v = ZOOM_package_option_get (p[i], "xmlUpdateDoc");
+            if (v)
+                printf("xmlUpdateDoc: %s\n", v);
+        }
         ZOOM_package_destroy (p[i]);
     }
 }
@@ -280,8 +280,8 @@ static void cmd_debug (ZOOM_connection *c, ZOOM_resultset *r,
 }
 
 static void cmd_search (ZOOM_connection *c, ZOOM_resultset *r,
-                       ZOOM_options options,
-                       const char **args)
+                        ZOOM_options options,
+                        const char **args)
 {
     ZOOM_query s;
     const char *query_str = *args;
@@ -296,45 +296,45 @@ static void cmd_search (ZOOM_connection *c, ZOOM_resultset *r,
     }
     else if (ZOOM_query_prefix (s, query_str))
     {
-       printf ("Bad PQF: %s\n", query_str);
-       return;
+        printf ("Bad PQF: %s\n", query_str);
+        return;
     }
     for (i = 0; i<MAX_CON; i++)
     {
-       if (c[i])
-       {
-           ZOOM_resultset_destroy (r[i]);
-           r[i] = 0;
-       }
-       if (c[i])
-           r[i] = ZOOM_connection_search (c[i], s);
+        if (c[i])
+        {
+            ZOOM_resultset_destroy (r[i]);
+            r[i] = 0;
+        }
+        if (c[i])
+            r[i] = ZOOM_connection_search (c[i], s);
     }
 
     while (ZOOM_event (MAX_CON, c))
-       ;
+        ;
 
     for (i = 0; i<MAX_CON; i++)
     {
-       int error;
-       const char *errmsg, *addinfo, *dset;
-       /* display errors if any */
-       if (!c[i])
-           continue;
-       if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
-           printf ("%s error: %s (%s:%d) %s\n",
-                   ZOOM_connection_option_get(c[i], "host"), errmsg,
-                   dset, error, addinfo);
-       else if (r[i])
-       {
-           /* OK, no major errors. Look at the result count */
-           int start = ZOOM_options_get_int (options, "start", 0);
-           int count = ZOOM_options_get_int (options, "count", 0);
-
-           printf ("%s: %d hits\n", ZOOM_connection_option_get(c[i], "host"),
-                   ZOOM_resultset_size(r[i]));
-           /* and display */
-           display_records (c[i], r[i], start, count);
-       }
+        int error;
+        const char *errmsg, *addinfo, *dset;
+        /* display errors if any */
+        if (!c[i])
+            continue;
+        if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
+            printf ("%s error: %s (%s:%d) %s\n",
+                    ZOOM_connection_option_get(c[i], "host"), errmsg,
+                    dset, error, addinfo);
+        else if (r[i])
+        {
+            /* OK, no major errors. Look at the result count */
+            int start = ZOOM_options_get_int (options, "start", 0);
+            int count = ZOOM_options_get_int (options, "count", 0);
+
+            printf ("%s: %d hits\n", ZOOM_connection_option_get(c[i], "host"),
+                    ZOOM_resultset_size(r[i]));
+            /* and display */
+            display_records (c[i], r[i], start, count);
+        }
     }
     ZOOM_query_destroy (s);
 }
@@ -368,7 +368,7 @@ static void cmd_scan (ZOOM_connection *c, ZOOM_resultset *r,
                 int occ = 0;
                 int len = 0;
                 const char *term = ZOOM_scanset_display_term(s[i], p,
-                               &occ, &len);
+                                &occ, &len);
                 fwrite(term, 1, len, stdout);
                 printf (" %d\n", occ);
             }            
@@ -397,8 +397,8 @@ static void cmd_sort (ZOOM_connection *c, ZOOM_resultset *r,
 }
 
 static void cmd_help (ZOOM_connection *c, ZOOM_resultset *r,
-                     ZOOM_options options,
-                     const char **args)
+                      ZOOM_options options,
+                      const char **args)
 {
     printf ("connect <zurl>\n");
     printf ("search <pqf>\n");
@@ -430,8 +430,8 @@ static void cmd_help (ZOOM_connection *c, ZOOM_resultset *r,
 }
 
 static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r,
-                        ZOOM_options options,
-                        const char **args)
+                         ZOOM_options options,
+                         const char **args)
 {
     int error;
     const char *errmsg, *addinfo, *dset;
@@ -439,79 +439,79 @@ static void cmd_connect (ZOOM_connection *c, ZOOM_resultset *r,
     int j, i;
     if (next_token_copy (args, host, sizeof(host)) < 0)
     {
-       printf ("missing host after connect\n");
-       return ;
+        printf ("missing host after connect\n");
+        return ;
     }
     for (j = -1, i = 0; i<MAX_CON; i++)
     {
-       const char *h;
-       if (c[i] && (h = ZOOM_connection_option_get(c[i], "host")) &&
-           !strcmp (h, host))
-       {
-           ZOOM_connection_destroy (c[i]);
-           break;
-       }
-       else if (c[i] == 0 && j == -1)
-           j = i;
+        const char *h;
+        if (c[i] && (h = ZOOM_connection_option_get(c[i], "host")) &&
+            !strcmp (h, host))
+        {
+            ZOOM_connection_destroy (c[i]);
+            break;
+        }
+        else if (c[i] == 0 && j == -1)
+            j = i;
     }
     if (i == MAX_CON)  /* no match .. */
     {
-       if (j == -1)
-       {
-           printf ("no more connection available\n");
-           return;
-       }
-       i = j;   /* OK, use this one is available */
+        if (j == -1)
+        {
+            printf ("no more connection available\n");
+            return;
+        }
+        i = j;   /* OK, use this one is available */
     }
     c[i] = ZOOM_connection_create (options);
     ZOOM_connection_connect (c[i], host, 0);
-       
+        
     if ((error = ZOOM_connection_error_x(c[i], &errmsg, &addinfo, &dset)))
        printf ("%s error: %s (%s:%d) %s\n",
-           ZOOM_connection_option_get(c[i], "host"), errmsg,
-           dset, error, addinfo);
+            ZOOM_connection_option_get(c[i], "host"), errmsg,
+            dset, error, addinfo);
 }
 
 static int cmd_parse (ZOOM_connection *c, ZOOM_resultset *r,
-                     ZOOM_options options, 
-                     const char **buf)
+                      ZOOM_options options, 
+                      const char **buf)
 {
     int cmd_len;
     const char *cmd_str;
 
     cmd_len = next_token (buf, &cmd_str);
     if (cmd_len < 0)
-       return 1;
+        return 1;
     if (is_command ("quit", cmd_str, cmd_len))
-       return 0;
+        return 0;
     else if (is_command ("set", cmd_str, cmd_len))
-       cmd_set (c, r, options, buf);
+        cmd_set (c, r, options, buf);
     else if (is_command ("get", cmd_str, cmd_len))
-       cmd_get (c, r, options, buf);
+        cmd_get (c, r, options, buf);
     else if (is_command ("connect", cmd_str, cmd_len))
-       cmd_connect (c, r, options, buf);
+        cmd_connect (c, r, options, buf);
     else if (is_command ("open", cmd_str, cmd_len))
-       cmd_connect (c, r, options, buf);
+        cmd_connect (c, r, options, buf);
     else if (is_command ("search", cmd_str, cmd_len))
-       cmd_search (c, r, options, buf);
+        cmd_search (c, r, options, buf);
     else if (is_command ("find", cmd_str, cmd_len))
-       cmd_search (c, r, options, buf);
+        cmd_search (c, r, options, buf);
     else if (is_command ("show", cmd_str, cmd_len))
-       cmd_show (c, r, options, buf);
+        cmd_show (c, r, options, buf);
     else if (is_command ("close", cmd_str, cmd_len))
-       cmd_close (c, r, options, buf);
+        cmd_close (c, r, options, buf);
     else if (is_command ("help", cmd_str, cmd_len))
-       cmd_help(c, r, options, buf);
+        cmd_help(c, r, options, buf);
     else if (is_command ("ext", cmd_str, cmd_len))
-       cmd_ext(c, r, options, buf);
+        cmd_ext(c, r, options, buf);
     else if (is_command ("debug", cmd_str, cmd_len))
-       cmd_debug(c, r, options, buf);
+        cmd_debug(c, r, options, buf);
     else if (is_command ("scan", cmd_str, cmd_len))
-       cmd_scan(c, r, options, buf);
+        cmd_scan(c, r, options, buf);
     else if (is_command ("sort", cmd_str, cmd_len))
-       cmd_sort(c, r, options, buf);
+        cmd_sort(c, r, options, buf);
     else
-       printf ("unknown command %.*s\n", cmd_len, cmd_str);
+        printf ("unknown command %.*s\n", cmd_len, cmd_str);
     return 2;
 }
 
@@ -521,32 +521,32 @@ void shell(ZOOM_connection *c, ZOOM_resultset *r,
     while (1)
     {
         char buf[1000];
-       char *cp;
-       const char *bp = buf;
+        char *cp;
+        const char *bp = buf;
 #if HAVE_READLINE_READLINE_H
-       char* line_in;
-       line_in=readline("ZOOM>");
-       if (!line_in)
-           break;
+        char* line_in;
+        line_in=readline("ZOOM>");
+        if (!line_in)
+            break;
 #if HAVE_READLINE_HISTORY_H
-       if (*line_in)
-           add_history(line_in);
+        if (*line_in)
+            add_history(line_in);
 #endif
-       if(strlen(line_in) > 999) {
-           printf("Input line too long\n");
-           break;
-       };
-       strcpy(buf,line_in);
-       free (line_in);
+        if(strlen(line_in) > 999) {
+            printf("Input line too long\n");
+            break;
+        };
+        strcpy(buf,line_in);
+        free (line_in);
 #else    
-       printf ("ZOOM>"); fflush (stdout);
-       if (!fgets (buf, 999, stdin))
-           break;
+        printf ("ZOOM>"); fflush (stdout);
+        if (!fgets (buf, 999, stdin))
+            break;
 #endif 
-       if ((cp = strchr(buf, '\n')))
-           *cp = '\0';
-       if (!cmd_parse (c, r, options, &bp))
-           break;
+        if ((cp = strchr(buf, '\n')))
+            *cp = '\0';
+        if (!cmd_parse (c, r, options, &bp))
+            break;
     }
 }
 
@@ -559,29 +559,29 @@ static void zoomsh(int argc, char **argv)
 
     for (i = 0; i<MAX_CON; i++)
     {
-       z39_con[i] = 0;
-       z39_res[i] = 0;
+        z39_con[i] = 0;
+        z39_res[i] = 0;
     }
 
     for (i = 0; i<MAX_CON; i++)
-       z39_con[i] = 0;
+        z39_con[i] = 0;
 
     res = 1;
     for (i = 1; i<argc; i++)
     {
-       const char *bp = argv[i];
-       res = cmd_parse(z39_con, z39_res, options, &bp);
-       if (res == 0)  /* received quit */
-           break;
+        const char *bp = argv[i];
+        res = cmd_parse(z39_con, z39_res, options, &bp);
+        if (res == 0)  /* received quit */
+            break;
     }
     if (res)  /* do cmdline shell only if not quitting */
-       shell(z39_con, z39_res, options);
+        shell(z39_con, z39_res, options);
     ZOOM_options_destroy(options);
 
     for (i = 0; i<MAX_CON; i++)
     {
-       ZOOM_connection_destroy(z39_con[i]);
-       ZOOM_resultset_destroy(z39_res[i]);
+        ZOOM_connection_destroy(z39_con[i]);
+        ZOOM_resultset_destroy(z39_res[i]);
     }
 }
 
@@ -610,3 +610,11 @@ int main(int argc, char **argv)
     nmem_exit();
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index a70e173..9023f55 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst1.c,v 1.3 2001-11-18 21:14:23 adam Exp $
+ * $Id: zoomtst1.c,v 1.4 2005-06-25 15:46:08 adam Exp $
  *
  * Synchronous single-target client doing search (but no retrieval)
  */
@@ -26,16 +26,24 @@ int main(int argc, char **argv)
     
     if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
     {
-       fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
-       exit (2);
+        fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
+        exit (2);
     }
 
     r = ZOOM_connection_search_pqf (z, argv[2]);
     if ((error = ZOOM_connection_error(z, &errmsg, &addinfo)))
-       fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
+        fprintf (stderr, "Error: %s (%d) %s\n", errmsg, error, addinfo);
     else
-       printf ("Result count: %d\n", ZOOM_resultset_size(r));
+        printf ("Result count: %d\n", ZOOM_resultset_size(r));
     ZOOM_resultset_destroy (r);
     ZOOM_connection_destroy (z);
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 1ff3612..f670802 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst2.c,v 1.5 2002-12-09 23:32:29 adam Exp $
+ * $Id: zoomtst2.c,v 1.6 2005-06-25 15:46:08 adam Exp $
  *
  * Asynchronous single-target client performing search (no retrieval)
  */
@@ -18,10 +18,10 @@ int main(int argc, char **argv)
 
     if (argc < 3)
     {
-       fprintf (stderr, "usage:\n%s target query\n", *argv);
-       fprintf (stderr,
-                "Verify: asynchronous single-target client\n");
-       exit (1);
+        fprintf (stderr, "usage:\n%s target query\n", *argv);
+        fprintf (stderr,
+                 "Verify: asynchronous single-target client\n");
+        exit (1);
     }
 
     /* create connection (don't connect yet) */
@@ -38,18 +38,26 @@ int main(int argc, char **argv)
 
     /* block here: only one connection */
     while (ZOOM_event (1, &z))
-       ;
+        ;
 
     /* see if any error occurred */
     if ((error = ZOOM_connection_error_x(z, &errmsg, &addinfo, &diagset)))
     {
-       fprintf (stderr, "Error: %s: %s (%d) %s\n", diagset, errmsg, error,
-                        addinfo);
-       exit (2);
+        fprintf (stderr, "Error: %s: %s (%d) %s\n", diagset, errmsg, error,
+                         addinfo);
+        exit (2);
     }
     else /* OK print hit count */
-       printf ("Result count: %d\n", ZOOM_resultset_size(r));  
+        printf ("Result count: %d\n", ZOOM_resultset_size(r));  
     ZOOM_resultset_destroy (r);
     ZOOM_connection_destroy (z);
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 224db5f..4b6cf9b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst3.c,v 1.8 2002-06-05 21:09:04 adam Exp $
+ * $Id: zoomtst3.c,v 1.9 2005-06-25 15:46:08 adam Exp $
  *
  * Asynchronous multi-target client doing search and piggyback retrieval
  */
@@ -24,14 +24,14 @@ int main(int argc, char **argv)
 
     if (argc < 3)
     {
-       fprintf (stderr, "usage:\n%s target1 target2 ... targetN query\n",
-                *argv);
-       exit (1);
+        fprintf (stderr, "usage:\n%s target1 target2 ... targetN query\n",
+                 *argv);
+        exit (1);
     }
     if (argc == 4 && isdigit(argv[1][0]) && !strchr(argv[1],'.'))
     {
-       no = atoi(argv[1]);
-       same_target = 1;
+        no = atoi(argv[1]);
+        same_target = 1;
     }
 
     if (no > 500)
@@ -50,14 +50,14 @@ int main(int argc, char **argv)
     /* connect to all */
     for (i = 0; i<no; i++)
     {
-       /* create connection - pass options (they are the same for all) */
-       z[i] = ZOOM_connection_create (o);
+        /* create connection - pass options (they are the same for all) */
+        z[i] = ZOOM_connection_create (o);
 
-       /* connect and init */
-       if (same_target)
-           ZOOM_connection_connect (z[i], argv[2], 0);
-       else
-           ZOOM_connection_connect (z[i], argv[1+i], 0);
+        /* connect and init */
+        if (same_target)
+            ZOOM_connection_connect (z[i], argv[2], 0);
+        else
+            ZOOM_connection_connect (z[i], argv[1+i], 0);
     }
     /* search all */
     for (i = 0; i<no; i++)
@@ -73,35 +73,35 @@ int main(int argc, char **argv)
     /* no more to be done. Inspect results */
     for (i = 0; i<no; i++)
     {
-       int error;
-       const char *errmsg, *addinfo;
-       const char *tname = (same_target ? argv[2] : argv[1+i]);
-       /* display errors if any */
-       if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
-           fprintf (stderr, "%s error: %s (%d) %s\n", tname, errmsg,
-                    error, addinfo);
-       else
-       {
-           /* OK, no major errors. Look at the result count */
-           int pos;
-           printf ("%s: %d hits\n", tname, ZOOM_resultset_size(r[i]));
-           /* go through all records at target */
-           for (pos = 0; pos < 10; pos++)
-           {
-               int len; /* length of buffer rec */
-               const char *rec =
-                   ZOOM_record_get (
+        int error;
+        const char *errmsg, *addinfo;
+        const char *tname = (same_target ? argv[2] : argv[1+i]);
+        /* display errors if any */
+        if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
+            fprintf (stderr, "%s error: %s (%d) %s\n", tname, errmsg,
+                     error, addinfo);
+        else
+        {
+            /* OK, no major errors. Look at the result count */
+            int pos;
+            printf ("%s: %d hits\n", tname, ZOOM_resultset_size(r[i]));
+            /* go through all records at target */
+            for (pos = 0; pos < 10; pos++)
+            {
+                int len; /* length of buffer rec */
+                const char *rec =
+                    ZOOM_record_get (
                         ZOOM_resultset_record (r[i], pos), "render", &len);
-               /* if rec is non-null, we got a record for display */
-               if (rec)
-               {
-                   printf ("%d\n", pos+1);
-                   if (rec)
-                       fwrite (rec, 1, len, stdout);
-                   printf ("\n");
-               }
-           }
-       }
+                /* if rec is non-null, we got a record for display */
+                if (rec)
+                {
+                    printf ("%d\n", pos+1);
+                    if (rec)
+                        fwrite (rec, 1, len, stdout);
+                    printf ("\n");
+                }
+            }
+        }
     }
     /* destroy and exit */
     for (i = 0; i<no; i++)
@@ -112,3 +112,11 @@ int main(int argc, char **argv)
     ZOOM_options_destroy(o);
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 7be0b96..9bc0eaa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst4.c,v 1.7 2001-11-30 08:24:06 adam Exp $
+ * $Id: zoomtst4.c,v 1.8 2005-06-25 15:46:08 adam Exp $
  *
  * Asynchronous multi-target going through proxy doing search and retrieve
  * using present.
@@ -14,7 +14,7 @@
 const char *my_callback (void *handle, const char *name)
 {
     if (!strcmp (name, "async"))
-       return "1";
+        return "1";
     return 0;
 }
 
@@ -29,9 +29,9 @@ int main(int argc, char **argv)
 
     if (argc < 4)
     {
-       fprintf (stderr, "usage:\n%s proxy target1 .. targetN query\n",
-                *argv);
-       exit (2);
+        fprintf (stderr, "usage:\n%s proxy target1 .. targetN query\n",
+                 *argv);
+        exit (2);
     }
     if (no > 500)
         no = 500;
@@ -52,32 +52,32 @@ int main(int argc, char **argv)
     q = ZOOM_query_create ();
     if (ZOOM_query_prefix (q, argv[argc-1]))
     {
-       printf ("bad PQF: %s\n", argv[argc-1]);
-       exit (1);
+        printf ("bad PQF: %s\n", argv[argc-1]);
+        exit (1);
     }
     /* connect - and search all */
     for (i = 0; i<no; i++)
     {
-       z[i] = ZOOM_connection_create (o);
-       ZOOM_connection_connect (z[i], argv[i+2], 0);
+        z[i] = ZOOM_connection_create (o);
+        ZOOM_connection_connect (z[i], argv[i+2], 0);
         r[i] = ZOOM_connection_search (z[i], q);
     }
 
     /* network I/O */
     while (ZOOM_event (no, z))
-       ;
+        ;
 
     /* handle errors */
     for (i = 0; i<no; i++)
     {
-       int error;
-       const char *errmsg, *addinfo;
-       if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
-           fprintf (stderr, "%s error: %s (%d) %s\n",
-                    ZOOM_connection_option_get(z[i], "host"),
+        int error;
+        const char *errmsg, *addinfo;
+        if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
+            fprintf (stderr, "%s error: %s (%d) %s\n",
+                     ZOOM_connection_option_get(z[i], "host"),
                      errmsg, error, addinfo);
         else
-           printf ("%s: %d hits\n", ZOOM_connection_option_get(z[i], "host"),
+            printf ("%s: %d hits\n", ZOOM_connection_option_get(z[i], "host"),
                     ZOOM_resultset_size(r[i]));
     }
 
@@ -91,3 +91,11 @@ int main(int argc, char **argv)
     ZOOM_options_destroy(o);
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 5061d13..b2e466d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst5.c,v 1.9 2002-02-28 13:21:16 adam Exp $
+ * $Id: zoomtst5.c,v 1.10 2005-06-25 15:46:08 adam Exp $
  *
  * Asynchronous multi-target client doing search, sort and present
  */
@@ -14,7 +14,7 @@
 const char *my_callback (void *handle, const char *name)
 {
     if (!strcmp (name, "async"))
-       return "1";
+        return "1";
     return 0;
 }
 
@@ -30,9 +30,9 @@ int main(int argc, char **argv)
     o = ZOOM_options_create ();
     if (argc < 4)
     {
-       fprintf (stderr, "usage:\n%s target1 .. targetN query sort\n",
-                *argv);
-       exit (2);
+        fprintf (stderr, "usage:\n%s target1 .. targetN query sort\n",
+                 *argv);
+        exit (2);
     }
     if (no > 500)
         no = 500;
@@ -51,65 +51,65 @@ int main(int argc, char **argv)
     q = ZOOM_query_create ();
     if (ZOOM_query_prefix (q, argv[argc-2]))
     {
-       printf ("bad PQF: %s\n", argv[argc-2]);
-       exit (1);
+        printf ("bad PQF: %s\n", argv[argc-2]);
+        exit (1);
     }
     if (ZOOM_query_sortby (q, argv[argc-1]))
     {
-       printf ("bad sort spec: %s\n", argv[argc-1]);
-       exit (1);
+        printf ("bad sort spec: %s\n", argv[argc-1]);
+        exit (1);
     }
     /* connect - and search all */
     for (i = 0; i<no; i++)
     {
-       z[i] = ZOOM_connection_create (o);
-       ZOOM_connection_connect (z[i], argv[i+1], 0);
+        z[i] = ZOOM_connection_create (o);
+        ZOOM_connection_connect (z[i], argv[i+1], 0);
         r[i] = ZOOM_connection_search (z[i], q);
     }
 
     /* network I/O */
     while (ZOOM_event (no, z))
-       ;
+        ;
 
     /* handle errors */
     for (i = 0; i<no; i++)
     {
-       int error;
-       const char *errmsg, *addinfo;
-       if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
-           fprintf (stderr, "%s error: %s (%d) %s\n",
-                    ZOOM_connection_option_get(z[i], "host"),
-                    errmsg, error, addinfo);
-       else
-       {
-           /* OK, no major errors. Look at the result count */
-           int pos;
-           printf ("%s: %d hits\n", ZOOM_connection_option_get(z[i], "host"),
-                   ZOOM_resultset_size(r[i]));
-           /* go through first 20 records at target */
-           for (pos = 0; pos < 20; pos++)
-           {
-               ZOOM_record rec;
-               const char *db, *syntax, *str;
-               int len;
+        int error;
+        const char *errmsg, *addinfo;
+        if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
+            fprintf (stderr, "%s error: %s (%d) %s\n",
+                     ZOOM_connection_option_get(z[i], "host"),
+                     errmsg, error, addinfo);
+        else
+        {
+            /* OK, no major errors. Look at the result count */
+            int pos;
+            printf ("%s: %d hits\n", ZOOM_connection_option_get(z[i], "host"),
+                    ZOOM_resultset_size(r[i]));
+            /* go through first 20 records at target */
+            for (pos = 0; pos < 20; pos++)
+            {
+                ZOOM_record rec;
+                const char *db, *syntax, *str;
+                int len;
 
-               rec = ZOOM_resultset_record (r[i], pos);
-               /* get database for record and record itself at pos */
+                rec = ZOOM_resultset_record (r[i], pos);
+                /* get database for record and record itself at pos */
 
-               db = ZOOM_record_get (rec,  "database", 0);
-               str = ZOOM_record_get (rec, "xml", &len);
-               syntax = ZOOM_record_get (rec, "syntax", &len);
-               /* if rec is non-null, we got a record for display */
-               if (str)
-               {
-                   printf ("%d %s %s\n", pos+1, syntax, 
-                           (db ? db : "unknown"));
-                   if (rec)
-                       fwrite (str, 1, len, stdout);
-                   printf ("\n");
-               }
-           }
-       }
+                db = ZOOM_record_get (rec,  "database", 0);
+                str = ZOOM_record_get (rec, "xml", &len);
+                syntax = ZOOM_record_get (rec, "syntax", &len);
+                /* if rec is non-null, we got a record for display */
+                if (str)
+                {
+                    printf ("%d %s %s\n", pos+1, syntax, 
+                            (db ? db : "unknown"));
+                    if (rec)
+                        fwrite (str, 1, len, stdout);
+                    printf ("\n");
+                }
+            }
+        }
     }
 
     /* destroy stuff and exit */
@@ -122,3 +122,11 @@ int main(int argc, char **argv)
     ZOOM_options_destroy(o);
     exit(0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index ecee61b..44177e0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst6.c,v 1.9 2002-02-20 14:40:42 adam Exp $
+ * $Id: zoomtst6.c,v 1.10 2005-06-25 15:46:08 adam Exp $
  *
  * Asynchronous multi-target client doing two searches
  */
@@ -50,9 +50,9 @@ int main(int argc, char **argv)
     o = ZOOM_options_create ();
     if (argc < 4)
     {
-       fprintf (stderr, "usage:\n%s target1 .. targetN query1 query2\n",
-                *argv);
-       exit (1);
+        fprintf (stderr, "usage:\n%s target1 .. targetN query1 query2\n",
+                 *argv);
+        exit (1);
     }
     if (no > 500)
         no = 500;
@@ -69,20 +69,20 @@ int main(int argc, char **argv)
     q = ZOOM_query_create ();
     if (ZOOM_query_prefix (q, argv[argc-2]))
     {
-       printf ("bad PQF: %s\n", argv[argc-2]);
-       exit (2);
+        printf ("bad PQF: %s\n", argv[argc-2]);
+        exit (2);
     }
     /* connect - and search all */
     for (i = 0; i<no; i++)
     {
-       z[i] = ZOOM_connection_create (o);
-       ZOOM_connection_connect (z[i], argv[i+1], 0);
+        z[i] = ZOOM_connection_create (o);
+        ZOOM_connection_connect (z[i], argv[i+1], 0);
         r1[i] = ZOOM_connection_search (z[i], q);
     }
     if (ZOOM_query_prefix (q, argv[argc-1]))
     {
-       printf ("bad sort spec: %s\n", argv[argc-1]);
-       exit (2);
+        printf ("bad sort spec: %s\n", argv[argc-1]);
+        exit (2);
     }
     /* queue second search */
     for (i = 0; i<no; i++)
@@ -94,22 +94,22 @@ int main(int argc, char **argv)
 
     /* network I/O */
     while (ZOOM_event (no, z))
-       ;
+        ;
 
     /* handle errors */
     for (i = 0; i<no; i++)
     {
-       int error;
-       const char *errmsg, *addinfo;
-       if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
-           fprintf (stderr, "%s error: %s (%d) %s\n",
-                    ZOOM_connection_option_get(z[i], "host"),
-                    errmsg, error, addinfo);
-       else
-       {
-           display_records (ZOOM_connection_option_get(z[i], "host"), r1[i]);
-           display_records (ZOOM_connection_option_get(z[i], "host"), r2[i]);
-       }
+        int error;
+        const char *errmsg, *addinfo;
+        if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
+            fprintf (stderr, "%s error: %s (%d) %s\n",
+                     ZOOM_connection_option_get(z[i], "host"),
+                     errmsg, error, addinfo);
+        else
+        {
+            display_records (ZOOM_connection_option_get(z[i], "host"), r1[i]);
+            display_records (ZOOM_connection_option_get(z[i], "host"), r2[i]);
+        }
     }
     /* destroy stuff and exit */
     ZOOM_query_destroy (q);
@@ -122,3 +122,11 @@ int main(int argc, char **argv)
     ZOOM_options_destroy(o);
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c1c9d8d..2192abd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst7.c,v 1.13 2005-02-03 09:09:55 adam Exp $
+ * $Id: zoomtst7.c,v 1.14 2005-06-25 15:46:08 adam Exp $
  *
  * API test..
  */
@@ -35,126 +35,126 @@ int main(int argc, char **argv)
 
     for (block = 0; block < 3; block++)
     {
-       switch (block)
-       {
-       case 0:
-           printf ("blocking - not calling ZOOM_events\n");
-           break;
-       case 1:
-           printf ("blocking - calling ZOOM_events\n");
-           break;
-       case 2:
-           printf ("non-blocking - calling ZOOM_events\n");
-           break;
-       }
-       if (block > 1)
-           ZOOM_options_set (o, "async", "1");
-       for (i = 0; i<10; i++)
-       {
-           char host[40];
-
-           printf ("session %2d", i);
-           sprintf (host, "localhost:9999/%d", i);
-           z = ZOOM_connection_create (o);
-           ZOOM_connection_connect (z, host, 0);
-           
-           for (j = 0; j < 10; j++)
-           {
-               ZOOM_record recs[2];
-               char query[40];
-               ZOOM_query s = ZOOM_query_create ();
-               
-               sprintf (query, "i%dr%d", i, j);
-               
-               if (ZOOM_query_prefix (s, query))
-               {
-                   printf ("bad PQF: %s\n", query);
-                   exit (2);
-               }
-               ZOOM_options_set (o, "start", "0");
-               ZOOM_options_set (o, "count", "0");
-               
-               r[j] = ZOOM_connection_search (z, s); /* non-piggy */
-               
-               ZOOM_resultset_records (r[j], recs, 0, 2);  /* first two */
-               
-               ZOOM_resultset_records (r[j], recs, 1, 2);  /* third */
-
-               ZOOM_resultset_records (r[j], recs, 0, 0);  /* ignored */
-
-               if (ZOOM_resultset_size (r[j]) > 2)
-               {
-                   if (!recs[0])
-                   {
-                       fprintf (stderr, "\nrecord missing\n");
-                       exit (1);
-                   }
-               }
-               
-               ZOOM_query_destroy (s);
-
-               printf (".");
-               if (block > 0)
-                   while (ZOOM_event (1, &z))
-                       ;
-           }
-           for (j = 0; j<i; j++)
-               ZOOM_resultset_destroy (r[j]);
-           ZOOM_connection_destroy (z);
-           for (; j < 10; j++)
-               ZOOM_resultset_destroy (r[j]);
-           printf ("10 searches, 20 presents done\n");
-
-       }
-
-       for (i = 0; i<1; i++)
-       {
-           ZOOM_query q = ZOOM_query_create ();
-           char host[40];
-
-           printf ("session %2d", i+10);
-           sprintf (host, "localhost:9999/%d", i);
-           z = ZOOM_connection_create (o);
-           ZOOM_connection_connect (z, host, 0);
-           
-           for (j = 0; j < 10; j++)
-           {
-               char query[40];
-               
-               sprintf (query, "i%dr%d", i, j);
-               
-               ZOOM_options_set (o, "count", "0");
-               
-               r[j] = ZOOM_connection_search_pqf (z, query);
-
-               printf (".");
-               if (block > 0)
-                   while (ZOOM_event (1, &z))
-                       ;
-           }
-
-           ZOOM_connection_destroy (z);
-           
-           for (j = 0; j < 10; j++)
-           {
-               ZOOM_resultset_records (r[j], 0, 0, 1);
-           }
-           for (j = 0; j < 10; j++)
-               ZOOM_resultset_destroy (r[j]);
-           ZOOM_query_destroy (q);
-           printf ("10 searches, 10 ignored presents done\n");
-       }
+        switch (block)
+        {
+        case 0:
+            printf ("blocking - not calling ZOOM_events\n");
+            break;
+        case 1:
+            printf ("blocking - calling ZOOM_events\n");
+            break;
+        case 2:
+            printf ("non-blocking - calling ZOOM_events\n");
+            break;
+        }
+        if (block > 1)
+            ZOOM_options_set (o, "async", "1");
+        for (i = 0; i<10; i++)
+        {
+            char host[40];
+
+            printf ("session %2d", i);
+            sprintf (host, "localhost:9999/%d", i);
+            z = ZOOM_connection_create (o);
+            ZOOM_connection_connect (z, host, 0);
+            
+            for (j = 0; j < 10; j++)
+            {
+                ZOOM_record recs[2];
+                char query[40];
+                ZOOM_query s = ZOOM_query_create ();
+                
+                sprintf (query, "i%dr%d", i, j);
+                
+                if (ZOOM_query_prefix (s, query))
+                {
+                    printf ("bad PQF: %s\n", query);
+                    exit (2);
+                }
+                ZOOM_options_set (o, "start", "0");
+                ZOOM_options_set (o, "count", "0");
+                
+                r[j] = ZOOM_connection_search (z, s); /* non-piggy */
+                
+                ZOOM_resultset_records (r[j], recs, 0, 2);  /* first two */
+                
+                ZOOM_resultset_records (r[j], recs, 1, 2);  /* third */
+
+                ZOOM_resultset_records (r[j], recs, 0, 0);  /* ignored */
+
+                if (ZOOM_resultset_size (r[j]) > 2)
+                {
+                    if (!recs[0])
+                    {
+                        fprintf (stderr, "\nrecord missing\n");
+                        exit (1);
+                    }
+                }
+                
+                ZOOM_query_destroy (s);
+
+                printf (".");
+                if (block > 0)
+                    while (ZOOM_event (1, &z))
+                        ;
+            }
+            for (j = 0; j<i; j++)
+                ZOOM_resultset_destroy (r[j]);
+            ZOOM_connection_destroy (z);
+            for (; j < 10; j++)
+                ZOOM_resultset_destroy (r[j]);
+            printf ("10 searches, 20 presents done\n");
+
+        }
+
+        for (i = 0; i<1; i++)
+        {
+            ZOOM_query q = ZOOM_query_create ();
+            char host[40];
+
+            printf ("session %2d", i+10);
+            sprintf (host, "localhost:9999/%d", i);
+            z = ZOOM_connection_create (o);
+            ZOOM_connection_connect (z, host, 0);
+            
+            for (j = 0; j < 10; j++)
+            {
+                char query[40];
+                
+                sprintf (query, "i%dr%d", i, j);
+                
+                ZOOM_options_set (o, "count", "0");
+                
+                r[j] = ZOOM_connection_search_pqf (z, query);
+
+                printf (".");
+                if (block > 0)
+                    while (ZOOM_event (1, &z))
+                        ;
+            }
+
+            ZOOM_connection_destroy (z);
+            
+            for (j = 0; j < 10; j++)
+            {
+                ZOOM_resultset_records (r[j], 0, 0, 1);
+            }
+            for (j = 0; j < 10; j++)
+                ZOOM_resultset_destroy (r[j]);
+            ZOOM_query_destroy (q);
+            printf ("10 searches, 10 ignored presents done\n");
+        }
 
 
         for (i = 0; i<1; i++)
         {
-           char host[40];
+            char host[40];
             ZOOM_scanset scan = 0;
 
-           printf ("session %2d", i);
-           sprintf (host, "localhost:9999/%d", i);
-           z = ZOOM_connection_create (o);
-           ZOOM_connection_connect (z, host, 0);
+            printf ("session %2d", i);
+            sprintf (host, "localhost:9999/%d", i);
+            z = ZOOM_connection_create (o);
+            ZOOM_connection_connect (z, host, 0);
 
             scan = ZOOM_connection_scan (z, "@attr 1=4 a");
             if (block > 0)
@@ -171,7 +171,7 @@ int main(int argc, char **argv)
                 
             }
             ZOOM_scanset_destroy (scan);
-           ZOOM_connection_destroy (z);
+            ZOOM_connection_destroy (z);
         }
 
     }
@@ -179,3 +179,11 @@ int main(int argc, char **argv)
     exit (0);
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2f500b7..cb1ff6d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: zoomtst8.c,v 1.3 2002-05-21 08:36:04 adam Exp $
+ * $Id: zoomtst8.c,v 1.4 2005-06-25 15:46:08 adam Exp $
  *
  * Asynchronous multi-target client doing scan
  */
@@ -21,9 +21,9 @@ int main(int argc, char **argv)
 
     if (argc < 3)
     {
-       fprintf (stderr, "usage:\n%s target1 target2 ... targetN scan\n",
-                *argv);
-       exit (1);
+        fprintf (stderr, "usage:\n%s target1 target2 ... targetN scan\n",
+                 *argv);
+        exit (1);
     }
     if (no > 500)
         no = 500;
@@ -34,11 +34,11 @@ int main(int argc, char **argv)
     /* connect to all */
     for (i = 0; i<no; i++)
     {
-       /* create connection - pass options (they are the same for all) */
-       z[i] = ZOOM_connection_create (o);
+        /* create connection - pass options (they are the same for all) */
+        z[i] = ZOOM_connection_create (o);
 
-       /* connect and init */
-       ZOOM_connection_connect (z[i], argv[1+i], 0);
+        /* connect and init */
+        ZOOM_connection_connect (z[i], argv[1+i], 0);
         
     }
     /* scan all */
@@ -56,11 +56,11 @@ int main(int argc, char **argv)
 
     for (i = 0; i<no; i++)
     {
-       int error;
-       const char *errmsg, *addinfo;
-       if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
-           fprintf (stderr, "%s error: %s (%d) %s\n",
-                    ZOOM_connection_option_get(z[i], "host"),
+        int error;
+        const char *errmsg, *addinfo;
+        if ((error = ZOOM_connection_error(z[i], &errmsg, &addinfo)))
+            fprintf (stderr, "%s error: %s (%d) %s\n",
+                     ZOOM_connection_option_get(z[i], "host"),
                      errmsg, error, addinfo);
         else
         {
@@ -86,3 +86,11 @@ int main(int argc, char **argv)
     ZOOM_options_destroy(o);
     exit (0);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 09472d9..f67f053 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: read-grs.c,v 1.12 2005-01-15 19:47:16 adam Exp $
+ * $Id: read-grs.c,v 1.13 2005-06-25 15:46:09 adam Exp $
  */
 
 /*
@@ -27,72 +27,72 @@ static Z_GenericRecord *read_grs1(FILE *f, ODR o)
 
     for (;;)
     {
-       Z_TaggedElement *t;
-       Z_ElementData *c;
+        Z_TaggedElement *t;
+        Z_ElementData *c;
 
-       while (fgets(buf = line, 512, f))
-       {
-           while (*buf && isspace(*(unsigned char *) buf))
-               buf++;
-           if (!*buf || *buf == '#')
-               continue;
-           break;
-       }
-       if (*buf == '}')
-           return r;
-       if (sscanf(buf, "(%d,%[^)])", &type, value) != 2)
-       {
-           yaz_log(YLOG_WARN, "Bad data in '%s'", buf);
-           return 0;
-       }
-       if (!type && *value == '0')
-           return r;
-       if (!(buf = strchr(buf, ')')))
-           return 0;
-       buf++;
-       while (*buf && isspace(*(unsigned char *) buf))
-           buf++;
-       if (!*buf)
-           return 0;
-       if (!r)
-       {
-           r = (Z_GenericRecord *)odr_malloc(o, sizeof(*r));
-           r->elements = (Z_TaggedElement **)
+        while (fgets(buf = line, 512, f))
+        {
+            while (*buf && isspace(*(unsigned char *) buf))
+                buf++;
+            if (!*buf || *buf == '#')
+                continue;
+            break;
+        }
+        if (*buf == '}')
+            return r;
+        if (sscanf(buf, "(%d,%[^)])", &type, value) != 2)
+        {
+            yaz_log(YLOG_WARN, "Bad data in '%s'", buf);
+            return 0;
+        }
+        if (!type && *value == '0')
+            return r;
+        if (!(buf = strchr(buf, ')')))
+            return 0;
+        buf++;
+        while (*buf && isspace(*(unsigned char *) buf))
+            buf++;
+        if (!*buf)
+            return 0;
+        if (!r)
+        {
+            r = (Z_GenericRecord *)odr_malloc(o, sizeof(*r));
+            r->elements = (Z_TaggedElement **)
                 odr_malloc(o, sizeof(Z_TaggedElement*) * GRS_MAX_FIELDS);
-           r->num_elements = 0;
-       }
-       r->elements[r->num_elements] = t = (Z_TaggedElement *)
+            r->num_elements = 0;
+        }
+        r->elements[r->num_elements] = t = (Z_TaggedElement *)
             odr_malloc(o, sizeof(Z_TaggedElement));
-       t->tagType = odr_intdup(o, type);
-       t->tagValue = (Z_StringOrNumeric *)
+        t->tagType = odr_intdup(o, type);
+        t->tagValue = (Z_StringOrNumeric *)
             odr_malloc(o, sizeof(Z_StringOrNumeric));
-       if ((ivalue = atoi(value)))
-       {
-           t->tagValue->which = Z_StringOrNumeric_numeric;
-           t->tagValue->u.numeric = odr_intdup(o, ivalue);
-       }
-       else
-       {
-           t->tagValue->which = Z_StringOrNumeric_string;
-           t->tagValue->u.string = (char *)odr_malloc(o, strlen(value)+1);
-           strcpy(t->tagValue->u.string, value);
-       }
-       t->tagOccurrence = 0;
-       t->metaData = 0;
-       t->appliedVariant = 0;
-       t->content = c = (Z_ElementData *)odr_malloc(o, sizeof(Z_ElementData));
-       if (*buf == '{')
-       {
-           c->which = Z_ElementData_subtree;
-           c->u.subtree = read_grs1(f, o);
-       }
-       else
-       {
-           c->which = Z_ElementData_string;
-           buf[strlen(buf)-1] = '\0';
-           c->u.string = odr_strdup(o, buf);
-       }
-       r->num_elements++;
+        if ((ivalue = atoi(value)))
+        {
+            t->tagValue->which = Z_StringOrNumeric_numeric;
+            t->tagValue->u.numeric = odr_intdup(o, ivalue);
+        }
+        else
+        {
+            t->tagValue->which = Z_StringOrNumeric_string;
+            t->tagValue->u.string = (char *)odr_malloc(o, strlen(value)+1);
+            strcpy(t->tagValue->u.string, value);
+        }
+        t->tagOccurrence = 0;
+        t->metaData = 0;
+        t->appliedVariant = 0;
+        t->content = c = (Z_ElementData *)odr_malloc(o, sizeof(Z_ElementData));
+        if (*buf == '{')
+        {
+            c->which = Z_ElementData_subtree;
+            c->u.subtree = read_grs1(f, o);
+        }
+        else
+        {
+            c->which = Z_ElementData_string;
+            buf[strlen(buf)-1] = '\0';
+            c->u.string = odr_strdup(o, buf);
+        }
+        r->num_elements++;
     }
 }
 
@@ -104,14 +104,22 @@ Z_GenericRecord *dummy_grs_record (int num, ODR o)
     int n;
 
     if (!f)
-       return 0;
+        return 0;
     while (fgets(line, 512, f))
-       if (*line == '#' && sscanf(line, "#%d", &n) == 1 && n == num)
-       {
-           r = read_grs1(f, o);
-           break;
-       }
+        if (*line == '#' && sscanf(line, "#%d", &n) == 1 && n == num)
+        {
+            r = read_grs1(f, o);
+            break;
+        }
     fclose(f);
     return r;
 }
 
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index c936a60..eb44631 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: read-marc.c,v 1.6 2005-01-15 19:47:16 adam Exp $
+ * $Id: read-marc.c,v 1.7 2005-06-25 15:46:09 adam Exp $
  */
 
 /*
@@ -1617,3 +1617,11 @@ char *dummy_xml_record (int num, ODR odr)
     yaz_marc_destroy(mt);
     return rec;
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
index 2bbc613..a6b71d2 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ztest.c,v 1.74 2005-03-03 23:16:20 adam Exp $
+ * $Id: ztest.c,v 1.75 2005-06-25 15:46:09 adam Exp $
  */
 
 /*
@@ -41,7 +41,7 @@ int ztest_search(void *handle, bend_search_rr *rr)
     /* if database is stop, stop this process.. For debugging only. */
     if (!yaz_matchstr (rr->basenames[0], "stop"))
     {
-       nmem_print_list_l(YLOG_LOG);
+        nmem_print_list_l(YLOG_LOG);
         exit(0);
     }
 #endif
@@ -68,7 +68,7 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
     (*counter)++;
 
     if (rr->esr->packageName)
-       yaz_log(log_level, "packagename: %s", rr->esr->packageName);
+        yaz_log(log_level, "packagename: %s", rr->esr->packageName);
     yaz_log(log_level, "Waitaction: %d", *rr->esr->waitAction);
 
 
@@ -80,86 +80,86 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
     }
     else if (rr->esr->taskSpecificParameters->which == Z_External_itemOrder)
     {
-       Z_ItemOrder *it = rr->esr->taskSpecificParameters->u.itemOrder;
-       yaz_log (log_level, "Received ItemOrder");
+        Z_ItemOrder *it = rr->esr->taskSpecificParameters->u.itemOrder;
+        yaz_log (log_level, "Received ItemOrder");
         if (it->which == Z_IOItemOrder_esRequest)
-       {
-           Z_IORequest *ir = it->u.esRequest;
-           Z_IOOriginPartToKeep *k = ir->toKeep;
-           Z_IOOriginPartNotToKeep *n = ir->notToKeep;
-           
-           if (k && k->contact)
-           {
-               if (k->contact->name)
-                   yaz_log(log_level, "contact name %s", k->contact->name);
-               if (k->contact->phone)
-                   yaz_log(log_level, "contact phone %s", k->contact->phone);
-               if (k->contact->email)
-                   yaz_log(log_level, "contact email %s", k->contact->email);
-           }
-           if (k->addlBilling)
-           {
-               yaz_log(log_level, "Billing info (not shown)");
-           }
-           
-           if (n->resultSetItem)
-           {
-               yaz_log(log_level, "resultsetItem");
-               yaz_log(log_level, "setId: %s", n->resultSetItem->resultSetId);
-               yaz_log(log_level, "item: %d", *n->resultSetItem->item);
-           }
-           if (n->itemRequest)
-           {
-               Z_External *r = (Z_External*) n->itemRequest;
-               ILL_ItemRequest *item_req = 0;
-               ILL_APDU *ill_apdu = 0;
-               if (r->direct_reference)
-               {
-                   oident *ent = oid_getentbyoid(r->direct_reference);
-                   if (ent)
-                       yaz_log(log_level, "OID %s", ent->desc);
+        {
+            Z_IORequest *ir = it->u.esRequest;
+            Z_IOOriginPartToKeep *k = ir->toKeep;
+            Z_IOOriginPartNotToKeep *n = ir->notToKeep;
+            
+            if (k && k->contact)
+            {
+                if (k->contact->name)
+                    yaz_log(log_level, "contact name %s", k->contact->name);
+                if (k->contact->phone)
+                    yaz_log(log_level, "contact phone %s", k->contact->phone);
+                if (k->contact->email)
+                    yaz_log(log_level, "contact email %s", k->contact->email);
+            }
+            if (k->addlBilling)
+            {
+                yaz_log(log_level, "Billing info (not shown)");
+            }
+            
+            if (n->resultSetItem)
+            {
+                yaz_log(log_level, "resultsetItem");
+                yaz_log(log_level, "setId: %s", n->resultSetItem->resultSetId);
+                yaz_log(log_level, "item: %d", *n->resultSetItem->item);
+            }
+            if (n->itemRequest)
+            {
+                Z_External *r = (Z_External*) n->itemRequest;
+                ILL_ItemRequest *item_req = 0;
+                ILL_APDU *ill_apdu = 0;
+                if (r->direct_reference)
+                {
+                    oident *ent = oid_getentbyoid(r->direct_reference);
+                    if (ent)
+                        yaz_log(log_level, "OID %s", ent->desc);
                     if (ent && ent->value == VAL_TEXT_XML)
                     {
-                       yaz_log (log_level, "ILL XML request");
+                        yaz_log (log_level, "ILL XML request");
                         if (r->which == Z_External_octet)
                             yaz_log (log_level, "%.*s", r->u.octet_aligned->len,
                                      r->u.octet_aligned->buf); 
                     }
-                   if (ent && ent->value == VAL_ISO_ILL_1)
-                   {
-                       yaz_log (log_level, "Decode ItemRequest begin");
-                       if (r->which == ODR_EXTERNAL_single)
-                       {
-                           odr_setbuf(rr->decode,
-                                      (char *) r->u.single_ASN1_type->buf,
-                                      r->u.single_ASN1_type->len, 0);
-                           
-                           if (!ill_ItemRequest (rr->decode, &item_req, 0, 0))
-                           {
-                               yaz_log (log_level,
+                    if (ent && ent->value == VAL_ISO_ILL_1)
+                    {
+                        yaz_log (log_level, "Decode ItemRequest begin");
+                        if (r->which == ODR_EXTERNAL_single)
+                        {
+                            odr_setbuf(rr->decode,
+                                       (char *) r->u.single_ASN1_type->buf,
+                                       r->u.single_ASN1_type->len, 0);
+                            
+                            if (!ill_ItemRequest (rr->decode, &item_req, 0, 0))
+                            {
+                                yaz_log (log_level,
                                     "Couldn't decode ItemRequest %s near %d",
                                        odr_errmsg(odr_geterror(rr->decode)),
                                        odr_offset(rr->decode));
                             }
-                           else
-                               yaz_log(log_level, "Decode ItemRequest OK");
-                           if (rr->print)
-                           {
-                               ill_ItemRequest (rr->print, &item_req, 0,
+                            else
+                                yaz_log(log_level, "Decode ItemRequest OK");
+                            if (rr->print)
+                            {
+                                ill_ItemRequest (rr->print, &item_req, 0,
                                     "ItemRequest");
-                               odr_reset (rr->print);
-                           }
-                       }
-                       if (!item_req && r->which == ODR_EXTERNAL_single)
-                       {
-                           yaz_log (log_level, "Decode ILL APDU begin");
-                           odr_setbuf(rr->decode,
-                                      (char*) r->u.single_ASN1_type->buf,
-                                      r->u.single_ASN1_type->len, 0);
-                           
-                           if (!ill_APDU (rr->decode, &ill_apdu, 0, 0))
-                           {
-                               yaz_log (log_level,
+                                odr_reset (rr->print);
+                            }
+                        }
+                        if (!item_req && r->which == ODR_EXTERNAL_single)
+                        {
+                            yaz_log (log_level, "Decode ILL APDU begin");
+                            odr_setbuf(rr->decode,
+                                       (char*) r->u.single_ASN1_type->buf,
+                                       r->u.single_ASN1_type->len, 0);
+                            
+                            if (!ill_APDU (rr->decode, &ill_apdu, 0, 0))
+                            {
+                                yaz_log (log_level,
                                     "Couldn't decode ILL APDU %s near %d",
                                        odr_errmsg(odr_geterror(rr->decode)),
                                        odr_offset(rr->decode));
@@ -168,245 +168,245 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
                                      (char *) r->u.single_ASN1_type->buf,
                                      r->u.single_ASN1_type->len);
                             }
-                           else
-                               yaz_log(log_level, "Decode ILL APDU OK");
-                           if (rr->print)
+                            else
+                                yaz_log(log_level, "Decode ILL APDU OK");
+                            if (rr->print)
                             {
-                               ill_APDU (rr->print, &ill_apdu, 0,
+                                ill_APDU (rr->print, &ill_apdu, 0,
                                     "ILL APDU");
-                               odr_reset (rr->print);
-                           }
-                       }
-                   }
-               }
-               if (item_req)
-               {
-                   yaz_log (log_level, "ILL protocol version = %d",
-                            *item_req->protocol_version_num);
-               }
-           }
+                                odr_reset (rr->print);
+                            }
+                        }
+                    }
+                }
+                if (item_req)
+                {
+                    yaz_log (log_level, "ILL protocol version = %d",
+                             *item_req->protocol_version_num);
+                }
+            }
             if (k)
             {
 
-               Z_External *ext = (Z_External *)
+                Z_External *ext = (Z_External *)
                     odr_malloc (rr->stream, sizeof(*ext));
-               Z_IUOriginPartToKeep *keep = (Z_IUOriginPartToKeep *)
+                Z_IUOriginPartToKeep *keep = (Z_IUOriginPartToKeep *)
                     odr_malloc (rr->stream, sizeof(*keep));
-               Z_IOTargetPart *targetPart = (Z_IOTargetPart *)
-                   odr_malloc (rr->stream, sizeof(*targetPart));
+                Z_IOTargetPart *targetPart = (Z_IOTargetPart *)
+                    odr_malloc (rr->stream, sizeof(*targetPart));
 
-               rr->taskPackage = (Z_TaskPackage *)
+                rr->taskPackage = (Z_TaskPackage *)
                     odr_malloc (rr->stream, sizeof(*rr->taskPackage));
-               rr->taskPackage->packageType =
-                   odr_oiddup (rr->stream, rr->esr->packageType);
-               rr->taskPackage->packageName = 0;
-               rr->taskPackage->userId = 0;
-               rr->taskPackage->retentionTime = 0;
-               rr->taskPackage->permissions = 0;
-               rr->taskPackage->description = 0;
-               rr->taskPackage->targetReference = (Odr_oct *)
-                   odr_malloc (rr->stream, sizeof(Odr_oct));
-               rr->taskPackage->targetReference->buf =
-                   (unsigned char *) odr_strdup (rr->stream, "911");
-               rr->taskPackage->targetReference->len =
-                   rr->taskPackage->targetReference->size =
-                   strlen((char *) (rr->taskPackage->targetReference->buf));
-               rr->taskPackage->creationDateTime = 0;
-               rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
-               rr->taskPackage->packageDiagnostics = 0;
-               rr->taskPackage->taskSpecificParameters = ext;
-
-               ext->direct_reference =
-                   odr_oiddup (rr->stream, rr->esr->packageType);
-               ext->indirect_reference = 0;
-               ext->descriptor = 0;
-               ext->which = Z_External_itemOrder;
-               ext->u.itemOrder = (Z_ItemOrder *)
-                   odr_malloc (rr->stream, sizeof(*ext->u.update));
-               ext->u.itemOrder->which = Z_IOItemOrder_taskPackage;
-               ext->u.itemOrder->u.taskPackage =  (Z_IOTaskPackage *)
-                   odr_malloc (rr->stream, sizeof(Z_IOTaskPackage));
-               ext->u.itemOrder->u.taskPackage->originPart = k;
-               ext->u.itemOrder->u.taskPackage->targetPart = targetPart;
+                rr->taskPackage->packageType =
+                    odr_oiddup (rr->stream, rr->esr->packageType);
+                rr->taskPackage->packageName = 0;
+                rr->taskPackage->userId = 0;
+                rr->taskPackage->retentionTime = 0;
+                rr->taskPackage->permissions = 0;
+                rr->taskPackage->description = 0;
+                rr->taskPackage->targetReference = (Odr_oct *)
+                    odr_malloc (rr->stream, sizeof(Odr_oct));
+                rr->taskPackage->targetReference->buf =
+                    (unsigned char *) odr_strdup (rr->stream, "911");
+                rr->taskPackage->targetReference->len =
+                    rr->taskPackage->targetReference->size =
+                    strlen((char *) (rr->taskPackage->targetReference->buf));
+                rr->taskPackage->creationDateTime = 0;
+                rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
+                rr->taskPackage->packageDiagnostics = 0;
+                rr->taskPackage->taskSpecificParameters = ext;
+
+                ext->direct_reference =
+                    odr_oiddup (rr->stream, rr->esr->packageType);
+                ext->indirect_reference = 0;
+                ext->descriptor = 0;
+                ext->which = Z_External_itemOrder;
+                ext->u.itemOrder = (Z_ItemOrder *)
+                    odr_malloc (rr->stream, sizeof(*ext->u.update));
+                ext->u.itemOrder->which = Z_IOItemOrder_taskPackage;
+                ext->u.itemOrder->u.taskPackage =  (Z_IOTaskPackage *)
+                    odr_malloc (rr->stream, sizeof(Z_IOTaskPackage));
+                ext->u.itemOrder->u.taskPackage->originPart = k;
+                ext->u.itemOrder->u.taskPackage->targetPart = targetPart;
 
                 targetPart->itemRequest = 0;
                 targetPart->statusOrErrorReport = 0;
                 targetPart->auxiliaryStatus = 0;
             }
-       }
+        }
     }
     else if (rr->esr->taskSpecificParameters->which == Z_External_update)
     {
-       Z_IUUpdate *up = rr->esr->taskSpecificParameters->u.update;
-       yaz_log (log_level, "Received DB Update");
-       if (up->which == Z_IUUpdate_esRequest)
-       {
-           Z_IUUpdateEsRequest *esRequest = up->u.esRequest;
-           Z_IUOriginPartToKeep *toKeep = esRequest->toKeep;
-           Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep;
-           
-           yaz_log (log_level, "action");
-           if (toKeep->action)
-           {
-               switch (*toKeep->action)
-               {
-               case Z_IUOriginPartToKeep_recordInsert:
-                   yaz_log (log_level, " recordInsert");
-                   break;
-               case Z_IUOriginPartToKeep_recordReplace:
-                   yaz_log (log_level, " recordReplace");
-                   break;
-               case Z_IUOriginPartToKeep_recordDelete:
-                   yaz_log (log_level, " recordDelete");
-                   break;
-               case Z_IUOriginPartToKeep_elementUpdate:
-                   yaz_log (log_level, " elementUpdate");
-                   break;
-               case Z_IUOriginPartToKeep_specialUpdate:
-                   yaz_log (log_level, " specialUpdate");
-                   break;
-               default:
-                   yaz_log (log_level, " unknown (%d)", *toKeep->action);
-               }
-           }
-           if (toKeep->databaseName)
-           {
-               yaz_log (log_level, "database: %s", toKeep->databaseName);
-               if (!strcmp(toKeep->databaseName, "fault"))
-               {
-                   rr->errcode = 109;
-                   rr->errstring = toKeep->databaseName;
-               }
-               if (!strcmp(toKeep->databaseName, "accept"))
-                   rr->errcode = -1;
-           }
-           if (toKeep)
-           {
-               Z_External *ext = (Z_External *)
+        Z_IUUpdate *up = rr->esr->taskSpecificParameters->u.update;
+        yaz_log (log_level, "Received DB Update");
+        if (up->which == Z_IUUpdate_esRequest)
+        {
+            Z_IUUpdateEsRequest *esRequest = up->u.esRequest;
+            Z_IUOriginPartToKeep *toKeep = esRequest->toKeep;
+            Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep;
+            
+            yaz_log (log_level, "action");
+            if (toKeep->action)
+            {
+                switch (*toKeep->action)
+                {
+                case Z_IUOriginPartToKeep_recordInsert:
+                    yaz_log (log_level, " recordInsert");
+                    break;
+                case Z_IUOriginPartToKeep_recordReplace:
+                    yaz_log (log_level, " recordReplace");
+                    break;
+                case Z_IUOriginPartToKeep_recordDelete:
+                    yaz_log (log_level, " recordDelete");
+                    break;
+                case Z_IUOriginPartToKeep_elementUpdate:
+                    yaz_log (log_level, " elementUpdate");
+                    break;
+                case Z_IUOriginPartToKeep_specialUpdate:
+                    yaz_log (log_level, " specialUpdate");
+                    break;
+                default:
+                    yaz_log (log_level, " unknown (%d)", *toKeep->action);
+                }
+            }
+            if (toKeep->databaseName)
+            {
+                yaz_log (log_level, "database: %s", toKeep->databaseName);
+                if (!strcmp(toKeep->databaseName, "fault"))
+                {
+                    rr->errcode = 109;
+                    rr->errstring = toKeep->databaseName;
+                }
+                if (!strcmp(toKeep->databaseName, "accept"))
+                    rr->errcode = -1;
+            }
+            if (toKeep)
+            {
+                Z_External *ext = (Z_External *)
                     odr_malloc (rr->stream, sizeof(*ext));
-               Z_IUOriginPartToKeep *keep = (Z_IUOriginPartToKeep *)
+                Z_IUOriginPartToKeep *keep = (Z_IUOriginPartToKeep *)
                     odr_malloc (rr->stream, sizeof(*keep));
-               Z_IUTargetPart *targetPart = (Z_IUTargetPart *)
-                   odr_malloc (rr->stream, sizeof(*targetPart));
+                Z_IUTargetPart *targetPart = (Z_IUTargetPart *)
+                    odr_malloc (rr->stream, sizeof(*targetPart));
 
-               rr->taskPackage = (Z_TaskPackage *)
+                rr->taskPackage = (Z_TaskPackage *)
                     odr_malloc (rr->stream, sizeof(*rr->taskPackage));
-               rr->taskPackage->packageType =
-                   odr_oiddup (rr->stream, rr->esr->packageType);
-               rr->taskPackage->packageName = 0;
-               rr->taskPackage->userId = 0;
-               rr->taskPackage->retentionTime = 0;
-               rr->taskPackage->permissions = 0;
-               rr->taskPackage->description = 0;
-               rr->taskPackage->targetReference = (Odr_oct *)
-                   odr_malloc (rr->stream, sizeof(Odr_oct));
-               rr->taskPackage->targetReference->buf =
-                   (unsigned char *) odr_strdup (rr->stream, "123");
-               rr->taskPackage->targetReference->len =
-                   rr->taskPackage->targetReference->size =
-                   strlen((char *) (rr->taskPackage->targetReference->buf));
-               rr->taskPackage->creationDateTime = 0;
-               rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
-               rr->taskPackage->packageDiagnostics = 0;
-               rr->taskPackage->taskSpecificParameters = ext;
-
-               ext->direct_reference =
-                   odr_oiddup (rr->stream, rr->esr->packageType);
-               ext->indirect_reference = 0;
-               ext->descriptor = 0;
-               ext->which = Z_External_update;
-               ext->u.update = (Z_IUUpdate *)
-                   odr_malloc (rr->stream, sizeof(*ext->u.update));
-               ext->u.update->which = Z_IUUpdate_taskPackage;
-               ext->u.update->u.taskPackage =  (Z_IUUpdateTaskPackage *)
-                   odr_malloc (rr->stream, sizeof(Z_IUUpdateTaskPackage));
-               ext->u.update->u.taskPackage->originPart = keep;
-               ext->u.update->u.taskPackage->targetPart = targetPart;
-
-               keep->action = (int *) odr_malloc (rr->stream, sizeof(int));
-               *keep->action = *toKeep->action;
-               keep->databaseName =
-                   odr_strdup (rr->stream, toKeep->databaseName);
-               keep->schema = 0;
-               keep->elementSetName = 0;
-               keep->actionQualifier = 0;
-
-               targetPart->updateStatus = odr_intdup (rr->stream, 1);
-               targetPart->num_globalDiagnostics = 0;
-               targetPart->globalDiagnostics = (Z_DiagRec **) odr_nullval();
-               targetPart->num_taskPackageRecords = 1;
-               targetPart->taskPackageRecords = 
+                rr->taskPackage->packageType =
+                    odr_oiddup (rr->stream, rr->esr->packageType);
+                rr->taskPackage->packageName = 0;
+                rr->taskPackage->userId = 0;
+                rr->taskPackage->retentionTime = 0;
+                rr->taskPackage->permissions = 0;
+                rr->taskPackage->description = 0;
+                rr->taskPackage->targetReference = (Odr_oct *)
+                    odr_malloc (rr->stream, sizeof(Odr_oct));
+                rr->taskPackage->targetReference->buf =
+                    (unsigned char *) odr_strdup (rr->stream, "123");
+                rr->taskPackage->targetReference->len =
+                    rr->taskPackage->targetReference->size =
+                    strlen((char *) (rr->taskPackage->targetReference->buf));
+                rr->taskPackage->creationDateTime = 0;
+                rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
+                rr->taskPackage->packageDiagnostics = 0;
+                rr->taskPackage->taskSpecificParameters = ext;
+
+                ext->direct_reference =
+                    odr_oiddup (rr->stream, rr->esr->packageType);
+                ext->indirect_reference = 0;
+                ext->descriptor = 0;
+                ext->which = Z_External_update;
+                ext->u.update = (Z_IUUpdate *)
+                    odr_malloc (rr->stream, sizeof(*ext->u.update));
+                ext->u.update->which = Z_IUUpdate_taskPackage;
+                ext->u.update->u.taskPackage =  (Z_IUUpdateTaskPackage *)
+                    odr_malloc (rr->stream, sizeof(Z_IUUpdateTaskPackage));
+                ext->u.update->u.taskPackage->originPart = keep;
+                ext->u.update->u.taskPackage->targetPart = targetPart;
+
+                keep->action = (int *) odr_malloc (rr->stream, sizeof(int));
+                *keep->action = *toKeep->action;
+                keep->databaseName =
+                    odr_strdup (rr->stream, toKeep->databaseName);
+                keep->schema = 0;
+                keep->elementSetName = 0;
+                keep->actionQualifier = 0;
+
+                targetPart->updateStatus = odr_intdup (rr->stream, 1);
+                targetPart->num_globalDiagnostics = 0;
+                targetPart->globalDiagnostics = (Z_DiagRec **) odr_nullval();
+                targetPart->num_taskPackageRecords = 1;
+                targetPart->taskPackageRecords = 
                     (Z_IUTaskPackageRecordStructure **)
                     odr_malloc (rr->stream,
                                 sizeof(Z_IUTaskPackageRecordStructure *));
-               targetPart->taskPackageRecords[0] =
+                targetPart->taskPackageRecords[0] =
                     (Z_IUTaskPackageRecordStructure *)
                     odr_malloc (rr->stream,
                                 sizeof(Z_IUTaskPackageRecordStructure));
                 
-               targetPart->taskPackageRecords[0]->which =
+                targetPart->taskPackageRecords[0]->which =
                     Z_IUTaskPackageRecordStructure_record;
-               targetPart->taskPackageRecords[0]->u.record = 
+                targetPart->taskPackageRecords[0]->u.record = 
                     z_ext_record (rr->stream, VAL_SUTRS, "test", 4);
-               targetPart->taskPackageRecords[0]->correlationInfo = 0; 
-               targetPart->taskPackageRecords[0]->recordStatus =
+                targetPart->taskPackageRecords[0]->correlationInfo = 0; 
+                targetPart->taskPackageRecords[0]->recordStatus =
                     odr_intdup (rr->stream,
                                 Z_IUTaskPackageRecordStructure_success);  
-               targetPart->taskPackageRecords[0]->num_supplementalDiagnostics
+                targetPart->taskPackageRecords[0]->num_supplementalDiagnostics
                     = 0;
 
-               targetPart->taskPackageRecords[0]->supplementalDiagnostics = 0;
+                targetPart->taskPackageRecords[0]->supplementalDiagnostics = 0;
             }
-           if (notToKeep)
-           {
-               int i;
-               for (i = 0; i < notToKeep->num; i++)
-               {
-                   Z_External *rec = notToKeep->elements[i]->record;
-
-                   if (rec->direct_reference)
-                   {
-                       struct oident *oident;
-                       oident = oid_getentbyoid(rec->direct_reference);
-                       if (oident)
-                           yaz_log (log_level, "record %d type %s", i,
-                                    oident->desc);
-                   }
-                   switch (rec->which)
-                   {
-                   case Z_External_sutrs:
-                       if (rec->u.octet_aligned->len > 170)
-                           yaz_log (log_level, "%d bytes:\n%.168s ...",
-                                    rec->u.sutrs->len,
-                                    rec->u.sutrs->buf);
-                       else
-                           yaz_log (log_level, "%d bytes:\n%s",
-                                    rec->u.sutrs->len,
-                                    rec->u.sutrs->buf);
+            if (notToKeep)
+            {
+                int i;
+                for (i = 0; i < notToKeep->num; i++)
+                {
+                    Z_External *rec = notToKeep->elements[i]->record;
+
+                    if (rec->direct_reference)
+                    {
+                        struct oident *oident;
+                        oident = oid_getentbyoid(rec->direct_reference);
+                        if (oident)
+                            yaz_log (log_level, "record %d type %s", i,
+                                     oident->desc);
+                    }
+                    switch (rec->which)
+                    {
+                    case Z_External_sutrs:
+                        if (rec->u.octet_aligned->len > 170)
+                            yaz_log (log_level, "%d bytes:\n%.168s ...",
+                                     rec->u.sutrs->len,
+                                     rec->u.sutrs->buf);
+                        else
+                            yaz_log (log_level, "%d bytes:\n%s",
+                                     rec->u.sutrs->len,
+                                     rec->u.sutrs->buf);
                         break;
-                   case Z_External_octet        :
-                       if (rec->u.octet_aligned->len > 170)
-                           yaz_log (log_level, "%d bytes:\n%.168s ...",
-                                    rec->u.octet_aligned->len,
-                                    rec->u.octet_aligned->buf);
-                       else
-                           yaz_log (log_level, "%d bytes\n%s",
-                                    rec->u.octet_aligned->len,
-                                    rec->u.octet_aligned->buf);
-                   }
-               }
-           }
-       }
+                    case Z_External_octet        :
+                        if (rec->u.octet_aligned->len > 170)
+                            yaz_log (log_level, "%d bytes:\n%.168s ...",
+                                     rec->u.octet_aligned->len,
+                                     rec->u.octet_aligned->buf);
+                        else
+                            yaz_log (log_level, "%d bytes\n%s",
+                                     rec->u.octet_aligned->len,
+                                     rec->u.octet_aligned->buf);
+                    }
+                }
+            }
+        }
     }
     else if (rr->esr->taskSpecificParameters->which == Z_External_update0)
     {
-       yaz_log(log_level, "Received DB Update (version 0)");
+        yaz_log(log_level, "Received DB Update (version 0)");
     }
     else
     {
         yaz_log (YLOG_WARN, "Unknown Extended Service(%d)",
-                rr->esr->taskSpecificParameters->which);
-       
+                 rr->esr->taskSpecificParameters->which);
+        
     }
     return 0;
 }
@@ -415,7 +415,7 @@ int ztest_esrequest (void *handle, bend_esrequest_rr *rr)
 int ztest_delete (void *handle, bend_delete_rr *rr)
 {
     if (rr->num_setnames == 1 && !strcmp (rr->setnames[0], "1"))
-       rr->delete_status = Z_DeleteStatus_success;
+        rr->delete_status = Z_DeleteStatus_success;
     else
         rr->delete_status = Z_DeleteStatus_resultSetDidNotExist;
     return 0;
@@ -447,23 +447,23 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
     if (r->request_format == VAL_SUTRS)
     {
         /* this section returns a small record */
-       char buf[100];
+        char buf[100];
         
-       sprintf(buf, "This is dummy SUTRS record number %d\n", r->number);
+        sprintf(buf, "This is dummy SUTRS record number %d\n", r->number);
 
-       r->len = strlen(buf);
-       r->record = (char *) odr_malloc (r->stream, r->len+1);
-       strcpy(r->record, buf);
+        r->len = strlen(buf);
+        r->record = (char *) odr_malloc (r->stream, r->len+1);
+        strcpy(r->record, buf);
     }
     else if (r->request_format == VAL_GRS1)
     {
-       r->len = -1;
-       r->record = (char*) dummy_grs_record(r->number, r->stream);
-       if (!r->record)
-       {
-           r->errcode = 13;
-           return 0;
-       }
+        r->len = -1;
+        r->record = (char*) dummy_grs_record(r->number, r->stream);
+        if (!r->record)
+        {
+            r->errcode = 13;
+            return 0;
+        }
     }
     else if (r->request_format == VAL_POSTSCRIPT)
     {
@@ -474,7 +474,7 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
         sprintf (fname, "part.%d.ps", r->number);
         f = fopen(fname, "rb");
         if (!f)
-       {
+        {
             r->errcode = 13;
             return 0;
         }
@@ -494,29 +494,29 @@ int ztest_fetch(void *handle, bend_fetch_rr *r)
     }
     else if (r->request_format == VAL_TEXT_XML)
     {
-       if ((cp = dummy_xml_record (r->number, r->stream)))
-       {
-           r->len = strlen(cp);
-           r->record = cp;
-           r->output_format = VAL_TEXT_XML;
-       }
-       else 
-       {
-           r->errcode = 14;
-           r->surrogate_flag = 1;
-           return 0;
-       }
+        if ((cp = dummy_xml_record (r->number, r->stream)))
+        {
+            r->len = strlen(cp);
+            r->record = cp;
+            r->output_format = VAL_TEXT_XML;
+        }
+        else 
+        {
+            r->errcode = 14;
+            r->surrogate_flag = 1;
+            return 0;
+        }
     }
     else if ((cp = dummy_marc_record(r->number, r->stream)))
     {
-       r->len = strlen(cp);
-       r->record = cp;
-       r->output_format = VAL_USMARC;
+        r->len = strlen(cp);
+        r->record = cp;
+        r->output_format = VAL_USMARC;
     }
     else
     {
-       r->errcode = 13;
-       return 0;
+        r->errcode = 13;
+        return 0;
     }
     r->errcode = 0;
     return 0;
@@ -549,91 +549,91 @@ int ztest_scan(void *handle, bend_scan_rr *q)
     q->status = BEND_SCAN_SUCCESS;
     if (!f && !(f = fopen("dummy-words", "r")))
     {
-       perror("dummy-words");
-       exit(1);
+        perror("dummy-words");
+        exit(1);
     }
     if (q->num_entries > 200)
     {
-       q->errcode = 31;
-       return 0;
+        q->errcode = 31;
+        return 0;
     }
     if (q->term)
     {
-       int len;
-       if (q->term->term->which != Z_Term_general)
-       {
-           q->errcode = 229; /* unsupported term type */
-           return 0;
-       }
-       if (*q->step_size != 0)
-       {
-           q->errcode = 205; /*Only zero step size supported for Scan */
-           return 0;
-       }
-       len = q->term->term->u.general->len;
-       if (len >= sizeof(term))
-           len = sizeof(term)-1;
-       memcpy(term, q->term->term->u.general->buf, len);
-       term[len] = '\0';
+        int len;
+        if (q->term->term->which != Z_Term_general)
+        {
+            q->errcode = 229; /* unsupported term type */
+            return 0;
+        }
+        if (*q->step_size != 0)
+        {
+            q->errcode = 205; /*Only zero step size supported for Scan */
+            return 0;
+        }
+        len = q->term->term->u.general->len;
+        if (len >= sizeof(term))
+            len = sizeof(term)-1;
+        memcpy(term, q->term->term->u.general->buf, len);
+        term[len] = '\0';
     }
     else if (q->scanClause)
     {
-       strncpy(term, q->scanClause, sizeof(term)-1);
-       term[sizeof(term)-1] = '\0';
+        strncpy(term, q->scanClause, sizeof(term)-1);
+        term[sizeof(term)-1] = '\0';
     }
     else
-       strcpy(term, "0");
+        strcpy(term, "0");
 
     for (p = term; *p; p++)
-       if (islower(*(unsigned char *) p))
-           *p = toupper(*p);
+        if (islower(*(unsigned char *) p))
+            *p = toupper(*p);
 
     fseek(f, 0, SEEK_SET);
     q->num_entries = 0;
 
     for (i = 0, pos = 0; fscanf(f, " %79[^:]:%d", entries[pos], &hits[pos]) == 2;
-       i++, pos < 199 ? pos++ : (pos = 0))
+        i++, pos < 199 ? pos++ : (pos = 0))
     {
-       if (!q->num_entries && strcmp(entries[pos], term) >= 0) /* s-point fnd */
-       {
-           if ((q->term_position = term_position_req) > i + 1)
-           {
-               q->term_position = i + 1;
-               q->status = BEND_SCAN_PARTIAL;
-           }
-           for (; q->num_entries < q->term_position; q->num_entries++)
-           {
-               int po;
-
-               po = pos - q->term_position + q->num_entries+1; /* find pos */
-               if (po < 0)
-                   po += 200;
-
-               if (!strcmp (term, "SD") && q->num_entries == 2)
-               {
-                   list[q->num_entries].term = entries[pos];
-                   list[q->num_entries].occurrences = -1;
-                   list[q->num_entries].errcode = 233;
-                   list[q->num_entries].errstring = "SD for Scan Term";
-               }
-               else
-               {
-                   list[q->num_entries].term = entries[po];
-                   list[q->num_entries].occurrences = hits[po];
-               }
-           }
-       }
-       else if (q->num_entries)
-       {
-           list[q->num_entries].term = entries[pos];
-           list[q->num_entries].occurrences = hits[pos];
-           q->num_entries++;
-       }
-       if (q->num_entries >= num_entries_req)
-           break;
+        if (!q->num_entries && strcmp(entries[pos], term) >= 0) /* s-point fnd */
+        {
+            if ((q->term_position = term_position_req) > i + 1)
+            {
+                q->term_position = i + 1;
+                q->status = BEND_SCAN_PARTIAL;
+            }
+            for (; q->num_entries < q->term_position; q->num_entries++)
+            {
+                int po;
+
+                po = pos - q->term_position + q->num_entries+1; /* find pos */
+                if (po < 0)
+                    po += 200;
+
+                if (!strcmp (term, "SD") && q->num_entries == 2)
+                {
+                    list[q->num_entries].term = entries[pos];
+                    list[q->num_entries].occurrences = -1;
+                    list[q->num_entries].errcode = 233;
+                    list[q->num_entries].errstring = "SD for Scan Term";
+                }
+                else
+                {
+                    list[q->num_entries].term = entries[po];
+                    list[q->num_entries].occurrences = hits[po];
+                }
+            }
+        }
+        else if (q->num_entries)
+        {
+            list[q->num_entries].term = entries[pos];
+            list[q->num_entries].occurrences = hits[pos];
+            q->num_entries++;
+        }
+        if (q->num_entries >= num_entries_req)
+            break;
     }
     if (feof(f))
-       q->status = BEND_SCAN_PARTIAL;
+        q->status = BEND_SCAN_PARTIAL;
     return 0;
 }
 
@@ -641,12 +641,12 @@ static int ztest_explain(void *handle, bend_explain_rr *rr)
 {
     if (rr->database && !strcmp(rr->database, "Default"))
     {
-       rr->explain_buf = "<explain>\n"
-           "\t<serverInfo>\n"
-           "\t\t<host>localhost</host>\n"
-           "\t\t<port>210</port>\n"
-           "\t</serverInfo>\n"
-           "</explain>\n";
+        rr->explain_buf = "<explain>\n"
+            "\t<serverInfo>\n"
+            "\t\t<host>localhost</host>\n"
+            "\t\t<port>210</port>\n"
+            "\t</serverInfo>\n"
+            "</explain>\n";
     }
     return 0;
 }
@@ -692,3 +692,11 @@ int main(int argc, char **argv)
 {
     return statserv_main(argc, argv, bend_init, bend_close);
 }
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+