Check-in [c3d71a3b91]
Overview
Comment:Exposed lc_handle_type() function to public (needs documentation) Updated lc_register_callback documentation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c3d71a3b91475a74fe062297922a37343f630e65
User & Date: rkeene on 2006-12-17 02:49:01
Other Links: manifest | tags
Context
2006-12-17
03:04
Added an "ADDR" var type (since it was already documented) Removed brain-dead (void *) to type casts in lc_handle_...() check-in: e07808cac6 user: rkeene tags: trunk
02:49
Exposed lc_handle_type() function to public (needs documentation) Updated lc_register_callback documentation check-in: c3d71a3b91 user: rkeene tags: trunk
00:11
Updated libconfig to reset lc_errno at the start of each function check-in: c8032b5a5e user: rkeene tags: trunk
Changes

Modified lc_register_callback.3.in from [caede5b68d] to [9235a07e28].

   169    169   int callback_ifmodule(const char *shortvar, const char *var,
   170    170                         const char *arguments, const char *value,
   171    171                         lc_flags_t flags, void *extra) {
   172    172   	if (flags == LC_FLAGS_SECTIONEND) {
   173    173   		return(LC_CBRET_OKAY);
   174    174   	}
   175    175   
   176         -	if (flags != LC_FLAGS_SECTIONSTART) {
   177         -		lc_seterrstr("IfModule can only be used as a \\
   178         -		              section.");
   179         -		return(LC_CBRET_ERROR);
   180         -	}
   181    176   	if (arguments == NULL) {
   182    177   		lc_seterrstr("You must specify an argument to \\
   183    178   		              IfModule.");
   184    179   		return(LC_CBRET_ERROR);
   185    180   	}
   186    181   
   187    182   	printf("IfModule %s\\n", arguments);
................................................................................
   190    185   		return(LC_CBRET_IGNORESECTION);
   191    186   	}
   192    187   
   193    188   	return(LC_CBRET_OKAY);
   194    189   }
   195    190   
   196    191   int main(int argc, char **argv) {
   197         -	int lc_rc_ret = 0, lc_p_ret;
          192  +	int lc_rc_ret, lc_p_ret;
   198    193   
   199         -	lc_rc_ret = lc_register_callback("*.IfModule", 0, LC_VAR_NONE,
          194  +	lc_rc_ret = lc_register_callback("*.IfModule", 0, LC_VAR_SECTION,
   200    195   	                                 callback_ifmodule, NULL);
   201    196   
   202    197   	if (lc_rc_ret != 0) {
   203    198   		fprintf(stderr, "Error registering callback.\\n");
   204    199   		return(EXIT_FAILURE);
   205    200   	}
   206    201   

Modified libconfig.c from [3125d83cbc] to [bc792aa0c5].

   296    296   
   297    297   	dataval = data;
   298    298   	*dataval = lc_process_size(value, endptr);
   299    299   
   300    300   	return(0);
   301    301   }
   302    302   
   303         -
   304         -static int lc_handle_type(lc_var_type_t type, const char *value, void *data) {
          303  +int lc_handle_type(lc_var_type_t type, const char *value, void *data) {
   305    304   	const char *next;
   306    305   	int is_list;
   307    306   
   308    307   	is_list = type & LC_VAR_LIST;
   309    308   
   310    309   	if (is_list == LC_VAR_LIST) {
          310  +		/* XXX */
   311    311   	}
   312    312   
   313    313   	switch (type) {
   314    314   		case LC_VAR_STRING:
   315    315   			return(lc_process_var_string(data, value, &next));
   316    316   			break;
   317    317   		case LC_VAR_LONG_LONG:
................................................................................
   373    373   			return(-1);
   374    374   		case LC_VAR_NONE:
   375    375   		case LC_VAR_UNKNOWN:
   376    376   		case LC_VAR_SECTION:
   377    377   		case LC_VAR_SECTIONSTART:
   378    378   		case LC_VAR_SECTIONEND:
   379    379   			return(0);
   380         -			break;
          380  +		case LC_VAR_LIST:
          381  +			return(0);
   381    382   	}
   382    383   
   383    384   	return(-1);
   384    385   }
   385    386   
   386    387   static int lc_handle(struct lc_varhandler_st *handler, const char *var, const char *varargs, const char *value, lc_flags_t flags) {
   387    388   	const char *localvar = NULL;
................................................................................
   397    398   	} else {
   398    399   		localvar = NULL;
   399    400   	}
   400    401   
   401    402   	switch (handler->mode) {
   402    403   		case LC_MODE_CALLBACK:
   403    404   			if (handler->callback != NULL) {
          405  +				lc_errno = LC_ERR_NONE;
          406  +				lc_err_usererrmsg = NULL;
          407  +
   404    408   				retval = handler->callback(localvar, var, varargs, value, flags, handler->extra);
   405    409   				if (retval < 0) {
   406    410   					lc_errno = LC_ERR_CALLBACK;
   407    411   				}
   408    412   				return(retval);
   409    413   			}
   410    414   			break;

Modified libconfig.h.in from [a51c1e0b82] to [14f8a60094].

     2      2   !define _RSK_LIBCONFIG_H
     3      3   !ifdef __cplusplus
     4      4   extern "C" {
     5      5   !endif
     6      6   
     7      7   __BLANK_LINE__
     8      8   
     9         -!define LC_VAR_LIST 0x80
    10         -
    11         -__BLANK_LINE__
    12         -
    13      9   typedef enum {
    14     10           LC_CONF_SECTION,
    15     11           LC_CONF_APACHE,
    16     12           LC_CONF_COLON,
    17     13           LC_CONF_EQUAL,
    18     14           LC_CONF_SPACE,
    19     15           LC_CONF_XML
................................................................................
    45     41           LC_VAR_SIZE_SIZE_T,
    46     42           LC_VAR_CIDR,
    47     43           LC_VAR_IP,
    48     44           LC_VAR_IP4,
    49     45           LC_VAR_IP6,
    50     46           LC_VAR_HOSTNAME4,
    51     47           LC_VAR_HOSTNAME6,
           48  +        LC_VAR_LIST = 0x80
    52     49   } lc_var_type_t;
    53     50   
    54     51   __BLANK_LINE__
    55     52   
    56     53   typedef enum {
    57     54           LC_FLAGS_VAR,
    58     55           LC_FLAGS_CMDLINE,
................................................................................
    79     76   int lc_process(int argc, char **argv, const char *appname, lc_conf_type_t type, const char *extra);
    80     77   int lc_register_callback(const char *var, char opt, lc_var_type_t type, int (*callback)(const char *, const char *, const char *, const char *, lc_flags_t, void *), void *extra);
    81     78   int lc_register_var(const char *var, lc_var_type_t type, void *data, char opt);
    82     79   lc_err_t lc_geterrno(void);
    83     80   void lc_seterrstr(const char *usererrstr);
    84     81   char *lc_geterrstr(void);
    85     82   int lc_process_file(const char *appname, const char *pathname, lc_conf_type_t type);
           83  +int lc_handle_type(lc_var_type_t type, const char *value, void *data);
    86     84   void lc_cleanup(void);
    87     85   
    88     86   __BLANK_LINE__
    89     87   
    90     88   !define LC_CBRET_IGNORESECTION (255)
    91     89   !define LC_CBRET_OKAY (0)
    92     90   !define LC_CBRET_ERROR (-1)