Remove debug yaz_log entries
[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.21 2004-01-07 11:17:05 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                     xfree(*schema);
479                     *schema = xstrdup(match_schema);
480                 }
481                 if (match_marcxml)
482                 {
483                     return -1;
484                 }
485                 if (match_error)
486                 {
487                     if (syntax_has_matched)  // if syntax did match, schema/ESN was bad
488                         return 25;
489                     if (syntax)
490                     {
491                         char dotoid_str[100];
492                         oid_to_dotstring(syntax, dotoid_str);
493                         *addinfo = odr_strdup(odr, dotoid_str);
494                     }
495                     return atoi(match_error);
496                 }
497                 return 0;
498             }
499         }
500     }
501 #endif
502     return 0;
503 }
504
505 #if HAVE_XSLT
506 xmlNodePtr Yaz_ProxyConfig::find_target_db(xmlNodePtr ptr, const char *db)
507 {
508     xmlNodePtr dptr;
509     if (!db)
510         return ptr;
511     if (!ptr)
512         return 0;
513     for (dptr = ptr->children; dptr; dptr = dptr->next)
514         if (dptr->type == XML_ELEMENT_NODE &&
515             !strcmp((const char *) dptr->name, "database"))
516         {
517             struct _xmlAttr *attr;
518             for (attr = dptr->properties; attr; attr = attr->next)
519                 if (!strcmp((const char *) attr->name, "name"))
520                 {
521                     if (attr->children
522                         && attr->children->type==XML_TEXT_NODE
523                         && attr->children->content 
524                         && (!strcmp((const char *) attr->children->content, db)
525                             || !strcmp((const char *) attr->children->content,
526                                        "*")))
527                         return dptr;
528                 }
529         }
530     return ptr;
531 }
532     
533 xmlNodePtr Yaz_ProxyConfig::find_target_node(const char *name, const char *db)
534 {
535     xmlNodePtr ptr;
536     if (!m_proxyPtr)
537         return 0;
538     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
539     {
540         if (ptr->type == XML_ELEMENT_NODE &&
541             !strcmp((const char *) ptr->name, "target"))
542         {
543             // default one ? 
544             if (!name)
545             {
546                 // <target default="1"> ?
547                 struct _xmlAttr *attr;
548                 for (attr = ptr->properties; attr; attr = attr->next)
549                     if (!strcmp((const char *) attr->name, "default") &&
550                         attr->children && attr->children->type == XML_TEXT_NODE)
551                     {
552                         xmlChar *t = attr->children->content;
553                         if (!t || *t == '1')
554                         {
555                             return find_target_db(ptr, db);
556                         }
557                     }
558             }
559             else
560             {
561                 // <target name="name"> ?
562                 struct _xmlAttr *attr;
563                 for (attr = ptr->properties; attr; attr = attr->next)
564                     if (!strcmp((const char *) attr->name, "name"))
565                     {
566                         if (attr->children
567                             && attr->children->type==XML_TEXT_NODE
568                             && attr->children->content 
569                             && (!strcmp((const char *) attr->children->content,
570                                         name)
571                                 || !strcmp((const char *) attr->children->content,
572                                            "*")))
573                         {
574                             return find_target_db(ptr, db);
575                         }
576                     }
577             }
578         }
579     }
580     return 0;
581 }
582 #endif
583
584 int Yaz_ProxyConfig::get_target_no(int no,
585                                    const char **name,
586                                    const char **url,
587                                    int *limit_bw,
588                                    int *limit_pdu,
589                                    int *limit_req,
590                                    int *target_idletime,
591                                    int *client_idletime,
592                                    int *max_clients,
593                                    int *keepalive_limit_bw,
594                                    int *keepalive_limit_pdu,
595                                    int *pre_init,
596                                    const char **cql2rpn)
597 {
598 #if HAVE_XSLT
599     xmlNodePtr ptr;
600     if (!m_proxyPtr)
601         return 0;
602     int i = 0;
603     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
604         if (ptr->type == XML_ELEMENT_NODE &&
605             !strcmp((const char *) ptr->name, "target"))
606         {
607             if (i == no)
608             {
609                 struct _xmlAttr *attr;
610                 for (attr = ptr->properties; attr; attr = attr->next)
611                     if (!strcmp((const char *) attr->name, "name"))
612                     {
613                         if (attr->children
614                             && attr->children->type==XML_TEXT_NODE
615                             && attr->children->content)
616                             *name = (const char *) attr->children->content;
617                     }
618                 return_target_info(ptr, url, limit_bw, limit_pdu, limit_req,
619                                    target_idletime, client_idletime,
620                                    keepalive_limit_bw, keepalive_limit_pdu,
621                                    pre_init, cql2rpn);
622                 return 1;
623             }
624             i++;
625         }
626 #endif
627     return 0;
628 }
629
630 int Yaz_ProxyConfig::mycmp(const char *hay, const char *item, size_t len)
631 {
632     if (len == strlen(item) && memcmp(hay, item, len) == 0)
633         return 1;
634     return 0;
635 }
636
637 void Yaz_ProxyConfig::get_generic_info(int *log_mask,
638                                        int *max_clients)
639 {
640 #if HAVE_XSLT
641     xmlNodePtr ptr;
642     if (!m_proxyPtr)
643         return;
644     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
645     {
646         if (ptr->type == XML_ELEMENT_NODE 
647             && !strcmp((const char *) ptr->name, "log"))
648         {
649             const char *v = get_text(ptr);
650             *log_mask = 0;
651             while (v && *v)
652             {
653                 const char *cp = v;
654                 while (*cp && *cp != ',' && !isspace(*cp))
655                     cp++;
656                 size_t len = cp - v;
657                 if (mycmp(v, "client-apdu", len))
658                     *log_mask |= PROXY_LOG_APDU_CLIENT;
659                 if (mycmp(v, "server-apdu", len))
660                     *log_mask |= PROXY_LOG_APDU_SERVER;
661                 if (mycmp(v, "client-requests", len))
662                     *log_mask |= PROXY_LOG_REQ_CLIENT;
663                 if (mycmp(v, "server-requests", len))
664                     *log_mask |= PROXY_LOG_REQ_SERVER;
665                 if (isdigit(*v))
666                     *log_mask |= atoi(v);
667                 if (*cp == ',')
668                     cp++;
669                 while (*cp && isspace(*cp))
670                     cp++;
671                 v = cp;
672             }
673         }
674         if (ptr->type == XML_ELEMENT_NODE &&
675             !strcmp((const char *) ptr->name, "max-clients"))
676         {
677             const char *t = get_text(ptr);
678             if (t)
679             {
680                 *max_clients = atoi(t);
681                 if (*max_clients  < 1)
682                     *max_clients = 1;
683             }
684         }
685     }
686 #endif
687 }
688
689 char *Yaz_ProxyConfig::get_explain(ODR odr, const char *name, const char *db,
690                                    int *len)
691 {
692 #if HAVE_XSLT
693     xmlNodePtr ptr = find_target_node(name, db);
694     if (ptr)
695     {
696         ptr = ptr->children;
697         for (; ptr; ptr = ptr->next)
698             if (ptr->type == XML_ELEMENT_NODE &&
699                 !strcmp((const char *) ptr->name, "explain"))
700             {
701                 xmlNodePtr ptr2 = xmlCopyNode(ptr, 1);
702
703                 xmlDocPtr doc = xmlNewDoc((const xmlChar *) "1.0");
704                 
705                 xmlDocSetRootElement(doc, ptr2);
706                 
707                 xmlChar *buf_out;
708                 int len_out;
709                 xmlDocDumpMemory(doc, &buf_out, len);
710                 char *content = (char*) odr_malloc(odr, *len);
711                 memcpy(content, buf_out, *len);
712                 
713                 xmlFree(buf_out);
714                 xmlFreeDoc(doc);
715                 return content;
716             }
717     }
718     else
719         yaz_log(LOG_WARN, "No explain node 1");
720
721 #endif
722     yaz_log(LOG_WARN, "No explain node");
723     return 0;
724 }
725
726 void Yaz_ProxyConfig::get_target_info(const char *name,
727                                       const char **url,
728                                       int *limit_bw,
729                                       int *limit_pdu,
730                                       int *limit_req,
731                                       int *target_idletime,
732                                       int *client_idletime,
733                                       int *max_clients,
734                                       int *keepalive_limit_bw,
735                                       int *keepalive_limit_pdu,
736                                       int *pre_init,
737                                       const char **cql2rpn)
738 {
739 #if HAVE_XSLT
740     xmlNodePtr ptr;
741     if (!m_proxyPtr)
742     {
743         url[0] = name;
744         url[1] = 0;
745         return;
746     }
747     url[0] = 0;
748     for (ptr = m_proxyPtr->children; ptr; ptr = ptr->next)
749     {
750         if (ptr->type == XML_ELEMENT_NODE &&
751             !strcmp((const char *) ptr->name, "max-clients"))
752         {
753             const char *t = get_text(ptr);
754             if (t)
755             {
756                 *max_clients = atoi(t);
757                 if (*max_clients  < 1)
758                     *max_clients = 1;
759             }
760         }
761     }
762     ptr = find_target_node(name, 0);
763     if (ptr)
764     {
765         if (name)
766         {
767             url[0] = name;
768             url[1] = 0;
769         }
770         return_target_info(ptr, url, limit_bw, limit_pdu, limit_req,
771                            target_idletime, client_idletime,
772                            keepalive_limit_bw, keepalive_limit_pdu,
773                            pre_init, cql2rpn);
774     }
775 #else
776     *url = name;
777     return;
778 #endif
779 }
780
781