/* This is useful to build named structs, like option or property sets. */
-/* Authors: Martin Quinson */
-/* Copyright (C) 2001,2002,2003,2004 the OURAGAN project. */
+/* Copyright (c) 2001,2002,2003,2004 Martin Quinson. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
- under the terms of the license (GNU LGPL) which comes with this package. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef _GRAS_CONFIG_H_
-#define _GRAS_CONFIG_H_
+#ifndef _XBT_CONFIG_H_
+#define _XBT_CONFIG_H_
-typedef struct {
- char *name;
- int port;
-} gras_host_t;
+#include "xbt/dynar.h"
+BEGIN_DECL
+
/* For now, a config is only a special dynar. But don't rely on it, */
/* it may change in the future. */
-typedef gras_dynar_t gras_cfg_t;
+typedef xbt_dynar_t xbt_cfg_t;
/* type of a typed hash cell */
typedef enum {
- gras_cfgelm_int=0, gras_cfgelm_double, gras_cfgelm_string, gras_cfgelm_host,
- gras_cfgelm_type_count
-} gras_cfgelm_type_t;
+ xbt_cfgelm_int=0, xbt_cfgelm_double, xbt_cfgelm_string, xbt_cfgelm_host,
+ xbt_cfgelm_type_count
+} e_xbt_cfgelm_type_t;
/*----[ Memory management ]-----------------------------------------------*/
-gras_error_t gras_cfg_new (gras_cfg_t **whereto); /* (whereto == NULL) is ok */
-gras_error_t gras_cfg_cpy(gras_cfg_t **whereto, gras_cfg_t *tocopy);
-void gras_cfg_free(gras_cfg_t **cfg);
-void gras_cfg_dump(const char *name,const char*indent,gras_cfg_t *cfg);
+xbt_cfg_t xbt_cfg_new (void);
+void xbt_cfg_cpy(xbt_cfg_t tocopy,
+ /* OUT */ xbt_cfg_t *whereto);
+void xbt_cfg_free(xbt_cfg_t *cfg);
+void xbt_cfg_dump(const char *name,const char*indent,xbt_cfg_t cfg);
/*----[ Registering stuff ]-----------------------------------------------*/
/* Register a possible cell */
-gras_error_t gras_cfg_register(gras_cfg_t *cfg,
- const char *name, gras_cfgelm_type_t type,
- int min, int max);
+void xbt_cfg_register(xbt_cfg_t cfg,
+ const char *name, e_xbt_cfgelm_type_t type,
+ int min, int max);
/* Unregister a possible cell */
-gras_error_t gras_cfg_unregister(gras_cfg_t *cfg, const char *name);
+xbt_error_t xbt_cfg_unregister(xbt_cfg_t cfg, const char *name);
/* Parse the configuration descriptor and register it */
/* Should be of the form "<name>:<min nb>_to_<max nb>_<type>", */
/* with type being one of 'string','int', 'host' or 'double' */
-gras_error_t gras_cfg_register_str(gras_cfg_t *cfg, const char *entry);
+xbt_error_t xbt_cfg_register_str(xbt_cfg_t cfg, const char *entry);
/* Check that each cell have the right amount of elements */
-gras_error_t gras_cfg_check(gras_cfg_t *cfg);
+xbt_error_t xbt_cfg_check(xbt_cfg_t cfg);
/* Get the type of this option in that repository */
-gras_error_t gras_cfg_get_type(gras_cfg_t *cfg, const char *name,
- /* OUT */ gras_cfgelm_type_t *type);
+xbt_error_t xbt_cfg_get_type(xbt_cfg_t cfg, const char *name,
+ /* OUT */ e_xbt_cfgelm_type_t *type);
/*----[ Setting ]---------------------------------------------------------
- * gras_cfg_set_* functions.
+ * xbt_cfg_set_* functions.
*
* If the registered maximum is equal to 1, those functions remplace the
* current value with the provided one. If max>1, the provided value is
*
* string values are strdup'ed before use, so you have to free your copy */
-gras_error_t gras_cfg_set_vargs(gras_cfg_t *cfg, va_list pa);
-gras_error_t gras_cfg_set(gras_cfg_t *cfg, ...);
+xbt_error_t xbt_cfg_set_vargs(xbt_cfg_t cfg, va_list pa);
+xbt_error_t xbt_cfg_set(xbt_cfg_t cfg, ...);
/*
Add the cells described in a string to a typed hash.
*/
-gras_error_t gras_cfg_set_parse(gras_cfg_t *cfg, const char *options);
+xbt_error_t xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options);
/*
Set the value of the cell @name in @cfg with the provided value.
*/
-gras_error_t gras_cfg_set_int (gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_set_int (xbt_cfg_t cfg, const char *name,
int val);
-gras_error_t gras_cfg_set_double(gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_set_double(xbt_cfg_t cfg, const char *name,
double val);
-gras_error_t gras_cfg_set_string(gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_set_string(xbt_cfg_t cfg, const char *name,
const char *val);
-gras_error_t gras_cfg_set_host (gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_set_host (xbt_cfg_t cfg, const char *name,
const char *host,int port);
/*
Remove the provided value from the cell @name in @cfg.
*/
-gras_error_t gras_cfg_rm_int (gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_rm_int (xbt_cfg_t cfg, const char *name,
int val);
-gras_error_t gras_cfg_rm_double(gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_rm_double(xbt_cfg_t cfg, const char *name,
double val);
-gras_error_t gras_cfg_rm_string(gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_rm_string(xbt_cfg_t cfg, const char *name,
const char *val);
-gras_error_t gras_cfg_rm_host (gras_cfg_t *cfg, const char *name,
+xbt_error_t xbt_cfg_rm_host (xbt_cfg_t cfg, const char *name,
const char *host,int port);
/* rm every values */
-gras_error_t gras_cfg_empty(gras_cfg_t *cfg, const char *name);
+xbt_error_t xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
/*----[ Getting ]---------------------------------------------------------*/
/* Returns a pointer to the values actually stored in the cache. Do not */
/* modify them unless you really know what you're doing. */
-gras_error_t gras_cfg_get_int (gras_cfg_t *cfg,
+xbt_error_t xbt_cfg_get_int (xbt_cfg_t cfg,
const char *name,
int *val);
-gras_error_t gras_cfg_get_double(gras_cfg_t *cfg,
+xbt_error_t xbt_cfg_get_double(xbt_cfg_t cfg,
const char *name,
double *val);
-gras_error_t gras_cfg_get_string(gras_cfg_t *cfg,
+xbt_error_t xbt_cfg_get_string(xbt_cfg_t cfg,
const char *name,
char **val);
-gras_error_t gras_cfg_get_host (gras_cfg_t *cfg,
+xbt_error_t xbt_cfg_get_host (xbt_cfg_t cfg,
const char *name,
char **host,
int *port);
-gras_error_t gras_cfg_get_dynar (gras_cfg_t *cfg,
- const char *name,
- gras_dynar_t **dynar);
+xbt_error_t xbt_cfg_get_dynar (xbt_cfg_t cfg,
+ const char *name,
+ /* OUT */ xbt_dynar_t *dynar);
-
-#endif /* _GRAS_CONFIG_H_ */
+END_DECL
+
+#endif /* _XBT_CONFIG_H_ */