38 #include <sys/types.h>
46 #define S_ISREG(x) (x & _S_IFREG)
55 #include <libxml/parser.h>
56 #include <libxml/tree.h>
87 const char *errstring);
135 else if (v <= INT_MIN)
148 const char *apdufile)
167 if (apdufile && *apdufile)
173 if (*apdufile ==
'@')
177 else if (*apdufile !=
'-')
180 sprintf(filename,
"%.200s.%ld", apdufile, (
long)getpid());
181 if (!(f = fopen(filename,
"w")))
186 setvbuf(f, 0, _IONBF, 0);
242 reason, message ? message :
"none");
294 "Incoming package too large", req);
371 assert(h && conn && assoc);
523 const char *encoding =
"UTF-8";
547 strcat(auth->
u.
open,
"/");
584 const char *match_schema = 0;
593 const char *backend_schema = 0;
614 else if (r == 1 || r == 3)
616 const char *details = input_schema;
626 if (input_syntax_raw)
646 const char *details = 0;
661 if (r == 0 && match_syntax &&
672 rr->
record = (
char *) opac;
676 details =
"XML to OPAC conversion failed";
708 const char **addinfo,
int *last_in_set)
775 else if (rr.
len >= 0)
792 Z_Query *query_result,
char **sortkeys_p)
851 query_result->
u.
type_1 = rpnquery;
866 int srw_error =
cql2pqf(odr, cql, ct, &query, &sortkeys);
892 if ((node =
ccl_find_str(bibset, ccl0, &errcode, &pos)) == 0)
958 "1.2.840.10003.16.2");
983 code, pqf_msg, (
long) off);
1039 start, number, rr.
hits);
1050 if (start > rr.
hits || start < 1)
1059 else if (number > 0)
1063 if (start + number > rr.
hits)
1072 bprr->
start = start;
1077 sizeof(*bprr->
comp));
1120 number *
sizeof(*srw_res->
records));
1126 for (i = 0; i<number; i++)
1129 int last_in_set = 0;
1130 const char *addinfo = 0;
1138 &addinfo, &last_in_set);
1178 const char *querystr =
"?";
1179 const char *querytype =
"?";
1196 else if (*http_code != 200)
1220 for (ptr = ptr->children; ptr; ptr = ptr->next)
1222 if (ptr->type != XML_ELEMENT_NODE)
1224 if (!strcmp((
const char *) ptr->name,
"explain"))
1227 xmlDocPtr doc = xmlNewDoc(BAD_CAST
"1.0");
1231 ptr = xmlCopyNode(ptr, 1);
1233 xmlDocSetRootElement(doc, ptr);
1235 xmlDocDumpMemory(doc, &buf_out, &len);
1237 memcpy(content, buf_out, len);
1238 content[len] =
'\0';
1272 rr.
schema =
"http://explain.z3950.org/dtd/2.0/";
1437 if (save_entries == bsrr->
entries &&
1454 const char *querytype = 0;
1455 const char *querystr = 0;
1468 querytype =
"UNKNOWN";
1567 else if (!strcmp(rr.
operation,
"replace"))
1579 "recordIdentifier");
1617 else if (!strcmp(rr.
operation,
"insert"))
1652 const char *pack_str =
1678 "No Update backend handler");
1732 if (strstr(path,
".."))
1740 FILE *inf = fopen(fname,
"rb");
1744 fseek(inf, 0L, SEEK_END);
1748 if (fread(buf, 1, *sz, inf) != *sz)
1760 Z_SOAP *soap_package = 0;
1765 const char *stylesheet = 0;
1767 int num_diagnostic = 0;
1777 && hreq->
path[0] ==
'/'
1791 size_t content_size = 0;
1792 char *content_buf =
read_file(hreq->
path+1, o, &content_size);
1800 const char *ctype = 0;
1844 &diagnostic, &num_diagnostic);
1849 int http_code = 200;
1865 if (http_code == 200)
1879 if (http_code == 200)
1893 if (http_code == 200)
1908 if (http_code == 200)
1917 "SOAP-ENV:Client",
"Bad method", 0);
1919 if (http_code == 200 || http_code == 500)
1933 if (!stylesheet && assoc->
server)
1937 if (stylesheet && *stylesheet ==
'\0')
1942 soap_handlers, charset, stylesheet);
1943 hres->
code = http_code;
1945 strcpy(ctype,
"text/xml");
1946 if (charset && strlen(charset) <
sizeof(ctype)-30)
1948 strcat(ctype,
"; charset=");
1949 strcat(ctype, charset);
1960 if (!strcmp(hreq->
version,
"1.0"))
1963 if (v && !strcmp(v,
"Keep-Alive"))
1972 if (v && !strcmp(v,
"close"))
1989 if (alive &&
yaz_isdigit(*(
const unsigned char *) alive))
1993 if (t < 0 || t > 3600)
2026 *msg =
"Unknown Error";
2030 *msg =
"Missing InitRequest";
2046 *msg =
"Cannot handle Scan APDU";
2055 *msg =
"Cannot handle Extended Services APDU";
2064 *msg =
"Cannot handle Sort APDU";
2076 *msg =
"Cannot handle Delete APDU";
2087 *msg =
"Cannot handle Segment APDU";
2094 *msg =
"Bad APDU received";
2270 strcat(options,
"srch");
2275 strcat(options,
" prst");
2281 strcat(options,
" del");
2287 strcat(options,
" extendedServices");
2293 strcat(options,
" namedresults");
2298 strcat(options,
" scan");
2303 strcat(options,
" concurrop");
2308 strcat(options,
" sort");
2335 strcat(options,
" negotiation");
2400 const char *slash = strchr(open,
'/');
2413 user ? user :
"-", group ? group :
"-");
2455 addinfo ?
" -- " :
"", addinfo ? addinfo :
"");
2467 addinfo ?
" -- " :
"", addinfo ? addinfo :
"");
2480 int error,
const char *addinfo)
2483 addinfo ?
" -- " :
"", addinfo ? addinfo :
"");
2493 int recno, total_length = 0, dumped_records = 0;
2506 else if (toget == 0)
2523 int this_length = 0;
2562 sprintf(s,
"%d", recno);
2582 this_length = freq.
len;
2586 this_length, total_length, dumped_records);
2591 if (this_length <= a->preferredMessageSize && recno > start)
2600 if (this_length < a->maximumRecordSize)
2611 dumped_records += this_length;
2625 dumped_records += this_length;
2790 *toget = bsrt->
hits;
2797 if (*toget > bsrt->
hits)
2798 *toget = bsrt->
hits;
2841 returnedrecs = *toget;
3123 if (save_entries == bsrr->
entries &&
3142 o->
buf = (
unsigned char *)
3369 static char *reasons[] =
3376 "securityViolation",
3389 "Association terminated by client", reqb);
3411 const char *ext_name =
"unknown";
3434 ext_name =
"ItemOrder";
break;
3436 ext_name =
"Update";
break;
3438 ext_name =
"Update0";
break;
3440 ext_name =
"Admin";
break;
3455 else if (esrequest.
errcode == 0)