gwenhywfar  5.4.1
csv.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Thu Oct 30 2003
3  copyright : (C) 2003-2013 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 
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
30 /* disable DBG_DEBUG() and DBG_VERBOUS() */
31 #define DISABLE_DEBUGLOG
32 
33 #include "csv_p.h"
34 #include <gwenhywfar/text.h>
35 #include <gwenhywfar/debug.h>
36 #include <gwenhywfar/stringlist.h>
37 #include <gwenhywfar/dbio_be.h>
38 #include <gwenhywfar/syncio_file.h>
39 
40 #include <stdlib.h>
41 #include <string.h>
42 #include <assert.h>
43 #include <sys/types.h>
44 #include <sys/stat.h>
45 #include <fcntl.h>
46 #include <string.h>
47 #include <errno.h>
48 
49 
50 
51 int GWEN_CSV_GetNameAndIndex(const char *name,
52  char *buffer,
53  unsigned int size)
54 {
55  unsigned int i;
56  int rv;
57 
58  i=0;
59  rv=0;
60  /* read and copy name */
61  while (name[i] && name[i]!='[' && i<size) {
62  buffer[i]=name[i];
63  i++;
64  } /* while */
65 
66  if (i>=size) {
67  DBG_INFO(0, "Name too long (%d>=%d)", i, size);
68  return -1;
69  }
70  buffer[i]=0;
71 
72  /* read and copy index, if any */
73  if (name[i]=='[') {
74  char numbuffer[16];
75  unsigned int j;
76 
77  j=0;
78  i++;
79  while (name[i] && name[i]!=']' && j<sizeof(numbuffer)) {
80  numbuffer[j]=name[i];
81  i++;
82  j++;
83  } /* while */
84  if (j>=sizeof(numbuffer)) {
85  DBG_INFO(0, "Index number too long (%u>=%d)", j,
86  (int)(sizeof(numbuffer)));
87  return -1;
88  }
89  numbuffer[j]=0;
90  rv=atoi(numbuffer);
91  }
92 
93  return rv;
94 }
95 
96 
97 
99  GWEN_SYNCIO *sio,
100  GWEN_DB_NODE *data,
101  GWEN_DB_NODE *cfg,
102  GWEN_UNUSED uint32_t flags)
103 {
104  GWEN_DB_NODE *colgr;
105  GWEN_DB_NODE *n;
106  int delimiter;
107  int quote;
108  const char *p;
109  const char *groupName;
110  int err;
111  unsigned int column;
112  int title;
113  GWEN_FAST_BUFFER *fb;
114 
115  assert(dbio);
116  assert(sio);
117  assert(cfg);
118  assert(data);
119 
120  fb=GWEN_FastBuffer_new(512, sio);
121 
122  /* get general configuration */
123  colgr=GWEN_DB_GetGroup(cfg, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "columns");
124  if (!colgr) {
125  DBG_ERROR(0, "Error in configuration: No columns specified");
127  return GWEN_ERROR_INVALID;
128  }
129  p=GWEN_DB_GetCharValue(cfg, "delimiter", 0, ";");
130  if (strcasecmp(p, "TAB")==0)
131  delimiter=9;
132  else if (strcasecmp(p, "SPACE")==0)
133  delimiter=32;
134  else
135  delimiter=p[0];
136  quote=GWEN_DB_GetIntValue(cfg, "quote", 0, 1);
137  groupName=GWEN_DB_GetCharValue(cfg, "group", 0, "");
138  title=GWEN_DB_GetIntValue(cfg, "title", 0, 1);
139 
140  if (title) {
141  /* write title */
142  for (column=1; ; column++) {
143  int idx;
144  char namebuffer[64];
145  char numbuffer[16];
146  char *np;
147 
148  /* create name for column */
149  GWEN_Text_NumToString(column, numbuffer, sizeof(numbuffer), 0);
150  p=GWEN_DB_GetCharValue(colgr, numbuffer, 0, 0);
151  if (!p) {
152  /* no value. finished */
153  GWEN_FASTBUFFER_WRITELINE(fb, err, "");
154  if (err<0) {
155  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", err);
157  return err;
158  }
159  DBG_VERBOUS(GWEN_LOGDOMAIN, "No colums left, line finished");
160  break;
161  }
162  /* break down to name and index */
163  idx=GWEN_CSV_GetNameAndIndex(p, namebuffer, sizeof(namebuffer));
164  if (idx==-1) {
165  DBG_INFO(0, "Error in configuration: Bad name for column %d",
166  column);
168  return GWEN_ERROR_GENERIC;
169  }
170 
171  /* add idx to name, if not 0 */
172  if (idx) {
173  GWEN_Text_NumToString(idx, numbuffer, sizeof(numbuffer), 0);
174  if (strlen(namebuffer)+strlen(numbuffer)+1>=sizeof(namebuffer)) {
175  DBG_ERROR(0, "Internal: namebuffer too small");
177  return -1;
178  }
179  strcat(namebuffer, numbuffer);
180  }
181  /* convert slashes to underscores */
182  np=namebuffer;
183  while (*np) {
184  if (*np=='/')
185  *np='_';
186  np++;
187  }
188 
189  if (column!=1) {
190  /* write delimiter */
191  GWEN_FASTBUFFER_WRITEBYTE(fb, err, delimiter);
192  if (err<0) {
193  DBG_INFO(0, "Called from here");
195  return err;
196  }
197  } /* if not first column */
198  if (quote) {
199  /* write quotation mark */
200  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
201  if (err<0) {
202  DBG_INFO(0, "Called from here");
204  return err;
205  }
206  } /* if quote */
207  /* write value */
208  GWEN_FASTBUFFER_WRITEFORCED(fb, err, namebuffer, -1);
209  if (err<0) {
210  DBG_INFO(0, "Called from here");
212  return err;
213  }
214  if (quote) {
215  /* write quotation mark */
216  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
217  if (err<0) {
218  DBG_INFO(0, "Called from here");
220  return err;
221  }
222  } /* if quote */
223  } /* for */
224  } /* if title */
225 
226  n=GWEN_DB_GetFirstGroup(data);
227  while (n) {
228  if (*groupName==0 || strcasecmp(groupName, GWEN_DB_GroupName(n))==0) {
229  for (column=1; ; column++) {
230  int idx;
231  char namebuffer[64];
232  char numbuffer[16];
234  char valbuffer[64];
235  int iv;
236 
237  /* create name for column */
238  GWEN_Text_NumToString(column, numbuffer, sizeof(numbuffer), 0);
239  p=GWEN_DB_GetCharValue(colgr, numbuffer, 0, 0);
240  if (!p) {
241  /* no value. finished */
242  GWEN_FASTBUFFER_WRITELINE(fb, err, "");
243  if (err<0) {
244  DBG_INFO(0, "Called from here");
246  return err;
247  }
248  DBG_VERBOUS(GWEN_LOGDOMAIN, "No colums left, line finished");
249  break;
250  }
251 
252  /* break down to name and index */
253  idx=GWEN_CSV_GetNameAndIndex(p, namebuffer, sizeof(namebuffer));
254  if (idx==-1) {
255  DBG_INFO(GWEN_LOGDOMAIN, "Error in configuration: Bad name for column %d",
256  column);
258  return GWEN_ERROR_GENERIC;
259  }
260  /* get data */
261  DBG_VERBOUS(GWEN_LOGDOMAIN, "Checking value of %s[%d]", namebuffer, idx);
262  if (GWEN_DB_VariableExists(n, namebuffer)) {
263  vt=GWEN_DB_GetValueTypeByPath(n, namebuffer, idx);
264  switch (vt) {
266  p=GWEN_DB_GetCharValue(n, namebuffer, idx, "");
267  break;
269  iv=GWEN_DB_GetIntValue(n, namebuffer, idx, 0);
270  snprintf(valbuffer, sizeof(valbuffer), "%d", iv);
271  p=valbuffer;
272  break;
273  default:
274  DBG_DEBUG(GWEN_LOGDOMAIN, "Unhandled value type %d", vt);
275  p="";
276  }
277  }
278  else
279  p="";
280 
281  if (column!=1) {
282  /* write delimiter */
283  GWEN_FASTBUFFER_WRITEBYTE(fb, err, delimiter);
284  if (err<0) {
285  DBG_INFO(0, "Called from here");
287  return err;
288  }
289  } /* if not first column */
290  if (quote) {
291  /* write quotation mark */
292  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
293  if (err<0) {
294  DBG_INFO(0, "Called from here");
296  return err;
297  }
298  } /* if quote */
299  /* write value */
300  GWEN_FASTBUFFER_WRITEFORCED(fb, err, p, -1);
301  if (err<0) {
302  DBG_INFO(0, "Called from here");
304  return err;
305  }
306  if (quote) {
307  /* write quotation mark */
308  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
309  if (err<0) {
310  DBG_INFO(0, "Called from here");
312  return err;
313  }
314  } /* if quote */
315 
316  } /* for */
317  } /* if group name matches */
319  } /* while n */
320 
321  /* flush */
322  GWEN_FASTBUFFER_FLUSH(fb, err);
323  if (err<0) {
324  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", err);
326  return err;
327  }
328 
330  return 0;
331 }
332 
333 
334 
336  GWEN_SYNCIO *sio,
337  GWEN_DB_NODE *data,
338  GWEN_DB_NODE *cfg,
339  GWEN_UNUSED uint32_t flags)
340 {
341  GWEN_DB_NODE *colgr;
342  int delimiter;
343  /*int quote;*/
344  const char *p;
345  const char *groupName;
346  int err;
347  int title;
348  GWEN_STRINGLIST *sl;
349  GWEN_BUFFER *lbuffer;
350  char delimiters[2];
351  int lines;
352  int ignoreLines;
353  int fixedWidth;
354  int condense;
355  GWEN_FAST_BUFFER *fb;
356 
357  assert(dbio);
358  assert(sio);
359  assert(cfg);
360  assert(data);
361 
362  fb=GWEN_FastBuffer_new(512, sio);
363 
364  /* get general configuration */
365  colgr=GWEN_DB_GetGroup(cfg, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "columns");
366  if (!colgr) {
367  DBG_ERROR(0, "Error in configuration: No columns specified");
369  return GWEN_ERROR_INVALID;
370  }
371  p=GWEN_DB_GetCharValue(cfg, "delimiter", 0, ";");
372  if (strcasecmp(p, "TAB")==0)
373  delimiter=9;
374  else if (strcasecmp(p, "SPACE")==0)
375  delimiter=32;
376  else
377  delimiter=p[0];
378  delimiters[0]=delimiter;
379  delimiters[1]=0;
380  /*quote=GWEN_DB_GetIntValue(cfg, "quote", 0, 1);*/
381  fixedWidth=GWEN_DB_GetIntValue(cfg, "fixedWidth", 0, 0);
382  condense=GWEN_DB_GetIntValue(cfg, "condense", 0, 0);
383  groupName=GWEN_DB_GetCharValue(cfg, "group", 0, "line");
384  title=GWEN_DB_GetIntValue(cfg, "title", 0, 1);
385  ignoreLines=GWEN_DB_GetIntValue(cfg, "ignoreLines", 0, 0);
386  if (title)
387  ignoreLines++;
388 
389  sl=GWEN_StringList_new();
390  lbuffer=GWEN_Buffer_new(0, 256, 0, 1);
391 
392  lines=0;
393  for (;;) {
394  GWEN_BUFFER *wbuffer;
395  int rv;
396  const char *s;
398  int col;
399  GWEN_DB_NODE *n;
400 
401  /* read line */
402  DBG_DEBUG(GWEN_LOGDOMAIN, "Reading line %d", lines);
403  GWEN_Buffer_Reset(lbuffer);
404  err=GWEN_FastBuffer_ReadLineToBuffer(fb, lbuffer);
405  if (err<0) {
406  if (err==GWEN_ERROR_EOF) {
407  DBG_VERBOUS(GWEN_LOGDOMAIN, "EOF met");
408  break;
409  }
410  else {
412  GWEN_Buffer_free(lbuffer);
415  return err;
416  }
417  }
418 
419  if (lines<ignoreLines) {
420  DBG_VERBOUS(GWEN_LOGDOMAIN, "Ignoring line %d", lines);
421  }
422  else {
423  /* read columns */
424  wbuffer=GWEN_Buffer_new(0, 256, 0, 1);
425 
426  s=GWEN_Buffer_GetStart(lbuffer);
427  if (fixedWidth) {
428  int i;
429  unsigned int llength;
430  unsigned int lpos=0;
431 
432  llength=strlen(s);
433  for (i=0; ; i++) {
434  int w;
435  char *t=0;
436  int left;
437 
438  left=llength-lpos;
439  w=GWEN_DB_GetIntValue(cfg, "width", i, -1);
440  if (w<1)
441  break;
442  if (w>left)
443  w=left;
444  if (w<1)
445  break;
446  t=(char *)malloc(w+1);
447  memmove(t, s, w);
448  t[w]=0;
449  if (condense) {
450  int j;
451 
452  for (j=w-1; j>=0; j--) {
453  if ((unsigned char)(t[j])>32) {
454  break;
455  }
456  t[j]=0;
457  }
458  }
459  /* take over new string */
460  GWEN_StringList_AppendString(sl, t, 1, 0);
461  s+=w;
462  lpos+=w;
463  }
464  }
465  else {
466  while (*s) {
467  rv=GWEN_Text_GetWordToBuffer(s, delimiters, wbuffer,
472  &s);
473  if (rv) {
474  DBG_DEBUG(GWEN_LOGDOMAIN, "here (%d)", rv);
475  GWEN_Buffer_free(wbuffer);
476  GWEN_Buffer_free(lbuffer);
479  return rv;
480  }
482  GWEN_Buffer_Reset(wbuffer);
483  if (*s) {
484  if (strchr(delimiters, *s))
485  s++;
486  }
487  } /* while */
488  }
489  GWEN_Buffer_free(wbuffer);
490 
491  /* store columns to db */
492  n=GWEN_DB_Group_new(groupName);
494  col=1;
495  while (se) {
496  char nbuff[16];
497  const char *vcol;
498 
499  DBG_DEBUG(0, "Handling column %d", col);
500  nbuff[0]=0;
501  snprintf(nbuff, sizeof(nbuff)-1, "%i", col);
502  nbuff[sizeof(nbuff)-1]=0;
503 
504  vcol=GWEN_DB_GetCharValue(colgr, nbuff, 0, 0);
505  if (vcol) {
506  const char *bracket;
507  GWEN_BUFFER *vname;
508 
509  bracket=strchr(vcol, '[');
510  if (bracket) {
511  /* copy column name without index */
512  vname=GWEN_Buffer_new(0, bracket-vcol+1, 0, 1);
513  GWEN_Buffer_AppendBytes(vname, vcol, bracket-vcol);
514  vcol=GWEN_Buffer_GetStart(vname);
515  }
516  else
517  vname=0;
519  vcol, GWEN_StringListEntry_Data(se));
520  GWEN_Buffer_free(vname);
521  }
522 
524  col++;
525  } /* while */
526 
527  /* add db to data */
528  GWEN_DB_AddGroup(data, n);
529  } /* if this is not the title line */
531  lines++;
532  } /* while */
533 
534  GWEN_Buffer_free(lbuffer);
536 
538 
539  return 0;
540 }
541 
542 
543 
545 {
546  int err;
547  const char *delimiters=";\t,";
548  GWEN_BUFFER *lbuffer;
549  GWEN_BUFFER *wbuffer;
550  int rv;
551  const char *s;
552 
553  assert(fb);
554 
555  /* read line */
556  lbuffer=GWEN_Buffer_new(0, 256, 0, 1);
557  GWEN_Buffer_Reset(lbuffer);
558  err=GWEN_FastBuffer_ReadLineToBuffer(fb, lbuffer);
559  if (err<0) {
561  GWEN_Buffer_free(lbuffer);
562  return err;
563  }
564 
565  /* read columns */
566  wbuffer=GWEN_Buffer_new(0, 256, 0, 1);
567 
568  s=GWEN_Buffer_GetStart(lbuffer);
569  while (*s) {
570  rv=GWEN_Text_GetWordToBuffer(s, delimiters, wbuffer,
575  &s);
576  if (rv) {
577  GWEN_Buffer_free(wbuffer);
578  GWEN_Buffer_free(lbuffer);
579  return rv;
580  }
582  GWEN_Buffer_Reset(wbuffer);
583  if (*s) {
584  if (strchr(delimiters, *s))
585  s++;
586  }
587  } /* while */
588  GWEN_Buffer_free(wbuffer);
589  GWEN_Buffer_free(lbuffer);
590 
591  return 0;
592 }
593 
594 
595 
597 {
598  int i;
599  int rv;
600  GWEN_SYNCIO *sio;
601  GWEN_STRINGLIST *sl;
602  GWEN_FAST_BUFFER *fb;
603 
606  rv=GWEN_SyncIo_Connect(sio);
607  if (rv<0) {
608  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
609  GWEN_SyncIo_free(sio);
610  return rv;
611  }
612 
613  fb=GWEN_FastBuffer_new(512, sio);
614 
615  /* read line into string list */
616  sl=GWEN_StringList_new();
617  if (GWEN_DBIO_CSV__ReadLine(fb, sl)) {
618  DBG_INFO(GWEN_LOGDOMAIN, "Error reading a line");
621  GWEN_SyncIo_free(sio);
623  }
624 
625  /* first column: number */
626  i=GWEN_StringList_Count(sl);
628  if (i) {
630  "Found %d columns, file might be supported", i);
633  GWEN_SyncIo_free(sio);
634  /*return GWEN_DBIO_CheckFileResultOk; */
636  }
637  else {
639  "Found no columns, file might not be supported");
642  GWEN_SyncIo_free(sio);
644  }
645 }
646 
647 
648 
650 {
651  GWEN_DBIO *dbio;
652 
653  dbio=GWEN_DBIO_new("csv", "Imports and exports CSV data");
657  return dbio;
658 }
659 
660 
661 
663  const char *modName,
664  const char *fileName)
665 {
666  GWEN_PLUGIN *pl;
667 
668  pl=GWEN_DBIO_Plugin_new(pm, modName, fileName);
669  assert(pl);
670 
672 
673  return pl;
674 
675 }
676 
677 
678 
679 
680 
681 
682 
683 
struct GWEN_PLUGIN_MANAGER GWEN_PLUGIN_MANAGER
Definition: plugin.h:40
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:235
struct GWEN_STRINGLISTENTRYSTRUCT GWEN_STRINGLISTENTRY
Definition: stringlist.h:51
#define GWEN_TEXT_FLAGS_DEL_TRAILING_BLANKS
Definition: text.h:45
int GWEN_SyncIo_Connect(GWEN_SYNCIO *sio)
Definition: syncio.c:97
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
struct GWEN_PLUGIN GWEN_PLUGIN
Definition: plugin.h:39
GWEN_DBIO * GWEN_DBIO_new(const char *name, const char *descr)
Definition: dbio.c:207
GWEN_DBIO_CHECKFILE_RESULT GWEN_DBIO_CSV_CheckFile(GWEN_UNUSED GWEN_DBIO *dbio, const char *fname)
Definition: csv.c:596
void GWEN_StringList_Clear(GWEN_STRINGLIST *sl)
Definition: stringlist.c:224
#define GWEN_ERROR_INVALID
Definition: error.h:67
#define GWEN_SYNCIO_FILE_FLAGS_READ
Definition: syncio_file.h:53
int GWEN_FastBuffer_ReadLineToBuffer(GWEN_FAST_BUFFER *fb, GWEN_BUFFER *buf)
Definition: fastbuffer.c:95
#define DBG_VERBOUS(dbg_logger, format, args...)
Definition: debug.h:217
GWEN_DBIO * GWEN_DBIO_CSV_Factory(GWEN_UNUSED GWEN_PLUGIN *pl)
Definition: csv.c:649
void GWEN_DBIO_SetCheckFileFn(GWEN_DBIO *dbio, GWEN_DBIO_CHECKFILEFN f)
Definition: dbio.c:344
void GWEN_FastBuffer_free(GWEN_FAST_BUFFER *fb)
Definition: fastbuffer.c:46
#define DBG_ERROR_ERR(dbg_logger, dbg_err)
Definition: debug.h:113
#define GWEN_LOGDOMAIN
Definition: logger.h:35
void GWEN_DBIO_SetImportFn(GWEN_DBIO *dbio, GWEN_DBIO_IMPORTFN f)
Definition: dbio.c:329
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:42
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:386
void GWEN_Buffer_Reset(GWEN_BUFFER *bf)
Definition: buffer.c:650
#define GWEN_FASTBUFFER_FLUSH(fb, var)
Definition: fastbuffer.h:162
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:402
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
Definition: stringlist.c:58
int GWEN_DB_AddGroup(GWEN_DB_NODE *n, GWEN_DB_NODE *nn)
Definition: db.c:1480
struct GWEN_SYNCIO GWEN_SYNCIO
Definition: syncio.h:40
#define GWEN_TEXT_FLAGS_NULL_IS_DELIMITER
Definition: text.h:48
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
Definition: stringlist.c:241
int GWEN_DBIO_CSV_Import(GWEN_DBIO *dbio, GWEN_SYNCIO *sio, GWEN_DB_NODE *data, GWEN_DB_NODE *cfg, GWEN_UNUSED uint32_t flags)
Definition: csv.c:335
#define DBG_DEBUG(dbg_logger, format, args...)
Definition: debug.h:209
const char * GWEN_DB_GroupName(GWEN_DB_NODE *n)
Definition: db.c:1406
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
Definition: stringlist.h:54
#define GWEN_ERROR_GENERIC
Definition: error.h:62
GWEN_DB_NODE * GWEN_DB_GetNextGroup(GWEN_DB_NODE *n)
Definition: db.c:459
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition: db.c:969
GWEN_PLUGIN * dbio_csv_factory(GWEN_PLUGIN_MANAGER *pm, const char *modName, const char *fileName)
Definition: csv.c:662
int GWEN_DB_VariableExists(GWEN_DB_NODE *n, const char *path)
Definition: db.c:1563
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
Definition: db.c:1379
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:89
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:38
void GWEN_SyncIo_free(GWEN_SYNCIO *sio)
Definition: syncio.c:78
void GWEN_SyncIo_AddFlags(GWEN_SYNCIO *sio, uint32_t fl)
Definition: syncio.c:179
int GWEN_Text_NumToString(int num, char *buffer, unsigned int bufsize, int fillchar)
Definition: text.c:1243
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:423
void GWEN_DBIO_Plugin_SetFactoryFn(GWEN_PLUGIN *pl, GWEN_DBIO_PLUGIN_FACTORYFN f)
Definition: dbio.c:188
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
#define GWEN_ERROR_EOF
Definition: error.h:96
struct GWEN_DBIO GWEN_DBIO
Definition: dbio.h:43
#define GWEN_FASTBUFFER_WRITEFORCED(fb, var, p, len)
Definition: fastbuffer.h:377
int GWEN_SyncIo_Disconnect(GWEN_SYNCIO *sio)
Definition: syncio.c:109
void GWEN_DBIO_SetExportFn(GWEN_DBIO *dbio, GWEN_DBIO_EXPORTFN f)
Definition: dbio.c:337
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
Definition: db.c:995
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:394
#define GWEN_FASTBUFFER_WRITEBYTE(fb, var, chr)
Definition: fastbuffer.h:134
GWEN_DBIO_CHECKFILE_RESULT
Definition: dbio.h:79
GWEN_DB_NODE_TYPE GWEN_DB_GetValueTypeByPath(GWEN_DB_NODE *n, const char *path, unsigned int i)
Definition: db.c:1610
int GWEN_DBIO_CSV_Export(GWEN_DBIO *dbio, GWEN_SYNCIO *sio, GWEN_DB_NODE *data, GWEN_DB_NODE *cfg, GWEN_UNUSED uint32_t flags)
Definition: csv.c:98
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:178
#define GWEN_TEXT_FLAGS_DEL_QUOTES
Definition: text.h:49
int GWEN_Text_GetWordToBuffer(const char *src, const char *delims, GWEN_BUFFER *buf, uint32_t flags, const char **next)
Definition: text.c:226
GWEN_DB_NODE_TYPE
Definition: db.h:233
#define GWEN_TEXT_FLAGS_DEL_LEADING_BLANKS
Definition: text.h:44
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
Definition: db.c:1161
int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
Definition: buffer.c:361
GWENHYWFAR_API GWEN_SYNCIO * GWEN_SyncIo_File_new(const char *path, GWEN_SYNCIO_FILE_CREATIONMODE cm)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
Definition: db.c:171
#define GWEN_FASTBUFFER_WRITELINE(fb, var, p)
Definition: fastbuffer.h:407
int GWEN_CSV_GetNameAndIndex(const char *name, char *buffer, unsigned int size)
Definition: csv.c:51
GWEN_DB_NODE * GWEN_DB_GetFirstGroup(GWEN_DB_NODE *n)
Definition: db.c:438
GWEN_FAST_BUFFER * GWEN_FastBuffer_new(uint32_t bsize, GWEN_SYNCIO *io)
Definition: fastbuffer.c:27
GWEN_STRINGLIST * GWEN_StringList_new(void)
Definition: stringlist.c:46
#define GWEN_PATH_FLAGS_NAMEMUSTEXIST
Definition: path.h:84
int GWEN_DBIO_CSV__ReadLine(GWEN_FAST_BUFFER *fb, GWEN_STRINGLIST *sl)
Definition: csv.c:544
#define GWEN_UNUSED
#define GWEN_DB_FLAGS_DEFAULT
Definition: db.h:168
GWEN_PLUGIN * GWEN_DBIO_Plugin_new(GWEN_PLUGIN_MANAGER *pm, const char *name, const char *fileName)
Definition: dbio.c:147