1 const char cgi_rcs[] = "$Id: cgi.c,v 1.7 2001/06/09 10:51:58 jongfoster Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $
6 * Purpose : Declares functions to intercept request, generate
7 * html or gif answers, and to compose HTTP resonses.
9 * Functions declared include:
12 * Copyright : Written by and Copyright (C) 2001 the SourceForge
13 * IJBSWA team. http://ijbswa.sourceforge.net
15 * Based on the Internet Junkbuster originally written
16 * by and Copyright (C) 1997 Anonymous Coders and
17 * Junkbusters Corporation. http://www.junkbusters.com
19 * This program is free software; you can redistribute it
20 * and/or modify it under the terms of the GNU General
21 * Public License as published by the Free Software
22 * Foundation; either version 2 of the License, or (at
23 * your option) any later version.
25 * This program is distributed in the hope that it will
26 * be useful, but WITHOUT ANY WARRANTY; without even the
27 * implied warranty of MERCHANTABILITY or FITNESS FOR A
28 * PARTICULAR PURPOSE. See the GNU General Public
29 * License for more details.
31 * The GNU General Public License should be included with
32 * this file. If not, you can view it at
33 * http://www.gnu.org/copyleft/gpl.html
34 * or write to the Free Software Foundation, Inc., 59
35 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39 * Revision 1.7 2001/06/09 10:51:58 jongfoster
40 * Changing "show URL info" handler to new style.
41 * Changing BUFSIZ ==> BUFFER_SIZE
43 * Revision 1.6 2001/06/07 23:05:19 jongfoster
44 * Removing code related to old forward and ACL files.
46 * Revision 1.5 2001/06/05 19:59:16 jongfoster
47 * Fixing multiline character string (a GCC-only "feature"), and snprintf (it's _snprintf under VC++).
49 * Revision 1.4 2001/06/04 10:41:52 swa
50 * show version string of cgi.h and cgi.c
52 * Revision 1.3 2001/06/03 19:12:16 oes
53 * introduced new cgi handling
55 * No revisions before 1.3
57 **********************************************************************/
63 #include <sys/types.h>
69 #define snprintf _snprintf
70 #endif /* def _WIN32 */
85 const char cgi_h_rcs[] = CGI_H_VERSION;
87 const struct cgi_dispatcher cgi_dispatcher[] = {
90 "Show information about the version and configuration" },
92 13, cgi_show_url_info,
93 "Show which actions apply to a URL and why" },
96 "HIDE Send the transparent or \"Junkbuster\" gif" },
99 "Junkbuster main page" },
100 { NULL, 0, NULL, NULL }
104 /*********************************************************************
106 * Function : dispatch_cgi
108 * Description : Checks if a request URL has either the magical hostname
109 * i.j.b or matches HOME_PAGE_URL/config/. If so, it parses
110 * the (rest of the) path as a cgi name plus query string,
111 * prepares a map that maps CGI parameter names to their values,
112 * initializes the http_response struct, and calls the
113 * relevant CGI handler function.
116 * 1 : csp = Current client state (buffers, headers, etc...)
118 * Returns : http_response if match, NULL if nonmatch or handler fail
120 *********************************************************************/
121 struct http_response *dispatch_cgi(struct client_state *csp)
123 char *argstring = NULL;
124 const struct cgi_dispatcher *d;
125 struct map *param_list;
126 struct http_response *rsp;
129 * Should we intercept ?
132 /* Either the host matches CGI_PREFIX_HOST ..*/
133 if (0 == strcmpic(csp->http->host, CGI_PREFIX_HOST))
135 /* ..then the path will all be for us */
136 argstring = csp->http->path;
138 /* Or it's the host part HOME_PAGE_URL, and the path /config ? */
139 else if ( (0 == strcmpic(csp->http->host, HOME_PAGE_URL + 7 ))
140 && (0 == strncmpic(csp->http->path,"/config", 7))
141 && ((csp->http->path[7] == '/') || (csp->http->path[7] == '\0')))
143 /* then it's everything following "/config" */
144 argstring = csp->http->path + 7;
152 * This is a CGI call.
155 /* Get mem for response or fail*/
156 if (NULL == ( rsp = zalloc(sizeof(*rsp))))
161 /* Remove leading slash */
162 if (*argstring == '/')
167 log_error(LOG_LEVEL_GPC, "%s%s cgi call", csp->http->hostport, csp->http->path);
168 log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 200 3",
169 csp->ip_addr_str, csp->http->cmd);
171 /* Find and start the right CGI function*/
172 for (d = cgi_dispatcher; d->handler; d++)
174 if (strncmp(argstring, d->name, d->name_length) == 0)
176 param_list = parse_cgi_parameters(argstring + d->name_length);
177 if ((d->handler)(csp, rsp, param_list))
182 free_map(param_list);
183 return(finish_http_response(rsp));
187 /* Can't get here, since cgi_default will match all requests */
194 /*********************************************************************
196 * Function : parse_cgi_parameters
198 * Description : Parse a URL-encoded argument string into name/value
199 * pairs and store them in a struct map list.
202 * 1 : string = string to be parsed
204 * Returns : poniter to param list, or NULL if failiure
206 *********************************************************************/
207 struct map *parse_cgi_parameters(char *argstring)
210 char *vector[BUFFER_SIZE];
212 struct map *cgi_params = NULL;
214 if(*argstring == '?') argstring++;
215 tmp = strdup(argstring);
217 pairs = ssplit(tmp, "&", vector, SZ(vector), 1, 1);
219 for (i = 0; i < pairs; i++)
221 if ((NULL != (p = strchr(vector[i], '='))) && (*(p+1) != '\0'))
224 cgi_params = map(cgi_params, url_decode(vector[i]), 0, url_decode(++p), 0);
234 /*********************************************************************
236 * Function : cgi_default
238 * Description : CGI function that is called if no action was given.
239 * Lists menu of available unhidden CGIs.
242 * 1 : csp = Current client state (buffers, headers, etc...)
243 * 2 : rsp = http_response data structure for output
244 * 3 : parameters = map of cgi parameters
248 *********************************************************************/
249 int cgi_default(struct client_state *csp, struct http_response *rsp,
250 struct map *parameters)
252 char *p, *tmp = NULL;
253 struct map *exports = default_exports(csp, "");
255 /* If there were other parameters, export a dump as "cgi-parameters" */
258 p = dump_map(parameters);
259 tmp = strsav(tmp, "<p>What made you think this cgi takes parameters?\n"
260 "Anyway, here they are, in case you're interested:</p>\n");
261 tmp = strsav(tmp, p);
262 exports = map(exports, "cgi-parameters", 1, tmp, 0);
267 exports = map(exports, "cgi-parameters", 1, "", 1);
270 rsp->body = fill_template(csp, "default", exports);
277 /*********************************************************************
279 * Function : cgi_send_banner
281 * Description : CGI function that returns a banner.
284 * 1 : csp = Current client state (buffers, headers, etc...)
285 * 2 : rsp = http_response data structure for output
286 * 3 : parameters = map of cgi parameters
289 * type : Selects the type of banner between "trans" and "jb".
290 * Defaults to "jb" if absent or != "trans".
294 *********************************************************************/
295 int cgi_send_banner(struct client_state *csp, struct http_response *rsp,
296 struct map *parameters)
298 if(strcmp(lookup(parameters, "type"), "trans"))
300 rsp->body = bindup(JBGIF, sizeof(JBGIF));
301 rsp->content_length = sizeof(JBGIF);
305 rsp->body = bindup(BLANKGIF, sizeof(BLANKGIF));
306 rsp->content_length = sizeof(BLANKGIF);
309 enlist(rsp->headers, "Content-Type: image/gif");
315 /*********************************************************************
317 * Function : cgi_show_status
319 * Description : CGI function that returns a a web page describing the
320 * current status of IJB.
323 * 1 : csp = Current client state (buffers, headers, etc...)
324 * 2 : rsp = http_response data structure for output
325 * 3 : parameters = map of cgi parameters
328 * type : Selects the type of banner between "trans" and "jb".
329 * Defaults to "jb" if absent or != "trans".
333 *********************************************************************/
334 int cgi_show_status(struct client_state *csp, struct http_response *rsp,
335 struct map *parameters)
339 struct map *exports = default_exports(csp, "show-status");
341 #ifdef SPLIT_PROXY_ARGS
343 char buf[BUFFER_SIZE];
345 const char * filename = NULL;
346 char * file_description = NULL;
349 p = lookup(parameters, "file");
353 if (csp->actions_list)
355 filename = csp->actions_list->filename;
356 file_description = "Actions List";
364 filename = csp->rlist->filename;
365 file_description = "Regex Filter List";
368 #endif /* def PCRS */
374 filename = csp->tlist->filename;
375 file_description = "Trust List";
378 #endif /* def TRUST_FILES */
381 if (NULL != filename)
383 exports = map(exports, "file-description", 1, file_description, 1);
384 exports = map(exports, "filepath", 1, html_encode(filename), 0);
386 if ((fp = fopen(filename, "r")) == NULL)
388 exports = map(exports, "content", 1, "<h1>ERROR OPENING FILE!</h1>", 1);
392 while (fgets(buf, sizeof(buf), fp))
394 p = html_encode(buf);
399 s = strsav(s, "<br>");
403 exports = map(exports, "contents", 1, s, 0);
405 rsp->body = fill_template(csp, "show-status-file", exports);
411 #endif /* def SPLIT_PROXY_ARGS */
413 exports = map(exports, "redirect-url", 1, REDIRECT_URL, 1);
416 for (i=0; i < Argc; i++)
418 s = strsav(s, Argv[i]);
421 exports = map(exports, "invocation", 1, s, 0);
423 exports = map(exports, "options", 1, csp->config->proxy_args, 1);
425 exports = map(exports, "sourceversions", 1, s, 0);
427 exports = map(exports, "defines", 1, s, 0);
430 exports = add_stats(exports);
432 exports = map_block_killer(exports, "statistics");
433 #endif /* ndef STATISTICS */
435 #ifdef SPLIT_PROXY_ARGS
437 exports = map_block_killer(exports, "no-split-args");
439 if (csp->actions_list)
441 exports = map(exports, "actions-filename", 1, csp->actions_list->filename, 1);
445 exports = map(exports, "actions-filename", 1, "None specified", 1);
451 exports = map(exports, "re-filter-filename", 1, csp->rlist->filename, 1);
455 exports = map(exports, "re-filter-filename", 1, "None specified", 1);
458 exports = map_block_killer(exports, "pcrs-support");
459 #endif /* ndef PCRS */
464 exports = map(exports, "trust-filename", 1, csp->tlist->filename, 1);
468 exports = map(exports, "trust-filename", 1, "None specified", 1);
471 exports = map_block_killer(exports, "trust-support");
472 #endif /* ndef TRUST_FILES */
474 #else /* ifndef SPLIT_PROXY_ARGS */
475 exports = map_block_killer(exports, "split-args");
479 map(exports, "clist", 1, csp->clist->proxy_args , 1);
485 map(exports, "rlist", 1, csp->rlist->proxy_args , 1);
487 #endif /* def PCRS */
492 map(exports, "tlist", 1, csp->tlist->proxy_args , 1);
494 #endif /* def TRUST_FILES */
496 #endif /* ndef SPLIT_PROXY_ARGS */
498 rsp->body = fill_template(csp, "show-status", exports);
505 /*********************************************************************
507 * Function : cgi_show_url_info
509 * Description : CGI function that determines and shows which actions
510 * junkbuster will perform for a given url, and which
511 * matches starting from the defaults have lead to that.
514 * 1 : csp = Current client state (buffers, headers, etc...)
515 * 2 : rsp = http_response data structure for output
516 * 3 : parameters = map of cgi parameters
519 * url : The url whose actions are to be determined.
520 * If url is unset, the url-given conditional will be
521 * set, so that all but the form can be suppressed in
526 *********************************************************************/
527 int cgi_show_url_info(struct client_state *csp, struct http_response *rsp,
\r
528 struct map *parameters)
\r
530 struct map *exports = default_exports(csp, "show-url-info");
531 char *url_param, *host = NULL;
533 if (NULL == (url_param = strdup(lookup(parameters, "url"))) || *url_param == '\0')
535 exports = map_block_killer(exports, "url-given");
536 exports = map(exports, "url", 1, "", 1);
540 char *matches = NULL;
545 struct file_list *fl;
546 struct url_actions *b;
547 struct url_spec url[1];
548 struct current_action_spec action[1];
551 host += (strncmp(url_param, "http://", 7)) ? 0 : 7;
553 exports = map(exports, "url", 1, host, 1);
\r
554 exports = map(exports, "url-html", 1, html_encode(host), 0);
\r\r
556 init_current_action(action);
558 s = current_action_to_text(action);
559 exports = map(exports, "default", 1, s , 0);
\r
561 if (((fl = csp->actions_list) == NULL) || ((b = fl->f) == NULL))
\r
563 exports = map(exports, "matches", 1, "none" , 1);
\r
564 exports = map(exports, "final", 1, lookup(exports, "default"), 1);
\r
567 free_current_action(action);
\r
569 rsp->body = fill_template(csp, "show-url-info", exports);
\r
575 s = strchr(host, '/');
585 s = strchr(host, ':');
595 /* if splitting the domain fails, punt */
596 if (url->dbuf == NULL)
598 exports = map(exports, "matches", 1, "none" , 1);
\r
599 exports = map(exports, "final", 1, lookup(exports, "default"), 1);
\r
603 free_current_action(action);
\r
605 rsp->body = fill_template(csp, "show-url-info", exports);
\r
611 for (b = b->next; NULL != b; b = b->next)
613 if ((b->url->port == 0) || (b->url->port == port))
615 if ((b->url->domain[0] == '\0') || (domaincmp(b->url, url) == 0))
617 if ((b->url->path == NULL) ||
619 (regexec(b->url->preg, path, 0, NULL, 0) == 0)
621 (strncmp(b->url->path, path, b->url->pathlen) == 0)
625 s = actions_to_text(b->action);
626 matches = strsav(matches, "<b>{");
627 matches = strsav(matches, s);
628 matches = strsav(matches, " }</b><br>\n<code>");
629 matches = strsav(matches, b->url->spec);
630 matches = strsav(matches, "</code><br>\n<br>\n");
633 merge_current_action(action, b->action);
642 exports = map(exports, "matches", 1, matches , 0);
646 exports = map(exports, "matches", 1, "none", 1);
656 s = current_action_to_text(action);
657 exports = map(exports, "final", 1, s, 0);
\r
660 free_current_action(action);
663 rsp->body = fill_template(csp, "show-url-info", exports);
\r
670 /*********************************************************************
672 * Function : error_response
674 * Description : returns an http_response that explains the reason
675 * why a request failed.
678 * 1 : csp = Current client state (buffers, headers, etc...)
679 * 2 : template = Which template should be used for the answer
680 * 3 : errno = system error number
682 * Returns : NULL if no memory, else http_response
684 *********************************************************************/
685 struct http_response *error_response(struct client_state *csp, const char *template, int err)
687 struct http_response *rsp;
688 struct map *exports = default_exports(csp, NULL);
690 if (NULL == ( rsp = (struct http_response *)zalloc(sizeof(*rsp))))
695 exports = map(exports, "host-html", 1, html_encode(csp->http->host), 0);
696 exports = map(exports, "hostport", 1, csp->http->hostport, 1);
697 exports = map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0);
698 exports = map(exports, "path", 1, csp->http->path, 1);
699 exports = map(exports, "path-html", 1, html_encode(csp->http->path), 0);
700 exports = map(exports, "error", 1, safe_strerror(err), 0);
701 exports = map(exports, "host-ip", 1, csp->http->host_ip_addr_str, 1);
703 rsp->body = fill_template(csp, template, exports);
706 if (!strcmp(template, "no-such-domain"))
708 rsp->status = strdup("404 No such domain");
710 else if (!strcmp(template, "connect-failed"))
712 rsp->status = strdup("503 Connect failed");
715 return(finish_http_response(rsp));
719 /*********************************************************************
721 * Function : finish_http_response
723 * Description : Fill in the missing headers in an http response,
724 * and flatten the headers to an http head.
727 * 1 : rsp = pointer to http_response to be processed
729 * Returns : http_response, or NULL on failiure
731 *********************************************************************/
732 struct http_response *finish_http_response(struct http_response *rsp)
734 char buf[BUFFER_SIZE];
737 * Fill in the HTTP Status
739 sprintf(buf, "HTTP/1.0 %s", rsp->status ? rsp->status : "200 OK");
740 enlist_first(rsp->headers, buf);
743 * Set the Content-Length
745 if (rsp->content_length == 0)
747 rsp->content_length = rsp->body ? strlen(rsp->body) : 0;
749 sprintf(buf, "Content-Length: %d", rsp->content_length);
750 enlist(rsp->headers, buf);
753 * Fill in the default headers FIXME: Are these correct? sequence OK? check rfc!
755 enlist_unique(rsp->headers, "Last-Modified: Thu Jul 31, 1997 07:42:22 pm GMT", 14);
756 enlist_unique(rsp->headers, "Expires: Thu Jul 31, 1997 07:42:22 pm GMT", 8);
757 enlist_unique(rsp->headers, "Content-Type: text/html", 13);
758 enlist(rsp->headers, "");
764 if (NULL == (rsp->head = list_to_text(rsp->headers)))
766 free_http_response(rsp);
769 rsp->head_length = strlen(rsp->head);
776 /*********************************************************************
778 * Function : free_http_response
780 * Description : Free the memory occupied by an http_response
781 * and its depandant structures.
784 * 1 : rsp = pointer to http_response to be freed
788 *********************************************************************/
789 void free_http_response(struct http_response *rsp)
796 destroy_list(rsp->headers);
803 /*********************************************************************
805 * Function : fill_template
807 * Description : CGI support function that loads a given HTML
808 * template from the confdir, and fills it in
809 * by replacing @name@ with value using pcrs,
810 * for each item in the output map.
813 * 1 : csp = Current client state (buffers, headers, etc...)
814 * 3 : template = name of the HTML template to be used
815 * 2 : exports = map with fill in symbol -> name pairs
817 * Returns : char * with filled out form, or NULL if failiure
819 *********************************************************************/
820 char *fill_template(struct client_state *csp, const char *template, struct map *exports)
823 pcrs_job *job, *joblist = NULL;
824 char buf[BUFFER_SIZE];
825 char *new, *old = NULL;
831 * Open template file or fail
833 snprintf(buf, BUFFER_SIZE, "%s/templates/%s", csp->config->confdir, template);
835 if(NULL == (fp = fopen(buf, "r")))
837 log_error(LOG_LEVEL_ERROR, "error loading template %s: %E", buf);
843 * Assemble pcrs joblist from exports map
845 for (m = exports; m; m = m->next)
849 /* Enclose name in @@ */
850 snprintf(buf, BUFFER_SIZE, "@%s@", m->name);
852 /* Make and chain in job */
853 if ( NULL == (job = (pcrs_make_job(buf, m->value, "sigTU", &error))) )
855 log_error(LOG_LEVEL_ERROR, "Error compiling template fill job %s: %d", m->name, error);
866 * Read the file, ignoring comments
868 while (fgets(buf, BUFFER_SIZE, fp))
870 /* skip lines starting with '#' */
871 if(*buf == '#') continue;
873 old = strsav(old, buf);
881 size = strlen(old) + 1;
884 for (job = joblist; NULL != job; job = job->next)
886 pcrs_execute(job, old, size, &new, &size);
887 if (old != buf) free(old);
893 * Free the jobs & return
895 pcrs_free_joblist(joblist);
901 /*********************************************************************
903 * Function : default_exports
905 * Description : returns a struct map list that contains exports
906 * which are common to all CGI functions.
909 * 1 : csp = Current client state (buffers, headers, etc...)
910 * 2 : caller = name of CGI who calls us and which should
911 * be excluded from the generated menu.
912 * Returns : NULL if no memory, else map
914 *********************************************************************/
915 struct map *default_exports(struct client_state *csp, char *caller)
917 struct map *exports = NULL;
920 exports = map(exports, "version", 1, VERSION, 1);
921 exports = map(exports, "my-ip-address", 1, csp->my_ip_addr_str ? csp->my_ip_addr_str : "unknown", 1);
922 exports = map(exports, "my-hostname", 1, csp->my_hostname ? csp->my_hostname : "unknown", 1);
923 exports = map(exports, "admin-address", 1, csp->config->admin_address ? csp->config->admin_address : "fill@me.in.please", 1);
924 exports = map(exports, "homepage", 1, HOME_PAGE_URL, 1);
925 exports = map(exports, "default-cgi", 1, HOME_PAGE_URL "/config", 1);
926 exports = map(exports, "menu", 1, make_menu(caller), 0);
927 exports = map(exports, "code-status", 1, CODE_STATUS, 1);
929 snprintf(buf, 20, "%d", csp->config->hport);
930 exports = map(exports, "my-port", 1, buf, 1);
932 if(!strcmp(CODE_STATUS, "stable"))
934 exports = map_block_killer(exports, "unstable");
937 if(csp->config->proxy_info_url != NULL)
939 exports = map(exports, "proxy-info-url", 1, csp->config->proxy_info_url, 1);
943 exports = map_block_killer(exports, "have-proxy-info");
951 /*********************************************************************
953 * Function : map_block_killer
955 * Description : Convenience function.
956 * Adds a "killer" for the conditional HTML-template
957 * block <name>, i.e. a substitution of the regex
958 * "if-<name>-start.*if-<name>-end" to the given
962 * 1 : exports = map to extend
963 * 2 : name = name of conditional block
965 * Returns : extended map
967 *********************************************************************/
968 struct map *map_block_killer(struct map *exports, char *name)
970 char buf[1000]; /* Will do, since the names are hardwired */
972 snprintf(buf, 1000, "if-%s-start.*if-%s-end", name, name);
973 exports = map(exports, buf, 1, "", 1);
980 /*********************************************************************
982 * Function : make_menu
984 * Description : Returns an HTML-formatted menu of the available
985 * unhidden CGIs, excluding the one given in <self>.
987 * Parameters : self = name of CGI to leave out, can be NULL
989 * Returns : menu string
991 *********************************************************************/
992 char *make_menu(const char *self)
994 const struct cgi_dispatcher *d;
995 char buf[BUFFER_SIZE], *tmp = NULL;
997 if (self == NULL) self = "NO-SUCH-CGI!";
999 /* List available unhidden CGI's and export as "other-cgis" */
1000 for (d = cgi_dispatcher; d->handler; d++)
1002 if (strncmp(d->description, "HIDE", 4) && strcmp(d->name, self))
1004 snprintf(buf, BUFFER_SIZE, "<li><a href=%s/config/%s>%s</a></li>\n",
1005 HOME_PAGE_URL, d->name, d->description);
1006 tmp = strsav(tmp, buf);
1014 /*********************************************************************
1016 * Function : dump_map
1018 * Description : HTML-dump a map for debugging
1021 * 1 : map = map to dump
1023 * Returns : string with HTML
1025 *********************************************************************/
1026 char *dump_map(struct map *map)
1028 struct map *p = map;
1032 ret = strsav(ret, "<table>\n");
1036 ret = strsav(ret, "<tr><td><b>");
1037 ret = strsav(ret, p->name);
1038 ret = strsav(ret, "</b></td><td>");
1039 ret = strsav(ret, p->value);
1040 ret = strsav(ret, "</td></tr>\n");
1044 ret = strsav(ret, "</table>\n");
1051 /*********************************************************************
1053 * Function : add_stats
1055 * Description : Add the blocking statistics to a given map.
1058 * 1 : exports = map to write to.
1060 * Returns : pointer to extended map
1062 *********************************************************************/
1063 struct map *add_stats(struct map *exports)
1065 float perc_rej; /* Percentage of http requests rejected */
1067 int local_urls_read = urls_read;
1068 int local_urls_rejected = urls_rejected;
1071 * Need to alter the stats not to include the fetch of this
1074 * Can't do following thread safely! doh!
1077 * urls_rejected--; * This will be incremented subsequently *
1080 if (local_urls_read == 0)
1082 exports = map_block_killer(exports, "have-stats");
1086 exports = map_block_killer(exports, "have-no-stats");
1088 perc_rej = (float)local_urls_rejected * 100.0F /
1089 (float)local_urls_read;
1091 sprintf(buf, "%d", local_urls_read);
1092 exports = map(exports, "requests-received", 1, buf, 1);
1094 sprintf(buf, "%d", local_urls_rejected);
1095 exports = map(exports, "requests-blocked", 1, buf, 1);
1097 sprintf(buf, "%6.2f", perc_rej);
1098 exports = map(exports, "percent-blocked", 1, buf, 1);
1104 #endif /* def STATISTICS */