You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Martin Kraemer <Ma...@mch.sni.de> on 1997/10/25 01:29:38 UTC
[PATCH] Take 3: Line Number counting in config file (cfg_getline() rewritten)
Okay, Dean, here we go again:
This patch introduces a new structure, as proposed by Dean, which holds
the information necessary to read / close a config file.
/* Common structure for reading of config files / passwd files etc. */
typedef struct {
int (*getch) (void *param); /* a getc()-like function */
void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */
int (*close) (void *param); /* a fclose()-like function */
void *param; /* the argument passed to getc()/close()/gets() */
const char *name; /* the filename / description */
unsigned line_number; /* current line number, starting at 1 */
} configfile_t;
With this patch, there are currently two ways to open a config file,
1) fopen() like:
configfile_t *pcfg_openfile(pool *p, const char *name);
2) custom tailored: assumes you opened the file somehow and want to
handle it using the cfg_getline() function later. You have to provide
a fgetc()-like (and optionally a fgets()-like) function for
reading using whatever pointer argument you passed to open_custom,
and a routine called on config file "close" (which doesn't really
have to close anything).
configfile_t *pcfg_open_custom(pool *p, const char *descr,
void *param, /* passed to getc(param), close(param) */
int(*getc)(void* param),
void *(*gets) (void *buf, size_t bufsiz, void *param),
int(*close)(void* param));
(the gets and close functions may be given as NULL).
Reading happens just like before by calling cfg_getline(), but the third
argument is now a configfile_t*
After finishing the config file, call cfg_closefile(configfile_t *fp);
instead of using fclose().
Line counting happens inside the cfg_getline() call, so it _should_ count
correctly now.... The old cmd structure fields config_file, config_line
and infile are obsoleted by this change and have been removed.
There is DEBUGging code in util.c which lets you monitor the opening and
closing of (and/or each line read from) configfile_t's.
These modifications have been made for the "normal" config files and for
places where cfg_getline() was used before:
main/http_config.c (reading the config)
main/http_core.c (nesting call for <IfModule>)
modules/standard/mod_auth.c (reading auth passwords/groups)
modules/standard/mod_digest.c (reading auth passwords)
modules/standard/mod_imap.c (reading .map files)
modules/standard/mod_info.c (reading the config)
modules/standard/mod_mime.c (reading mime.types)
Martin
--
| S I E M E N S | <Ma...@mch.sni.de> | Siemens Nixdorf
| ------------- | Voice: +49-89-636-46021 | Informationssysteme AG
| N I X D O R F | FAX: +49-89-636-44994 | 81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request
Re: [PATCH] Take 3: Line Number counting in config file (cfg_getline() rewritten)
Posted by Dean Gaudet <dg...@arctic.org>.
On Sat, 25 Oct 1997, Martin Kraemer wrote:
> Okay, Dean, here we go again:
Hey you make it sound like I'm demanding! :)
+1 all the way on this patch!
Dean
Re: [PATCH] Take 3: Line Number counting in config file (cfg_getline() rewritten)
Posted by Paul Sutton <pa...@ukweb.com>.
On Sat, 25 Oct 1997, Martin Kraemer wrote:
> This patch introduces a new structure, as proposed by Dean, which holds
> the information necessary to read / close a config file.
Did I say this works on NT? Anyway it does, and its nice. +1.
//pcs