Subversion Repositories wimsdev

Rev

Rev 8185 | Rev 14873 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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