Reformatting
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 31 Mar 2011 12:34:44 +0000 (14:34 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 31 Mar 2011 12:35:02 +0000 (14:35 +0200)
src/marcdisp.c
src/spipe.c
src/srw.c
src/zoom-c.c
src/zoom-z3950.c

index 667f671..00d1ed8 100644 (file)
@@ -245,15 +245,17 @@ void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag,
     mt->subfield_pp = &n->u.datafield.subfields;
 }
 
-// Magic function: adds a attribute value to the element name if it is plain characters.
-// if not, and if the attribute name is not null, it will append a attribute element with the value
-// if attribute name is null it will return a non-zero value meaning it couldnt handle the value.
-
+/** \brief adds a attribute value to the element name if it is plain chars
+    
+    If not, and if the attribute name is not null, it will append a
+    attribute element with the value if attribute name is null it will
+    return a non-zero value meaning it couldnt handle the value.
+*/
 static int element_name_append_attribute_value(
     yaz_marc_t mt, WRBUF buffer,
     const char *attribute_name, char *code_data, size_t code_len)
 {
-    // TODO Map special codes to something possible for XML ELEMENT names
+    /* TODO Map special codes to something possible for XML ELEMENT names */
 
     int encode = 0;
     int index = 0;
@@ -265,7 +267,7 @@ static int element_name_append_attribute_value(
               (code_data[index] >= 'A' && code_data[index] <= 'Z')))
             encode = 1;
     }
-    // Add as attribute
+    /* Add as attribute */
     if (encode && attribute_name)
         wrbuf_printf(buffer, " %s=\"", attribute_name);
 
@@ -275,7 +277,7 @@ static int element_name_append_attribute_value(
         success = -1;
 
     if (encode && attribute_name)
-        wrbuf_printf(buffer, "\"");    // return error if we couldn't handle it.
+        wrbuf_printf(buffer, "\""); /* return error if we couldn't handle it.*/
     return success;
 }
 
@@ -302,7 +304,7 @@ void yaz_marc_add_datafield_xml2(yaz_marc_t mt, char *tag_value, char *indicator
     n->u.datafield.indicator = indicators;
     n->u.datafield.subfields = 0;
 
-    // make subfield_pp the current (last one)
+    /* make subfield_pp the current (last one) */
     mt->subfield_pp = &n->u.datafield.subfields;
 }
 
@@ -720,7 +722,7 @@ static int yaz_marc_write_marcxml_wrbuf(yaz_marc_t mt, WRBUF wr,
                 wrbuf_puts(wr, ">\n");
             }
             wrbuf_printf(wr, "  </%s", datafield_name[turbo]);
-            //TODO Not CDATA
+            /* TODO Not CDATA */
             if (turbo)
                wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.datafield.tag,
                                         strlen(n->u.datafield.tag));
@@ -737,7 +739,7 @@ static int yaz_marc_write_marcxml_wrbuf(yaz_marc_t mt, WRBUF wr,
             }
             else
             {
-                //TODO convert special
+                /* TODO convert special */
                 wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.controlfield.tag,
                                        strlen(n->u.controlfield.tag));
                 wrbuf_iconv_puts(wr, mt->iconv_cd, ">");
@@ -747,7 +749,7 @@ static int yaz_marc_write_marcxml_wrbuf(yaz_marc_t mt, WRBUF wr,
                                     strlen(n->u.controlfield.data));
             marc_iconv_reset(mt, wr);
             wrbuf_printf(wr, "</%s", controlfield_name[turbo]);
-            //TODO convert special
+            /* TODO convert special */
             if (turbo)
                 wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.controlfield.tag,
                                        strlen(n->u.controlfield.tag));
