# Sample Configuration file for the Internet Junkbuster 2.0
#
-# $Id: config,v 1.3 2001/05/20 01:21:20 jongfoster Exp $
+# $Id: config,v 1.4 2001/05/22 17:43:35 oes Exp $
#
# Table of Contents
#
# Indicates that the blockfile is named 'blocklist.ini'.
#
-# The '#' indicates a comment. Any part of a line following a # is
-# ignored.
+# The '#' indicates a comment. Any part of a line following a '#' is
+# ignored, except if the '#' is preceded by a '\'.
#
# Thus, by placing a # at the start of an existing configuration line,
# you can make it a comment and it will be treated as if it weren't there.
# off features: If you comment out the "logfile" line, junkbuster will
# not log at all. Watch for the "default:" section in each explanation
# to see what happens if the option is left unset (or commented out).
+#
+# Long lines can be continued on the next line by using a `\' as
+# the last character. This also works if comments are present in
+# between.
#
#
-const char loaders_rcs[] = "$Id: loaders.c,v 1.3 2001/05/20 01:21:20 jongfoster Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.4 2001/05/22 18:56:28 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
*
* Revisions :
* $Log: loaders.c,v $
+ * Revision 1.4 2001/05/22 18:56:28 oes
+ * CRLF -> LF
+ *
* Revision 1.3 2001/05/20 01:21:20 jongfoster
* Version 2.9.4 checkin.
* - Merged popupfile and cookiefile, and added control over PCRS
* Function : read_config_line
*
* Description : Read a single non-empty line from a file and return
- * it. Trims comments, leading and trailing whitespace.
- * Also wites the file to fs->proxy_args.
+ * it. Trims comments, leading and trailing whitespace
+ * and respects escaping of newline and comment char.
+ * Also writes the file to fs->proxy_args.
*
* Parameters :
* 1 : buf = Buffer to use.
{
char *p, *q;
char linebuf[BUFSIZ];
+ int contflag = 0;
+
+ *buf = '\0';
while (fgets(linebuf, sizeof(linebuf), fp))
{
}
#endif /* ndef SPLIT_PROXY_ARGS */
- /* Trim off newline and any comment */
- if ((p = strpbrk(linebuf, "\r\n#")) != NULL)
+ /* Trim off newline */
+ if ((p = strpbrk(linebuf, "\r\n")) != NULL)
{
*p = '\0';
}
+
+ /* Line continuation? Trim escape and set flag. */
+ if ((p != linebuf) && (*--p == '\\'))
+ {
+ contflag = 1;
+ *p = '\0';
+ }
+
+ /* If there's a comment char.. */
+ if ((p = strpbrk(linebuf, "#")) != NULL)
+ {
+ /* ..and it's escaped, left-shift the line over the escape. */
+ if ((p != linebuf) && (*(p-1) == '\\'))
+ {
+ q = p-1;
+ while ((*q++ = *p++) != '\0') /* nop */;
+ }
+ /* Else, chop off the rest of the line */
+ else
+ {
+ *p = '\0';
+ }
+ }
/* Trim leading whitespace */
p = linebuf;
while (*p && ijb_isspace(*p))
{
- *p++;
+ p++;
}
if (*p)
/* More paranoia. This if statement is always true. */
if (*linebuf)
{
- strcpy(buf, linebuf);
- return buf;
+ strncat(buf, linebuf, buflen - strlen(buf));
+ if (contflag)
+ {
+ contflag = 0;
+ continue;
+ }
+ else
+ {
+ return buf;
+ }
}
}
}