nfs-ganesha 1.4
|
00001 /* ---------------------------------------------------------------------------- 00002 * Copyright CEA/DAM/DIF (2007) 00003 * contributeur : Thomas LEIBOVICI thomas.leibovici@cea.fr 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 3 of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * --------------------------------------- 00020 */ 00021 00022 #ifndef CONFPARSER_H 00023 #define CONFPARSER_H 00024 00025 #include <stdio.h> 00026 00027 #define MAXSTRLEN 1024 00028 00029 /* A program consists of several blocks, 00030 * each block consists of variables definitions 00031 * and subblocks. 00032 */ 00033 00034 /* forward declaration of generic item */ 00035 struct _generic_item_; 00036 00037 typedef enum 00038 { 00039 TYPE_BLOCK, 00040 TYPE_AFFECT 00041 } type_item; 00042 00043 typedef struct _type_affect_ 00044 { 00045 00046 char varname[MAXSTRLEN]; 00047 char varvalue[MAXSTRLEN]; 00048 00049 } type_affect; 00050 00051 typedef struct _type_block_ 00052 { 00053 00054 char block_name[MAXSTRLEN]; 00055 struct _generic_item_ *block_content; 00056 00057 } type_block; 00058 00059 typedef struct _generic_item_ 00060 { 00061 00062 type_item type; 00063 union 00064 { 00065 type_block block; 00066 type_affect affect; 00067 } item; 00068 00069 /* next item in the list */ 00070 struct _generic_item_ *next; 00071 00072 } generic_item; 00073 00074 typedef generic_item *list_items; 00075 00079 list_items *config_CreateItemsList(); 00080 00084 generic_item *config_CreateBlock(char *blockname, list_items * list); 00085 00089 generic_item *config_CreateAffect(char *varname, char *varval); 00090 00094 void config_AddItem(list_items * list, generic_item * item); 00095 00099 void config_print_list(FILE * output, list_items * list); 00100 00105 void config_free_list(list_items * list); 00106 00107 #endif