Subversion Repositories wimsdev

Rev

Rev 8122 | Rev 8185 | 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
#include "../../Lib/libwims.h"
22
 
23
char parmbuf[MAX_LINELEN+1];
24
char *objline[MAX_OBJLINES];
25
int objlinecnt, thisobjline, thislinelen;
26
int expl1, expl2;
27
char *reqtype;
28
int logdir, linelogdir;
29
char *fnd_position;
30
char *fnd_nextpos;
31
 
8136 bpr 32
regex regexchk[MAX_REGEX];
33
 
10 reyssat 34
int regexcnt=0;
35
 
36
struct {
37
    char *name;
38
    void (*routine)(void);
39
} req[]={
40
    {"cut",             req_cut},
41
    {"extract",         req_extract},
42
    {"not",             req_not},
43
    {"reverse",         req_not},
44
    {"type",            req_type},
45
};
46
int request;
47
#define reqcnt (sizeof(req)/sizeof(req[0]))
48
 
49
void parm()
50
{
51
    char *p, *pp;
52
    for(pp=parmbuf;*pp;pp++) if(*pp=='  ') *pp='\n';
53
    for(objlinecnt=0,p=parmbuf; *p && objlinecnt<MAX_OBJLINES; p=pp) {
54
        pp=strchr(p,'\n'); if(pp) *pp++=0; else pp=p+strlen(p);
55
        strip_trailing_spaces(p);
56
        objline[objlinecnt]=p; objlinecnt++;
57
    }
58
    if(objlinecnt<1) error("Empty input data.");
59
    logdir=0;
60
    if((p=wordchr(objline[0],"<"))!=NULL) {
3718 reyssat 61
        logdir=-1; ovlstrcpy(p,p+1);
10 reyssat 62
    }
63
    if((p=wordchr(objline[0],">"))!=NULL) {
3718 reyssat 64
        logdir=1; ovlstrcpy(p,p+1);
10 reyssat 65
    }
66
    p=find_word_start(objline[0]); pp=find_word_end(p); if(*pp) *pp++=0;
67
    objline[0]=pp;
68
    for(request=0;request<reqcnt && strcasecmp(req[request].name,p)!=0; request++);
69
    if(request>=reqcnt) error("Bad request.");
70
    p=find_word_start(pp); pp=find_word_end(p); if(*pp) *pp++=0;
71
    objline[0]=pp; reqtype=p;
72
}
73
 
74
int main()
75
{
76
    char *p;
77
    int i;
8122 bpr 78
    string_modify=string_modify1;
10 reyssat 79
    error1=error; error2=error; error3=error;
80
    p=getenv("wims_exec_parm");
81
    if(p==NULL || *p==0) error("No input data.");
82
    snprintf(parmbuf,sizeof(parmbuf),"%s",p);
83
    parm();
84
    req[request].routine();
3838 kbelabas 85
    for(i=0;i<regexcnt;i++) if(regexchk[i].isvar==0) regfree(&(regexchk[i].cmpreg));
10 reyssat 86
    return 0;
87
}
88