Reformat. Add YAZ_END_CDECL
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 3 Aug 2010 11:21:19 +0000 (13:21 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 3 Aug 2010 11:21:19 +0000 (13:21 +0200)
include/yaz/facet.h
src/facet.c

index 56dd17a..3f21374 100644 (file)
@@ -41,7 +41,6 @@
 
 YAZ_BEGIN_CDECL
 
 
 YAZ_BEGIN_CDECL
 
-
 /*
  * Helper function for extracting facet values from the ASN structures.
  *
 /*
  * Helper function for extracting facet values from the ASN structures.
  *
@@ -67,19 +66,19 @@ void facet_struct_init(struct yaz_facet_attr *attr_values);
 
 /* Use attribute, @attr1, can be numeric or string */
 YAZ_EXPORT
 
 /* Use attribute, @attr1, can be numeric or string */
 YAZ_EXPORT
-void useattr ( Z_AttributeElement *ae, struct yaz_facet_attr *av );
+void useattr(Z_AttributeElement *ae, struct yaz_facet_attr *av);
 
 YAZ_EXPORT
 
 YAZ_EXPORT
-void relationattr ( Z_AttributeElement *ae, struct yaz_facet_attr *av );
+void relationattr(Z_AttributeElement *ae, struct yaz_facet_attr *av);
 
 YAZ_EXPORT
 
 YAZ_EXPORT
-void limitattr ( Z_AttributeElement *ae, struct yaz_facet_attr *av );
+void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av);
 
 YAZ_EXPORT
 
 YAZ_EXPORT
-void limitattr ( Z_AttributeElement *ae, struct yaz_facet_attr *av );
+void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av);
 
 YAZ_EXPORT
 
 YAZ_EXPORT
-void facetattrs( Z_AttributeList *attributes, struct yaz_facet_attr *av );
+void facetattrs(Z_AttributeList *attributes, struct yaz_facet_attr *av);
 
 YAZ_EXPORT
 Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input);
 
 YAZ_EXPORT
 Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input);
@@ -91,16 +90,21 @@ YAZ_EXPORT
 Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq);
 
 YAZ_EXPORT
 Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq);
 
 YAZ_EXPORT
-Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes, int num_terms);
+Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes,
+                                int num_terms);
 
 YAZ_EXPORT
 
 YAZ_EXPORT
-void facet_field_term_set(ODR odr, Z_FacetField *field, Z_FacetTerm *facetTerm, int index);
+void facet_field_term_set(ODR odr, Z_FacetField *field,
+                         Z_FacetTerm *facetTerm, int index);
 
 YAZ_EXPORT
 Z_FacetList* facet_list_create(ODR odr, int num_facets);
 
 YAZ_EXPORT
 
 YAZ_EXPORT
 Z_FacetList* facet_list_create(ODR odr, int num_facets);
 
 YAZ_EXPORT
-void facet_list_field_set(ODR odr, Z_FacetList *list, Z_FacetField *field, int index);
+void facet_list_field_set(ODR odr, Z_FacetList *list, Z_FacetField *field,
+                         int index);
+
+YAZ_END_CDECL
 
 #endif
 /*
 
 #endif
 /*
index bf1904b..82a8365 100644 (file)
@@ -23,7 +23,8 @@
 /* Gets the first string, there is usually only one */
 /* in case of errors, returns null */
 
 /* Gets the first string, there is usually only one */
 /* in case of errors, returns null */
 