@@ -850,7 +852,7 @@ void add_marc_datafield_turbo_xml(yaz_marc_t mt, struct yaz_marc_node *n,
     struct yaz_marc_subfield *s;
     WRBUF subfield_name = wrbuf_alloc();
 
-    //TODO consider if safe
+    /* TODO consider if safe */
     char field[10];
     field[0] = 'd';
     strncpy(field + 1, n->u.datafield.tag, 3);
@@ -889,7 +891,7 @@ void add_marc_datafield_turbo_xml(yaz_marc_t mt, struct yaz_marc_node *n,
                                        BAD_CAST wrbuf_cstr(wr_cdata));
         if (not_written)
         {
-            // Generate code attribute value and add
+            /* Generate code attribute value and add */
             wrbuf_rewind(wr_cdata);
             wrbuf_iconv_write(wr_cdata, mt->iconv_cd,s->code_data, using_code_len);
             xmlNewProp(ptr_subfield, BAD_CAST "code",  BAD_CAST wrbuf_cstr(wr_cdata));
index a2ee268..2a3bf14 100644 (file)
@@ -125,7 +125,7 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
 #endif
         fd_set write_set;
 
-        // create server socket
+        /* create server socket */
         p->m_socket = socket(AF_INET, SOCK_STREAM, 0);
         if (p->m_socket == YAZ_INVALID_SOCKET)
         {
@@ -147,7 +147,7 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
             }
         }
 #endif
-        // bind server socket
+        /* bind server socket */
         add.sin_family = AF_INET;
         add.sin_port = htons(port_to_use);
         add.sin_addr.s_addr = INADDR_ANY;
@@ -169,7 +169,7 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
             return 0;
         }
 
