Subversion Repositories wimsdev

Rev

Rev 8086 | Rev 8122 | 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
 
18
        /* Mathematical expression manipulations for WIMS */
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
 
32
struct {
33
    char *srcreg;
34
    regex_t cmpreg;
35
    int isvar;
36
} regexchk[MAX_REGEX];
37
int regexcnt=0;
38
 
39
#include "tables.c"
40
#include "errors.c"
8100 bpr 41
#include "../../Lib/lines.c"
10 reyssat 42
#include "basic.c"
43
#include "extract.c"
44
#include "type.c"
45
#include "not.c"
46
 
47
struct {
48
    char *name;
49
    void (*routine)(void);
50
} req[]={
51
    {"cut",             req_cut},
52
    {"extract",         req_extract},
53
    {"not",             req_not},
54
    {"reverse",         req_not},
55
    {"type",            req_type},
56
};
57
int request;
58
#define reqcnt (sizeof(req)/sizeof(req[0]))
59
 
60
void parm()
61
{
62
    char *p, *pp;
63
    for(pp=parmbuf;*pp;pp++) if(*pp=='  ') *pp='\n';
64
    for(objlinecnt=0,p=parmbuf; *p && objlinecnt<MAX_OBJLINES; p=pp) {
65
        pp=strchr(p,'\n'); if(pp) *pp++=0; else pp=p+strlen(p);
66
        strip_trailing_spaces(p);
67
        objline[objlinecnt]=p; objlinecnt++;
68
    }
69
    if(objlinecnt<1) error("Empty input data.");
70
    logdir=0;
71
    if((p=wordchr(objline[0],"<"))!=NULL) {
3718 reyssat 72
        logdir=-1; ovlstrcpy(p,p+1);
10 reyssat 73
    }
74
    if((p=wordchr(objline[0],">"))!=NULL) {
3718 reyssat 75
        logdir=1; ovlstrcpy(p,p+1);
10 reyssat 76
    }
77
    p=find_word_start(objline[0]); pp=find_word_end(p); if(*pp) *pp++=0;
78
    objline[0]=pp;
79
    for(request=0;request<reqcnt && strcasecmp(req[request].name,p)!=0; request++);
80
    if(request>=reqcnt) error("Bad request.");
81
    p=find_word_start(pp); pp=find_word_end(p); if(*pp) *pp++=0;
82
    objline[0]=pp; reqtype=p;
83
}
84
 
8086 bpr 85
void (*string_modify)(char *start, char *bad_beg, char *bad_end, char *good,...)=string_modify1;
86
 
10 reyssat 87
int main()
88
{
89
    char *p;
90
    int i;
8086 bpr 91
 
10 reyssat 92
    error1=error; error2=error; error3=error;
93
    p=getenv("wims_exec_parm");
94
    if(p==NULL || *p==0) error("No input data.");
95
    snprintf(parmbuf,sizeof(parmbuf),"%s",p);
96
    parm();
97
    req[request].routine();
3838 kbelabas 98
    for(i=0;i<regexcnt;i++) if(regexchk[i].isvar==0) regfree(&(regexchk[i].cmpreg));
10 reyssat 99
    return 0;
100
}
101