-const char loaders_rcs[] = "$Id: loaders.c,v 1.4 2001/05/22 18:56:28 oes Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.5 2001/05/23 10:39:05 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
*
* Revisions :
* $Log: loaders.c,v $
+ * Revision 1.5 2001/05/23 10:39:05 oes
+ * - Added support for escaping the comment character
+ * in config files by a backslash
+ * - Added support for line continuation in config
+ * files
+ * - Fixed a buffer overflow bug with long config lines
+ *
* Revision 1.4 2001/05/22 18:56:28 oes
* CRLF -> LF
*
char linebuf[BUFSIZ];
int contflag = 0;
- *buf = '\0';
+ *buf = '\0';
while (fgets(linebuf, sizeof(linebuf), fp))
{
}
/* Line continuation? Trim escape and set flag. */
- if ((p != linebuf) && (*--p == '\\'))
- {
- contflag = 1;
- *p = '\0';
- }
+ 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';
- }
- }
+ /* ..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;
/* More paranoia. This if statement is always true. */
if (*linebuf)
{
- strncat(buf, linebuf, buflen - strlen(buf));
- if (contflag)
- {
- contflag = 0;
- continue;
- }
- else
- {
- return buf;
- }
+ strncat(buf, linebuf, buflen - strlen(buf));
+ if (contflag)
+ {
+ contflag = 0;
+ continue;
+ }
+ else
+ {
+ return buf;
+ }
}
}
}