-        // client socket
+        /* client socket */
         tmpadd = (unsigned) inet_addr("127.0.0.1");
         if (!tmpadd)
         {
@@ -194,9 +194,9 @@ yaz_spipe_t yaz_spipe_create(int port_to_use, WRBUF *err_msg)
         {
             if (
 #ifdef WIN32
-            WSAGetLastError() != WSAEWOULDBLOCK
+                WSAGetLastError() != WSAEWOULDBLOCK
 #else
-            errno != EINPROGRESS
+                errno != EINPROGRESS
 #endif
                 )
             {
index bd3c577..dfd3aad 100644 (file)
--- a/src/srw.c
+++ b/src/srw.c
@@ -398,7 +398,7 @@ static int yaz_srw_version(ODR o, xmlNodePtr pptr, Z_SRW_recordVersion *rec,
         }
     }
     else if (o->direction == ODR_ENCODE)
-        {
+    {
         xmlNodePtr ptr = pptr;
         add_xsd_string(ptr, "versionType", rec->versionType);
         add_xsd_string(ptr, "versionValue", rec->versionValue);
@@ -438,7 +438,7 @@ static int yaz_srw_versions(ODR o, xmlNodePtr pptr,
     {
         int i;
         for (i = 0; i < *num; i++)
-            {
+        {
             xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "version",
                                           0);
             yaz_srw_version(o, rptr, (*vers)+i, client_data, ns);
@@ -447,8 +447,8 @@ static int yaz_srw_versions(ODR o, xmlNodePtr pptr,
     return 0;
 }
 
-Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node) {
-
+Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node)
+{
     int freq;
     xmlNodePtr child;
     WRBUF wrbuf = wrbuf_alloc();
@@ -461,7 +461,7 @@ Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node) {
 
     for (child = node->children; child ; child = child->next) {
         if (child->type == XML_TEXT_NODE)
-        wrbuf_puts(wrbuf, (const char *) child->content);
+            wrbuf_puts(wrbuf, (const char *) child->content);
     }
     term = term_create(odr, wrbuf_cstr(wrbuf));
     yaz_log(YLOG_DEBUG, "sru-proxy facet: %s %d", wrbuf_cstr(wrbuf), freq);
@@ -469,13 +469,14 @@ Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node) {
     return facet_term_create(odr, term, freq);
 };
 
-static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr) {
+static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr)
+{
     Z_AttributeList *list;
     Z_FacetField *facet_field;
     int num_terms = 0;
     int index = 0;
     xmlNodePtr node;
-    // USE attribute
+    /* USE attribute */
     const char* name = yaz_element_attribute_value_get(ptr, "facet", "code");
     yaz_log(YLOG_DEBUG, "sru-proxy facet type: %s", name);
 
@@ -486,16 +487,19 @@ static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr) {
     }
     facet_field = facet_field_create(odr, list, num_terms);
     index = 0;
-    for (node = ptr->children; node; node = node->next) {
-        if (match_element(node, "facetvalue")) {
+    for (node = ptr->children; node; node = node->next)
+    {
+        if (match_element(node, "facetvalue"))
+        {
             facet_field_term_set(odr, facet_field, yaz_sru_proxy_get_facet_term_count(odr, node), index);
-        index++;
+            index++;
         }
     }
     return facet_field;
 }
 
-static int yaz_sru_proxy_decode_facets(ODR o, xmlNodePtr root, Z_FacetList **facetList)
+static int yaz_sru_proxy_decode_facets(ODR o, xmlNodePtr root,
+                                       Z_FacetList **facetList)
 {
     xmlNodePtr ptr;
 
@@ -538,19 +542,19 @@ static int yaz_srw_decode_diagnostics(ODR o, xmlNodePtr pptr,
     *num = 0;
     for (ptr = pptr; ptr; ptr = ptr->next)
     {
-            if (ptr->type == XML_ELEMENT_NODE &&
-                !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
-                (*num)++;
+        if (ptr->type == XML_ELEMENT_NODE &&
+            !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
+            (*num)++;
     }
     if (!*num)
         return 1;
     *recs = (Z_SRW_diagnostic *) odr_malloc(o, *num * sizeof(**recs));
     for (i = 0; i < *num; i++)
-        {
-            (*recs)[i].uri = 0;
-            (*recs)[i].details = 0;
-            (*recs)[i].message = 0;
-        } 
+    {
+        (*recs)[i].uri = 0;
+        (*recs)[i].details = 0;
+        (*recs)[i].message = 0;
+    } 
     for (i = 0, ptr = pptr; ptr; ptr = ptr->next)
     {
         if (ptr->type == XML_ELEMENT_NODE &&
@@ -659,7 +663,7 @@ static int yaz_srw_term(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm *term,
             if (match_xsd_string(ptr, "value", o,  &term->value))
                 ;
             else if (match_xsd_integer(ptr, "numberOfRecords", o, 
-                                   &term->numberOfRecords))
+                                       &term->numberOfRecords))
                 ;
             else if (match_xsd_string(ptr, "displayTerm", o, 
                                       &term->displayTerm))
@@ -763,13 +767,13 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                      &(*p)->srw_version))
                     ;
                 else if (match_xsd_string(ptr, "query", o, 
-                                     &req->query.cql))
+                                          &req->query.cql))
                     req->query_type = Z_SRW_query_type_cql;
                 else if (match_xsd_string(ptr, "pQuery", o, 
-                                     &req->query.pqf))
+                                          &req->query.pqf))
                     req->query_type = Z_SRW_query_type_pqf;
                 else if (match_xsd_string(ptr, "xQuery", o, 
-                                     &req->query.xcql))
+                                          &req->query.xcql))
                     req->query_type = Z_SRW_query_type_xcql;
                 else if (match_xsd_integer(ptr, "startRecord", o,
                                            &req->startRecord))
@@ -793,10 +797,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                           &req->sort.sortKeys))
                     req->sort_type = Z_SRW_sort_type_sort;
                 else if (match_xsd_string(ptr, "stylesheet", o,
-                                           &req->stylesheet))
+                                          &req->stylesheet))
                     ;
                 else if (match_xsd_string(ptr, "database", o,
-                                           &req->database))
+                                          &req->database))
                     ;
             }
             if (!req->query.cql && !req->query.pqf && !req->query.xcql)
