17#define BOOLEAN boolean
33#if !defined(TSINGULAR) && !defined(ESINGULAR)
48#define MAXPATHLEN 1024
59 vfprintf(stderr, fmt,
ap);
62void error(
const char* fmt, ...)
69 j += vsprintf(
buf +
j,fmt,args);
70 j += sprintf(
buf +
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"
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 syscall = (
char*)
omAlloc(strlen(emacs) +
229 sprintf(syscall,
"%s %s -e %s ", emacs, EXTRA_XTERM_ARGS, singular);
231 for (
i=1;
i<argc;
i++)
235 strcat(syscall,
" ");
236 strcat(syscall, argv[
i]);
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",
252 if (singular ==
NULL)
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",
261 if (emacs_dir ==
NULL)
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",
269 if (emacs_load ==
NULL)
272 emacs_load =
getenv(
"ESINGULAR_EMACS_LOAD");
273 if (access(emacs_load, R_OK))
276 emacs_load =
getenv(
"HOME");
278 if ((emacs_load==
NULL)||(!access(emacs_load,X_OK)))
279 emacs_load =
getenv(
"SINGHOME");
281 sprintf(cwd,
"%s/.emacs-singular", emacs_load);
282 if (! access(cwd, R_OK))
290 if (emacs_load ==
NULL)
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",
301 syscall = (
char*)
omAlloc(strlen(emacs) +
306 const char* prefix =
"--";
307 if (strstr(emacs,
"xemacs") || strstr(emacs,
"Xemacs") || strstr(emacs,
"XEMACS"))
311 if (cwd[strlen(cwd)-1] !=
'/') strcat(cwd,
"/");
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,
320 for (
i=1;
i<argc;
i++)
324 strcat(syscall,
"\"");
325 strcat(syscall, argv[
i]);
326 strcat(syscall,
"\" ");
329 strcat(syscall,
") \"singular\"))'");
334 printf(
"%s\n", syscall);
338 if (system(syscall) != 0)
340 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.