Subversion Repositories wimsdev

Rev

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