-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
mini.h
97 lines (61 loc) · 2.11 KB
/
mini.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef __MINI
#define __MINI
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef WIN32
#include <io.h>
#include <sys/locking.h>
#else
#include <sys/file.h>
#define _locking lockf
#define LK_LOCK F_LOCK
#define LK_UNLCK F_ULOCK
#endif
typedef struct s_section {
int type ;
char * name ;
struct s_section * next ; // section suivante
struct s_key * first ; // première clé
} SSECTION ;
typedef struct s_key {
int type ;
char * name ;
void * value ;
struct s_key * next ;
} SKEY ;
typedef struct s_ini {
char * name ;
struct s_section * first ;
} SINI ;
SSECTION * newSECTION( const char * name ) ;
SKEY * newKEY( const char * name, const char * value ) ;
SINI * newINI( void ) ;
void freeSECTION( SSECTION ** Section ) ;
void freeKEY( SKEY ** Key ) ;
void freeINI( SINI ** Ini ) ;
int addSECTION( SSECTION * Section, SSECTION * SectionAdd ) ;
int addINI( SINI * Ini, SSECTION * Section ) ;
int delSECTION( SSECTION * Section, const char * name ) ;
int addKEY( SSECTION * Section, SKEY * Key ) ;
int delKEY( SSECTION * Section, const char * name ) ;
SSECTION * getSECTION( SSECTION * Section, const char * name ) ;
SSECTION * lastSECTION( SSECTION * Section ) ;
SKEY * getKEY( SSECTION * Section, const char * name ) ;
char * getvalueKEY( SKEY * Key ) ;
int setKEY( SKEY * Key, char * value ) ;
void printKEY( SKEY * Key ) ;
void printSECTION( SSECTION * Section ) ;
void printINI( SINI * Ini ) ;
int loadINI( SINI * Ini, const char * fileName ) ;
int readINI( const char * filename, const char * section, const char * key, char * pStr) ;
int storeKEY( SKEY * Key, FILE * fp ) ;
int storeSECTION( SSECTION * Section, FILE * fp ) ;
int storeINI( SINI * Ini, const char * filename ) ;
int writeINI( const char * filename, const char * section, const char * key, const char * value ) ;
int writeINISec( const char * filename, const char * section, const char * key, const char * value ) ;
int delINI( const char * filename, const char * section, const char * key ) ;
int delINISec( const char * filename, const char * section, const char * key ) ;
#endif