64-bit BER integers. Fixes bug #114.
[yaz-moved-to-github.git] / src / srw.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2009 Index Data
3  * See the file LICENSE for details.
4  */
5 /**
6  * \file srw.c
7  * \brief Implements SRW/SRU package encoding and decoding
8  */
9
10 #include <yaz/srw.h>
11 #if YAZ_HAVE_XML2
12 #include <libxml/parser.h>
13 #include <libxml/tree.h>
14 #include <assert.h>
15
16 static void add_XML_n(xmlNodePtr ptr, const char *elem, char *val, int len,
17                       xmlNsPtr ns_ptr)
18 {
19     if (val)
20     {
21         xmlDocPtr doc = xmlParseMemory(val,len);
22         if (doc)
23         {
24             xmlNodePtr c = xmlNewChild(ptr, ns_ptr, BAD_CAST elem, 0);
25             xmlNodePtr t = xmlDocGetRootElement(doc);
26             xmlAddChild(c, xmlCopyNode(t,1));
27             xmlFreeDoc(doc);
28         }
29     }
30 }
31
32 xmlNodePtr add_xsd_string_n(xmlNodePtr ptr, const char *elem, const char *val,
33                             int len)
34 {
35     if (val)
36     {
37         xmlNodePtr c = xmlNewChild(ptr, 0, BAD_CAST elem, 0);
38         xmlNodePtr t = xmlNewTextLen(BAD_CAST val, len);
39         xmlAddChild(c, t);
40         return t;
41     }
42     return 0;
43 }
44
45 xmlNodePtr add_xsd_string_ns(xmlNodePtr ptr, const char *elem, const char *val,
46                              xmlNsPtr ns_ptr)
47 {
48     if (val)
49     {
50         xmlNodePtr c = xmlNewChild(ptr, ns_ptr, BAD_CAST elem, 0);
51         xmlNodePtr t = xmlNewText(BAD_CAST val);
52         xmlAddChild(c, t);
53         return t;
54     }
55     return 0;
56 }
57
58 xmlNodePtr add_xsd_string(xmlNodePtr ptr, const char *elem, const char *val)
59 {
60     return add_xsd_string_ns(ptr, elem, val, 0);
61 }
62
63 static void add_xsd_integer(xmlNodePtr ptr, const char *elem,
64                             const odr_int_t *val)
65 {
66     if (val)
67     {
68         char str[40];
69         sprintf(str, ODR_INT_PRINTF, *val);
70         xmlNewTextChild(ptr, 0, BAD_CAST elem, BAD_CAST str);
71     }
72 }
73
74 static int match_element(xmlNodePtr ptr, const char *elem)
75 {
76     if (ptr->type == XML_ELEMENT_NODE && !xmlStrcmp(ptr->name, BAD_CAST elem))
77     {
78         return 1;
79     }
80     return 0;
81 }
82
83 #define CHECK_TYPE 0
84
85 static int match_xsd_string_n(xmlNodePtr ptr, const char *elem, ODR o,
86                               char **val, int *len)
87 {
88 #if CHECK_TYPE
89     struct _xmlAttr *attr;
90 #endif
91     if (!match_element(ptr, elem))
92         return 0;
93 #if CHECK_TYPE
94     for (attr = ptr->properties; attr; attr = attr->next)
95         if (!strcmp(attr->name, "type") &&
96             attr->children && attr->children->type == XML_TEXT_NODE)
97         {
98             const char *t = strchr(attr->children->content, ':');
99             if (t)
100                 t = t + 1;
101             else
102                 t = attr->children->content;
103             if (!strcmp(t, "string"))
104                 break;
105         }
106     if (!attr)
107         return 0;
108 #endif
109     ptr = ptr->children;
110     if (!ptr || ptr->type != XML_TEXT_NODE)
111     {
112         *val = "";
113         return 1;
114     }
115     *val = odr_strdup(o, (const char *) ptr->content);
116     if (len)
117         *len = xmlStrlen(ptr->content);
118     return 1;
119 }
120
121
122 static int match_xsd_string(xmlNodePtr ptr, const char *elem, ODR o,
123                             char **val)
124 {
125     return match_xsd_string_n(ptr, elem, o, val, 0);
126 }
127
128 static int match_xsd_XML_n(xmlNodePtr ptr, const char *elem, ODR o,
129                            char **val, int *len)
130 {
131     xmlBufferPtr buf;
132
133     if (!match_element(ptr, elem))
134         return 0;
135
136     buf = xmlBufferCreate();
137
138     /* Copy each element nodes at top.
139        In most cases there is only one root node.. At least one server
140        http://www.theeuropeanlibrary.org/sru/sru.pl
141        has multiple root nodes in recordData.
142     */
143     for (ptr = ptr->children; ptr; ptr = ptr->next)
144     {
145         if (ptr->type == XML_ELEMENT_NODE)
146         {
147             /* copy node to get NS right (bug #740). */
148             xmlNode *tmp = xmlCopyNode(ptr, 1);
149             
150             xmlNodeDump(buf, tmp->doc, tmp, 0, 0);
151             
152             xmlFreeNode(tmp);
153         }
154     }
155     
156     *val = (char *) odr_malloc(o, buf->use+1);
157     memcpy (*val, buf->content, buf->use);
158     (*val)[buf->use] = '\0';
159
160     if (len)
161         *len = buf->use;
162
163     xmlBufferFree(buf);
164
165     return 1;
166 }
167                      
168 static int match_xsd_integer(xmlNodePtr ptr, const char *elem, ODR o,
169                              odr_int_t **val)
170 {
171 #if CHECK_TYPE
172     struct _xmlAttr *attr;
173 #endif
174     if (!match_element(ptr, elem))
175         return 0;
176 #if CHECK_TYPE
177     for (attr = ptr->properties; attr; attr = attr->next)
178         if (!strcmp(attr->name, "type") &&
179             attr->children && attr->children->type == XML_TEXT_NODE)
180         {
181             const char *t = strchr(attr->children->content, ':');
182             if (t)
183                 t = t + 1;
184             else
185                 t = attr->children->content;
186             if (!strcmp(t, "integer"))
187                 break;
188         }
189     if (!attr)
190         return 0;
191 #endif
192     ptr = ptr->children;
193     if (!ptr || ptr->type != XML_TEXT_NODE)
194         return 0;
195     *val = odr_intdup(o, atoi((const char *) ptr->content));
196     return 1;
197 }
198
199 char *yaz_negotiate_sru_version(char *input_ver)
200 {
201     if (!input_ver)
202         input_ver = "1.1";
203
204     if (!strcmp(input_ver, "1.1"))
205         return "1.1";
206     return  "1.2"; /* our latest supported version */
207 }
208
209 static int yaz_srw_record(ODR o, xmlNodePtr pptr, Z_SRW_record *rec,
210                           Z_SRW_extra_record **extra,
211                           void *client_data, const char *ns)
212 {
213     if (o->direction == ODR_DECODE)
214     {
215         Z_SRW_extra_record ex;
216
217         char *spack = 0;
218         int pack = Z_SRW_recordPacking_string;
219         xmlNodePtr ptr;
220         xmlNodePtr data_ptr = 0;
221         rec->recordSchema = 0;
222         rec->recordData_buf = 0;
223         rec->recordData_len = 0;
224         rec->recordPosition = 0;
225         *extra = 0;
226
227         ex.extraRecordData_buf = 0;
228         ex.extraRecordData_len = 0;
229         ex.recordIdentifier = 0;
230
231         for (ptr = pptr->children; ptr; ptr = ptr->next)
232         {
233             
234             if (match_xsd_string(ptr, "recordSchema", o, 
235                                  &rec->recordSchema))
236                 ;
237             else if (match_xsd_string(ptr, "recordPacking", o, &spack))
238             {
239                 if (spack)
240                     pack = yaz_srw_str_to_pack(spack);
241             }
242             else if (match_xsd_integer(ptr, "recordPosition", o, 
243                                        &rec->recordPosition))
244                 ;
245             else if (match_element(ptr, "recordData"))
246             {
247                 /* save position of Data until after the loop
248                    then we will know the packing (hopefully), and
249                    unpacking is done once
250                 */
251                 data_ptr = ptr;
252             }
253             else if (match_xsd_XML_n(ptr, "extraRecordData", o, 
254                                      &ex.extraRecordData_buf,
255                                      &ex.extraRecordData_len) )
256                 ;
257             else if (match_xsd_string(ptr, "recordIdentifier", o, 
258                                       &ex.recordIdentifier))
259                 ;
260
261         }
262         if (data_ptr)
263         {
264             switch(pack)
265             {
266             case Z_SRW_recordPacking_XML:
267                 match_xsd_XML_n(data_ptr, "recordData", o, 
268                                 &rec->recordData_buf, &rec->recordData_len);
269                 break;
270             case Z_SRW_recordPacking_URL:
271                 /* just store it as a string.
272                    leave it to the backend to collect the document */
273                 match_xsd_string_n(data_ptr, "recordData", o, 
274                                    &rec->recordData_buf, &rec->recordData_len);
275                 break;
276             case Z_SRW_recordPacking_string:
277                 match_xsd_string_n(data_ptr, "recordData", o, 
278                                    &rec->recordData_buf, &rec->recordData_len);
279                 break;
280             }
281         }
282         rec->recordPacking = pack;
283         if (ex.extraRecordData_buf || ex.recordIdentifier)
284         {
285             *extra = (Z_SRW_extra_record *)
286                 odr_malloc(o, sizeof(Z_SRW_extra_record));
287             memcpy(*extra, &ex, sizeof(Z_SRW_extra_record));
288         }
289     }
290     else if (o->direction == ODR_ENCODE)
291     {
292         xmlNodePtr ptr = pptr;
293         int pack = rec->recordPacking;
294         const char *spack = yaz_srw_pack_to_str(pack);
295
296         add_xsd_string(ptr, "recordSchema", rec->recordSchema);
297         if (spack)
298             add_xsd_string(ptr, "recordPacking", spack);
299         switch(pack)
300         {
301         case Z_SRW_recordPacking_string:
302             add_xsd_string_n(ptr, "recordData", rec->recordData_buf,
303                              rec->recordData_len);
304             break;
305         case Z_SRW_recordPacking_XML:
306             add_XML_n(ptr, "recordData", rec->recordData_buf,
307                       rec->recordData_len, 0);
308             break;
309         case Z_SRW_recordPacking_URL:
310             add_xsd_string_n(ptr, "recordData", rec->recordData_buf,
311                              rec->recordData_len);
312             break;
313         }
314         if (rec->recordPosition)
315             add_xsd_integer(ptr, "recordPosition", rec->recordPosition );
316         if (extra && *extra)
317         {
318             if ((*extra)->recordIdentifier)
319                 add_xsd_string(ptr, "recordIdentifier",
320                                (*extra)->recordIdentifier);
321             if ((*extra)->extraRecordData_buf)
322                 add_XML_n(ptr, "extraRecordData",
323                           (*extra)->extraRecordData_buf,
324                           (*extra)->extraRecordData_len, 0);
325         }
326     }
327     return 0;
328 }
329
330 static int yaz_srw_records(ODR o, xmlNodePtr pptr, Z_SRW_record **recs,
331                            Z_SRW_extra_record ***extra,
332                            int *num, void *client_data, const char *ns)
333 {
334     if (o->direction == ODR_DECODE)
335     {
336         int i;
337         xmlNodePtr ptr;
338         *num = 0;
339         for (ptr = pptr->children; ptr; ptr = ptr->next)
340         {
341             if (ptr->type == XML_ELEMENT_NODE &&
342                 !xmlStrcmp(ptr->name, BAD_CAST "record"))
343                 (*num)++;
344         }
345         if (!*num)
346             return 1;
347         *recs = (Z_SRW_record *) odr_malloc(o, *num * sizeof(**recs));
348         *extra = (Z_SRW_extra_record **) odr_malloc(o, *num * sizeof(**extra));
349         for (i = 0, ptr = pptr->children; ptr; ptr = ptr->next)
350         {
351             if (ptr->type == XML_ELEMENT_NODE &&
352                 !xmlStrcmp(ptr->name, BAD_CAST "record"))
353             {
354                 yaz_srw_record(o, ptr, *recs + i, *extra + i, client_data, ns);
355                 i++;
356             }
357         }
358     }
359     else if (o->direction == ODR_ENCODE)
360     {
361         int i;
362         for (i = 0; i < *num; i++)
363         {
364             xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "record",
365                                           0);
366             yaz_srw_record(o, rptr, (*recs)+i, (*extra ? *extra + i : 0),
367                            client_data, ns);
368         }
369     }
370     return 0;
371 }
372
373 static int yaz_srw_version(ODR o, xmlNodePtr pptr, Z_SRW_recordVersion *rec,
374                            void *client_data, const char *ns)
375 {
376     if (o->direction == ODR_DECODE)
377     {
378         xmlNodePtr ptr;
379         rec->versionType = 0;
380         rec->versionValue = 0;
381         for (ptr = pptr->children; ptr; ptr = ptr->next)
382         {
383             
384             if (match_xsd_string(ptr, "versionType", o, 
385                                  &rec->versionType))
386                 ;
387             else if (match_xsd_string(ptr, "versionValue", o, 
388                                       &rec->versionValue))
389                 ;
390         }
391     }
392     else if (o->direction == ODR_ENCODE)
393         {
394         xmlNodePtr ptr = pptr;
395         add_xsd_string(ptr, "versionType", rec->versionType);
396         add_xsd_string(ptr, "versionValue", rec->versionValue);
397     }
398     return 0;
399 }
400
401 static int yaz_srw_versions(ODR o, xmlNodePtr pptr, 
402                             Z_SRW_recordVersion **vers,
403                             int *num, void *client_data, const char *ns)
404 {
405     if (o->direction == ODR_DECODE)
406     {
407         int i;
408         xmlNodePtr ptr;
409         *num = 0;
410         for (ptr = pptr->children; ptr; ptr = ptr->next)
411         {
412             if (ptr->type == XML_ELEMENT_NODE &&
413                 !xmlStrcmp(ptr->name, BAD_CAST "recordVersion"))
414                 (*num)++;
415         }
416         if (!*num)
417             return 1;
418         *vers = (Z_SRW_recordVersion *) odr_malloc(o, *num * sizeof(**vers));
419         for (i = 0, ptr = pptr->children; ptr; ptr = ptr->next)
420         {
421             if (ptr->type == XML_ELEMENT_NODE &&
422                 !xmlStrcmp(ptr->name, BAD_CAST "recordVersion"))
423             {
424                 yaz_srw_version(o, ptr, *vers + i, client_data, ns);
425                 i++;
426             }
427         }
428     }
429     else if (o->direction == ODR_ENCODE)
430     {
431         int i;
432         for (i = 0; i < *num; i++)
433             {
434             xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "version",
435                                           0);
436             yaz_srw_version(o, rptr, (*vers)+i, client_data, ns);
437         }
438     }
439     return 0;
440 }
441
442
443 static int yaz_srw_decode_diagnostics(ODR o, xmlNodePtr pptr,
444                                       Z_SRW_diagnostic **recs, int *num,
445                                       void *client_data, const char *ns)
446     
447 {
448     int i;
449     xmlNodePtr ptr;
450     *num = 0;
451     for (ptr = pptr; ptr; ptr = ptr->next)
452     {
453             if (ptr->type == XML_ELEMENT_NODE &&
454                 !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
455                 (*num)++;
456     }
457     if (!*num)
458         return 1;
459     *recs = (Z_SRW_diagnostic *) odr_malloc(o, *num * sizeof(**recs));
460     for (i = 0; i < *num; i++)
461         {
462             (*recs)[i].uri = 0;
463             (*recs)[i].details = 0;
464             (*recs)[i].message = 0;
465         } 
466     for (i = 0, ptr = pptr; ptr; ptr = ptr->next)
467     {
468         if (ptr->type == XML_ELEMENT_NODE &&
469             !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
470         {
471             xmlNodePtr rptr;
472             (*recs)[i].uri = 0;
473             (*recs)[i].details = 0;
474             (*recs)[i].message = 0;
475             for (rptr = ptr->children; rptr; rptr = rptr->next)
476             {
477                 if (match_xsd_string(rptr, "uri", o, 
478                                      &(*recs)[i].uri))
479                     ;
480                 else if (match_xsd_string(rptr, "details", o, 
481                                           &(*recs)[i].details))
482                     ;
483                 else if (match_xsd_string(rptr, "message", o, 
484                                           &(*recs)[i].message))
485                     ;
486             }
487             i++;
488         }
489     }
490     return 0;
491 }
492
493 int sru_decode_surrogate_diagnostics(const char *buf, size_t len,
494                                      Z_SRW_diagnostic **diag,
495                                      int *num, ODR odr)
496 {
497     int ret = 0;
498     xmlDocPtr doc = xmlParseMemory(buf, len);
499     if (doc)
500     {
501         xmlNodePtr ptr = xmlDocGetRootElement(doc);
502         while (ptr && ptr->type != XML_ELEMENT_NODE)
503             ptr = ptr->next;
504         if (ptr && ptr->ns 
505             && !xmlStrcmp(ptr->ns->href,
506                           BAD_CAST "http://www.loc.gov/zing/srw/diagnostic/"))
507         {
508             ret = yaz_srw_decode_diagnostics(odr, ptr, diag, num, 0, 0);
509         }
510         xmlFreeDoc(doc);
511     }
512     return ret;
513 }
514
515 static int yaz_srw_diagnostics(ODR o, xmlNodePtr pptr, Z_SRW_diagnostic **recs,
516                                int *num, void *client_data, const char *ns)
517 {
518     if (o->direction == ODR_DECODE)
519     {
520         return yaz_srw_decode_diagnostics(o, pptr->children, recs, num, client_data, ns);
521     }
522     else if (o->direction == ODR_ENCODE)
523     {
524         int i;
525         xmlNsPtr ns_diag =
526             xmlNewNs(pptr, BAD_CAST YAZ_XMLNS_DIAG_v1_1, BAD_CAST "diag" );
527         for (i = 0; i < *num; i++)
528         {
529             const char *std_diag = "info:srw/diagnostic/1/";
530             const char *ucp_diag = "info:srw/diagnostic/12/";
531             xmlNodePtr rptr = xmlNewChild(pptr, ns_diag,
532                                           BAD_CAST "diagnostic", 0);
533             add_xsd_string(rptr, "uri", (*recs)[i].uri);
534             if ((*recs)[i].message)
535                 add_xsd_string(rptr, "message", (*recs)[i].message);
536             else if ((*recs)[i].uri )
537             {
538                 if (!strncmp((*recs)[i].uri, std_diag, strlen(std_diag)))
539                 {
540                     int no = atoi((*recs)[i].uri + strlen(std_diag));
541                     const char *message = yaz_diag_srw_str(no);
542                     if (message)
543                         add_xsd_string(rptr, "message", message);
544                 }
545                 else if (!strncmp((*recs)[i].uri, ucp_diag, strlen(ucp_diag)))
546                 {
547                     int no = atoi((*recs)[i].uri + strlen(ucp_diag));
548                     const char *message = yaz_diag_sru_update_str(no);
549                     if (message)
550                         add_xsd_string(rptr, "message", message);
551                 }
552             }
553             add_xsd_string(rptr, "details", (*recs)[i].details);
554         }
555     }
556     return 0;
557 }
558
559 static int yaz_srw_term(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm *term,
560                         void *client_data, const char *ns)
561 {
562     if (o->direction == ODR_DECODE)
563     {
564         xmlNodePtr ptr;
565         term->value = 0;
566         term->numberOfRecords = 0;
567         term->displayTerm = 0;
568         term->whereInList = 0;
569         for (ptr = pptr->children; ptr; ptr = ptr->next)
570         {
571             if (match_xsd_string(ptr, "value", o,  &term->value))
572                 ;
573             else if (match_xsd_integer(ptr, "numberOfRecords", o, 
574                                    &term->numberOfRecords))
575                 ;
576             else if (match_xsd_string(ptr, "displayTerm", o, 
577                                       &term->displayTerm))
578                 ;
579             else if (match_xsd_string(ptr, "whereInList", o, 
580                                       &term->whereInList))
581                 ;
582         }
583     }
584     else if (o->direction == ODR_ENCODE)
585     {
586         xmlNodePtr ptr = pptr;
587         add_xsd_string(ptr, "value", term->value);
588         add_xsd_integer(ptr, "numberOfRecords", term->numberOfRecords);
589         add_xsd_string(ptr, "displayTerm", term->displayTerm);
590         add_xsd_string(ptr, "whereInList", term->whereInList);
591     }
592     return 0;
593 }
594
595 static int yaz_srw_terms(ODR o, xmlNodePtr pptr, Z_SRW_scanTerm **terms,
596                          int *num, void *client_data, const char *ns)
597 {
598     if (o->direction == ODR_DECODE)
599     {
600         int i;
601         xmlNodePtr ptr;
602         *num = 0;
603         for (ptr = pptr->children; ptr; ptr = ptr->next)
604         {
605             if (ptr->type == XML_ELEMENT_NODE &&
606                 !xmlStrcmp(ptr->name, BAD_CAST "term"))
607                 (*num)++;
608         }
609         if (!*num)
610             return 1;
611         *terms = (Z_SRW_scanTerm *) odr_malloc(o, *num * sizeof(**terms));
612         for (i = 0, ptr = pptr->children; ptr; ptr = ptr->next, i++)
613         {
614             if (ptr->type == XML_ELEMENT_NODE &&
615                 !xmlStrcmp(ptr->name, BAD_CAST "term"))
616                 yaz_srw_term(o, ptr, (*terms)+i, client_data, ns);
617         }
618     }
619     else if (o->direction == ODR_ENCODE)
620     {
621         int i;
622         for (i = 0; i < *num; i++)
623         {
624             xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "term", 0);
625             yaz_srw_term(o, rptr, (*terms)+i, client_data, ns);
626         }
627     }
628     return 0;
629 }
630
631 int yaz_srw_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
632                   void *client_data, const char *ns)
633 {
634     xmlNodePtr pptr = (xmlNodePtr) vptr;
635     if (o->direction == ODR_DECODE)
636     {
637         Z_SRW_PDU **p = handler_data;
638         xmlNodePtr method = pptr->children;
639         char *neg_version;
640
641         while (method && method->type == XML_TEXT_NODE)
642             method = method->next;
643         
644         if (!method)
645             return -1;
646         if (method->type != XML_ELEMENT_NODE)
647             return -1;
648
649         *p = yaz_srw_get_core_v_1_1(o);
650         
651         if (!xmlStrcmp(method->name, BAD_CAST "searchRetrieveRequest"))
652         {
653             xmlNodePtr ptr = method->children;
654             Z_SRW_searchRetrieveRequest *req;
655
656             (*p)->which = Z_SRW_searchRetrieve_request;
657             req = (*p)->u.request = (Z_SRW_searchRetrieveRequest *)
658                 odr_malloc(o, sizeof(*req));
659             req->query_type = Z_SRW_query_type_cql;
660             req->query.cql = 0;
661             req->sort_type = Z_SRW_sort_type_none;
662             req->sort.none = 0;
663             req->startRecord = 0;
664             req->maximumRecords = 0;
665             req->recordSchema = 0;
666             req->recordPacking = 0;
667             req->recordXPath = 0;
668             req->resultSetTTL = 0;
669             req->stylesheet = 0;
670             req->database = 0;
671
672             for (; ptr; ptr = ptr->next)
673             {
674                 if (match_xsd_string(ptr, "version", o,
675                                      &(*p)->srw_version))
676                     ;
677                 else if (match_xsd_string(ptr, "query", o, 
678                                      &req->query.cql))
679                     req->query_type = Z_SRW_query_type_cql;
680                 else if (match_xsd_string(ptr, "pQuery", o, 
681                                      &req->query.pqf))
682                     req->query_type = Z_SRW_query_type_pqf;
683                 else if (match_xsd_string(ptr, "xQuery", o, 
684                                      &req->query.xcql))
685                     req->query_type = Z_SRW_query_type_xcql;
686                 else if (match_xsd_integer(ptr, "startRecord", o,
687                                            &req->startRecord))
688                     ;
689                 else if (match_xsd_integer(ptr, "maximumRecords", o,
690                                            &req->maximumRecords))
691                     ;
692                 else if (match_xsd_string(ptr, "recordPacking", o,
693                                           &req->recordPacking))
694                     ;
695                 else if (match_xsd_string(ptr, "recordSchema", o, 
696                                           &req->recordSchema))
697                     ;
698                 else if (match_xsd_string(ptr, "recordXPath", o,
699                                           &req->recordXPath))
700                     ;
701                 else if (match_xsd_integer(ptr, "resultSetTTL", o,
702                                            &req->resultSetTTL))
703                     ;
704                 else if (match_xsd_string(ptr, "sortKeys", o, 
705                                           &req->sort.sortKeys))
706                     req->sort_type = Z_SRW_sort_type_sort;
707                 else if (match_xsd_string(ptr, "stylesheet", o,
708                                            &req->stylesheet))
709                     ;
710                 else if (match_xsd_string(ptr, "database", o,
711                                            &req->database))
712                     ;
713             }
714             if (!req->query.cql && !req->query.pqf && !req->query.xcql)
715             {
716                 /* should put proper diagnostic here */
717                 return -1;
718             }
719         }
720         else if (!xmlStrcmp(method->name, BAD_CAST "searchRetrieveResponse"))
721         {
722             xmlNodePtr ptr = method->children;
723             Z_SRW_searchRetrieveResponse *res;
724
725             (*p)->which = Z_SRW_searchRetrieve_response;
726             res = (*p)->u.response = (Z_SRW_searchRetrieveResponse *)
727                 odr_malloc(o, sizeof(*res));
728
729             res->numberOfRecords = 0;
730             res->resultSetId = 0;
731             res->resultSetIdleTime = 0;
732             res->records = 0;
733             res->num_records = 0;
734             res->diagnostics = 0;
735             res->num_diagnostics = 0;
736             res->nextRecordPosition = 0;
737
738             for (; ptr; ptr = ptr->next)
739             {
740                 if (match_xsd_string(ptr, "version", o,
741                                      &(*p)->srw_version))
742                     ;
743                 else if (match_xsd_integer(ptr, "numberOfRecords", o, 
744                                       &res->numberOfRecords))
745                     ;
746                 else if (match_xsd_string(ptr, "resultSetId", o, 
747                                           &res->resultSetId))
748                     ;
749                 else if (match_xsd_integer(ptr, "resultSetIdleTime", o, 
750                                            &res->resultSetIdleTime))
751                     ;
752                 else if (match_element(ptr, "records"))
753                     yaz_srw_records(o, ptr, &res->records,
754                                     &res->extra_records,
755                                     &res->num_records, client_data, ns);
756                 else if (match_xsd_integer(ptr, "nextRecordPosition", o,
757                                            &res->nextRecordPosition))
758                     ;
759                 else if (match_element(ptr, "diagnostics"))
760                     yaz_srw_diagnostics(o, ptr, &res->diagnostics,
761                                         &res->num_diagnostics,
762                                         client_data, ns);
763             }
764         }
765         else if (!xmlStrcmp(method->name, BAD_CAST "explainRequest"))
766         {
767             Z_SRW_explainRequest *req;
768             xmlNodePtr ptr = method->children;
769             
770             (*p)->which = Z_SRW_explain_request;
771             req = (*p)->u.explain_request = (Z_SRW_explainRequest *)
772                 odr_malloc(o, sizeof(*req));
773             req->recordPacking = 0;
774             req->database = 0;
775             req->stylesheet = 0;
776             for (; ptr; ptr = ptr->next)
777             {
778                 if (match_xsd_string(ptr, "version", o,
779                                            &(*p)->srw_version))
780                     ;
781                 else if (match_xsd_string(ptr, "stylesheet", o,
782                                           &req->stylesheet))
783                     ;
784                 else if (match_xsd_string(ptr, "recordPacking", o,
785                                      &req->recordPacking))
786                     ;
787                 else if (match_xsd_string(ptr, "database", o,
788                                      &req->database))
789                     ;
790             }
791         }
792         else if (!xmlStrcmp(method->name, BAD_CAST "explainResponse"))
793         {
794             Z_SRW_explainResponse *res;
795             xmlNodePtr ptr = method->children;
796
797             (*p)->which = Z_SRW_explain_response;
798             res = (*p)->u.explain_response = (Z_SRW_explainResponse*)
799                 odr_malloc(o, sizeof(*res));
800             res->diagnostics = 0;
801             res->num_diagnostics = 0;
802             res->record.recordSchema = 0;
803             res->record.recordData_buf = 0;
804             res->record.recordData_len = 0;
805             res->record.recordPosition = 0;
806
807             for (; ptr; ptr = ptr->next)
808             {
809                 if (match_xsd_string(ptr, "version", o,
810                                            &(*p)->srw_version))
811                     ;
812                 else if (match_element(ptr, "record"))
813                     yaz_srw_record(o, ptr, &res->record, &res->extra_record,
814                                    client_data, ns);
815                 else if (match_element(ptr, "diagnostics"))
816                     yaz_srw_diagnostics(o, ptr, &res->diagnostics,
817                                         &res->num_diagnostics,
818                                         client_data, ns);
819                 ;
820             }
821         }
822         else if (!xmlStrcmp(method->name, BAD_CAST "scanRequest"))
823         {
824             Z_SRW_scanRequest *req;
825             xmlNodePtr ptr = method->children;
826
827             (*p)->which = Z_SRW_scan_request;
828             req = (*p)->u.scan_request = (Z_SRW_scanRequest *)
829                 odr_malloc(o, sizeof(*req));
830             req->query_type = Z_SRW_query_type_cql;
831             req->scanClause.cql = 0;
832             req->responsePosition = 0;
833             req->maximumTerms = 0;
834             req->stylesheet = 0;
835             req->database = 0;
836             
837             for (; ptr; ptr = ptr->next)
838             {
839                 if (match_xsd_string(ptr, "version", o,
840                                      &(*p)->srw_version))
841                     ;
842                 else if (match_xsd_string(ptr, "scanClause", o,
843                                      &req->scanClause.cql))
844                     ;
845                 else if (match_xsd_string(ptr, "pScanClause", o,
846                                           &req->scanClause.pqf))
847                 {
848                     req->query_type = Z_SRW_query_type_pqf;
849                 }
850                 else if (match_xsd_integer(ptr, "responsePosition", o,
851                                            &req->responsePosition))
852                     ;
853                 else if (match_xsd_integer(ptr, "maximumTerms", o,
854                                            &req->maximumTerms))
855                     ;
856                 else if (match_xsd_string(ptr, "stylesheet", o,
857                                           &req->stylesheet))
858                     ;
859                 else if (match_xsd_string(ptr, "database", o,
860                                           &req->database))
861                     ;
862             }
863         }
864         else if (!xmlStrcmp(method->name, BAD_CAST "scanResponse"))
865         {
866             Z_SRW_scanResponse *res;
867             xmlNodePtr ptr = method->children;
868
869             (*p)->which = Z_SRW_scan_response;
870             res = (*p)->u.scan_response = (Z_SRW_scanResponse *)
871                 odr_malloc(o, sizeof(*res));
872             res->terms = 0;
873             res->num_terms = 0;
874             res->diagnostics = 0;
875             res->num_diagnostics = 0;
876             
877             for (; ptr; ptr = ptr->next)
878             {
879                 if (match_xsd_string(ptr, "version", o,
880                                      &(*p)->srw_version))
881                     ;
882                 else if (match_element(ptr, "terms"))
883                     yaz_srw_terms(o, ptr, &res->terms,
884                                   &res->num_terms, client_data,
885                                   ns);
886                 else if (match_element(ptr, "diagnostics"))
887                     yaz_srw_diagnostics(o, ptr, &res->diagnostics,
888                                         &res->num_diagnostics,
889                                         client_data, ns);
890             }
891         }
892         else
893         {
894             *p = 0;
895             return -1;
896         }
897         neg_version = yaz_negotiate_sru_version((*p)->srw_version);
898         if (neg_version)
899             (*p)->srw_version = neg_version;
900     }
901     else if (o->direction == ODR_ENCODE)
902     {
903         Z_SRW_PDU **p = handler_data;
904         xmlNsPtr ns_srw;
905         
906         if ((*p)->which == Z_SRW_searchRetrieve_request)
907         {
908             Z_SRW_searchRetrieveRequest *req = (*p)->u.request;
909             xmlNodePtr ptr = xmlNewChild(pptr, 0,
910                                          BAD_CAST "searchRetrieveRequest", 0);
911             ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
912             xmlSetNs(ptr, ns_srw);
913
914             if ((*p)->srw_version)
915                 add_xsd_string(ptr, "version", (*p)->srw_version);
916             switch(req->query_type)
917             {
918             case Z_SRW_query_type_cql:
919                 add_xsd_string(ptr, "query", req->query.cql);
920                 break;
921             case Z_SRW_query_type_xcql:
922                 add_xsd_string(ptr, "xQuery", req->query.xcql);
923                 break;
924             case Z_SRW_query_type_pqf:
925                 add_xsd_string(ptr, "pQuery", req->query.pqf);
926                 break;
927             }
928             add_xsd_integer(ptr, "startRecord", req->startRecord);
929             add_xsd_integer(ptr, "maximumRecords", req->maximumRecords);
930             add_xsd_string(ptr, "recordPacking", req->recordPacking);
931             add_xsd_string(ptr, "recordSchema", req->recordSchema);
932             add_xsd_string(ptr, "recordXPath", req->recordXPath);
933             add_xsd_integer(ptr, "resultSetTTL", req->resultSetTTL);
934             switch(req->sort_type)
935             {
936             case Z_SRW_sort_type_none:
937                 break;
938             case Z_SRW_sort_type_sort:
939                 add_xsd_string(ptr, "sortKeys", req->sort.sortKeys);
940                 break;
941             case Z_SRW_sort_type_xSort:
942                 add_xsd_string(ptr, "xSortKeys", req->sort.xSortKeys);
943                 break;
944             }
945             add_xsd_string(ptr, "stylesheet", req->stylesheet);
946             add_xsd_string(ptr, "database", req->database);
947         }
948         else if ((*p)->which == Z_SRW_searchRetrieve_response)
949         {
950             Z_SRW_searchRetrieveResponse *res = (*p)->u.response;
951             xmlNodePtr ptr = xmlNewChild(pptr, 0,
952                                          BAD_CAST "searchRetrieveResponse", 0);
953             ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
954             xmlSetNs(ptr, ns_srw);
955
956             if ((*p)->srw_version)
957                 add_xsd_string(ptr, "version", (*p)->srw_version);
958             add_xsd_integer(ptr, "numberOfRecords", res->numberOfRecords);
959             add_xsd_string(ptr, "resultSetId", res->resultSetId);
960             add_xsd_integer(ptr, "resultSetIdleTime", res->resultSetIdleTime);
961             if (res->num_records)
962             {
963                 xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "records", 0);
964                 yaz_srw_records(o, rptr, &res->records, &res->extra_records,
965                                 &res->num_records,
966                                 client_data, ns);
967             }
968             add_xsd_integer(ptr, "nextRecordPosition",
969                             res->nextRecordPosition);
970             if (res->num_diagnostics)
971             {
972                 xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "diagnostics",
973                                               0);
974                 yaz_srw_diagnostics(o, rptr, &res->diagnostics,
975                                     &res->num_diagnostics, client_data, ns);
976             }
977         }
978         else if ((*p)->which == Z_SRW_explain_request)
979         {
980             Z_SRW_explainRequest *req = (*p)->u.explain_request;
981             xmlNodePtr ptr = xmlNewChild(pptr, 0, BAD_CAST "explainRequest",
982                                          0);
983             ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
984             xmlSetNs(ptr, ns_srw);
985
986             add_xsd_string(ptr, "version", (*p)->srw_version);
987             add_xsd_string(ptr, "recordPacking", req->recordPacking);
988             add_xsd_string(ptr, "stylesheet", req->stylesheet);
989             add_xsd_string(ptr, "database", req->database);
990         }
991         else if ((*p)->which == Z_SRW_explain_response)
992         {
993             Z_SRW_explainResponse *res = (*p)->u.explain_response;
994             xmlNodePtr ptr = xmlNewChild(pptr, 0, BAD_CAST "explainResponse",
995                                          0);
996             ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
997             xmlSetNs(ptr, ns_srw);
998
999             add_xsd_string(ptr, "version", (*p)->srw_version);
1000             if (1)
1001             {
1002                 xmlNodePtr ptr1 = xmlNewChild(ptr, 0, BAD_CAST "record", 0);
1003                 yaz_srw_record(o, ptr1, &res->record, &res->extra_record,
1004                                client_data, ns);
1005             }
1006             if (res->num_diagnostics)
1007             {
1008                 xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "diagnostics",
1009                                               0);
1010                 yaz_srw_diagnostics(o, rptr, &res->diagnostics,
1011                                     &res->num_diagnostics, client_data, ns);
1012             }
1013         }
1014         else if ((*p)->which == Z_SRW_scan_request)
1015         {
1016             Z_SRW_scanRequest *req = (*p)->u.scan_request;
1017             xmlNodePtr ptr = xmlNewChild(pptr, 0, BAD_CAST "scanRequest", 0);
1018             ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
1019             xmlSetNs(ptr, ns_srw);
1020
1021             add_xsd_string(ptr, "version", (*p)->srw_version);
1022             switch(req->query_type)
1023             {
1024             case Z_SRW_query_type_cql:
1025                 add_xsd_string(ptr, "scanClause", req->scanClause.cql);
1026                 break;
1027             case Z_SRW_query_type_pqf:
1028                 add_xsd_string(ptr, "pScanClause", req->scanClause.pqf);
1029                 break;
1030             }
1031             add_xsd_integer(ptr, "responsePosition", req->responsePosition);
1032             add_xsd_integer(ptr, "maximumTerms", req->maximumTerms);
1033             add_xsd_string(ptr, "stylesheet", req->stylesheet);
1034             add_xsd_string(ptr, "database", req->database);
1035         }
1036         else if ((*p)->which == Z_SRW_scan_response)
1037         {
1038             Z_SRW_scanResponse *res = (*p)->u.scan_response;
1039             xmlNodePtr ptr = xmlNewChild(pptr, 0, BAD_CAST "scanResponse", 0);
1040             ns_srw = xmlNewNs(ptr, BAD_CAST ns, BAD_CAST "zs");
1041             xmlSetNs(ptr, ns_srw);
1042
1043             add_xsd_string(ptr, "version", (*p)->srw_version);
1044
1045             if (res->num_terms)
1046             {
1047                 xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "terms", 0);
1048                 yaz_srw_terms(o, rptr, &res->terms, &res->num_terms,
1049                               client_data, ns);
1050             }
1051             if (res->num_diagnostics)
1052             {
1053                 xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "diagnostics",
1054                                               0);
1055                 yaz_srw_diagnostics(o, rptr, &res->diagnostics,
1056                                     &res->num_diagnostics, client_data, ns);
1057             }
1058         }
1059         else
1060             return -1;
1061
1062     }
1063     return 0;
1064 }
1065
1066 int yaz_ucp_codec(ODR o, void * vptr, Z_SRW_PDU **handler_data,
1067                   void *client_data, const char *ns_ucp_str)
1068 {
1069     xmlNodePtr pptr = (xmlNodePtr) vptr;
1070     const char *ns_srw_str = YAZ_XMLNS_SRU_v1_1;
1071     if (o->direction == ODR_DECODE)
1072     {
1073         Z_SRW_PDU **p = handler_data;
1074         xmlNodePtr method = pptr->children;
1075
1076         while (method && method->type == XML_TEXT_NODE)
1077             method = method->next;
1078         
1079         if (!method)
1080             return -1;
1081         if (method->type != XML_ELEMENT_NODE)
1082             return -1;
1083
1084         *p = yaz_srw_get_core_v_1_1(o);
1085         
1086         if (!xmlStrcmp(method->name, BAD_CAST "updateRequest"))
1087         {
1088             xmlNodePtr ptr = method->children;
1089             Z_SRW_updateRequest *req;
1090             char *oper = 0;
1091
1092             (*p)->which = Z_SRW_update_request;
1093             req = (*p)->u.update_request = (Z_SRW_updateRequest *)
1094                 odr_malloc(o, sizeof(*req));
1095             req->database = 0;
1096             req->operation = 0;
1097             req->recordId = 0;
1098             req->recordVersions = 0;
1099             req->num_recordVersions = 0;
1100             req->record = 0;
1101             req->extra_record = 0;
1102             req->extraRequestData_buf = 0;
1103             req->extraRequestData_len = 0;
1104             req->stylesheet = 0;
1105
1106             for (; ptr; ptr = ptr->next)
1107             {
1108                 if (match_xsd_string(ptr, "version", o,
1109                                      &(*p)->srw_version))
1110                     ;
1111                 else if (match_xsd_string(ptr, "action", o, 
1112                                           &oper)){
1113                     if ( oper ){
1114                         if ( !strcmp(oper, "info:srw/action/1/delete"))
1115                             req->operation = "delete";
1116                         else if (!strcmp(oper,"info:srw/action/1/replace" ))
1117                             req->operation = "replace";
1118                         else if ( !strcmp( oper, "info:srw/action/1/create"))
1119                             req->operation = "insert";
1120                     }
1121                 }
1122                 else if (match_xsd_string(ptr, "recordIdentifier", o,
1123                                           &req->recordId))
1124                     ;
1125                 else if (match_element(ptr, "recordVersions" ) )
1126                     yaz_srw_versions( o, ptr, &req->recordVersions,
1127                                       &req->num_recordVersions, client_data,
1128                                       ns_ucp_str);
1129                 else if (match_element(ptr, "record"))
1130                 {
1131                     req->record = yaz_srw_get_record(o);
1132                     yaz_srw_record(o, ptr, req->record, &req->extra_record,
1133                                    client_data, ns_ucp_str);
1134                 }
1135                 else if (match_xsd_string(ptr, "stylesheet", o,
1136                                            &req->stylesheet))
1137                     ;
1138                 else if (match_xsd_string(ptr, "database", o,
1139                                            &req->database))
1140                     ;
1141             }
1142         }
1143         else if (!xmlStrcmp(method->name, BAD_CAST "updateResponse"))
1144         {
1145             xmlNodePtr ptr = method->children;
1146             Z_SRW_updateResponse *res;
1147
1148             (*p)->which = Z_SRW_update_response;
1149             res = (*p)->u.update_response = (Z_SRW_updateResponse *)
1150                 odr_malloc(o, sizeof(*res));
1151
1152             res->operationStatus = 0;
1153             res->recordId = 0;
1154             res->recordVersions = 0;
1155             res->num_recordVersions = 0;
1156             res->diagnostics = 0;
1157             res->num_diagnostics = 0;
1158             res->record = 0;
1159             res->extra_record = 0;
1160             res->extraResponseData_buf = 0;
1161             res->extraResponseData_len = 0;
1162
1163             for (; ptr; ptr = ptr->next)
1164             {
1165                 if (match_xsd_string(ptr, "version", o,
1166                                      &(*p)->srw_version))
1167                     ;
1168                 else if (match_xsd_string(ptr, "operationStatus", o, 
1169                                       &res->operationStatus ))
1170                     ;
1171                 else if (match_xsd_string(ptr, "recordIdentifier", o, 
1172                                           &res->recordId))
1173                     ;
1174                 else if (match_element(ptr, "recordVersions" )) 
1175                     yaz_srw_versions(o, ptr, &res->recordVersions,
1176                                      &res->num_recordVersions,
1177                                      client_data, ns_ucp_str);
1178                 else if (match_element(ptr, "record"))
1179                 {
1180                     res->record = yaz_srw_get_record(o);
1181                     yaz_srw_record(o, ptr, res->record, &res->extra_record,
1182                                    client_data, ns_ucp_str);
1183                 }
1184                 else if (match_element(ptr, "diagnostics"))
1185                     yaz_srw_diagnostics(o, ptr, &res->diagnostics,
1186                                         &res->num_diagnostics,
1187                                         client_data, ns_ucp_str);
1188             }
1189         }
1190         else if (!xmlStrcmp(method->name, BAD_CAST "explainUpdateRequest"))
1191         {
1192         }
1193         else if (!xmlStrcmp(method->name, BAD_CAST "explainUpdateResponse"))
1194         {
1195         }
1196         else
1197         {
1198             *p = 0;
1199             return -1;
1200         }
1201     }
1202     else if (o->direction == ODR_ENCODE)
1203     {
1204         Z_SRW_PDU **p = handler_data;
1205         xmlNsPtr ns_ucp, ns_srw;
1206
1207
1208         if ((*p)->which == Z_SRW_update_request)
1209         {
1210             Z_SRW_updateRequest *req = (*p)->u.update_request;
1211             xmlNodePtr ptr = xmlNewChild(pptr, 0, BAD_CAST "updateRequest", 0);
1212             ns_ucp = xmlNewNs(ptr, BAD_CAST ns_ucp_str, BAD_CAST "zu");
1213             xmlSetNs(ptr, ns_ucp);
1214             ns_srw = xmlNewNs(ptr, BAD_CAST ns_srw_str, BAD_CAST "zs");
1215
1216             add_xsd_string_ns(ptr, "version", (*p)->srw_version, ns_srw);
1217             add_xsd_string(ptr, "action", req->operation);
1218             add_xsd_string(ptr, "recordIdentifier", req->recordId );
1219             if (req->recordVersions)
1220                 yaz_srw_versions( o, ptr, &req->recordVersions,
1221                                   &req->num_recordVersions,
1222                                   client_data, ns_ucp_str);
1223             if (req->record && req->record->recordData_len)
1224             {
1225                 xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "record", 0);
1226                 xmlSetNs(rptr, ns_srw);
1227                 yaz_srw_record(o, rptr, req->record, &req->extra_record,
1228                                client_data, ns_ucp_str);
1229             }
1230             if (req->extraRequestData_len)
1231             {
1232                 add_XML_n(ptr, "extraRequestData", 
1233                           req->extraRequestData_buf, 
1234                           req->extraRequestData_len, ns_srw);
1235             }
1236             add_xsd_string(ptr, "stylesheet", req->stylesheet);
1237             add_xsd_string(ptr, "database", req->database);
1238         }
1239         else if ((*p)->which == Z_SRW_update_response)
1240         {
1241             Z_SRW_updateResponse *res = (*p)->u.update_response;
1242             xmlNodePtr ptr = xmlNewChild(pptr, 0, (xmlChar *) 
1243                                          "updateResponse", 0);
1244             ns_ucp = xmlNewNs(ptr, BAD_CAST ns_ucp_str, BAD_CAST "zu");
1245             xmlSetNs(ptr, ns_ucp);
1246             ns_srw = xmlNewNs(ptr, BAD_CAST ns_srw_str, BAD_CAST "zs");
1247             
1248             add_xsd_string_ns(ptr, "version", (*p)->srw_version, ns_srw);
1249             add_xsd_string(ptr, "operationStatus", res->operationStatus );
1250             add_xsd_string(ptr, "recordIdentifier", res->recordId );
1251             if (res->recordVersions)
1252                 yaz_srw_versions(o, ptr, &res->recordVersions,
1253                                  &res->num_recordVersions,
1254                                  client_data, ns_ucp_str);
1255             if (res->record && res->record->recordData_len)
1256             {
1257                 xmlNodePtr rptr = xmlNewChild(ptr, 0, BAD_CAST "record", 0);
1258                 xmlSetNs(rptr, ns_srw);
1259                 yaz_srw_record(o, rptr, res->record, &res->extra_record,
1260                                client_data, ns_ucp_str);
1261             }
1262             if (res->num_diagnostics)
1263             {
1264                 xmlNsPtr ns_diag =
1265                     xmlNewNs(pptr, BAD_CAST YAZ_XMLNS_DIAG_v1_1,
1266                              BAD_CAST "diag" );
1267                 
1268                 xmlNodePtr rptr = xmlNewChild(ptr, ns_diag, BAD_CAST "diagnostics", 0);
1269                 yaz_srw_diagnostics(o, rptr, &res->diagnostics,
1270                                     &res->num_diagnostics, client_data,
1271                                     ns_ucp_str);
1272             }
1273             if (res->extraResponseData_len)
1274                 add_XML_n(ptr, "extraResponseData", 
1275                           res->extraResponseData_buf, 
1276                           res->extraResponseData_len, ns_srw);
1277         }
1278         else
1279             return -1;
1280
1281     }
1282     return 0;
1283 }
1284
1285 #endif
1286
1287
1288 /*
1289  * Local variables:
1290  * c-basic-offset: 4
1291  * c-file-style: "Stroustrup"
1292  * indent-tabs-mode: nil
1293  * End:
1294  * vim: shiftwidth=4 tabstop=8 expandtab
1295  */
1296