Subversion Repositories wimsdev

Rev

Rev 8501 | Rev 8529 | 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) 1998-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
 
7674 bpr 18
/* Interface gap to wims */
10 reyssat 19
 
20
/*************** Customization: change values hereafter ****************/
8120 bpr 21
#include "common.h"
10 reyssat 22
 
7674 bpr 23
/* gap prompt string */
10 reyssat 24
#define gapprompt "gap> "
7674 bpr 25
/* This string tells gap to exit. */
8120 bpr 26
char *quitstring="\nquit;\n";
7674 bpr 27
/* The way to print a string in the program. */
8120 bpr 28
char *stringprinter="Print(\"%s\\n\");\n";
7674 bpr 29
/* This is GAP home page. To be kept up to date. */
8501 bpr 30
#define homepage "http://www.gap-system.org/"
10 reyssat 31
 
8120 bpr 32
/* limit of input/output file sizes */
33
int fsizelim=131072;
34
int precision=20; /* default */
35
 
10 reyssat 36
char *nameofcmd="gap.sh -T -n";
37
char header[]="\n\
38
";
39
 
40
struct {
8120 bpr 41
    char *wname; char *defaultval;
10 reyssat 42
} setups[]={
43
};
44
 
7674 bpr 45
/* names which are not allowed */
10 reyssat 46
char *illegal[]={
47
      "Reread","Process","Exec","Filename","SaveWorkspace"
48
};
49
 
8120 bpr 50
int illegal_no=(sizeof(illegal)/sizeof(illegal[0]));
51
 
7674 bpr 52
/* name parts which are not allowed */
10 reyssat 53
char *illpart[]={
54
    "File", "Path", "Read", "To"
55
};
56
 
8120 bpr 57
int illpart_no=(sizeof(illpart)/sizeof(illpart[0]));
58
 
10 reyssat 59
/***************** Nothing should need change hereafter *****************/
60
 
8120 bpr 61
char *progname="gap";
10 reyssat 62
 
7674 bpr 63
/* check for security violations in command string */
10 reyssat 64
void check_parm(char *pm)
65
{
66
    char *pp; int l;
7674 bpr 67
/* Underscore replacement */
10 reyssat 68
    for(pp=strchr(pm,'_'); pp!=NULL; pp=strchr(pp+1,'_')) *pp='K';
8100 bpr 69
    strip_trailing_spaces2(pm); l=strlen(pm);
10 reyssat 70
    if(l>0 && pm[l-1]!=';') strcat(pm,";");
71
    find_illegal(pm);
72
}
73
 
7674 bpr 74
/* process and print gap output */
10 reyssat 75
void output(char *p)
76
{
77
    int i,n;
78
    char *pp, *pe, *pt;
79
 
80
    pp=strstr(p,gapprompt); if(pp==NULL) return;
3718 reyssat 81
    while((pt=strstr(pp,"\\\n"))!=NULL) ovlstrcpy(pt,pt+2);
10 reyssat 82
    while(pp!=NULL) {
7674 bpr 83
      pp+=strlen(gapprompt);
84
      pe=strstr(pp,gapprompt);
85
      if(pe>=pp) *pe=0;
86
      if(pe!=NULL && pp>=pe) {
87
          emptyline:
88
          puts(""); pp=pe; continue;
89
      }
90
      n=strlen(pp);
91
      if(n==0) goto emptyline;
92
/* make every output one-line */
93
      for(i=0;i<n;i++) {
94
          if(*(pp+i)=='\n') {
95
            if(*(pp+i+1)!='%') *(pp+i)=' ';
96
            else {*(pp+i)=0; break;}
97
          }
98
      }
99
/* strip leading and trailing spaces */
100
      while(isspace(*pp) && pp<pe) pp++;
101
      pt=pp+strlen(pp)-1;
102
      while(isspace(*pt) && pt>pp) *pt--=0;
103
      if(*pp=='[' && *pt==']') {
104
          *(pt--)=0; pp++;
105
      }
106
      puts(pp); pp=pe;
10 reyssat 107
    }
108
}
109
 
110
void about(void)
111
{
112
/*    char *p;
113
*/
5762 bpr 114
    printf("<a href=\"%s\">GAP4</a>",homepage); return;
10 reyssat 115
/*    prepabout(quitstring,outputfname,NULL);
116
    if(readabout()>0) {
7674 bpr 117
      p=strchr(aboutbuf,'\n'); if(p!=NULL) *p=0;
118
      strip_trailing_spaces(aboutbuf);
119
      printf("<A HREF=\"%s\">%s</A>",homepage,aboutbuf);
10 reyssat 120
    }
121
*/
122
}
123
 
124
char *dynsetup(char *ptr, char *end)
125
{
126
    int i;
127
    char *p, *pp;
128
    for(i=0;i<SETUP_NO;i++) {
7674 bpr 129
      p=getenv(setups[i].wname);
130
      if(p!=NULL) for(pp=p;*pp;pp++) if(!isspace(*pp) && !isalnum(*pp)) p="";
131
      if(p==NULL || *p==0) p=setups[i].defaultval;
10 reyssat 132
    }
133
    return ptr;
134
}
135
 
136
int main(int argc,char *argv[])
137
{
138
    prepare1();
8526 bpr 139
    setenv("HOME","/nodir",1);
10 reyssat 140
    run();
7674 bpr 141
    return 0;
10 reyssat 142
}