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