@@ -834,7 +838,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                          &(*p)->extraResponseData_len))
                     ;
                 else if (match_xsd_integer(ptr, "numberOfRecords", o, 
-                                      &res->numberOfRecords))
+                                           &res->numberOfRecords))
                     ;
                 else if (match_xsd_string(ptr, "resultSetId", o, 
                                           &res->resultSetId))
@@ -871,7 +875,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_XML_n(ptr, "extraResponseData", o, 
                                          &(*p)->extraResponseData_buf,
@@ -881,10 +885,10 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                           &req->stylesheet))
                     ;
                 else if (match_xsd_string(ptr, "recordPacking", o,
-                                     &req->recordPacking))
+                                          &req->recordPacking))
                     ;
                 else if (match_xsd_string(ptr, "database", o,
-                                     &req->database))
+                                          &req->database))
                     ;
             }
         }
@@ -906,7 +910,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_XML_n(ptr, "extraResponseData", o, 
                                          &(*p)->extraResponseData_buf,
@@ -947,7 +951,7 @@ int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                          &(*p)->extraResponseData_len))
                     ;
                 else if (match_xsd_string(ptr, "scanClause", o,
-                                     &req->scanClause.cql))
+                                          &req->scanClause.cql))
                     ;
                 else if (match_xsd_string(ptr, "pScanClause", o,
                                           &req->scanClause.pqf))
@@ -1246,10 +1250,10 @@ int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                    client_data, ns_ucp_str);
                 }
                 else if (match_xsd_string(ptr, "stylesheet", o,
-                                           &req->stylesheet))
+                                          &req->stylesheet))
                     ;
                 else if (match_xsd_string(ptr, "database", o,
-                                           &req->database))
+                                          &req->database))
                     ;
             }
         }
@@ -1279,7 +1283,7 @@ int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
                                      &(*p)->srw_version))
                     ;
                 else if (match_xsd_string(ptr, "operationStatus", o, 
-                                      &res->operationStatus ))
+                                          &res->operationStatus ))
                     ;
                 else if (match_xsd_string(ptr, "recordIdentifier", o, 
                                           &res->recordId))
index c3aa0ed..c9a8676 100644 (file)
@@ -557,7 +557,7 @@ ZOOM_API(void)
         cs_close(c->cs);
 
 #if ZOOM_RESULT_LISTS
