/**************************************** * Computer Algebra System SINGULAR * ****************************************/ /* * ABSTRACT: Esingular main file */ #include "config.h" #include #include #include #ifdef DecAlpha_OSF1 #define _BSD #endif #include #include #include #ifdef ix86_Win #include #endif #include #include #include #include #if !defined(TSINGULAR) && !defined(ESINGULAR) #define ESINGULAR #endif #ifdef system #undef system #endif #ifndef BOOLEAN #define BOOLEAN int #endif #ifndef FALSE #define FALSE 0 #endif #ifndef TRUE #define TRUE 1 #endif #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif # define DIR_SEP '/' # define DIR_SEPP "/" # define UP_DIR ".." #ifndef ix86_Win void error(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stderr, fmt, ap); } #else void error(char* fmt, ...) { char buf[4096]; int j =0; va_list args; va_start(args, fmt); j = sprintf(buf, ""); j += vsprintf(buf + j,fmt,args); j += sprintf(buf + j,"\n"); va_end(args); MessageBox(NULL, buf, "ESingular.exe", MB_ICONSTOP); exit(1); } #endif #define Warn error #define WarnS error #define StringAppend printf #define Print error #define feReportBug(s) fePrintReportBug(s, __FILE__, __LINE__) void fePrintReportBug(char* msg, char* file, int line) { error("YOU HAVE FOUND A BUG IN SINGULAR.\n" "Please, email the following output to singular@mathematik.uni-kl.de\n" "Bug occured at %s:%d\n" "Message: %s\n" "Version: " S_UNAME S_VERSION1 " (%lu) " __DATE__ __TIME__, file, line, msg, feVersionId); } void mainUsage() { error( "Use `%s --help' for a complete list of options\n", feArgv0); } extern char* feResourceDefault(const char id); extern char* feResourceDefault(const char* key); int main(int argc, char** argv) { char* singular = NULL; char* emacs = NULL; char* emacs_dir = NULL; char* emacs_load = NULL; int no_emacs_call = 0; char cwd[MAXPATHLEN]; // parse-cmdline options feInitResources(argv[0]); feResource('S'); feResource('b'); feResource('r'); int optc, option_index; while ((optc = fe_getopt_long(argc, argv, SHORT_OPTS_STRING, feOptSpec, &option_index)) != EOF) { switch(optc) { case 'h': extern void feOptHelp(const char* name); feOptHelp(feArgv0); exit(0); case '?': case ':': case '\0': mainUsage(); exit(1); case LONG_OPTION_RETURN: { switch(option_index) { #ifdef TSINGULAR case FE_OPT_XTERM: emacs = fe_optarg; break; #else case FE_OPT_EMACS: emacs = fe_optarg; break; case FE_OPT_EMACS_DIR: emacs_dir = fe_optarg; break; case FE_OPT_EMACS_LOAD: emacs_load = fe_optarg; break; #endif case FE_OPT_SINGULAR: singular = fe_optarg; break; case FE_OPT_NO_CALL: no_emacs_call = 1; break; default: goto NEXT; } // delete options from option-list if (fe_optind > 2 && *argv[fe_optind-1] != '-' && fe_optarg != NULL && feOptSpec[option_index].has_arg) { argv[fe_optind-2] = NULL; } argv[fe_optind-1] = NULL; } } NEXT:{} } int i, length = 0; char* syscall; for (i=1; i