gwenhywfar  4.3.3
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 
31 #include <gwenhywfar/gwenhywfarapi.h>
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 
216 #define GWEN_DB_DEFAULT_LOCK_TIMEOUT 1000
217 
218 
226 typedef struct GWEN_DB_NODE GWEN_DB_NODE;
227 
231 typedef enum {
249 
250 
251 
256 
264 GWEN_DB_NODE *GWEN_DB_Group_new(const char *name);
265 
273 
274 
283 
303 
328 
329 
342 GWEN_DB_NODE *GWEN_DB_FindFirstGroup(GWEN_DB_NODE *n, const char *name);
343 
363 GWEN_DB_NODE *GWEN_DB_FindNextGroup(GWEN_DB_NODE *n, const char *name);
364 
365 
376 typedef void *(*GWEN_DB_NODES_CB)(GWEN_DB_NODE *node, void *user_data);
377 
396  void *user_data);
397 
402 unsigned int GWEN_DB_Groups_Count(const GWEN_DB_NODE *node);
403 
409 
468 const char *GWEN_DB_GetCharValue(GWEN_DB_NODE *n,
469  const char *path,
470  int idx,
471  const char *defVal);
482  uint32_t flags,
483  const char *path,
484  const char *val);
485 
486 
499  const char *path,
500  const char *val,
501  int senseCase,
502  int check);
503 
504 
516  const char *path,
517  const char *val,
518  int senseCase);
519 
520 
530  const char *path,
531  int idx,
532  int defVal);
533 
544  uint32_t flags,
545  const char *path,
546  int val);
547 
548 
561 const void *GWEN_DB_GetBinValue(GWEN_DB_NODE *n,
562  const char *path,
563  int idx,
564  const void *defVal,
565  unsigned int defValSize,
566  unsigned int *returnValueSize);
567 
580  uint32_t flags,
581  const char *path,
582  const void *val,
583  unsigned int valSize);
584 
585 
595  const char *path,
596  int idx,
597  void *defVal);
598 
610  uint32_t flags,
611  const char *path,
612  void *val);
621 
633  uint32_t flags,
634  const char *path);
635 
640 const char *GWEN_DB_GroupName(GWEN_DB_NODE *n);
641 
648 void GWEN_DB_GroupRename(GWEN_DB_NODE *n, const char *newname);
649 
665 int GWEN_DB_AddGroup(GWEN_DB_NODE *parent, GWEN_DB_NODE *node);
666 
683 int GWEN_DB_InsertGroup(GWEN_DB_NODE *parent, GWEN_DB_NODE *node);
684 
696 
708 
717  const char *path);
727  const char *path);
728 
736 int GWEN_DB_IsGroup(const GWEN_DB_NODE *n);
737 
750  uint32_t GWEN_DB_GetNodeFlags(const GWEN_DB_NODE *n);
751 
759  uint32_t flags);
760 
771  uint32_t newflags,
772  uint32_t mask);
773 
784  uint32_t newflags,
785  uint32_t mask);
786 
800 
803  GWEN_FAST_BUFFER *fb,
804  uint32_t dbflags);
805 
807 int GWEN_DB_ReadFromIo(GWEN_DB_NODE *n, GWEN_SYNCIO *sio, uint32_t dbflags);
808 
811  const char *fname,
812  uint32_t dbflags);
813 
816  const char *str,
817  int len,
818  uint32_t dbflags);
819 
822  GWEN_FAST_BUFFER *fb,
823  uint32_t dbflags);
824 
827  GWEN_SYNCIO *sio,
828  uint32_t dbflags);
829 
830 
833  const char *fname,
834  uint32_t dbflags);
835 
838  GWEN_BUFFER *buf,
839  uint32_t dbflags);
840 
853  const char *fname,
854  const char *type,
855  GWEN_DB_NODE *params,
856  uint32_t dbflags);
857 
870  const char *fname,
871  const char *type,
872  GWEN_DB_NODE *params,
873  uint32_t dbflags);
874 
875 
890 
891 
915 
921 const char *GWEN_DB_VariableName(GWEN_DB_NODE *n);
922 
923 
925 void GWEN_DB_VariableRename(GWEN_DB_NODE *n, const char *newname);
926 
945  void *user_data);
946 
952 unsigned int GWEN_DB_Variables_Count(const GWEN_DB_NODE *node);
953 
961  const char *p);
962 
971  const char *path);
972 
981  const char *path);
982 
992  const char *path,
993  unsigned int idx);
994 
1002 int GWEN_DB_IsVariable(const GWEN_DB_NODE *n);
1003 
1004 
1017 GWEN_DB_NODE *GWEN_DB_FindFirstVar(GWEN_DB_NODE *n, const char *name);
1018 
1038 GWEN_DB_NODE *GWEN_DB_FindNextVar(GWEN_DB_NODE *n, const char *name);
1039 
1054 
1073 
1092  void *user_data);
1093 
1098 unsigned int GWEN_DB_Values_Count(const GWEN_DB_NODE *node);
1099 
1106 
1109  const char *p,
1110  unsigned int i);
1111 
1117 const char *GWEN_DB_GetCharValueFromNode(const GWEN_DB_NODE *n);
1118 
1124 int GWEN_DB_SetCharValueInNode(GWEN_DB_NODE *n, const char *s);
1125 
1128 
1130 const void *GWEN_DB_GetBinValueFromNode(const GWEN_DB_NODE *n,
1131  unsigned int *size);
1132 
1133 
1141 int GWEN_DB_IsValue(const GWEN_DB_NODE *n);
1155 
1162 void GWEN_DB_Dump(GWEN_DB_NODE *n, int insert);
1167 
1168 
1169 #ifdef __cplusplus
1170 }
1171 #endif
1172 
1173 
1174 #endif
1175 
1176 
1177