vars.h

00001 /*
00002  * Copyright (c) 2005-2012 by KoanLogic s.r.l. <http://www.koanlogic.com>
00003  * All rights reserved.
00004  *
00005  * This file is part of KLone, and as such it is subject to the license stated
00006  * in the LICENSE file which you have received as part of this distribution.
00007  *
00008  * $Id: vars.h,v 1.10 2008/04/18 17:31:11 tat Exp $
00009  */
00010 
00011 #ifndef _KLONE_VARLIST_H_
00012 #define _KLONE_VARLIST_H_
00013 
00014 #include <u/libu.h>
00015 #include <klone/var.h>
00016 
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 enum { 
00022     VARS_FLAG_NONE = 0,
00023     VARS_FLAG_FOREIGN = 1 << 0  /* don't free the list of var_t on vars_free */
00024 };
00025 
00026 struct vars_s;
00027 typedef struct vars_s vars_t;
00028 
00029 typedef int (*vars_cb_t)(var_t*, void*);
00030 
00031 int vars_create(vars_t ** pvs);
00032 int vars_free(vars_t *vs);
00033 
00034 int vars_set_flags(vars_t *vs, int flags);
00035 
00036 int vars_add(vars_t *vs, var_t *v);
00037 int vars_del(vars_t *vs, var_t *v);
00038 
00039 /* str must be a 'name=value' string */
00040 int vars_add_strvar(vars_t *vs, const char *str);
00041 
00042 /* str must be a (possibly url-encoded) 'name=value' string */
00043 int vars_add_urlvar(vars_t *vs, const char *cstr, var_t **v);
00044 
00045 var_t* vars_getn(vars_t *vs, size_t n);
00046 size_t vars_count(vars_t *vs);
00047 
00048 size_t vars_countn(vars_t *vs, const char *name);
00049 
00050 void vars_foreach(vars_t *vs, int (*foreach)(var_t*, void*), void *arg);
00051 
00052 /* get first variable called "name" */
00053 var_t* vars_get(vars_t *vs, const char *name);
00054 const char* vars_get_value(vars_t *vs, const char *name);
00055 int vars_get_value_i(vars_t *vs, const char *name);
00056 u_string_t* vars_get_value_s(vars_t *vs, const char *name);
00057 
00058 /* get i-th variable called "name" */
00059 var_t* vars_geti(vars_t *vs, const char *name, size_t ith);
00060 const char* vars_geti_value(vars_t *vs, const char *name, size_t ith);
00061 int vars_geti_value_i(vars_t *vs, const char *name, size_t ith);
00062 u_string_t* vars_geti_value_s(vars_t *vs, const char *name, size_t ith);
00063 
00064 #ifdef __cplusplus
00065 }
00066 #endif 
00067 
00068 #endif

←Products
Copyright © 2005-2012 - KoanLogic S.r.l. - All rights reserved