| 1 |
tdb |
1.1 |
/* config.c - routines for parsing configuration files */ |
| 2 |
|
|
|
| 3 |
|
|
/* Copyright 1992 Mark Russell, University of Kent at Canterbury. |
| 4 |
|
|
* |
| 5 |
|
|
* You can do what you like with this source code as long as |
| 6 |
|
|
* you don't try to make money out of it and you include an |
| 7 |
|
|
* unaltered copy of this message (including the copyright). |
| 8 |
|
|
*/ |
| 9 |
|
|
|
| 10 |
tdb |
1.2 |
char ukcprog_config_sccsid[] = "$Id: config.c,v 1.1 2002/03/08 14:37:29 tdb Exp $ UKC"; |
| 11 |
tdb |
1.1 |
|
| 12 |
|
|
#include <stdio.h> /* for NULL */ |
| 13 |
|
|
#include <ctype.h> |
| 14 |
|
|
#include <string.h> |
| 15 |
|
|
|
| 16 |
|
|
#include "ukcprog.h" |
| 17 |
|
|
|
| 18 |
|
|
/* Trim anything following a `#' and leading and trailing whitespace |
| 19 |
|
|
* from a line. We do this in place and return a pointer to the |
| 20 |
|
|
* trimmed line. |
| 21 |
|
|
*/ |
| 22 |
|
|
char * |
| 23 |
|
|
config_trim_line(line) |
| 24 |
|
|
char *line; |
| 25 |
|
|
{ |
| 26 |
|
|
char *hash; |
| 27 |
|
|
int len; |
| 28 |
|
|
|
| 29 |
|
|
while (isspace(*line)) |
| 30 |
|
|
++line; |
| 31 |
|
|
if ((hash = strchr(line, '#')) != NULL) |
| 32 |
|
|
*hash = '\0'; |
| 33 |
|
|
|
| 34 |
|
|
len = strlen(line); |
| 35 |
|
|
while (--len >= 0) { |
| 36 |
|
|
if (!isspace(line[len])) |
| 37 |
|
|
break; |
| 38 |
|
|
} |
| 39 |
|
|
line[len + 1] = '\0'; |
| 40 |
|
|
|
| 41 |
|
|
return line; |
| 42 |
|
|
} |