17 #define BOOLEAN boolean 36 #if !defined(TSINGULAR) && !defined(ESINGULAR) 51 #define MAXPATHLEN 1024 58 void error(
const char *fmt, ...)
62 vfprintf(stderr, fmt, ap);
65 void error(
const char* fmt, ...)
72 j += vsprintf(
buf +
j,fmt,args);
73 j += sprintf(
buf +
j,
"\n");
75 MessageBox(
NULL,
buf,
"ESingular.exe", MB_ICONSTOP);
82 #define StringAppend printf 85 #define feReportBug(s) fePrintReportBug(s, __FILE__, __LINE__) 88 error(
"YOU HAVE FOUND A BUG IN SINGULAR.\n" 89 "Please, email the following output to singular@mathematik.uni-kl.de\n" 90 "Bug occurred at %s:%d\n" 92 "Version: " S_UNAME
VERSION __DATE__ __TIME__,
99 error(
"Use `%s --help' for a complete list of options\n",
feArgv0);
106 int main(
int argc,
char** argv)
108 char* singular =
NULL;
111 char* emacs_dir =
NULL;
112 char* emacs_load =
NULL;
115 int no_emacs_call = 0;
124 int optc, option_index;
157 case FE_OPT_EMACS_DIR:
161 case FE_OPT_EMACS_LOAD:
165 case FE_OPT_SINGULAR:
173 case FE_OPT_DUMP_VERSIONTUPLE:
195 for (
i=1;
i<argc;
i++)
197 if (argv[
i] !=
NULL) length += strlen(argv[
i]) + 3;
205 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",
207 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",
215 if (singular ==
NULL)
217 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",
224 #define EXTRA_XTERM_ARGS "+vb -sl 2000 -fb Courier-bold-12 -tn xterm -cr Red3" 226 #define EXTRA_XTERM_ARGS "" 229 syscall = (
char*)
omAlloc(strlen(emacs) +
232 sprintf(syscall,
"%s %s -e %s ", emacs, EXTRA_XTERM_ARGS, singular);
234 for (
i=1;
i<argc;
i++)
238 strcat(syscall,
" ");
239 strcat(syscall, argv[
i]);
248 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",
255 if (singular ==
NULL)
257 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",
264 if (emacs_dir ==
NULL)
266 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",
272 if (emacs_load ==
NULL)
275 emacs_load =
getenv(
"ESINGULAR_EMACS_LOAD");
276 if (access(emacs_load, R_OK))
279 emacs_load =
getenv(
"HOME");
281 if ((emacs_load==
NULL)||(!access(emacs_load,X_OK)))
282 emacs_load =
getenv(
"SINGHOME");
284 sprintf(cwd,
"%s/.emacs-singular", emacs_load);
285 if (! access(cwd, R_OK))
293 if (emacs_load ==
NULL)
295 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",
304 syscall = (
char*)
omAlloc(strlen(emacs) +
309 const char* prefix =
"--";
310 if (strstr(emacs,
"xemacs") || strstr(emacs,
"Xemacs") || strstr(emacs,
"XEMACS"))
314 if (cwd[strlen(cwd)-1] !=
'/') strcat(cwd,
"/");
318 sprintf(syscall,
"%s %sno-init-file %seval '(progn (setq singular-emacs-home-directory \"%s\") (load-file \"%s\") (singular-other \"%s\" \"%s\" (list ",
319 emacs, prefix, prefix, emacs_dir, emacs_load,
323 for (
i=1;
i<argc;
i++)
327 strcat(syscall,
"\"");
328 strcat(syscall, argv[
i]);
329 strcat(syscall,
"\" ");
332 strcat(syscall,
") \"singular\"))'");
337 printf(
"%s\n", syscall);
343 error(
"Error: Execution of\n%s\n", syscall);
static char * feResource(feResourceConfig config, int warn)
void error(const char *fmt,...)
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)
int main(int argc, char **argv)
char * feResourceDefault(const char id)
void feOptDumpVersionTuple(void)
void fePrintReportBug(char *msg, char *file, int line)
int status int void * buf
struct fe_option feOptSpec[]
char name(const Variable &v)
#define LONG_OPTION_RETURN
void feOptHelp(const char *name)
const char SHORT_OPTS_STRING[]