0e5fe3188e6cc71fbadafdb4a68d9d0382d1f98e
[yazpp-moved-to-github.git] / src / yaz-proxy-config.cpp
1 /*
2  * Copyright (c) 1998-2004, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Id: yaz-proxy-config.cpp,v 1.20 2004-01-07 11:10:55 adam Exp $
6  */
7
8 #include <ctype.h>
9 #include <yaz/log.h>
10 #include <yaz++/proxy.h>
11
12 Yaz_ProxyConfig::Yaz_ProxyConfig()
13 {
14     m_copy = 0;
15 #if HAVE_XSLT
16     m_docPtr = 0;
17     m_proxyPtr = 0;
18 #endif
19 }
20
21 Yaz_ProxyConfig::~Yaz_ProxyConfig()
22 {
23 #if HAVE_XSLT
24     if (!m_copy && m_docPtr)
25         xmlFreeDoc(m_docPtr);
26 #endif
27 }
28
29 int Yaz_ProxyConfig::read_xml(const char *fname)
30 {
31 #if HAVE_XSLT
32     xmlDocPtr ndoc = xmlParseFile(fname);
33
34     if (!ndoc)
35     {
36         yaz_log(LOG_WARN, "Config file %s not found or parse error", fname);
37         return -1;  // no good
38     }
39     xmlNodePtr proxyPtr = xmlDocGetRootElement(ndoc);
40     if (!proxyPtr || proxyPtr->type != XML_ELEMENT_NODE ||
41         strcmp((const char *) proxyPtr->name, "proxy"))
42     {
43         yaz_log(LOG_WARN, "No proxy element in %s", fname);
44         xmlFreeDoc(ndoc);
45         return -1;
46     }
47     m_proxyPtr = proxyPtr;
48
49     // OK: release previous and make it the current one.
50     if (m_docPtr)
51         xmlFreeDoc(m_docPtr);
52     m_docPtr = ndoc;
53     return 0;
54 #else
55     return -2;
56 #endif
57 }
58
59 #if HAVE_XSLT
60 const char *Yaz_ProxyConfig::get_text(xmlNodePtr ptr)
61 {
62     for(ptr = ptr->children; ptr; ptr = ptr->next)
63         if (ptr->type == XML_TEXT_NODE)
64         {
65             xmlChar *t = ptr->content;
66             if (t)
67             {
68                 while (*t == ' ')
69                     t++;
70                 return (const char *) t;
71             }
72         }
73     return 0;
74 }
75 #endif
76
77 #if HAVE_XSLT
78 void Yaz_ProxyConfig::return_limit(xmlNodePtr ptr,
79                                    int *limit_bw,
80                                    int *limit_pdu,
81                                    int *limit_req)
82 {
83     for (ptr = ptr->children; ptr; ptr = ptr->next)
84     {
85         if (ptr->type == XML_ELEMENT_NODE 
86             && !strcmp((const char *) ptr->name, "bandwidth"))
87         {
88             const char *t = get_text(ptr);
89             if (t)
90                 *limit_bw = atoi(t);
91         }
92         if (ptr->type == XML_ELEMENT_NODE 
93             && !strcmp((const char *) ptr->name, "retrieve"))
94         {
95             const char *t = get_text(ptr);
96             if (t)
97                 *limit_req = atoi(t);
98         }
99         if (ptr->type == XML_ELEMENT_NODE 
100             && !strcmp((const char *) ptr->name, "pdu"))
101         {
102             const char *t = get_text(ptr);
103             if (t)
104                 *limit_pdu = atoi(t);
105         }
106     }
107 }
108 #endif
109
110 #if HAVE_XSLT
111 void Yaz_ProxyConfig::return_target_info(xmlNodePtr ptr,
112                                          const char **url,
113                                          int *limit_bw,
114                                          int *limit_pdu,
115                                          int *limit_req,
116                                          int *target_idletime,
117                                          int *client_idletime,
118                                          int *keepalive_limit_bw,
119                                          int *keepalive_limit_pdu,
120                                          int *pre_init,
121                                          const char **cql2rpn)
122 {
123     *pre_init = 0;
124     int no_url = 0;
125     ptr = ptr->children;
126     for (; ptr; ptr = ptr->next)
127     {
128         if (ptr->type == XML_ELEMENT_NODE 
129             && !strcmp((const char *) ptr->name, "preinit"))
130         {
131             const char *v = get_text(ptr);
132             *pre_init = v ? atoi(v) : 1;
133         }
134         if (ptr->type == XML_ELEMENT_NODE 
135             && !strcmp((const char *) ptr->name, "url"))
136         {
137             const char *t = get_text(ptr);
138             if (t && no_url < MAX_ZURL_PLEX)
139             {
140                 url[no_url++] = t;
141                 url[no_url] = 0;
142             }
143         }
144         if (ptr->type == XML_ELEMENT_NODE 
145             && !strcmp((const char *) ptr->name, "keepalive"))
146         {
147             int dummy;
148             *keepalive_limit_bw = 500000;
149             *keepalive_limit_pdu = 1000;
150             return_limit(ptr, keepalive_limit_bw, keepalive_limit_pdu,
151                          &dummy);
152         }
153         if (ptr->type == XML_ELEMENT_NODE 
154             && !strcmp((const char *) ptr->name, "limit"))
155             return_limit(ptr, limit_bw, limit_pdu, limit_req);
156         if (ptr->type == XML_ELEMENT_NODE 
157             && !strcmp((const char *) ptr->name, "target-timeout"))
158         {
159             const char *t = get_text(ptr);
160             if (t)
161             {
162                 *target_idletime = atoi(t);
163                 if (*target_idletime < 0)
164                     *target_idletime = 0;
165             }
166         }
167         if (ptr->type == XML_ELEMENT_NODE 
168             && !strcmp((const char *) ptr->name, "client-timeout"))
169         {
170             const char *t = get_text(ptr);
171             if (t)
172             {
173                 *client_idletime = atoi(t);
174                 if (*client_idletime < 0)
175                     *client_idletime = 0;
176             }
177         }
178         if (ptr->type == XML_ELEMENT_NODE 
179             && !strcmp((const char *) ptr->name, "cql2rpn"))
180         {
181             const char *t = get_text(ptr);
182             if (t)
183                 *cql2rpn = t;
184         }
185     }
186 }
187 #endif
188
189 int Yaz_ProxyConfig::atoi_l(const char **cp)
190 {
191     int v = 0;
192     while (**cp && isdigit(**cp))
193     {
194         v = v*10 + (**cp - '0');
195         (*cp)++;
196     }
197     return v;
198 }
199
200 int Yaz_ProxyConfig::match_list(int v, const char *m)
201 {
202   while(m && *m)
203   {
204       while(*m && isspace(*m))
205           m++;
206       if (*m == '*')
207           return 1;
208       int l = atoi_l(&m);
209       int h = l;
210       if (*m == '-')
211       {
212           ++m;
213           h = atoi_l(&m);
214       }
215       if (v >= l && v <= h)
216           return 1;
217       if (*m == ',')
218           m++;
219   }
220   return 0;
221 }
222
223 #if HAVE_XSLT
224 int Yaz_ProxyConfig::check_type_1_attributes(ODR odr, xmlNodePtr ptrl,
225                                              Z_AttributeList *attrs,
226                                              char **addinfo)
227 {
228     int i;
229     for (i = 0; i<attrs->num_attributes; i++)
230     {
231         Z_AttributeElement *el = attrs->attributes[i];
232         
233         if (!el->attributeType)
234             continue;
235         int type = *el->attributeType;
236         int *value = 0;
237         
238         if (el->which == Z_AttributeValue_numeric && el->value.numeric)
239             value = el->value.numeric;
240         
241         xmlNodePtr ptr;
242         for(ptr = ptrl->children; ptr; ptr = ptr->next)
243         {
244             if (ptr->type == XML_ELEMENT_NODE &&
245                 !strcmp((const char *) ptr->name, "attribute"))
246             {
247                 const char *match_type = 0;
248                 const char *match_value = 0;
249                 const char *match_error = 0;
250                 struct _xmlAttr *attr;
251                 for (attr = ptr->properties; attr; attr = attr->next)
252                 {
253                     if (!strcmp((const char *) attr->name, "type") &&
254                         attr->children && attr->children->type == XML_TEXT_NODE)
255                         match_type = (const char *) attr->children->content;
256                     if (!strcmp((const char *) attr->name, "value") &&
257                         attr->children && attr->children->type == XML_TEXT_NODE)
258                         match_value = (const char *) attr->children->content;
259                     if (!strcmp((const char *) attr->name, "error") &&
260                         attr->children && attr->children->type == XML_TEXT_NODE)
261                         match_error = (const char *) attr->children->content;
262                 }
263                 if (match_type && match_value)
264                 {
265                     char addinfo_str[20];
266                     if (!match_list(type, match_type))
267                         continue;
268                     
269                     *addinfo_str = '\0';
270                     if (!strcmp(match_type, "*"))
271                         sprintf (addinfo_str, "%d", type);
272                     else if (value)
273                     {
274                         if (!match_list(*value, match_value))
275                             continue;
276                         sprintf (addinfo_str, "%d", *value);
277                     }
278                     else
279                         continue;
280                     
281                     if (match_error)
282                     {
283                         if (*addinfo_str)
284                             *addinfo = odr_strdup(odr, addinfo_str);
285                         return atoi(match_error);
286                     }
287                     break;
288                 }
289             }
290         }
291     }
292     return 0;
293 }
294 #endif
295
296 #if HAVE_XSLT
297 int Yaz_ProxyConfig::check_type_1_structure(ODR odr, xmlNodePtr ptr,
298                                             Z_RPNStructure *q,
299                                             char **addinfo)
300 {
301     if (q->which == Z_RPNStructure_complex)
302     {
303         int e = check_type_1_structure(odr, ptr, q->u.complex->s1, addinfo);
304         if (e)
305             return e;
306         e = check_type_1_structure(odr, ptr, q->u.complex->s2, addinfo);
307         return e;
308     }
309     else if (q->which == Z_RPNStructure_simple)
310     {
311         if (q->u.simple->which == Z_Operand_APT)
312         {
313             return check_type_1_attributes(
314                 odr, ptr, q->u.simple->u.attributesPlusTerm->attributes,
315                 addinfo);
316         }
317     }
318     return 0;
319 }
320 #endif
321
322 #if HAVE_XSLT
323 int Yaz_ProxyConfig::check_type_1(ODR odr, xmlNodePtr ptr, Z_RPNQuery *query,
324                                   char **addinfo)
325 {
326     // possibly check for Bib-1
327     return check_type_1_structure(odr, ptr, query->RPNStructure, addinfo);
328 }
329 #endif
330
331 int Yaz_ProxyConfig::check_query(ODR odr, const char *name, Z_Query *query,
332                                  char **addinfo)
333 {
334 #if HAVE_XSLT
335     xmlNodePtr ptr;
336     
337     ptr = find_target_node(name, 0);
338     if (ptr)
339     {
340         if (query->which == Z_Query_type_1 || query->which == Z_Query_type_101)
341             return check_type_1(odr, ptr, query->u.type_1, addinfo);
342     }
343 #endif
344     return 0;
345 }
346
347 #if HAVE_XSLT
348 int Yaz_ProxyConfig::check_schema(xmlNodePtr ptr, Z_RecordComposition *comp,
349                                   const char **found_schema,
350                                   const char *schema_identifier)
351 {
352     char *esn = 0;
353     int default_match = 1;
354     *found_schema = schema_identifier;  // may be NULL
355     if (comp && comp->which == Z_RecordComp_simple &&
356         comp->u.simple && comp->u.simple->which == Z_ElementSetNames_generic)
357     {
358         esn = comp->u.simple->u.generic;
359     }
360     // if no ESN/schema was given accept..
361     if (!esn)
362         return 1;
363     // check if schema identifier match
364     if (schema_identifier && !strcmp(esn, schema_identifier))
365         return 1;
366     *found_schema = esn;
367     // Check each name element
368     for (; ptr; ptr = ptr->next)
369     {
370         if (ptr->type == XML_ELEMENT_NODE 
371             && !strcmp((const char *) ptr->name, "name"))
372         {
373             xmlNodePtr tptr = ptr->children;
374             default_match = 0;
375             for (; tptr; tptr = tptr->next)
376                 if (tptr->type == XML_TEXT_NODE && tptr->content)
377                 {
378                     xmlChar *t = tptr->content;
379                     while (*t && isspace(*t))
380                         t++;
381                     int i = 0;
382                     while (esn[i] && esn[i] == t[i])
383                         i++;
384                     if (!esn[i] && (!t[i] || isspace(t[i])))
385                         return 1;
386                 }
387         }
388     }
389     return default_match;
390 }
391 #endif
392
393 int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
394                                   Odr_oid *syntax, Z_RecordComposition *comp,
395                                   char **addinfo,
396                                   char **stylesheet, char **schema)
397 {
398     if (stylesheet)
399     {
400         xfree (*stylesheet);
401         *stylesheet = 0;
402     }
403     if (schema)
404     {
405         xfree (*schema);
406         *schema = 0;
407     }
408 #if HAVE_XSLT
409     int syntax_has_matched = 0;
410     xmlNodePtr ptr;
411     
412     ptr = find_target_node(name, 0);
413     if (!ptr)
414         return 0;
415     for(ptr = ptr->children; ptr; ptr = ptr->next)
416     {
417         if (ptr->type == XML_ELEMENT_NODE &&
418             !strcmp((const char *) ptr->name, "syntax"))
419         {
420             int match = 0;  // if we match record syntax
421             const char *match_type = 0;
422             const char *match_error = 0;
423             const char *match_marcxml = 0;
424             const char *match_stylesheet = 0;
425             const char *match_identifier = 0;
426             struct _xmlAttr *attr;
427             for (attr = ptr->properties; attr; attr = attr->next)
428             {
429                 if (!strcmp((const char *) attr->name, "type") &&
430                     attr->children && attr->children->type == XML_TEXT_NODE)
431                     match_type = (const char *) attr->children->content;
432                 if (!strcmp((const char *) attr->name, "error") &&
433                     attr->children && attr->children->type == XML_TEXT_NODE)
434                     match_error = (const char *) attr->children->content;
435                 if (!strcmp((const char *) attr->name, "marcxml") &&
436                     attr->children && attr->children->type == XML_TEXT_NODE)
437                     match_marcxml = (const char *) attr->children->content;
438                 if (!strcmp((const char *) attr->name, "stylesheet") &&
439                     attr->children && attr->children->type == XML_TEXT_NODE)
440                     match_stylesheet = (const char *) attr->children->content;
441                 if (!strcmp((const char *) attr->name, "identifier") &&
442                     attr->children && attr->children->type == XML_TEXT_NODE)
443                     match_identifier = (const char *) attr->children->content;
444             }
445             if (match_type)
446             {
447                 if (!strcmp(match_type, "*"))
448                     match = 1;
449                 else if (!strcmp(match_type, "none"))
450                 {
451                     if (syntax == 0)
452                         match = 1;
453                 }
454                 else if (syntax)
455                 {
456                     int match_oid[OID_SIZE];
457                     oid_name_to_oid(CLASS_RECSYN, match_type, match_oid);
458                     if (oid_oidcmp(match_oid, syntax) == 0)
459                         match = 1;
460                 }
461             }
462             const char *match_schema = 0;
463             if (match)
464             {
465                 syntax_has_matched = 1;
466                 match = check_schema(ptr->children, comp, &match_schema,
467                                      match_identifier);
468             }
469             if (match)
470             {
471                 if (stylesheet && match_stylesheet)
472                 {
473                     xfree(*stylesheet);
474                     *stylesheet = xstrdup(match_stylesheet);
475                 }
476                 if (schema && match_schema)
477                 {
478                     yaz_log(LOG_LOG, "Match_schema=%s", match_schema);
479                     xfree(*schema);
480                     *schema = xstrdup(match_schema);
481                 }
482                 else
483                     yaz_log(LOG_LOG, "NO SCHEMA");
484                 if (match_marcxml)
485                 {
486                     return -1;
487                 }
488                 if (match_error)
489                 {
490                     if (syntax_has_matched)  // if syntax did match, schema/ESN was bad
491                         return 25;
492                     if (syntax)
493                     {
494                         char dotoid_str[100];
495                         oid_to_dotstring(syntax, dotoid_str);
496                         *addinfo = odr_strdup(odr, dotoid_str);
497                     }
498                     return atoi(match_error);
499                 }
500                 return 0;
501             }
502         }
503     }
504 #endif
505     return 0;
506 }
507
508 #if HAVE_XSLT
509 xmlNodePtr Yaz_ProxyConfig::find_target_db(xmlNodePtr ptr, const char *db)
510 {
511     xmlNodePtr dptr;
512     if (!db)
513         return ptr;
514     if (!ptr)
515         return 0;
516     for (dptr = ptr->children; dptr; dptr = dptr->next)
517         if (dptr->type == XML_ELEMENT_NODE &&
518             !strcmp((const char *) dptr->name, "database"))
519         {
520             struct _xmlAttr *attr;
521             for (attr = dptr->properties; attr; attr = attr->next)
522                 if (!strcmp((const char *) attr->name, "name"))
523                 {
524                     if (attr->children
525                         && attr->children->type==XML_TEXT_NODE
526                         && attr->children->content 
527                         && (!strcmp((const char *) attr->children->content, db)
528                             || !strcmp((const char *) attr->children->content,
529                                        "*")))
530                         return dptr;
531                 }
532         }
533     return ptr;
534 }
535     
536 xmlNodePtr Yaz_ProxyConfig::find_target_node(const char *name, const char *db)
537 {
538     xmlNodePtr ptr;
539     if (!m_proxyPtr)
540         return 0;
541     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
542     {
543         if (ptr->type == XML_ELEMENT_NODE &&
544             !strcmp((const char *) ptr->name, "target"))
545         {
546             // default one ? 
547             if (!name)
548             {
549                 // <target default="1"> ?
550                 struct _xmlAttr *attr;
551                 for (attr = ptr->properties; attr; attr = attr->next)
552                     if (!strcmp((const char *) attr->name, "default") &&
553                         attr->children && attr->children->type == XML_TEXT_NODE)
554                     {
555                         xmlChar *t = attr->children->content;
556                         if (!t || *t == '1')
557                         {
558                             return find_target_db(ptr, db);
559                         }
560                     }
561             }
562             else
563             {
564                 // <target name="name"> ?
565                 struct _xmlAttr *attr;
566                 for (attr = ptr->properties; attr; attr = attr->next)
567                     if (!strcmp((const char *) attr->name, "name"))
568                     {
569                         if (attr->children
570                             && attr->children->type==XML_TEXT_NODE
571                             && attr->children->content 
572                             && (!strcmp((const char *) attr->children->content,
573                                         name)
574                                 || !strcmp((const char *) attr->children->content,
575                                            "*")))
576                         {
577                             return find_target_db(ptr, db);
578                         }
579                     }
580             }
581         }
582     }
583     return 0;
584 }
585 #endif
586
587 int Yaz_ProxyConfig::get_target_no(int no,
588                                    const char **name,
589                                    const char **url,
590                                    int *limit_bw,
591                                    int *limit_pdu,
592                                    int *limit_req,
593                                    int *target_idletime,
594                                    int *client_idletime,
595                                    int *max_clients,
596                                    int *keepalive_limit_bw,
597                                    int *keepalive_limit_pdu,
598                                    int *pre_init,
599                                    const char **cql2rpn)
600 {
601 #if HAVE_XSLT
602     xmlNodePtr ptr;
603     if (!m_proxyPtr)
604         return 0;
605     int i = 0;
606     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
607         if (ptr->type == XML_ELEMENT_NODE &&
608             !strcmp((const char *) ptr->name, "target"))
609         {
610             if (i == no)
611             {
612                 struct _xmlAttr *attr;
613                 for (attr = ptr->properties; attr; attr = attr->next)
614                     if (!strcmp((const char *) attr->name, "name"))
615                     {
616                         if (attr->children
617                             && attr->children->type==XML_TEXT_NODE
618                             && attr->children->content)
619                             *name = (const char *) attr->children->content;
620                     }
621                 return_target_info(ptr, url, limit_bw, limit_pdu, limit_req,
622                                    target_idletime, client_idletime,
623                                    keepalive_limit_bw, keepalive_limit_pdu,
624                                    pre_init, cql2rpn);
625                 return 1;
626             }
627             i++;
628         }
629 #endif
630     return 0;
631 }
632
633 int Yaz_ProxyConfig::mycmp(const char *hay, const char *item, size_t len)
634 {
635     if (len == strlen(item) && memcmp(hay, item, len) == 0)
636         return 1;
637     return 0;
638 }
639
640 void Yaz_ProxyConfig::get_generic_info(int *log_mask,
641                                        int *max_clients)
642 {
643 #if HAVE_XSLT
644     xmlNodePtr ptr;
645     if (!m_proxyPtr)
646         return;
647     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
648     {
649         if (ptr->type == XML_ELEMENT_NODE 
650             && !strcmp((const char *) ptr->name, "log"))
651         {
652             const char *v = get_text(ptr);
653             *log_mask = 0;
654             while (v && *v)
655             {
656                 const char *cp = v;
657                 while (*cp && *cp != ',' && !isspace(*cp))
658                     cp++;
659                 size_t len = cp - v;
660                 if (mycmp(v, "client-apdu", len))
661                     *log_mask |= PROXY_LOG_APDU_CLIENT;
662                 if (mycmp(v, "server-apdu", len))
663                     *log_mask |= PROXY_LOG_APDU_SERVER;
664                 if (mycmp(v, "client-requests", len))
665                     *log_mask |= PROXY_LOG_REQ_CLIENT;
666                 if (mycmp(v, "server-requests", len))
667                     *log_mask |= PROXY_LOG_REQ_SERVER;
668                 if (isdigit(*v))
669                     *log_mask |= atoi(v);
670                 if (*cp == ',')
671                     cp++;
672                 while (*cp && isspace(*cp))
673                     cp++;
674                 v = cp;
675             }
676         }
677         if (ptr->type == XML_ELEMENT_NODE &&
678             !strcmp((const char *) ptr->name, "max-clients"))
679         {
680             const char *t = get_text(ptr);
681             if (t)
682             {
683                 *max_clients = atoi(t);
684                 if (*max_clients  < 1)
685                     *max_clients = 1;
686             }
687         }
688     }
689 #endif
690 }
691
692 char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db,
693                                    int *len)
694 {
695 #if HAVE_XSLT
696     xmlNodePtr ptr = find_target_node(name, db);
697     if (ptr)
698     {
699         ptr = ptr->children;
700         for (; ptr; ptr = ptr->next)
701             if (ptr->type == XML_ELEMENT_NODE &&
702                 !strcmp((const char *) ptr->name, "explain"))
703             {
704                 xmlNodePtr ptr2 = xmlCopyNode(ptr, 1);
705
706                 xmlDocPtr doc = xmlNewDoc((const xmlChar *) "1.0");
707                 
708                 xmlDocSetRootElement(doc, ptr2);
709                 
710                 xmlChar *buf_out;
711                 int len_out;
712                 xmlDocDumpMemory(doc, &buf_out, len);
713                 char *content = (char*) odr_malloc(odr, *len);
714                 memcpy(content, buf_out, *len);
715                 
716                 xmlFree(buf_out);
717                 xmlFreeDoc(doc);
718                 return content;
719             }
720     }
721     else
722         yaz_log(LOG_WARN, "No explain node 1");
723
724 #endif
725     yaz_log(LOG_WARN, "No explain node");
726     return 0;
727 }
728
729 void Yaz_ProxyConfig::get_target_info(const char *name,
730                                       const char **url,
731                                       int *limit_bw,
732                                       int *limit_pdu,
733                                       int *limit_req,
734                                       int *target_idletime,
735                                       int *client_idletime,
736                                       int *max_clients,
737                                       int *keepalive_limit_bw,
738                                       int *keepalive_limit_pdu,
739                                       int *pre_init,
740                                       const char **cql2rpn)
741 {
742 #if HAVE_XSLT
743     xmlNodePtr ptr;
744     if (!m_proxyPtr)
745     {
746         url[0] = name;
747         url[1] = 0;
748         return;
749     }
750     url[0] = 0;
751     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
752     {
753         if (ptr->type == XML_ELEMENT_NODE &&
754             !strcmp((const char *) ptr->name, "max-clients"))
755         {
756             const char *t = get_text(ptr);
757             if (t)
758             {
759                 *max_clients = atoi(t);
760                 if (*max_clients  < 1)
761                     *max_clients = 1;
762             }
763         }
764     }
765     ptr = find_target_node(name, 0);
766     if (ptr)
767     {
768         if (name)
769         {
770             url[0] = name;
771             url[1] = 0;
772         }
773         return_target_info(ptr, url, limit_bw, limit_pdu, limit_req,
774                            target_idletime, client_idletime,
775                            keepalive_limit_bw, keepalive_limit_pdu,
776                            pre_init, cql2rpn);
777     }
778 #else
779     *url = name;
780     return;
781 #endif
782 }
783
784