-void facet_struct_init(struct yaz_facet_attr *attr_values) {
+void facet_struct_init(struct yaz_facet_attr *attr_values)
+{
     attr_values->errcode   = 0;
     attr_values->errstring = 0;
     attr_values->relation  = 0;
     attr_values->errcode   = 0;
     attr_values->errstring = 0;
     attr_values->relation  = 0;
@@ -32,54 +33,62 @@ void facet_struct_init(struct yaz_facet_attr *attr_values) {
     attr_values->limit     = 0;
 }
 
     attr_values->limit     = 0;
 }
 
-const char *stringattr( Z_ComplexAttribute *c ) {
+const char *stringattr(Z_ComplexAttribute *c)
+{
     int i;
      Z_StringOrNumeric *son;
     int i;
      Z_StringOrNumeric *son;
-    for ( i = 0; i < c->num_list; i++ ) {
+    for (i = 0; i < c->num_list; i++)
+    {
         son = c->list[i];
         son = c->list[i];
-        if ( son->which == Z_StringOrNumeric_string )
+        if ( son->which == Z_StringOrNumeric_string)
             return son->u.string;
     }
     return 0;
 }
 
 /* Use attribute, @attr1, can be numeric or string */
             return son->u.string;
     }
     return 0;
 }
 
 /* Use attribute, @attr1, can be numeric or string */
-void useattr ( Z_AttributeElement *ae,
-                       struct yaz_facet_attr *av )
+void useattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
 {
     const char *s;
 {
     const char *s;
-    if ( ae->which == Z_AttributeValue_complex ) {
-        s = stringattr( ae->value.complex );
+    if (ae->which == Z_AttributeValue_complex)
+    {
+        s = stringattr(ae->value.complex);
         yaz_log(YLOG_DEBUG, "useattr %s %s", s, av->useattr);
         yaz_log(YLOG_DEBUG, "useattr %s %s", s, av->useattr);
-        if (s) {
+        if (s)
+        {
             if (!av->useattr)
                 av->useattr = s;
             if (!av->useattr)
                 av->useattr = s;
-            else { /* already seen one, can't have duplicates */
+            else
+            { /* already seen one, can't have duplicates */
                 av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE_COMBI;
                 av->errstring = "multiple use attributes";
             }
                 av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE_COMBI;
                 av->errstring = "multiple use attributes";
             }
-        } else { /* complex that did not return a string */
+        }
+        else
+        { /* complex that did not return a string */
             av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE_COMBI;
             av->errstring = "non-string complex attribute";
         }
             av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE_COMBI;
             av->errstring = "non-string complex attribute";
         }
-    } else { /* numeric - could translate 4 to 'title' etc */
-        sprintf(av->useattrbuff, ODR_INT_PRINTF, *ae->value.numeric );
+    }
+    else
+    { /* numeric - could translate 4 to 'title' etc */
+        sprintf(av->useattrbuff, ODR_INT_PRINTF, *ae->value.numeric);
         av->useattr = av->useattrbuff;
     }
 } /* useattr */
 
 
 /* TODO rename to sortorder attr */
         av->useattr = av->useattrbuff;
     }
 } /* useattr */
 
 
 /* TODO rename to sortorder attr */
-void relationattr ( Z_AttributeElement *ae,
-                           struct yaz_facet_attr *av )
+void relationattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
 {
 {
-    if ( ae->which == Z_AttributeValue_numeric ) {
-        if ( *ae->value.numeric == 0 )
+    if (ae->which == Z_AttributeValue_numeric)
+    {
+        if (*ae->value.numeric == 0)
             av->relation = "desc";
             av->relation = "desc";
-        else if ( *ae->value.numeric == 1 )
+        else if (*ae->value.numeric == 1)
                 av->relation = "asc";
             else
                 av->relation = "asc";
             else
-        if ( *ae->value.numeric == 3 ) {
+        if (*ae->value.numeric == 3) {
             av->relation = "unknown/unordered";
         } else {
             av->errcode = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
             av->relation = "unknown/unordered";
         } else {
             av->errcode = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
@@ -87,20 +96,23 @@ void relationattr ( Z_AttributeElement *ae,
                         *ae-> attributeType);
             av->errstring = av->useattrbuff;
         }
                         *ae-> attributeType);
             av->errstring = av->useattrbuff;
         }
-    } else {
+    }
+    else
+    {
         av->errcode = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
         av->errstring = "non-numeric relation attribute";
     }
 } /* relationattr */
 
         av->errcode = YAZ_BIB1_UNSUPP_RELATION_ATTRIBUTE;
         av->errstring = "non-numeric relation attribute";
     }
 } /* relationattr */
 