-    // Remove the connection's usage of resultsets
+    /* Remove the connection's usage of resultsets */
     list = c->resultsets;
     while (list) {
         ZOOM_resultsets removed = list;
index a8cf99b..9db6319 100644 (file)
@@ -991,63 +991,60 @@ static void response_diag(ZOOM_connection c, Z_DiagRec *p)
 }
 
 static int es_response_taskpackage_update(ZOOM_connection c,
-               Z_IUUpdateTaskPackage *utp)
+                                          Z_IUUpdateTaskPackage *utp)
 {
-       if (utp && utp->targetPart)
-       {
-               Z_IUTargetPart *targetPart = utp->targetPart;
-               switch ( *targetPart->updateStatus ) {
-                       case Z_IUTargetPart_success:
-                               ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "success");
-                               break;
-                       case Z_IUTargetPart_partial:
-                               ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "partial");
-                               break;
-                       case Z_IUTargetPart_failure:
-                               ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "failure");
-                               if (targetPart->globalDiagnostics && targetPart->num_globalDiagnostics > 0)
-                                       response_diag(c, targetPart->globalDiagnostics[0]);
-                               break;
-               }
-               // NOTE: Individual record status, surrogate diagnostics, and supplemental diagnostics ARE NOT REPORTED.
-       }
+    if (utp && utp->targetPart)
+    {
+        Z_IUTargetPart *targetPart = utp->targetPart;
+        switch ( *targetPart->updateStatus ) {
+        case Z_IUTargetPart_success:
+            ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "success");
+            break;
+        case Z_IUTargetPart_partial:
+            ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "partial");
+            break;
+        case Z_IUTargetPart_failure:
+            ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "failure");
+            if (targetPart->globalDiagnostics && targetPart->num_globalDiagnostics > 0)
+                response_diag(c, targetPart->globalDiagnostics[0]);
+            break;
+        }
+        /* NOTE: Individual record status, surrogate diagnostics, and supplemental diagnostics ARE NOT REPORTED. */
+    }
     return 1;
 }
 
 static int es_response_taskpackage(ZOOM_connection c,
                                    Z_TaskPackage *taskPackage)
 {
-       // targetReference
-       Odr_oct *id = taskPackage->targetReference;
-       if (id)
-               ZOOM_options_setl(c->tasks->u.package->options,
-                                                       "targetReference", (char*) id->buf, id->len);
-       
-       // taskStatus
-       switch ( *taskPackage->taskStatus ) {
-               case Z_TaskPackage_pending:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
-                       break;
-               case Z_TaskPackage_active:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "active");
-                       break;
-               case Z_TaskPackage_complete:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "complete");
-                       break;
-               case Z_TaskPackage_aborted:
-                       ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "aborted");
-                       if ( taskPackage->num_packageDiagnostics && taskPackage->packageDiagnostics )
-                               response_diag(c, taskPackage->packageDiagnostics[0]);
-                       break;
-       }
-       
-       // taskSpecificParameters
-       // NOTE: Only Update implemented, no others.
-       if ( taskPackage->taskSpecificParameters->which == Z_External_update ) {
-                       Z_IUUpdateTaskPackage *utp = taskPackage->taskSpecificParameters->u.update->u.taskPackage;
-                       es_response_taskpackage_update(c, utp);
-       }
-       return 1;
+    Odr_oct *id = taskPackage->targetReference;
+    if (id)
+        ZOOM_options_setl(c->tasks->u.package->options,
+                          "targetReference", (char*) id->buf, id->len);
+    
+    switch ( *taskPackage->taskStatus ) {
+    case Z_TaskPackage_pending:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
+        break;
+    case Z_TaskPackage_active:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "active");
+        break;
+    case Z_TaskPackage_complete:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "complete");
+        break;
+    case Z_TaskPackage_aborted:
+        ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "aborted");
+        if ( taskPackage->num_packageDiagnostics && taskPackage->packageDiagnostics )
+            response_diag(c, taskPackage->packageDiagnostics[0]);
+        break;
+    }
+    /* NOTE: Only Update implemented, no others. */
+    if ( taskPackage->taskSpecificParameters->which == Z_External_update )
+    {
+        Z_IUUpdateTaskPackage *utp = taskPackage->taskSpecificParameters->u.update->u.taskPackage;
+        es_response_taskpackage_update(c, utp);
+    }
+    return 1;
 }
 
 
@@ -1056,18 +1053,19 @@ static int handle_Z3950_es_response(ZOOM_connection c,
 {
     if (!c->tasks || c->tasks->which != ZOOM_TASK_PACKAGE)
         return 0;
-    switch (*res->operationStatus) {
-        case Z_ExtendedServicesResponse_done:
-            ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "done");
-            break;
-        case Z_ExtendedServicesResponse_accepted:
-            ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "accepted");
-            break;
-        case Z_ExtendedServicesResponse_failure:
-            ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "failure");
-            if (res->diagnostics && res->num_diagnostics > 0)
-                response_diag(c, res->diagnostics[0]);
-            break;
+    switch (*res->operationStatus)
+    {
+    case Z_ExtendedServicesResponse_done:
+        ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "done");
+        break;
+    case Z_ExtendedServicesResponse_accepted:
+        ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "accepted");
+        break;
+    case Z_ExtendedServicesResponse_failure:
+        ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "failure");
+        if (res->diagnostics && res->num_diagnostics > 0)
+            response_diag(c, res->diagnostics[0]);
+        break;
     }
     if (res->taskPackage &&
         res->taskPackage->which == Z_External_extendedService)