Rev 8195 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 2002-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program; if not, write to the Free Software |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
17 | |||
8122 | bpr | 18 | /* Mathematical expression manipulations for WIMS */ |
10 | reyssat | 19 | |
20 | #include "mathexp.h" |
||
21 | |||
22 | char parmbuf[MAX_LINELEN+1]; |
||
23 | char *objline[MAX_OBJLINES]; |
||
24 | int objlinecnt, thisobjline, thislinelen; |
||
25 | int expl1, expl2; |
||
26 | char *reqtype; |
||
27 | int logdir, linelogdir; |
||
14873 | georgesk | 28 | |
29 | /** |
||
30 | * GK 2020-04-18 |
||
31 | * commented out those extra declarations, which raise errors with gcc-10 |
||
32 | * since "fnd_position" is already defined in libwims.c, line 22 and |
||
33 | * "fnd_nextpos" is already defined in libwims.c, line 23 |
||
10 | reyssat | 34 | char *fnd_position; |
35 | char *fnd_nextpos; |
||
14873 | georgesk | 36 | **/ |
10 | reyssat | 37 | |
8136 | bpr | 38 | regex regexchk[MAX_REGEX]; |
39 | |||
10 | reyssat | 40 | int regexcnt=0; |
41 | |||
42 | struct { |
||
43 | char *name; |
||
44 | void (*routine)(void); |
||
45 | } req[]={ |
||
46 | {"cut", req_cut}, |
||
47 | {"extract", req_extract}, |
||
48 | {"not", req_not}, |
||
49 | {"reverse", req_not}, |
||
50 | {"type", req_type}, |
||
51 | }; |
||
52 | int request; |
||
53 | #define reqcnt (sizeof(req)/sizeof(req[0])) |
||
54 | |||
55 | void parm() |
||
56 | { |
||
57 | char *p, *pp; |
||
58 | for(pp=parmbuf;*pp;pp++) if(*pp==' ') *pp='\n'; |
||
59 | for(objlinecnt=0,p=parmbuf; *p && objlinecnt<MAX_OBJLINES; p=pp) { |
||
60 | pp=strchr(p,'\n'); if(pp) *pp++=0; else pp=p+strlen(p); |
||
61 | strip_trailing_spaces(p); |
||
62 | objline[objlinecnt]=p; objlinecnt++; |
||
63 | } |
||
64 | if(objlinecnt<1) error("Empty input data."); |
||
65 | logdir=0; |
||
66 | if((p=wordchr(objline[0],"<"))!=NULL) { |
||
3718 | reyssat | 67 | logdir=-1; ovlstrcpy(p,p+1); |
10 | reyssat | 68 | } |
69 | if((p=wordchr(objline[0],">"))!=NULL) { |
||
3718 | reyssat | 70 | logdir=1; ovlstrcpy(p,p+1); |
10 | reyssat | 71 | } |
72 | p=find_word_start(objline[0]); pp=find_word_end(p); if(*pp) *pp++=0; |
||
73 | objline[0]=pp; |
||
74 | for(request=0;request<reqcnt && strcasecmp(req[request].name,p)!=0; request++); |
||
75 | if(request>=reqcnt) error("Bad request."); |
||
76 | p=find_word_start(pp); pp=find_word_end(p); if(*pp) *pp++=0; |
||
77 | objline[0]=pp; reqtype=p; |
||
78 | } |
||
79 | |||
80 | int main() |
||
81 | { |
||
82 | char *p; |
||
83 | int i; |
||
8122 | bpr | 84 | string_modify=string_modify1; |
10 | reyssat | 85 | p=getenv("wims_exec_parm"); |
86 | if(p==NULL || *p==0) error("No input data."); |
||
87 | snprintf(parmbuf,sizeof(parmbuf),"%s",p); |
||
88 | parm(); |
||
89 | req[request].routine(); |
||
3838 | kbelabas | 90 | for(i=0;i<regexcnt;i++) if(regexchk[i].isvar==0) regfree(&(regexchk[i].cmpreg)); |
10 | reyssat | 91 | return 0; |
92 | } |
||
93 |