-void limitattr ( Z_AttributeElement *ae,
-                        struct yaz_facet_attr *av )
+void limitattr(Z_AttributeElement *ae, struct yaz_facet_attr *av)
 {
 {
-  /* TODO - check numeric first, then value! */
-    if ( ae->which == Z_AttributeValue_numeric ) {
+    if (ae->which == Z_AttributeValue_numeric)
+    {
         av->limit = *ae->value.numeric;
         yaz_log(YLOG_DEBUG, "limitattr %d ", av->limit);
         av->limit = *ae->value.numeric;
         yaz_log(YLOG_DEBUG, "limitattr %d ", av->limit);
-    } else {
+    }
+    else
+    {
         av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE;
         av->errstring = "non-numeric limit attribute";
     }
         av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE;
         av->errstring = "non-numeric limit attribute";
     }
@@ -116,23 +128,30 @@ void limitattr ( Z_AttributeElement *ae,
    so no need to free that string!
 */
 
    so no need to free that string!
 */
 
-void facetattrs( Z_AttributeList *attributes,
-                          struct yaz_facet_attr *av )
+void facetattrs(Z_AttributeList *attributes, struct yaz_facet_attr *av)
 {
     int i;
     Z_AttributeElement *ae;
 {
     int i;
     Z_AttributeElement *ae;
-    yaz_log(YLOG_DEBUG, "Attribute num attributes: %d", attributes->num_attributes);
-    for ( i=0; i < attributes->num_attributes; i++ ) {
+    yaz_log(YLOG_DEBUG, "Attribute num attributes: %d",
+            attributes->num_attributes);
+    for (i=0; i < attributes->num_attributes; i++) {
         ae = attributes->attributes[i];
         /* ignoring the attributeSet here */
         yaz_log(YLOG_DEBUG, "Attribute type %d", (int) *ae->attributeType);
         ae = attributes->attributes[i];
         /* ignoring the attributeSet here */
         yaz_log(YLOG_DEBUG, "Attribute type %d", (int) *ae->attributeType);
-        if ( *ae->attributeType == 1 ) { /* use attribute */
+        if (*ae->attributeType == 1)
+        { /* use attribute */
             useattr(ae, av);
             useattr(ae, av);
-        } else if ( *ae->attributeType == 2 ) { /* sortorder */
+        }
+        else if (*ae->attributeType == 2)
+        { /* sortorder */
             relationattr(ae, av);
             relationattr(ae, av);
-        } else if ( *ae->attributeType == 3 ) { /* limit */
+        }
+        else if (*ae->attributeType == 3)
+        { /* limit */
             limitattr(ae, av);
             limitattr(ae, av);
-        } else { /* unknown attribute */
+        }
+        else
+        { /* unknown attribute */
             av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE_TYPE;
             sprintf(av->useattrbuff, ODR_INT_PRINTF,
                         *ae-> attributeType);
             av->errcode = YAZ_BIB1_UNSUPP_ATTRIBUTE_TYPE;
             sprintf(av->useattrbuff, ODR_INT_PRINTF,
                         *ae-> attributeType);
@@ -141,26 +160,31 @@ void facetattrs( Z_AttributeList *attributes,
             /* would like to give a better message, but the standard */
             /* tells me to return the attribute type */
         }
             /* would like to give a better message, but the standard */
             /* tells me to return the attribute type */
         }
-        if ( av->errcode )
+        if (av->errcode)
             return; /* no need to dig deeper, return on first error */
     }
     return;
 } /* facetattrs */
 
 
             return; /* no need to dig deeper, return on first error */
     }
     return;
 } /* facetattrs */
 
 
-Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input) {
-    Z_FacetList *facet_list = yaz_oi_get_facetlist_oid(&search_input, odr, yaz_oid_userinfo_facet_1, 1, 0);
+Z_FacetList *extract_facet_request(ODR odr, Z_OtherInformation *search_input)
+{
+    Z_FacetList *facet_list =
+        yaz_oi_get_facetlist_oid(&search_input, odr,
+                                 yaz_oid_userinfo_facet_1, 1, 0);
     return facet_list;
 }
 
     return facet_list;
 }
 
-Z_Term *term_create(ODR odr, const char *cstr) {
+Z_Term *term_create(ODR odr, const char *cstr)
+{
     Z_Term *term = odr_malloc(odr, sizeof(*term));
     term->which = Z_Term_characterString;
     term->u.characterString = odr_strdup(odr, cstr);
     return term;
 }
 
     Z_Term *term = odr_malloc(odr, sizeof(*term));
     term->which = Z_Term_characterString;
     term->u.characterString = odr_strdup(odr, cstr);
     return term;
 }
 
-Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq) {
+Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq)
+{
     Z_FacetTerm *facet_term = odr_malloc(odr, sizeof(*facet_term));
     facet_term->count = odr_malloc(odr, sizeof(*facet_term->count));
     facet_term->term = term;
     Z_FacetTerm *facet_term = odr_malloc(odr, sizeof(*facet_term));
     facet_term->count = odr_malloc(odr, sizeof(*facet_term->count));
     facet_term->term = term;
@@ -168,7 +192,9 @@ Z_FacetTerm* facet_term_create(ODR odr, Z_Term *term, int freq) {
     return facet_term;
 }
 
     return facet_term;
 }
 
-Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes, int num_terms) {
+Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes,
+                                 int num_terms)
+{
     Z_FacetField *facet_field = odr_malloc(odr, sizeof(*facet_field));
     facet_field->attributes = attributes;
     facet_field->num_terms = num_terms;
     Z_FacetField *facet_field = odr_malloc(odr, sizeof(*facet_field));
     facet_field->attributes = attributes;
     facet_field->num_terms = num_terms;
@@ -176,19 +202,25 @@ Z_FacetField* facet_field_create(ODR odr, Z_AttributeList *attributes, int num_t
     return facet_field;
 }
 
     return facet_field;
 }
 
-void facet_field_term_set(ODR odr, Z_FacetField *field, Z_FacetTerm *facet_term, int index) {
+void facet_field_term_set(ODR odr, Z_FacetField *field,
+                          Z_FacetTerm *facet_term, int index)
+{
     assert(0 <= index && index < field->num_terms);
     field->terms[index] = facet_term;
 }
 
     assert(0 <= index && index < field->num_terms);
     field->terms[index] = facet_term;
 }
 
-Z_FacetList* facet_list_create(ODR odr, int num_facets) {
+Z_FacetList* facet_list_create(ODR odr, int num_facets)
+{
     Z_FacetList *facet_list = odr_malloc(odr, sizeof(*facet_list));
     facet_list->num = num_facets;
     Z_FacetList *facet_list = odr_malloc(odr, sizeof(*facet_list));
     facet_list->num = num_facets;
-    facet_list->elements = odr_malloc(odr, facet_list->num * sizeof(*facet_list->elements));
+    facet_list->elements =
+        odr_malloc(odr, facet_list->num * sizeof(*facet_list->elements));
     return facet_list;
 }
 
     return facet_list;
 }
 
-void facet_list_field_set(ODR odr, Z_FacetList *list, Z_FacetField *field, int index) {
+void facet_list_field_set(ODR odr, Z_FacetList *list, Z_FacetField *field,
+                          int index)
+{
     assert(0 <= index && index < list->num);
     list->elements[index] = field;
 }
     assert(0 <= index && index < list->num);
     list->elements[index] = field;
 }