gwenhywfar  4.12.0beta
db.h
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Tue Sep 09 2003
3  copyright : (C) 2003-2010 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2.1 of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * Lesser General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU Lesser General Public *
19  * License along with this library; if not, write to the Free Software *
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21  * MA 02111-1307 USA *
22  * *
23  ***************************************************************************/
24 
25 
28 #ifndef GWENHYWFAR_DB_H
29 #define GWENHYWFAR_DB_H
30 
32 #include <gwenhywfar/path.h>
33 #include <gwenhywfar/fastbuffer.h>
34 #include <gwenhywfar/types.h>
35 #include <stdio.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 
102 #define GWEN_DB_LINE_MAXSIZE 1024
103 
119 #define GWEN_DB_FLAGS_ALLOW_EMPTY_STREAM 0x00008000
120 
121 #define GWEN_DB_FLAGS_OVERWRITE_VARS 0x00010000
122 
123 #define GWEN_DB_FLAGS_OVERWRITE_GROUPS 0x00020000
124 
125 #define GWEN_DB_FLAGS_QUOTE_VARNAMES 0x00040000
126 
127 #define GWEN_DB_FLAGS_QUOTE_VALUES 0x00080000
128 
129 #define GWEN_DB_FLAGS_WRITE_SUBGROUPS 0x00100000
130 
131 #define GWEN_DB_FLAGS_DETAILED_GROUPS 0x00200000
132 
134 #define GWEN_DB_FLAGS_INDEND 0x00400000
135 
137 #define GWEN_DB_FLAGS_ADD_GROUP_NEWLINES 0x00800000
138 
140 #define GWEN_DB_FLAGS_USE_COLON 0x01000000
141 
142 #define GWEN_DB_FLAGS_UNTIL_EMPTY_LINE 0x02000000
143 
145 #define GWEN_DB_FLAGS_OMIT_TYPES 0x04000000
146 
147 #define GWEN_DB_FLAGS_APPEND_FILE 0x08000000
148 
149 #define GWEN_DB_FLAGS_ESCAPE_CHARVALUES 0x10000000
150 
152 #define GWEN_DB_FLAGS_UNESCAPE_CHARVALUES 0x10000000
153 
155 #define GWEN_DB_FLAGS_LOCKFILE 0x20000000
156 
160 #define GWEN_DB_FLAGS_INSERT 0x40000000
161 
165 #define GWEN_DB_FLAGS_DOSMODE 0x80000000
166 
168 #define GWEN_DB_FLAGS_DEFAULT \
169  (\
170  GWEN_DB_FLAGS_QUOTE_VALUES | \
171  GWEN_DB_FLAGS_WRITE_SUBGROUPS | \
172  GWEN_DB_FLAGS_DETAILED_GROUPS | \
173  GWEN_DB_FLAGS_INDEND | \
174  GWEN_DB_FLAGS_ADD_GROUP_NEWLINES | \
175  GWEN_DB_FLAGS_ESCAPE_CHARVALUES | \
176  GWEN_DB_FLAGS_UNESCAPE_CHARVALUES\
177  )
178 
179 
182 #define GWEN_DB_FLAGS_COMPACT \
183  (\
184  GWEN_DB_FLAGS_QUOTE_VALUES | \
185  GWEN_DB_FLAGS_WRITE_SUBGROUPS | \
186  GWEN_DB_FLAGS_ESCAPE_CHARVALUES | \
187  GWEN_DB_FLAGS_UNESCAPE_CHARVALUES\
188  )
189 
193 #define GWEN_DB_FLAGS_HTTP \
194  (\
195  GWEN_DB_FLAGS_USE_COLON |\
196  GWEN_DB_FLAGS_UNTIL_EMPTY_LINE |\
197  GWEN_DB_FLAGS_OMIT_TYPES | \
198  GWEN_DB_FLAGS_DOSMODE \
199  )
200 
207 #define GWEN_DB_NODE_FLAGS_DIRTY 0x00000001
208 
209 #define GWEN_DB_NODE_FLAGS_VOLATILE 0x00000002
210 
212 #define GWEN_DB_NODE_FLAGS_INHERIT_HASH_MECHANISM 0x00000004
213 
214 #define GWEN_DB_NODE_FLAGS_SAFE 0x00000008
215 
218 #define GWEN_DB_DEFAULT_LOCK_TIMEOUT 1000
219 
220 
228 typedef struct GWEN_DB_NODE GWEN_DB_NODE;
229 
233 typedef enum {
251 
252 
253 
258 
266 GWEN_DB_NODE *GWEN_DB_Group_new(const char *name);
267 
275 
276 
285 
305 
330 
331 
344 GWEN_DB_NODE *GWEN_DB_FindFirstGroup(GWEN_DB_NODE *n, const char *name);
345 
365 GWEN_DB_NODE *GWEN_DB_FindNextGroup(GWEN_DB_NODE *n, const char *name);
366 
367 
378 typedef void *(*GWEN_DB_NODES_CB)(GWEN_DB_NODE *node, void *user_data);
379 
398  void *user_data);
399 
404 unsigned int GWEN_DB_Groups_Count(const GWEN_DB_NODE *node);
405 
411 
470 const char *GWEN_DB_GetCharValue(GWEN_DB_NODE *n,
471  const char *path,
472  int idx,
473  const char *defVal);
484  uint32_t flags,
485  const char *path,
486  const char *val);
487 
488 
501  const char *path,
502  const char *val,
503  int senseCase,
504  int check);
505 
506 
518  const char *path,
519  const char *val,
520  int senseCase);
521 
522 
532  const char *path,
533  int idx,
534  int defVal);
535 
546  uint32_t flags,
547  const char *path,
548  int val);
549 
550 
563 const void *GWEN_DB_GetBinValue(GWEN_DB_NODE *n,
564  const char *path,
565  int idx,
566  const void *defVal,
567  unsigned int defValSize,
568  unsigned int *returnValueSize);
569 
582  uint32_t flags,
583  const char *path,
584  const void *val,
585  unsigned int valSize);
586 
587 
597  const char *path,
598  int idx,
599  void *defVal);
600 
612  uint32_t flags,
613  const char *path,
614  void *val);
623 
635  uint32_t flags,
636  const char *path);
637 
642 const char *GWEN_DB_GroupName(GWEN_DB_NODE *n);
643 
650 void GWEN_DB_GroupRename(GWEN_DB_NODE *n, const char *newname);
651 
667 int GWEN_DB_AddGroup(GWEN_DB_NODE *parent, GWEN_DB_NODE *node);
668 
685 int GWEN_DB_InsertGroup(GWEN_DB_NODE *parent, GWEN_DB_NODE *node);
686 
698 
710 
719  const char *path);
729  const char *path);
730 
738 int GWEN_DB_IsGroup(const GWEN_DB_NODE *n);
739 
752  uint32_t GWEN_DB_GetNodeFlags(const GWEN_DB_NODE *n);
753 
761  uint32_t flags);
762 
773  uint32_t newflags,
774  uint32_t mask);
775 
786  uint32_t newflags,
787  uint32_t mask);
788 
802 
805  GWEN_FAST_BUFFER *fb,
806  uint32_t dbflags);
807 
809 int GWEN_DB_ReadFromIo(GWEN_DB_NODE *n, GWEN_SYNCIO *sio, uint32_t dbflags);
810 
813  const char *fname,
814  uint32_t dbflags);
815 
818  const char *str,
819  int len,
820  uint32_t dbflags);
821 
824  GWEN_FAST_BUFFER *fb,
825  uint32_t dbflags);
826 
829  GWEN_SYNCIO *sio,
830  uint32_t dbflags);
831 
832 
835  const char *fname,
836  uint32_t dbflags);
837 
840  GWEN_BUFFER *buf,
841  uint32_t dbflags);
842 
855  const char *fname,
856  const char *type,
857  GWEN_DB_NODE *params,
858  uint32_t dbflags);
859 
872  const char *fname,
873  const char *type,
874  GWEN_DB_NODE *params,
875  uint32_t dbflags);
876 
877 
892 
893 
917 
923 const char *GWEN_DB_VariableName(GWEN_DB_NODE *n);
924 
925 
927 void GWEN_DB_VariableRename(GWEN_DB_NODE *n, const char *newname);
928 
947  void *user_data);
948 
954 unsigned int GWEN_DB_Variables_Count(const GWEN_DB_NODE *node);
955 
963  const char *p);
964 
973  const char *path);
974 
983  const char *path);
984 
994  const char *path,
995  unsigned int idx);
996 
1004 int GWEN_DB_IsVariable(const GWEN_DB_NODE *n);
1005 
1006 
1019 GWEN_DB_NODE *GWEN_DB_FindFirstVar(GWEN_DB_NODE *n, const char *name);
1020 
1040 GWEN_DB_NODE *GWEN_DB_FindNextVar(GWEN_DB_NODE *n, const char *name);
1041 
1056 
1075 
1094  void *user_data);
1095 
1100 unsigned int GWEN_DB_Values_Count(const GWEN_DB_NODE *node);
1101 
1108 
1111  const char *p,
1112  unsigned int i);
1113 
1119 const char *GWEN_DB_GetCharValueFromNode(const GWEN_DB_NODE *n);
1120 
1126 int GWEN_DB_SetCharValueInNode(GWEN_DB_NODE *n, const char *s);
1127 
1130 
1132 const void *GWEN_DB_GetBinValueFromNode(const GWEN_DB_NODE *n,
1133  unsigned int *size);
1134 
1135 
1143 int GWEN_DB_IsValue(const GWEN_DB_NODE *n);
1157 
1164 void GWEN_DB_Dump(GWEN_DB_NODE *n, int insert);
1169 
1170 
1171 #ifdef __cplusplus
1172 }
1173 #endif
1174 
1175 
1176 #endif
1177 
1178 
1179