17#define BOOLEAN boolean
33#if !defined(TSINGULAR) && !defined(ESINGULAR)
48#define MAXPATHLEN 1024
59 vfprintf(stderr, fmt,
ap);
62void error(
const char* fmt, ...)
68 j = snprintf(
buf,4096,
"");
69 j += vsnprintf(
buf +
j,4096-
j,fmt,args);
70 j += snprintf(
buf +
j,4096-
j,
"\n");
72 MessageBox(
NULL,
buf,
"ESingular.exe", MB_ICONSTOP);
79#define StringAppend printf
82#define feReportBug(s) fePrintReportBug(s, __FILE__, __LINE__)
85 error(
"YOU HAVE FOUND A BUG IN SINGULAR.\n"
86"Please, email the following output to singular@mathematik.uni-kl.de\n"
87"Bug occurred at %s:%d\n"
89"Version: " S_UNAME
VERSION VERSION_DATE,
96 error(
"Use `%s --help' for a complete list of options\n",
feArgv0);
105 char* singular =
NULL;
108 char* emacs_dir =
NULL;
109 char* emacs_load =
NULL;
112 int no_emacs_call = 0;
121 int optc, option_index;
154 case FE_OPT_EMACS_DIR:
158 case FE_OPT_EMACS_LOAD:
162 case FE_OPT_SINGULAR:
170 case FE_OPT_DUMP_VERSIONTUPLE:
192 for (
i=1;
i<argc;
i++)
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",
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",
212 if (singular ==
NULL)
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",
221#define EXTRA_XTERM_ARGS "+vb -sl 2000 -fb Courier-bold-12 -tn xterm -cr Red3"
223#define EXTRA_XTERM_ARGS ""
226 size_t len=strlen(emacs) + strlen(singular) +
length + 300;
227 syscall = (
char*)
omAlloc(len);
228 snprintf(syscall,len,
"%s %s -e %s ", emacs, EXTRA_XTERM_ARGS, singular);
230 for (
i=1;
i<argc;
i++)
234 strcat(syscall,
" ");
235 strcat(syscall, argv[
i]);
244 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",
251 if (singular ==
NULL)
253 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",
260 if (emacs_dir ==
NULL)
262 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",
268 if (emacs_load ==
NULL)
271 emacs_load =
getenv(
"ESINGULAR_EMACS_LOAD");
272 if (access(emacs_load, R_OK))
275 emacs_load =
getenv(
"HOME");
277 if ((emacs_load==
NULL)||(!access(emacs_load,X_OK)))
278 emacs_load =
getenv(
"SINGHOME");
280 snprintf(cwd,
MAXPATHLEN,
"%s/.emacs-singular", emacs_load);
281 if (! access(cwd, R_OK))
289 if (emacs_load ==
NULL)
291 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",
300 size_t len=strlen(emacs) + strlen(singular) + strlen(emacs_dir) + strlen(emacs_load) +
length +300;
301 syscall = (
char*)
omAlloc(len);
302 const char* prefix =
"--";
303 if (strstr(emacs,
"xemacs") || strstr(emacs,
"Xemacs") || strstr(emacs,
"XEMACS"))
307 if (cwd[strlen(cwd)-1] !=
'/') strcat(cwd,
"/");
311 snprintf(syscall,len,
"%s %sno-init-file %seval '(progn (setq singular-emacs-home-directory \"%s\") (load-file \"%s\") (singular-other \"%s\" \"%s\" (list ",
312 emacs, prefix, prefix, emacs_dir, emacs_load,
316 for (
i=1;
i<argc;
i++)
320 strcat(syscall,
"\"");
321 strcat(syscall, argv[
i]);
322 strcat(syscall,
"\" ");
325 strcat(syscall,
") \"singular\"))'");
330 printf(
"%s\n", syscall);
334 if (system(syscall) != 0)
336 error(
"Error: Execution of\n%s\n", syscall);
char * feResourceDefault(const char id)
void fePrintReportBug(char *msg, char *file, int line)
#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 status int void * buf
int name
New type name for int.