TPCCLIB
Loading...
Searching...
No Matches
quots.c
Go to the documentation of this file.
1
5/****************************************************************************/
6#include "libtpcmisc.h"
7/*****************************************************************************/
8
9/*****************************************************************************/
19 const char *str1,
21 const char *str2
22) {
23 unsigned int i, test_len;
24 unsigned int single_quotation=0;
25 unsigned int double_quotation=0;
26 char *cptr;
27
28 if(str1==NULL) return((char*)NULL);
29 if(str2==NULL) return((char*)str1);
30 test_len=strlen(str2); if(test_len<1) return((char*)str1);
31 for(i=0, cptr=(char*)str1; i<strlen(str1); i++, cptr++) {
32 if(*cptr=='\'') {
33 if(single_quotation==0) single_quotation=1; else single_quotation=0;
34 continue;
35 }
36 if(*cptr=='\"') {
37 if(double_quotation==0) double_quotation=1; else double_quotation=0;
38 continue;
39 }
40 if(single_quotation==1 || double_quotation==1) continue;
41 if(strncmp(cptr, str2, test_len)==0) return(cptr);
42 }
43 return((char*)NULL);
44}
45/*****************************************************************************/
46
47/*****************************************************************************/
55 char *str1,
57 const char *str2,
59 int maxlen
60) {
61 char *cptr;
62 int i;
63
64 if(str1==NULL || maxlen<1) return(0);
65 str1[0]=(char)0; if(str2==NULL || strlen(str2)<1) return(0);
66 cptr=(char*)str2; cptr+=strspn(str2, "\"\'\t\n\r ");
67 strncpy(str1, cptr, maxlen-1); str1[maxlen-1]=(char)0;
68 i=strlen(str1); if(i<1) return(0);
69 cptr=str1+(i-1);
70 while(i>0) {
71 if(*cptr!='\"' && *cptr!='\'' && *cptr!='\t' && *cptr!='\n' &&
72 *cptr!='\r' && *cptr!=' ')
73 break;
74 i--; str1[i]=(char)0; cptr--;
75 }
76 return(i);
77}
78/*****************************************************************************/
79
80/*****************************************************************************/
81
Header file for libtpcmisc.
char * strstr_noquotation(const char *str1, const char *str2)
Definition quots.c:17
int strnCopyClean(char *str1, const char *str2, int maxlen)
Definition quots.c:52