conf-file.h 2.51 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
/*
2 3
 * $Id: conf-file.h,v 1.12 2003/08/23 16:38:18 ceder Exp $
 * Copyright (C) 1994, 1998-1999, 2002-2003  Lysator Academic Computer Association.
Per Cederqvist's avatar
Per Cederqvist committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 1, or (at your option) 
 * any later version.
 * 
 * LysKOM is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
Per Cederqvist's avatar
Per Cederqvist committed
23
 * Please report bugs at http://bugzilla.lysator.liu.se/. 
Per Cederqvist's avatar
Per Cederqvist committed
24 25 26 27 28 29 30 31
 */
/* 
 * Read configuration files.
 */

#ifndef CONF_FILE_INCLUDED
#define CONF_FILE_INCLUDED

32 33 34
struct parameter;

struct datatype {
35 36
    /* Assign a value to the parameter pointed to by par.  The value
       comes from the val. */
Per Cederqvist's avatar
Per Cederqvist committed
37
    Success (*assigner)(const char *val, const struct parameter *par);
38 39 40 41 42 43 44 45 46

    /* Constructor: initialize the parameter pointed to by par.  May
       allocate memory.  However, the memory pointed to by par must
       already be allocated.   NULL if no construction is needed. */
    void    (*ctor)(const struct parameter *par);

    /* Destructor: undo whatever the constructor did.  NULL if no
       destruction is needed. */
    void    (*dtor)(const struct parameter *par);
47 48 49 50 51
};

struct parameter {
    const char *name;
    const struct datatype *tp;
Per Cederqvist's avatar
Per Cederqvist committed
52 53
    int   min_assignments;
    int   max_assignments;	/* -1 == eternity */
54
    const char *default_val;	/* String, as read from the config file. */
Per Cederqvist's avatar
Per Cederqvist committed
55
    void *value;
56 57
    const char *default_suffix;	/* Default suffix for assigners that
				   cares about such things. */
Per Cederqvist's avatar
Per Cederqvist committed
58 59
};

60
Success read_config(const char *config_file, const struct parameter *par);
61
void free_config(const struct parameter *par);
Per Cederqvist's avatar
Per Cederqvist committed
62

63 64 65 66 67 68 69 70 71 72
extern const struct datatype cf_text_no;
extern const struct datatype cf_conf_no;
extern const struct datatype cf_int;
extern const struct datatype cf_ulong;
extern const struct datatype cf_uint;
extern const struct datatype cf_string;
extern const struct datatype cf_bool;
extern const struct datatype cf_double;
extern const struct datatype cf_timeval;

Per Cederqvist's avatar
Per Cederqvist committed
73
#endif