1 const char parsers_rcs[] = "$Id: parsers.c,v 1.3 2001/05/20 01:21:20 jongfoster Exp $";
2 /*********************************************************************
4 * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $
6 * Purpose : Declares functions to parse/crunch headers and pages.
7 * Functions declared include:
8 * `add_to_iob', `client_cookie_adder', `client_from',
9 * `client_referrer', `client_send_cookie', `client_ua',
10 * `client_uagent', `client_x_forwarded',
11 * `client_x_forwarded_adder', `client_xtra_adder',
12 * `content_type', `crumble', `destroy_list', `enlist',
13 * `flush_socket', `free_http_request', `get_header',
14 * `list_to_text', `match', `parse_http_request', `sed',
15 * and `server_set_cookie'.
17 * Copyright : Written by and Copyright (C) 2001 the SourceForge
18 * IJBSWA team. http://ijbswa.sourceforge.net
20 * Based on the Internet Junkbuster originally written
21 * by and Copyright (C) 1997 Anonymous Coders and
22 * Junkbusters Corporation. http://www.junkbusters.com
24 * This program is free software; you can redistribute it
25 * and/or modify it under the terms of the GNU General
26 * Public License as published by the Free Software
27 * Foundation; either version 2 of the License, or (at
28 * your option) any later version.
30 * This program is distributed in the hope that it will
31 * be useful, but WITHOUT ANY WARRANTY; without even the
32 * implied warranty of MERCHANTABILITY or FITNESS FOR A
33 * PARTICULAR PURPOSE. See the GNU General Public
34 * License for more details.
36 * The GNU General Public License should be included with
37 * this file. If not, you can view it at
38 * http://www.gnu.org/copyleft/gpl.html
39 * or write to the Free Software Foundation, Inc., 59
40 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
44 * Revision 1.3 2001/05/20 01:21:20 jongfoster
45 * Version 2.9.4 checkin.
46 * - Merged popupfile and cookiefile, and added control over PCRS
47 * filtering, in new "permissionsfile".
48 * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
49 * file error you now get a message box (in the Win32 GUI) rather
50 * than the program exiting with no explanation.
51 * - Made killpopup use the PCRS MIME-type checking and HTTP-header
53 * - Removed tabs from "config"
54 * - Moved duplicated url parsing code in "loaders.c" to a new funcition.
55 * - Bumped up version number.
57 * Revision 1.2 2001/05/17 23:02:36 oes
58 * - Made referrer option accept 'L' as a substitute for 'ยง'
60 * Revision 1.1.1.1 2001/05/15 13:59:01 oes
61 * Initial import of version 2.9.3 source tree
64 *********************************************************************/
70 #include <sys/types.h>
88 #include "jbsockets.h"
91 const char parsers_h_rcs[] = PARSERS_H_VERSION;
93 /* Fix a problem with Solaris. There should be no effect on other
95 * Solaris's isspace() is a macro which uses it's argument directly
96 * as an array index. Therefore we need to make sure that high-bit
97 * characters generate +ve values, and ideally we also want to make
98 * the argument match the declared parameter type of "int".
100 * Why did they write a character function that can't take a simple
101 * "char" argument? Doh!
103 #define ijb_isupper(__X) isupper((int)(unsigned char)(__X))
104 #define ijb_tolower(__X) tolower((int)(unsigned char)(__X))
107 const struct parsers client_patterns[] = {
108 { "referer:", 8, client_referrer },
109 { "user-agent:", 11, client_uagent },
110 { "ua-", 3, client_ua },
111 { "from:", 5, client_from },
112 { "cookie:", 7, client_send_cookie },
113 { "x-forwarded-for:", 16, client_x_forwarded },
114 { "proxy-connection:", 17, crumble },
116 { "Accept-Encoding: gzip", 21, crumble },
117 #endif /* def DENY_GZIP */
118 #if defined(DETECT_MSIE_IMAGES)
119 { "Accept:", 7, client_accept },
120 #endif /* defined(DETECT_MSIE_IMAGES) */
122 { "Host:", 5, client_host },
123 #endif /* def FORCE_LOAD */
124 /* { "if-modified-since:", 18, crumble }, */
128 const struct interceptors intercept_patterns[] = {
129 { "show-proxy-args", 14, show_proxy_args },
130 { "ijb-send-banner", 14, ijb_send_banner },
132 { "ij-untrusted-url", 15, ij_untrusted_url },
133 #endif /* def TRUST_FILES */
137 const struct parsers server_patterns[] = {
138 { "set-cookie:", 11, server_set_cookie },
139 { "connection:", 11, crumble },
140 #if defined(PCRS) || defined(KILLPOPUPS)
141 { "Content-Type:", 13, content_type },
142 { "Content-Length:", 15, crumble },
143 #endif /* defined(PCRS) || defined(KILLPOPUPS) */
148 void (* const add_client_headers[])(struct client_state *) = {
150 client_x_forwarded_adder,
156 void (* const add_server_headers[])(struct client_state *) = {
161 /*********************************************************************
165 * Description : Do a `strncmpic' on every pattern in pats.
168 * 1 : buf = a string to match to a list of patterns
169 * 2 : pats = list of strings to compare against buf.
171 * Returns : Return the matching "struct parsers *",
172 * or NULL if no pattern matches.
174 *********************************************************************/
175 static const struct parsers *match(char *buf, const struct parsers *pats)
177 const struct parsers *v;
182 log_error(LOG_LEVEL_ERROR, "NULL parameter to match()");
186 for (v = pats; v->str ; v++)
188 if (strncmpic(buf, v->str, v->len) == 0)
198 /*********************************************************************
200 * Function : flush_socket
202 * Description : Write any pending "buffered" content.
205 * 1 : fd = file descriptor of the socket to read
206 * 2 : csp = Current client state (buffers, headers, etc...)
208 * Returns : On success, the number of bytes written are returned (zero
209 * indicates nothing was written). On error, -1 is returned,
210 * and errno is set appropriately. If count is zero and the
211 * file descriptor refers to a regular file, 0 will be
212 * returned without causing any other effect. For a special
213 * file, the results are not portable.
215 *********************************************************************/
216 int flush_socket(int fd, struct client_state *csp)
218 struct iob *iob = csp->iob;
219 int n = iob->eod - iob->cur;
226 n = write_socket(fd, iob->cur, n);
227 iob->eod = iob->cur = iob->buf;
233 /*********************************************************************
235 * Function : add_to_iob
237 * Description : Add content to the buffered page.
240 * 1 : csp = Current client state (buffers, headers, etc...)
241 * 2 : buf = holds the content to be added to the page
242 * 3 : n = number of bytes to be added
244 * Returns : Number of bytes in the content buffer.
246 *********************************************************************/
247 int add_to_iob(struct client_state *csp, char *buf, int n)
249 struct iob *iob = csp->iob;
253 have = iob->eod - iob->cur;
262 if ((p = (char *)malloc(need + 1)) == NULL)
264 log_error(LOG_LEVEL_ERROR, "malloc() iob failed: %E");
270 /* there is something in the buffer - save it */
271 memcpy(p, iob->cur, have);
273 /* replace the buffer with the new space */
277 /* point to the end of the data */
282 /* the buffer is empty, free it and reinitialize */
287 /* copy the new data into the iob buffer */
290 /* point to the end of the data */
293 /* null terminate == cheap insurance */
296 /* set the pointers to the new values */
305 /*********************************************************************
307 * Function : get_header
309 * Description : This (odd) routine will parse the csp->iob
312 * 1 : csp = Current client state (buffers, headers, etc...)
314 * Returns : Any one of the following:
316 * 1) a pointer to a dynamically allocated string that contains a header line
317 * 2) NULL indicating that the end of the header was reached
318 * 3) "" indicating that the end of the iob was reached before finding
319 * a complete header line.
321 *********************************************************************/
322 char *get_header(struct client_state *csp)
328 if ((iob->cur == NULL)
329 || ((p = strchr(iob->cur, '\n')) == NULL))
331 return(""); /* couldn't find a complete header */
336 ret = strdup(iob->cur);
340 if ((q = strchr(ret, '\r'))) *q = '\0';
342 /* is this a blank linke (i.e. the end of the header) ? */
354 /*********************************************************************
358 * Description : Append a string into a specified string list.
361 * 1 : h = pointer to list 'dummy' header
362 * 2 : s = string to add to the list
366 *********************************************************************/
367 void enlist(struct list *h, const char *s)
369 struct list *n = (struct list *)malloc(sizeof(*n));
392 /*********************************************************************
394 * Function : destroy_list
396 * Description : Destroy a string list (opposite of enlist)
399 * 1 : h = pointer to list 'dummy' header
403 *********************************************************************/
404 void destroy_list(struct list *h)
408 for (p = h->next; p ; p = n)
415 memset(h, '\0', sizeof(*h));
420 /*********************************************************************
422 * Function : list_to_text
424 * Description : "Flaten" a string list into 1 long \r\n delimited string.
427 * 1 : h = pointer to list 'dummy' header
429 * Returns : NULL on malloc error, else new long string.
431 *********************************************************************/
432 static char *list_to_text(struct list *h)
441 for (p = h->next; p ; p = p->next)
445 size += strlen(p->str) + 2;
449 if ((ret = (char *)malloc(size + 1)) == NULL)
458 for (p = h->next; p ; p = p->next)
464 *s++ = '\r'; *s++ = '\n';
473 /*********************************************************************
477 * Description : add, delete or modify lines in the HTTP header streams.
478 * On entry, it receives a linked list of headers space
479 * that was allocated dynamically (both the list nodes
480 * and the header contents).
482 * As a side effect it frees the space used by the original
486 * 1 : pats = list of patterns to match against headers
487 * 2 : more_headers = list of functions to add more
488 * headers (client or server)
489 * 3 : csp = Current client state (buffers, headers, etc...)
491 * Returns : Single pointer to a fully formed header.
493 *********************************************************************/
494 char *sed(const struct parsers pats[], void (* const more_headers[])(struct client_state *), struct client_state *csp)
497 const struct parsers *v;
501 for (p = csp->headers->next; p ; p = p->next)
503 log_error(LOG_LEVEL_HEADER, "scan: %s", p->str);
505 if ((v = match(p->str, pats)))
507 hdr = v->parser(v, p->str, csp);
514 /* place any additional headers on the csp->headers list */
515 for (f = more_headers; *f ; f++)
520 /* add the blank line at the end of the header */
521 enlist(csp->headers, "");
523 hdr = list_to_text(csp->headers);
530 /*********************************************************************
532 * Function : free_http_request
534 * Description : Freez a http_request structure
537 * 1 : http = points to a http_request structure to free
541 *********************************************************************/
542 void free_http_request(struct http_request *http)
547 freez(http->hostport);
554 /*********************************************************************
556 * Function : parse_http_request
558 * Description : Parse out the host and port from the URL. Find the
559 * hostname & path, port (if ':'), and/or password (if '@')
562 * 1 : req = URL (or is it URI?) to break down
563 * 2 : http = pointer to the http structure to hold elements
564 * 3 : csp = Current client state (buffers, headers, etc...)
568 *********************************************************************/
569 void parse_http_request(char *req, struct http_request *http, struct client_state *csp)
571 char *buf, *v[10], *url, *p;
574 memset(http, '\0', sizeof(*http));
576 http->cmd = strdup(req);
580 n = ssplit(buf, " \r\n", v, SZ(v), 1, 1);
584 /* this could be a CONNECT request */
585 if (strcmpic(v[0], "connect") == 0)
588 http->gpc = strdup(v[0]);
589 http->hostport = strdup(v[1]);
590 http->ver = strdup(v[2]);
595 /* This next line is a little ugly, but it simplifies the if statement below. */
596 /* Basically if using webDAV, we want the OR condition to use these too. */
600 * These are the headers as defined in RFC2518 to add webDAV support
603 #define OR_WEBDAV || \
604 (0 == strcmpic(v[0], "propfind")) || \
605 (0 == strcmpic(v[0], "proppatch")) || \
606 (0 == strcmpic(v[0], "move")) || \
607 (0 == strcmpic(v[0], "copy")) || \
608 (0 == strcmpic(v[0], "mkcol")) || \
609 (0 == strcmpic(v[0], "lock")) || \
610 (0 == strcmpic(v[0], "unlock"))
612 #else /* No webDAV support is enabled. Provide an empty OR_WEBDAV macro. */
618 /* or it could be a GET or a POST (possibly webDAV too) */
619 if ((strcmpic(v[0], "get") == 0) ||
620 (strcmpic(v[0], "head") == 0) OR_WEBDAV ||
621 (strcmpic(v[0], "post") == 0))
624 http->gpc = strdup(v[0]);
626 http->ver = strdup(v[2]);
628 if (strncmpic(url, "http://", 7) == 0)
632 else if (strncmpic(url, "https://", 8) == 0)
641 if (url && (p = strchr(url, '/')))
643 http->path = strdup(p);
645 http->hostport = strdup(url);
653 if (http->hostport == NULL)
655 free_http_request(http);
659 buf = strdup(http->hostport);
662 /* check if url contains password */
663 n = ssplit(buf, "@", v, SZ(v), 1, 1);
666 char * newbuf = NULL;
667 newbuf = strdup(v[1]);
672 n = ssplit(buf, ":", v, SZ(v), 1, 1);
676 http->host = strdup(v[0]);
682 http->host = strdup(v[0]);
683 http->port = atoi(v[1]);
688 if (http->host == NULL)
690 free_http_request(http);
693 if (http->path == NULL)
695 http->path = strdup("");
701 /* here begins the family of parser functions that reformat header lines */
704 /*********************************************************************
708 * Description : This is called if a header matches a pattern to "crunch"
711 * 1 : v = Pointer to parsers structure, which basically holds
712 * headers (client or server) that we want to "crunch"
713 * 2 : s = header (from sed) to "crunch"
714 * 3 : csp = Current client state (buffers, headers, etc...)
716 * Returns : Always NULL.
718 *********************************************************************/
719 char *crumble(const struct parsers *v, char *s, struct client_state *csp)
721 log_error(LOG_LEVEL_HEADER, "crunch!");
727 #if defined(PCRS) || defined(KILLPOPUPS)
729 /*********************************************************************
731 * Function : content_type
733 * Description : Is this a text/* or javascript MIME Type?
737 * 2 : s = header string we are "considering"
738 * 3 : csp = Current client state (buffers, headers, etc...)
740 * Returns : A duplicate string pointer to this header (ie. pass thru)
742 *********************************************************************/
743 char *content_type(const struct parsers *v, char *s, struct client_state *csp)
745 if (strstr (s, " text/") || strstr (s, "application/x-javascript"))
754 #endif /* defined(PCRS) || defined(KILLPOPUPS) */
757 /*********************************************************************
759 * Function : client_referrer
761 * Description : Handle the "referer" config setting properly.
766 * 2 : s = header (from sed) to "crunch"
767 * 3 : csp = Current client state (buffers, headers, etc...)
769 * Returns : NULL if crunched, or a malloc'ed string with the original
772 *********************************************************************/
773 char *client_referrer(const struct parsers *v, char *s, struct client_state *csp)
776 /* Since the referrer can include the prefix even
777 * even if the request itself is non-forced, we must
778 * clean it unconditionally
780 strclean(s, FORCE_PREFIX);
781 #endif /* def FORCE_LOAD */
783 csp->referrer = strdup(s);
785 if (referrer == NULL)
787 log_error(LOG_LEVEL_HEADER, "crunch!");
791 if (*referrer == '.')
796 if (*referrer == '@')
798 if (csp->permissions & PERMIT_COOKIE_READ)
804 log_error(LOG_LEVEL_HEADER, "crunch!");
810 * New option ยง or L: Forge a referer as http://[hostname:port of REQUEST]/
811 * to fool stupid checks for in-site links
814 if (*referrer == 'ยง' || *referrer == 'L')
816 if (csp->permissions & PERMIT_COOKIE_READ)
822 log_error(LOG_LEVEL_HEADER, "crunch+forge!");
823 s = strsav(NULL, "Referer: ");
824 s = strsav(s, "http://");
825 s = strsav(s, csp->http->hostport);
831 log_error(LOG_LEVEL_HEADER, "modified");
833 s = strsav( NULL, "Referer: " );
834 s = strsav( s, referrer );
840 /*********************************************************************
842 * Function : client_uagent
844 * Description : Handle the "user-agent" config setting properly.
849 * 2 : s = header (from sed) to "crunch"
850 * 3 : csp = Current client state (buffers, headers, etc...)
852 * Returns : A malloc'ed pointer to the default agent, or
853 * a malloc'ed string pointer to this header (ie. pass thru).
855 *********************************************************************/
856 char *client_uagent(const struct parsers *v, char *s, struct client_state *csp)
858 #ifdef DETECT_MSIE_IMAGES
859 if (strstr (s, "MSIE "))
861 /* This is Microsoft Internet Explorer.
862 * Enable auto-detect.
864 csp->accept_types |= ACCEPT_TYPE_IS_MSIE;
866 #endif /* def DETECT_MSIE_IMAGES */
870 log_error(LOG_LEVEL_HEADER, "default");
871 return(strdup(DEFAULT_USER_AGENT));
881 if (csp->permissions & PERMIT_COOKIE_READ)
887 log_error(LOG_LEVEL_HEADER, "default");
888 return(strdup(DEFAULT_USER_AGENT));
892 log_error(LOG_LEVEL_HEADER, "modified");
894 s = strsav( NULL, "User-Agent: " );
895 s = strsav( s, uagent );
901 /*********************************************************************
903 * Function : client_ua
905 * Description : Handle "ua-" headers properly. Called from `sed'.
909 * 2 : s = header (from sed) to "crunch"
910 * 3 : csp = Current client state (buffers, headers, etc...)
912 * Returns : NULL if crunched, or a malloc'ed string to original header
914 *********************************************************************/
915 char *client_ua(const struct parsers *v, char *s, struct client_state *csp)
919 log_error(LOG_LEVEL_HEADER, "crunch!");
930 if (csp->permissions & PERMIT_COOKIE_READ)
936 log_error(LOG_LEVEL_HEADER, "crunch!");
941 log_error(LOG_LEVEL_HEADER, "crunch!");
947 /*********************************************************************
949 * Function : client_from
951 * Description : Handle the "from" config setting properly.
956 * 2 : s = header (from sed) to "crunch"
957 * 3 : csp = Current client state (buffers, headers, etc...)
959 * Returns : NULL if crunched, or a malloc'ed string to
960 * modified/original header.
962 *********************************************************************/
963 char *client_from(const struct parsers *v, char *s, struct client_state *csp)
965 /* if not set, zap it */
968 log_error(LOG_LEVEL_HEADER, "crunch!");
977 log_error(LOG_LEVEL_HEADER, " modified");
979 s = strsav( NULL, "From: " );
980 s = strsav( s, from );
986 /*********************************************************************
988 * Function : client_send_cookie
990 * Description : Handle the "cookie" header properly. Called from `sed'.
991 * If cookie is accepted, add it to the cookie_list,
992 * else we crunch it. Mmmmmmmmmmm ... cookie ......
995 * 1 : v = pattern of cookie `sed' found matching
996 * 2 : s = header (from sed) to "crunch"
997 * 3 : csp = Current client state (buffers, headers, etc...)
999 * Returns : Always NULL.
1001 *********************************************************************/
1002 char *client_send_cookie(const struct parsers *v, char *s, struct client_state *csp)
1004 if (csp->permissions & PERMIT_COOKIE_READ)
1006 enlist(csp->cookie_list, s + v->len + 1);
1010 log_error(LOG_LEVEL_HEADER, " crunch!");
1014 * Always return NULL here. The cookie header
1015 * will be sent at the end of the header.
1022 /*********************************************************************
1024 * Function : client_x_forwarded
1026 * Description : Handle the "x-forwarded-for" config setting properly,
1027 * also used in the add_client_headers list. Called from `sed'.
1031 * 2 : s = header (from sed) to "crunch"
1032 * 3 : csp = Current client state (buffers, headers, etc...)
1034 * Returns : Always NULL.
1036 *********************************************************************/
1037 char *client_x_forwarded(const struct parsers *v, char *s, struct client_state *csp)
1041 csp->x_forwarded = strdup(s);
1045 * Always return NULL, since this information
1046 * will be sent at the end of the header.
1053 #if defined(DETECT_MSIE_IMAGES)
1054 /*********************************************************************
1056 * Function : client_accept
1058 * Description : Detect whether the client wants HTML or an image.
1059 * Clients do not always make this information available
1060 * in a sane way. Always passes the header through
1061 * the proxy unchanged.
1065 * 2 : s = Header string. Null terminated.
1066 * 3 : csp = Current client state (buffers, headers, etc...)
1068 * Returns : Duplicate of argument s.
1070 *********************************************************************/
1071 char *client_accept(const struct parsers *v, char *s, struct client_state *csp)
1073 #ifdef DETECT_MSIE_IMAGES
1074 if (strstr (s, "image/gif"))
1076 /* Client will accept HTML. If this seems counterintuitive,
1079 csp->accept_types |= ACCEPT_TYPE_MSIE_HTML;
1083 csp->accept_types |= ACCEPT_TYPE_MSIE_IMAGE;
1085 #endif /* def DETECT_MSIE_IMAGES */
1090 #endif /* defined(DETECT_MSIE_IMAGES) */
1094 /* the following functions add headers directly to the header list */
1097 /*********************************************************************
1099 * Function : client_cookie_adder
1101 * Description : Used in the add_client_headers list. Called from `sed'.
1104 * 1 : csp = Current client state (buffers, headers, etc...)
1108 *********************************************************************/
1109 void client_cookie_adder(struct client_state *csp)
1115 for (l = csp->cookie_list->next; l ; l = l->next)
1119 tmp = strsav(tmp, "; ");
1121 tmp = strsav(tmp, l->str);
1124 for (l = wafer_list->next; l ; l = l->next)
1128 tmp = strsav(tmp, "; ");
1131 if ((e = cookie_encode(l->str)))
1133 tmp = strsav(tmp, e);
1142 ret = strdup("Cookie: ");
1143 ret = strsav(ret, tmp);
1144 log_error(LOG_LEVEL_HEADER, "addh: %s", ret);
1145 enlist(csp->headers, ret);
1153 /*********************************************************************
1155 * Function : client_xtra_adder
1157 * Description : Used in the add_client_headers list. Called from `sed'.
1160 * 1 : csp = Current client state (buffers, headers, etc...)
1164 *********************************************************************/
1165 void client_xtra_adder(struct client_state *csp)
1169 for (l = xtra_list->next; l ; l = l->next)
1171 log_error(LOG_LEVEL_HEADER, "addh: %s", l->str);
1172 enlist(csp->headers, l->str);
1178 /*********************************************************************
1180 * Function : client_x_forwarded_adder
1182 * Description : Used in the add_client_headers list. Called from `sed'.
1185 * 1 : csp = Current client state (buffers, headers, etc...)
1189 *********************************************************************/
1190 void client_x_forwarded_adder(struct client_state *csp)
1194 if (add_forwarded == 0) return;
1196 if (csp->x_forwarded)
1198 p = strsav(p, csp->x_forwarded);
1199 p = strsav(p, ", ");
1200 p = strsav(p, csp->ip_addr_str);
1204 p = strsav(p, "X-Forwarded-For: ");
1205 p = strsav(p, csp->ip_addr_str);
1208 log_error(LOG_LEVEL_HEADER, "addh: %s", p);
1209 enlist(csp->headers, p);
1214 /*********************************************************************
1216 * Function : server_set_cookie
1218 * Description : Handle the server "cookie" header properly.
1219 * Log cookie to the jar file. Then "crunch" it,
1220 * or accept it. Called from `sed'.
1223 * 1 : v = parser pattern that matched this header
1224 * 2 : s = header that matched this pattern
1225 * 3 : csp = Current client state (buffers, headers, etc...)
1227 * Returns : `crumble' or a newly malloc'ed string.
1229 *********************************************************************/
1230 char *server_set_cookie(const struct parsers *v, char *s, struct client_state *csp)
1235 fprintf(jar, "%s\t%s\n", csp->http->host, (s + v->len + 1));
1237 #endif /* def JAR_FILES */
1239 if (!(csp->permissions & PERMIT_COOKIE_SET))
1241 return(crumble(v, s, csp));
1250 /*********************************************************************
1252 * Function : client_host
1254 * Description : Clean the FORCE_PREFIX out of the 'host' http
1255 * header, if we use force
1259 * 2 : s = header (from sed) to clean
1260 * 3 : csp = Current client state (buffers, headers, etc...)
1262 * Returns : A malloc'ed pointer to the cleaned host header
1264 *********************************************************************/
1265 char *client_host(const struct parsers *v, char *s, struct client_state *csp)
1267 char *cleanhost = strdup(s);
1270 strclean(cleanhost, FORCE_PREFIX);
1274 #endif /* def FORCE_LOAD */
1278 /*********************************************************************
1280 * Function : strclean
1282 * Description : In-Situ-Eliminate all occurances of substring in
1286 * 1 : string = string to clean
1287 * 2 : substring = substring to eliminate
1289 * Returns : Number of eliminations
1291 *********************************************************************/
1292 int strclean(const char *string, const char *substring)
1294 int hits = 0, len = strlen(substring);
1297 while((pos = strstr(string, substring)))
1304 while (*p++ != '\0');
1311 #endif /* def FORCE_LOAD */