-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconfread.h
More file actions
61 lines (47 loc) · 1.4 KB
/
confread.h
File metadata and controls
61 lines (47 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* ----------------------------------------------------------------------------
HEADER FILE
Name: confread.h
Program: Configuration Reader
Developer: Andrew Burian
Created On: 2015-03-07
Description:
A config file reading library for C
Revisions:
Andrew Burian
2015-08-21
Revised sections and pair to be a linked list rather than
reallocating continuous memory sections.
---------------------------------------------------------------------------- */
#ifndef CONFREAD_H
#define CONFREAD_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
// The struct for the entire configuration file
struct confread_file {
char *name;
struct confread_section *sections;
};
// The struct for each config section
struct confread_section {
char *name;
struct confread_pair *pairs;
struct confread_section *next;
};
// The key-value pair
struct confread_pair {
char *key;
char *value;
struct confread_pair *next;
};
// functions
struct confread_file *confread_open(char *path);
struct confread_section *confread_find_section(struct confread_file *confFile,
char *name);
struct confread_pair *confread_find_pair(struct confread_section *confSec,
char *key);
char *confread_find_value(struct confread_section *confSec, char *key);
int confread_check_pair(struct confread_section *section, char *key, char *value);
void confread_close(struct confread_file **confFile);
#endif