gwenhywfar  4.99.8beta
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  unsigned int i;
55  int rv;
56 
57  i=0;
58  rv=0;
59  /* read and copy name */
60  while(name[i] && name[i]!='[' && i<size) {
61  buffer[i]=name[i];
62  i++;
63  } /* while */
64 
65  if (i>=size) {
66  DBG_INFO(0, "Name too long (%d>=%d)", i, size);
67  return -1;
68  }
69  buffer[i]=0;
70 
71  /* read and copy index, if any */
72  if (name[i]=='[') {
73  char numbuffer[16];
74  unsigned int j;
75 
76  j=0;
77  i++;
78  while(name[i] && name[i]!=']' && j<sizeof(numbuffer)) {
79  numbuffer[j]=name[i];
80  i++;
81  j++;
82  } /* while */
83  if (j>=sizeof(numbuffer)) {
84  DBG_INFO(0, "Index number too long (%u>=%d)", j,
85  (int)(sizeof(numbuffer)));
86  return -1;
87  }
88  numbuffer[j]=0;
89  rv=atoi(numbuffer);
90  }
91 
92  return rv;
93 }
94 
95 
96 
98  GWEN_SYNCIO *sio,
99  GWEN_DB_NODE *data,
100  GWEN_DB_NODE *cfg,
101  uint32_t flags) {
102  GWEN_DB_NODE *colgr;
103  GWEN_DB_NODE *n;
104  int delimiter;
105  int quote;
106  const char *p;
107  const char *groupName;
108  int err;
109  unsigned int column;
110  int title;
111  GWEN_FAST_BUFFER *fb;
112 
113  assert(dbio);
114  assert(sio);
115  assert(cfg);
116  assert(data);
117 
118  fb=GWEN_FastBuffer_new(512, sio);
119 
120  /* get general configuration */
121  colgr=GWEN_DB_GetGroup(cfg, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "columns");
122  if (!colgr) {
123  DBG_ERROR(0, "Error in configuration: No columns specified");
125  return GWEN_ERROR_INVALID;
126  }
127  p=GWEN_DB_GetCharValue(cfg, "delimiter", 0, ";");
128  if (strcasecmp(p, "TAB")==0)
129  delimiter=9;
130  else if (strcasecmp(p, "SPACE")==0)
131  delimiter=32;
132  else
133  delimiter=p[0];
134  quote=GWEN_DB_GetIntValue(cfg, "quote", 0, 1);
135  groupName=GWEN_DB_GetCharValue(cfg, "group", 0, "");
136  title=GWEN_DB_GetIntValue(cfg, "title", 0, 1);
137 
138  if (title) {
139  /* write title */
140  for (column=1; ; column++) {
141  int idx;
142  char namebuffer[64];
143  char numbuffer[16];
144  char *np;
145 
146  /* create name for column */
147  GWEN_Text_NumToString(column, numbuffer, sizeof(numbuffer), 0);
148  p=GWEN_DB_GetCharValue(colgr, numbuffer, 0, 0);
149  if (!p) {
150  /* no value. finished */
151  GWEN_FASTBUFFER_WRITELINE(fb, err, "");
152  if (err<0) {
153  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", err);
155  return err;
156  }
157  DBG_VERBOUS(GWEN_LOGDOMAIN, "No colums left, line finished");
158  break;
159  }
160  /* break down to name and index */
161  idx=GWEN_CSV_GetNameAndIndex(p, namebuffer, sizeof(namebuffer));
162  if (idx==-1) {
163  DBG_INFO(0, "Error in configuration: Bad name for column %d",
164  column);
166  return GWEN_ERROR_GENERIC;
167  }
168 
169  /* add idx to name, if not 0 */
170  if (idx) {
171  GWEN_Text_NumToString(idx, numbuffer, sizeof(numbuffer), 0);
172  if (strlen(namebuffer)+strlen(numbuffer)+1>=sizeof(namebuffer)) {
173  DBG_ERROR(0, "Internal: namebuffer too small");
175  return -1;
176  }
177  strcat(namebuffer, numbuffer);
178  }
179  /* convert slashes to underscores */
180  np=namebuffer;
181  while(*np) {
182  if (*np=='/')
183  *np='_';
184  np++;
185  }
186 
187  if (column!=1) {
188  /* write delimiter */
189  GWEN_FASTBUFFER_WRITEBYTE(fb, err, delimiter);
190  if (err<0) {
191  DBG_INFO(0, "Called from here");
193  return err;
194  }
195  } /* if not first column */
196  if (quote) {
197  /* write quotation mark */
198  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
199  if (err<0) {
200  DBG_INFO(0, "Called from here");
202  return err;
203  }
204  } /* if quote */
205  /* write value */
206  GWEN_FASTBUFFER_WRITEFORCED(fb, err, namebuffer, -1);
207  if (err<0) {
208  DBG_INFO(0, "Called from here");
210  return err;
211  }
212  if (quote) {
213  /* write quotation mark */
214  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
215  if (err<0) {
216  DBG_INFO(0, "Called from here");
218  return err;
219  }
220  } /* if quote */
221  } /* for */
222  } /* if title */
223 
224  n=GWEN_DB_GetFirstGroup(data);
225  while (n) {
226  if (*groupName==0 || strcasecmp(groupName, GWEN_DB_GroupName(n))==0) {
227  for (column=1; ; column++) {
228  int idx;
229  char namebuffer[64];
230  char numbuffer[16];
232  char valbuffer[64];
233  int iv;
234 
235  /* create name for column */
236  GWEN_Text_NumToString(column, numbuffer, sizeof(numbuffer), 0);
237  p=GWEN_DB_GetCharValue(colgr, numbuffer, 0, 0);
238  if (!p) {
239  /* no value. finished */
240  GWEN_FASTBUFFER_WRITELINE(fb, err, "");
241  if (err<0) {
242  DBG_INFO(0, "Called from here");
244  return err;
245  }
246  DBG_VERBOUS(GWEN_LOGDOMAIN, "No colums left, line finished");
247  break;
248  }
249 
250  /* break down to name and index */
251  idx=GWEN_CSV_GetNameAndIndex(p, namebuffer, sizeof(namebuffer));
252  if (idx==-1) {
253  DBG_INFO(GWEN_LOGDOMAIN, "Error in configuration: Bad name for column %d",
254  column);
256  return GWEN_ERROR_GENERIC;
257  }
258  /* get data */
259  DBG_VERBOUS(GWEN_LOGDOMAIN, "Checking value of %s[%d]", namebuffer, idx);
260  if (GWEN_DB_VariableExists(n, namebuffer)) {
261  vt=GWEN_DB_GetValueTypeByPath(n, namebuffer, idx);
262  switch(vt) {
264  p=GWEN_DB_GetCharValue(n, namebuffer, idx, "");
265  break;
267  iv=GWEN_DB_GetIntValue(n, namebuffer, idx, 0);
268  snprintf(valbuffer, sizeof(valbuffer), "%d", iv);
269  p=valbuffer;
270  break;
271  default:
272  DBG_DEBUG(GWEN_LOGDOMAIN, "Unhandled value type %d", vt);
273  p="";
274  }
275  }
276  else
277  p="";
278 
279  if (column!=1) {
280  /* write delimiter */
281  GWEN_FASTBUFFER_WRITEBYTE(fb, err, delimiter);
282  if (err<0) {
283  DBG_INFO(0, "Called from here");
285  return err;
286  }
287  } /* if not first column */
288  if (quote) {
289  /* write quotation mark */
290  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
291  if (err<0) {
292  DBG_INFO(0, "Called from here");
294  return err;
295  }
296  } /* if quote */
297  /* write value */
298  GWEN_FASTBUFFER_WRITEFORCED(fb, err, p, -1);
299  if (err<0) {
300  DBG_INFO(0, "Called from here");
302  return err;
303  }
304  if (quote) {
305  /* write quotation mark */
306  GWEN_FASTBUFFER_WRITEBYTE(fb, err, '\"');
307  if (err<0) {
308  DBG_INFO(0, "Called from here");
310  return err;
311  }
312  } /* if quote */
313 
314  } /* for */
315  } /* if group name matches */
317  } /* while n */
318 
319  /* flush */
320  GWEN_FASTBUFFER_FLUSH(fb, err);
321  if (err<0) {
322  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", err);
324  return err;
325  }
326 
328  return 0;
329 }
330 
331 
332 
334  GWEN_SYNCIO *sio,
335  GWEN_DB_NODE *data,
336  GWEN_DB_NODE *cfg,
337  uint32_t flags) {
338  GWEN_DB_NODE *colgr;
339  int delimiter;
340  int quote;
341  const char *p;
342  const char *groupName;
343  int err;
344  int title;
345  GWEN_STRINGLIST *sl;
346  GWEN_BUFFER *lbuffer;
347  char delimiters[2];
348  int lines;
349  int ignoreLines;
350  int fixedWidth;
351  int condense;
352  GWEN_FAST_BUFFER *fb;
353 
354  assert(dbio);
355  assert(sio);
356  assert(cfg);
357  assert(data);
358 
359  fb=GWEN_FastBuffer_new(512, sio);
360 
361  /* get general configuration */
362  colgr=GWEN_DB_GetGroup(cfg, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "columns");
363  if (!colgr) {
364  DBG_ERROR(0, "Error in configuration: No columns specified");
366  return GWEN_ERROR_INVALID;
367  }
368  p=GWEN_DB_GetCharValue(cfg, "delimiter", 0, ";");
369  if (strcasecmp(p, "TAB")==0)
370  delimiter=9;
371  else if (strcasecmp(p, "SPACE")==0)
372  delimiter=32;
373  else
374  delimiter=p[0];
375  delimiters[0]=delimiter;
376  delimiters[1]=0;
377  quote=GWEN_DB_GetIntValue(cfg, "quote", 0, 1);
378  fixedWidth=GWEN_DB_GetIntValue(cfg, "fixedWidth", 0, 0);
379  condense=GWEN_DB_GetIntValue(cfg, "condense", 0, 0);
380  groupName=GWEN_DB_GetCharValue(cfg, "group", 0, "line");
381  title=GWEN_DB_GetIntValue(cfg, "title", 0, 1);
382  ignoreLines=GWEN_DB_GetIntValue(cfg, "ignoreLines", 0, 0);
383  if (title)
384  ignoreLines++;
385 
386  sl=GWEN_StringList_new();
387  lbuffer=GWEN_Buffer_new(0, 256, 0, 1);
388 
389  lines=0;
390  for (;;) {
391  GWEN_BUFFER *wbuffer;
392  int rv;
393  const char *s;
395  int col;
396  GWEN_DB_NODE *n;
397 
398  /* read line */
399  DBG_DEBUG(GWEN_LOGDOMAIN, "Reading line %d", lines);
400  GWEN_Buffer_Reset(lbuffer);
401  err=GWEN_FastBuffer_ReadLineToBuffer(fb, lbuffer);
402  if (err<0) {
403  if (err==GWEN_ERROR_EOF) {
404  DBG_VERBOUS(GWEN_LOGDOMAIN, "EOF met");
405  break;
406  }
407  else {
409  GWEN_Buffer_free(lbuffer);
412  return err;
413  }
414  }
415 
416  if (lines<ignoreLines){
417  DBG_VERBOUS(GWEN_LOGDOMAIN, "Ignoring line %d", lines);
418  }
419  else {
420  /* read columns */
421  wbuffer=GWEN_Buffer_new(0, 256, 0, 1);
422 
423  s=GWEN_Buffer_GetStart(lbuffer);
424  if (fixedWidth) {
425  int i;
426  unsigned int llength;
427  unsigned int lpos=0;
428 
429  llength=strlen(s);
430  for (i=0; ; i++) {
431  int w;
432  char *t=0;
433  int left;
434 
435  left=llength-lpos;
436  w=GWEN_DB_GetIntValue(cfg, "width", i, -1);
437  if (w<1)
438  break;
439  if (w>left)
440  w=left;
441  if (w<1)
442  break;
443  t=(char*)malloc(w+1);
444  memmove(t, s, w);
445  t[w]=0;
446  if (condense) {
447  int j;
448 
449  for(j=w-1; j>=0; j--) {
450  if ((unsigned char)(t[j])>32) {
451  break;
452  }
453  t[j]=0;
454  }
455  }
456  /* take over new string */
457  GWEN_StringList_AppendString(sl, t, 1, 0);
458  s+=w;
459  lpos+=w;
460  }
461  }
462  else {
463  while(*s) {
464  rv=GWEN_Text_GetWordToBuffer(s, delimiters, wbuffer,
469  &s);
470  if (rv) {
471  DBG_DEBUG(GWEN_LOGDOMAIN, "here (%d)", rv);
472  GWEN_Buffer_free(wbuffer);
473  GWEN_Buffer_free(lbuffer);
476  return rv;
477  }
479  GWEN_Buffer_Reset(wbuffer);
480  if (*s) {
481  if (strchr(delimiters, *s))
482  s++;
483  }
484  } /* while */
485  }
486  GWEN_Buffer_free(wbuffer);
487 
488  /* store columns to db */
489  n=GWEN_DB_Group_new(groupName);
491  col=1;
492  while(se) {
493  char nbuff[16];
494  const char *vcol;
495 
496  DBG_DEBUG(0, "Handling column %d", col);
497  nbuff[0]=0;
498  snprintf(nbuff, sizeof(nbuff)-1, "%i", col);
499  nbuff[sizeof(nbuff)-1]=0;
500 
501  vcol=GWEN_DB_GetCharValue(colgr, nbuff, 0, 0);
502  if (vcol) {
503  const char *bracket;
504  GWEN_BUFFER *vname;
505 
506  bracket=strchr(vcol, '[');
507  if (bracket) {
508  /* copy column name without index */
509  vname=GWEN_Buffer_new(0, bracket-vcol+1, 0, 1);
510  GWEN_Buffer_AppendBytes(vname, vcol, bracket-vcol);
511  vcol=GWEN_Buffer_GetStart(vname);
512  }
513  else
514  vname=0;
516  vcol, GWEN_StringListEntry_Data(se));
517  GWEN_Buffer_free(vname);
518  }
519 
521  col++;
522  } /* while */
523 
524  /* add db to data */
525  GWEN_DB_AddGroup(data, n);
526  } /* if this is not the title line */
528  lines++;
529  } /* while */
530 
531  GWEN_Buffer_free(lbuffer);
533 
535 
536  return 0;
537 }
538 
539 
540 
542  int err;
543  const char *delimiters=";\t,";
544  GWEN_BUFFER *lbuffer;
545  GWEN_BUFFER *wbuffer;
546  int rv;
547  const char *s;
548 
549  assert(fb);
550 
551  /* read line */
552  lbuffer=GWEN_Buffer_new(0, 256, 0, 1);
553  GWEN_Buffer_Reset(lbuffer);
554  err=GWEN_FastBuffer_ReadLineToBuffer(fb, lbuffer);
555  if (err<0) {
557  GWEN_Buffer_free(lbuffer);
558  return err;
559  }
560 
561  /* read columns */
562  wbuffer=GWEN_Buffer_new(0, 256, 0, 1);
563 
564  s=GWEN_Buffer_GetStart(lbuffer);
565  while(*s) {
566  rv=GWEN_Text_GetWordToBuffer(s, delimiters, wbuffer,
571  &s);
572  if (rv) {
573  GWEN_Buffer_free(wbuffer);
574  GWEN_Buffer_free(lbuffer);
575  return rv;
576  }
578  GWEN_Buffer_Reset(wbuffer);
579  if (*s) {
580  if (strchr(delimiters, *s))
581  s++;
582  }
583  } /* while */
584  GWEN_Buffer_free(wbuffer);
585  GWEN_Buffer_free(lbuffer);
586 
587  return 0;
588 }
589 
590 
591 
593  int i;
594  int rv;
595  GWEN_SYNCIO *sio;
596  GWEN_STRINGLIST *sl;
597  GWEN_FAST_BUFFER *fb;
598 
601  rv=GWEN_SyncIo_Connect(sio);
602  if (rv<0) {
603  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
604  GWEN_SyncIo_free(sio);
605  return rv;
606  }
607 
608  fb=GWEN_FastBuffer_new(512, sio);
609 
610  /* read line into string list */
611  sl=GWEN_StringList_new();
612  if (GWEN_DBIO_CSV__ReadLine(fb, sl)) {
613  DBG_INFO(GWEN_LOGDOMAIN, "Error reading a line");
616  GWEN_SyncIo_free(sio);
618  }
619 
620  /* first column: number */
621  i=GWEN_StringList_Count(sl);
623  if (i) {
625  "Found %d columns, file might be supported", i);
628  GWEN_SyncIo_free(sio);
629  /*return GWEN_DBIO_CheckFileResultOk; */
631  }
632  else {
634  "Found no columns, file might not be supported");
637  GWEN_SyncIo_free(sio);
639  }
640 }
641 
642 
643 
645  GWEN_DBIO *dbio;
646 
647  dbio=GWEN_DBIO_new("csv", "Imports and exports CSV data");
651  return dbio;
652 }
653 
654 
655 
657  const char *modName,
658  const char *fileName) {
659  GWEN_PLUGIN *pl;
660 
661  pl=GWEN_DBIO_Plugin_new(pm, modName, fileName);
662  assert(pl);
663 
665 
666  return pl;
667 
668 }
669 
670 
671 
672 
673 
674 
675 
676 
struct GWEN_PLUGIN_MANAGER GWEN_PLUGIN_MANAGER
Definition: plugin.h:40
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:223
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:94
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:201
void GWEN_StringList_Clear(GWEN_STRINGLIST *sl)
Definition: stringlist.c:214
#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:92
#define DBG_VERBOUS(dbg_logger, format, args...)
Definition: debug.h:200
void GWEN_DBIO_SetCheckFileFn(GWEN_DBIO *dbio, GWEN_DBIO_CHECKFILEFN f)
Definition: dbio.c:327
void GWEN_FastBuffer_free(GWEN_FAST_BUFFER *fb)
Definition: fastbuffer.c:45
#define DBG_ERROR_ERR(dbg_logger, dbg_err)
Definition: debug.h:108
#define GWEN_LOGDOMAIN
Definition: logger.h:35
void GWEN_DBIO_SetImportFn(GWEN_DBIO *dbio, GWEN_DBIO_IMPORTFN f)
Definition: dbio.c:314
int GWEN_DBIO_CSV_Export(GWEN_DBIO *dbio, GWEN_SYNCIO *sio, GWEN_DB_NODE *data, GWEN_DB_NODE *cfg, uint32_t flags)
Definition: csv.c:97
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:38
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:352
void GWEN_Buffer_Reset(GWEN_BUFFER *bf)
Definition: buffer.c:684
#define GWEN_FASTBUFFER_FLUSH(fb, var)
Definition: fastbuffer.h:162
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:366
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
Definition: stringlist.c:57
int GWEN_DB_AddGroup(GWEN_DB_NODE *n, GWEN_DB_NODE *nn)
Definition: db.c:1358
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:230
#define DBG_DEBUG(dbg_logger, format, args...)
Definition: debug.h:192
GWEN_DBIO * GWEN_DBIO_CSV_Factory(GWEN_PLUGIN *pl)
Definition: csv.c:644
const char * GWEN_DB_GroupName(GWEN_DB_NODE *n)
Definition: db.c:1286
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:406
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition: db.c:897
GWEN_PLUGIN * dbio_csv_factory(GWEN_PLUGIN_MANAGER *pm, const char *modName, const char *fileName)
Definition: csv.c:656
int GWEN_DB_VariableExists(GWEN_DB_NODE *n, const char *path)
Definition: db.c:1437
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
Definition: db.c:1260
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:83
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:41
void GWEN_SyncIo_free(GWEN_SYNCIO *sio)
Definition: syncio.c:76
void GWEN_SyncIo_AddFlags(GWEN_SYNCIO *sio, uint32_t fl)
Definition: syncio.c:169
int GWEN_Text_NumToString(int num, char *buffer, unsigned int bufsize, int fillchar)
Definition: text.c:1196
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:382
void GWEN_DBIO_Plugin_SetFactoryFn(GWEN_PLUGIN *pl, GWEN_DBIO_PLUGIN_FACTORYFN f)
Definition: dbio.c:183
#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:105
void GWEN_DBIO_SetExportFn(GWEN_DBIO *dbio, GWEN_DBIO_EXPORTFN f)
Definition: dbio.c:321
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
Definition: db.c:922
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:359
#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:1481
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:164
#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:198
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:1048
int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf, const char *buffer, uint32_t size)
Definition: buffer.c:348
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:131
#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:386
GWEN_DBIO_CHECKFILE_RESULT GWEN_DBIO_CSV_CheckFile(GWEN_DBIO *dbio, const char *fname)
Definition: csv.c:592
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:541
#define GWEN_DB_FLAGS_DEFAULT
Definition: db.h:168
int GWEN_DBIO_CSV_Import(GWEN_DBIO *dbio, GWEN_SYNCIO *sio, GWEN_DB_NODE *data, GWEN_DB_NODE *cfg, uint32_t flags)
Definition: csv.c:333
GWEN_PLUGIN * GWEN_DBIO_Plugin_new(GWEN_PLUGIN_MANAGER *pm, const char *name, const char *fileName)
Definition: dbio.c:145