104{
105 char* singular =
NULL;
107#ifndef TSINGULAR
108 char* emacs_dir =
NULL;
109 char* emacs_load =
NULL;
111#endif
112 int no_emacs_call = 0;
113
114
115
120
121 int optc, option_index;
122
125 != EOF)
126 {
127 switch(optc)
128 {
129 case 'h':
131
133 exit(0);
134 break;
135 case '?':
136 case ':':
137 case '\0':
139 exit(1);
140
142 {
143 switch(option_index)
144 {
145#ifdef TSINGULAR
146 case FE_OPT_XTERM:
148 break;
149#else
150 case FE_OPT_EMACS:
152 break;
153
154 case FE_OPT_EMACS_DIR:
156 break;
157
158 case FE_OPT_EMACS_LOAD:
160 break;
161#endif
162 case FE_OPT_SINGULAR:
164 break;
165
166 case FE_OPT_NO_CALL:
167 no_emacs_call = 1;
168 break;
169
170 case FE_OPT_DUMP_VERSIONTUPLE:
172 exit(0);
173 break;
174
175 default:
177 }
178
181 {
183 }
185 }
186 }
188 }
189
191 char* syscall;
192 for (
i=1;
i<argc;
i++)
193 {
195 }
196
197#ifdef TSINGULAR
200 {
201 #ifdef __CYGWIN__
202 error(
"Error: Can't find rxvt program. \n Expected it at %s\n Specify alternative with --rxvt=PROGRAM option,\n or set RXVT environment variable to the name of the program to use as rxvt.\n",
203 #else
204 error(
"Error: Can't find xterm program. \n Expected it at %s\n Specify alternative with --xterm=PROGRAM option,\n or set XTERM environment variable to the name of the program to use as xterm.\n",
205 #endif
208 exit(1);
209 }
210
212 if (singular ==
NULL)
213 {
214 error(
"Error: Can't find singular executable.\n Expected it at %s\n Specify with --singular option,\n or set TSINGULAR_SINGULAR environment variable.\n",
217 exit(1);
218 }
219
220#ifdef __CYGWIN__
221#define EXTRA_XTERM_ARGS "+vb -sl 2000 -fb Courier-bold-12 -tn xterm -cr Red3"
222#else
223#define EXTRA_XTERM_ARGS ""
224#endif
225
226 syscall = (
char*)
omAlloc(strlen(emacs) +
227 strlen(singular) +
229 sprintf(syscall, "%s %s -e %s ", emacs, EXTRA_XTERM_ARGS, singular);
230
231 for (
i=1;
i<argc;
i++)
232 {
234 {
235 strcat(syscall, " ");
236 strcat(syscall, argv[
i]);
237 }
238 }
239#else
240
244 {
245 error(
"Error: Can't find emacs or xemacs executable. \n Expected it at %s or %s\n Specify alternative with --emacs option,\n or set ESINGULAR_EMACS environment variable.\n",
248 exit(1);
249 }
250
252 if (singular ==
NULL)
253 {
254 error(
"Error: Can't find singular executable.\n Expected it at %s\n Specify with --singular option,\n or set ESINGULAR_SINGULAR environment variable.\n",
257 exit(1);
258 }
259
261 if (emacs_dir ==
NULL)
262 {
263 error(
"Error: Can't find emacs directory for Singular lisp files. \n Expected it at %s\n Specify with --emacs-dir option,\n or set ESINGULAR_EMACS_DIR environment variable.\n",
266 exit(1);
267 }
268
269 if (emacs_load ==
NULL)
270 {
271
272 emacs_load =
getenv(
"ESINGULAR_EMACS_LOAD");
273 if (access(emacs_load, R_OK))
274 {
275
276 emacs_load =
getenv(
"HOME");
277#ifdef __CYGWIN__
278 if ((emacs_load==
NULL)||(!access(emacs_load,X_OK)))
279 emacs_load =
getenv(
"SINGHOME");
280#endif
281 sprintf(cwd, "%s/.emacs-singular", emacs_load);
282 if (! access(cwd, R_OK))
283 {
285 }
286 else
287 {
288
290 if (emacs_load ==
NULL)
291 {
292 error(
"Error: Can't find emacs load file for Singular mode. \n Expected it at %s\n Specify with --emacs-load option,\n or set ESINGULAR_EMACS_LOAD environment variable,\n or put file '.emacs-singular' in your home directory.\n",
295 exit(1);
296 }
297 }
298 }
299 }
300
301 syscall = (
char*)
omAlloc(strlen(emacs) +
302 strlen(singular) +
303 strlen(emacs_dir) +
304 strlen(emacs_load) +
306 const char* prefix = "--";
307 if (strstr(emacs, "xemacs") || strstr(emacs, "Xemacs") || strstr(emacs, "XEMACS"))
308 prefix = "-";
310
311 if (cwd[strlen(cwd)-1] != '/') strcat(cwd, "/");
312
313
314
315 sprintf(syscall, "%s %sno-init-file %seval '(progn (setq singular-emacs-home-directory \"%s\") (load-file \"%s\") (singular-other \"%s\" \"%s\" (list ",
316 emacs, prefix, prefix, emacs_dir, emacs_load,
317 singular, cwd);
318
319
320 for (
i=1;
i<argc;
i++)
321 {
323 {
324 strcat(syscall, "\"");
325 strcat(syscall, argv[
i]);
326 strcat(syscall, "\" ");
327 }
328 }
329 strcat(syscall, ") \"singular\"))'");
330#endif
331
332 if (no_emacs_call)
333 {
334 printf("%s\n", syscall);
335 }
336 else
337 {
338 if (system(syscall) != 0)
339 {
340 error(
"Error: Execution of\n%s\n", syscall);
342 exit(1);
343 }
344 }
345}
char * feResourceDefault(const char id)
#define LONG_OPTION_RETURN
const char SHORT_OPTS_STRING[]
void feOptDumpVersionTuple(void)
void feOptHelp(const char *name)
EXTERN_VAR struct fe_option feOptSpec[]
static char * feResource(feResourceConfig config, int warn)
void feInitResources(const char *argv0)
int fe_getopt_long(int argc, char *const *argv, const char *options, const struct fe_option *long_options, int *opt_index)
static BOOLEAN length(leftv result, leftv arg)
int name
New type name for int.