TPCCLIB
Loading...
Searching...
No Matches
csvfind.c
Go to the documentation of this file.
1
4/*****************************************************************************/
5#include "tpcclibConfig.h"
6/*****************************************************************************/
7#include "tpcextensions.h"
8/*****************************************************************************/
9#include <stdio.h>
10#include <stdlib.h>
11#include <string.h>
12#include <strings.h>
13#include <ctype.h>
14#include <math.h>
15#include <time.h>
16/*****************************************************************************/
17#include "tpccsv.h"
18/*****************************************************************************/
19
20/*****************************************************************************/
29 CSV *csv,
31 const char *s,
33 int start_index
34) {
35 if(csv==NULL || s==NULL) return -2;
36 if(start_index<0 || start_index>=csv->nr) return -2;
37 for(int i=start_index; i<csv->nr; i++) if(csv->c[i].content!=NULL)
38 if(strcasecmp(csv->c[i].content, s)==0) return i;
39 return -1;
40}
41/*****************************************************************************/
42
43/*****************************************************************************/
52 CSV *csv,
54 const char *s,
56 int start_index
57) {
58 if(csv==NULL || s==NULL) return -2;
59 if(start_index<0 || start_index>=csv->nr) return -2;
60 for(int i=start_index; i<csv->nr; i++) {
61 if(csv->c[i].content==NULL || csv->c[i].content[0]=='\0') {
62 if(*s=='\0') return i; else continue;
63 }
64 if(*s=='\0') continue;
65 if(strcasestr(csv->c[i].content, s)!=NULL) return i;
66 }
67 return -1;
68}
69/*****************************************************************************/
70
71/*****************************************************************************/
int csvFindField(CSV *csv, const char *s, int start_index)
Definition csvfind.c:27
int csvSearchField(CSV *csv, const char *s, int start_index)
Definition csvfind.c:50
char * strcasestr(const char *haystack, const char *needle)
Definition stringext.c:155
char * content
Definition tpccsv.h:30
Definition tpccsv.h:36
CSV_item * c
Definition tpccsv.h:38
int nr
Definition tpccsv.h:42
Header file for library libtpccsv.
Header file for library libtpcextensions.