Adding centos.json to be used with packer to generate a VM with PROX
[samplevnf.git] / VNFs / DPPD-PROX / cfgfile.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _CFG_FILE_H_
18 #define _CFG_FILE_H_
19
20 #include <stdio.h>
21 #include "defaults.h"
22
23 #define DEFAULT_CONFIG_FILE     "./prox.cfg"
24
25 /* configuration file line parser procedure */
26 typedef int (*cfg_parser)(unsigned sindex, char *str, void *data);
27
28 #define CFG_INDEXED     0x80000000      /* section contains index [name #] */
29 #define MAX_INDEX       64
30
31 struct cfg_section {
32         const char      *name;  /* section name without [] */
33         cfg_parser      parser; /* section parser function */
34         void            *data;  /* data to be passed to the parser */
35         /* set by parsing procedure */
36         unsigned        indexp[MAX_INDEX];
37         int             raw_lines; /* if set, do not remove text after ';' */
38         int             nbindex;
39         int             error;
40 };
41
42 #define MAX_CFG_STRING_LEN (3 * MAX_PKT_SIZE)
43 #define STRING_TERMINATOR_LEN 4
44
45 struct cfg_file {
46         char            *name;
47         FILE            *pfile;
48         unsigned        line;
49         unsigned        index_line;
50         /* set in case of any error */
51         unsigned        err_line;
52         char            *err_section;
53         unsigned        err_entry;
54         char            cur_line[MAX_CFG_STRING_LEN + STRING_TERMINATOR_LEN];
55 };
56
57 struct cfg_file *cfg_open(const char *cfg_name);
58 int cfg_parse(struct cfg_file *pcfg, struct cfg_section *psec);
59 int cfg_close(struct cfg_file *pcfg);
60
61 #endif /* _CFGFILE_H_ */