Changeset e08f69 in git for Singular/tesths.cc
- Timestamp:
- Aug 25, 1999, 5:26:02 PM (25 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- abcc453829974f82c44759593b2abe1da573a348
- Parents:
- 2762d8f63b36cec5598227c07c50ae666e0dcd1a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/tesths.cc
r2762d8f re08f69 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: tesths.cc,v 1.6 8 1999-08-13 11:21:44 SingularExp $ */4 /* $Id: tesths.cc,v 1.69 1999-08-25 15:26:02 obachman Exp $ */ 5 5 6 6 /* … … 31 31 #include <factory.h> 32 32 #endif 33 #include "getopt.h" 34 35 // define the long option names here 36 #define LON_BATCH "batch" 37 #define LON_BROWSER "browser" 38 #define LON_EXECUTE "execute" 39 #define LON_EMACS "emacs" 40 #define LON_ECHO "echo" 41 #define LON_HELP "help" 42 #define LON_RANDOM "random" 43 #define LON_QUIET "quiet" 44 #define LON_NO_TTY "no-tty" 45 #define LON_USER_OPTION "user-option" 46 #define LON_VERSION "verbose" 47 #define LON_MIN_TIME "min-time" 48 #define LON_NO_STDLIB "no-stdlib" 49 #define LON_NO_RC "no-rc" 50 #define LON_TICKS_PER_SEC "ticks-per-sec" 51 #define LON_TCLMODE "tclmode" 52 #define LON_MP_PORT "MPport" 53 #define LON_MP_HOST "MPhost" 54 #define LON_NO_WARN "no-warn" 55 #define LON_NO_OUT "no-out" 56 #define LON_SDB "sdb" 57 // undocumented options 58 #ifdef HAVE_MPSR 59 #define LON_MP_TRANSP "MPtransp" 60 #define LON_MP_MODE "MPmode" 61 #endif 62 63 #define LONG_OPTION_RETURN 13 64 static struct option longopts[] = 65 { 66 #ifdef HAVE_MPSR 67 {LON_BATCH, 0, 0, 'b'}, 68 #endif 69 {LON_EXECUTE, 1, 0, 'c'}, 70 {LON_SDB, 0, 0, 'd'}, 71 {LON_ECHO, 2, 0, 'e'}, 72 {LON_HELP, 0, 0, 'h'}, 73 {LON_QUIET, 0, 0, 'q'}, 74 {LON_RANDOM, 1, 0, 'r'}, 75 {LON_NO_TTY, 0, 0, 't'}, 76 {LON_USER_OPTION, 1, 0, 'u'}, 77 {LON_VERSION, 0, 0, 'v'}, 78 #ifdef HAVE_TCL 79 {LON_TCLMODE, 0, 0, 'x'}, 80 #endif 81 {LON_BROWSER, 1, 0, LONG_OPTION_RETURN}, 82 {LON_NO_STDLIB, 0, 0, LONG_OPTION_RETURN}, 83 {LON_NO_RC, 0, 0, LONG_OPTION_RETURN}, 84 {LON_NO_WARN, 0, 0, LONG_OPTION_RETURN}, 85 {LON_NO_OUT, 0, 0, LONG_OPTION_RETURN}, 86 {LON_MIN_TIME, 1, 0, LONG_OPTION_RETURN}, 87 #ifdef HAVE_MPSR 88 {LON_MP_PORT, 1, 0, LONG_OPTION_RETURN}, 89 {LON_MP_HOST, 1, 0, LONG_OPTION_RETURN}, 90 #endif 91 {LON_TICKS_PER_SEC, 1, 0, LONG_OPTION_RETURN}, 92 // undocumented options 93 {LON_EMACS, 0, 0, LONG_OPTION_RETURN}, 94 #ifdef HAVE_MPSR 95 {LON_MP_TRANSP, 1, 0, LONG_OPTION_RETURN}, 96 {LON_MP_MODE, 1, 0, LONG_OPTION_RETURN}, 97 #endif 98 // terminator 99 { 0, 0, 0, 0 } 100 }; 101 // #define SHORT_OPTS_STRING "bc:e::hqr:tu:v" 102 #define SHORT_OPTS_STRING "bdhqtvxec:r:u:" 103 104 struct sing_option 105 { 106 const char* name; // as in option 107 108 const char* arg_name;// name of argument, if has_arg > 0 109 const char* help; // (short) help string 110 char* val; // (default) value of option: 0: not set 1:set 111 // string:"" if has_arg > 0 112 }; 113 114 // mention only documented options here 115 // or let help string start with // then option is like undocumented 116 static struct sing_option sing_longopts[] = 117 { 118 #ifdef HAVE_MPSR 119 {LON_BATCH, 0, "Run in MP batch mode", 0}, 120 #endif 121 {LON_BROWSER, "BROWSER", "Display help in BROWSER ([x,tk]info, netscape)", ""}, 122 {LON_HELP, 0, "Print help message and exit", 0}, 123 {LON_QUIET, 0, "Do not print start-up banner and library load messages", 0}, 124 {LON_SDB, 0, "Enable sdb debugger (experimental)", 0}, 125 {LON_NO_TTY, 0, "Do not redefine the terminal characteristics", 0}, 126 {LON_VERSION, 0, "Print extended version and configuration info", 0}, 127 #ifdef HAVE_TCL 128 {LON_TCLMODE, 0, "Run in TCL mode, i.e., with TCL user interface", 0}, 129 #endif 130 {LON_ECHO, "VAL", "Set value of variable `echo' to (integer) VAL", ""}, 131 {LON_EXECUTE, "STRING", "Execute STRING on start-up", ""}, 132 {LON_RANDOM, "SEED", "Seed random generator with integer (integer) SEED", ""}, 133 {LON_USER_OPTION, "STRING", "Return STRING on `system(\"--user-option\")'", ""}, 134 {LON_NO_STDLIB, 0, "Do not load `standard.lib' on start-up", 0}, 135 {LON_NO_RC, 0, "Do not execute `.singularrc' file on start-up", 0}, 136 {LON_NO_WARN, 0, "Do not display warning messages", 0}, 137 {LON_NO_OUT, 0, "Suppress all output", 0}, 138 {LON_MIN_TIME, "SECS", "Do not display times smaller than SECS (in seconds)", "0.5"}, 139 #ifdef HAVE_MPSR 140 {LON_MP_PORT, "PORT", "Use PORT number for MP conections", ""}, 141 {LON_MP_HOST, "HOST", "Use HOST for MP connections", ""}, 142 #endif 143 {LON_TICKS_PER_SEC, "TICKS", "Sets unit of timer to TICKS per second", "1"}, 144 // option whose help should not clutter up the normal help stuff 145 {LON_EMACS, 0, "// Support singular-emacs mode", 0}, 146 { 0, 0, 0, 0 } 147 }; 148 149 static struct sing_option* mainGetSingOption(const char* name) 150 { 151 int i = 0; 152 while (sing_longopts[i].name != 0) 153 { 154 if (strcmp(name, sing_longopts[i].name) == 0) 155 return &(sing_longopts[i]); 156 i++; 157 } 158 return NULL; 159 } 160 161 void mainSetSingOptionValue(const char* name, char* value) 162 { 163 sing_option* sopt = mainGetSingOption(name); 164 if (sopt != NULL) 165 { 166 sopt->val = value; 167 } 168 } 169 170 char* mainGetSingOptionValue(const char* name) 171 { 172 sing_option* sopt = mainGetSingOption(name); 173 if (sopt!=NULL) 174 return sopt->val; 175 return NULL; 176 } 177 178 179 // Prints help message 180 static void mainHelp(const char* name) 181 { 182 int i = 0; 183 struct sing_option *sopt; 184 char tmp[20]; 185 186 printf("Singular version %s -- a CAS for polynomial computations. Usage:\n", S_VERSION1); 187 printf(" %s [options] [file1 [file2 ...]]\n", name); 188 printf("Options:\n"); 189 190 while (longopts[i].name != 0) 191 { 192 sopt = mainGetSingOption(longopts[i].name); 193 if (sopt != NULL && sopt->help != NULL 194 #ifdef NDEBUG 195 && *(sopt->help) != '/' 196 #endif 197 ) 198 { 199 if (longopts[i].has_arg > 0) 200 { 201 if (longopts[i].has_arg > 1) 202 sprintf(tmp, "%s[=%s]", longopts[i].name, sopt->arg_name); 203 else 204 sprintf(tmp, "%s=%s", longopts[i].name, sopt->arg_name); 205 206 printf(" %c%c --%-19s %s\n", 207 (longopts[i].val != 0 ? '-' : ' '), 208 (longopts[i].val != 0 ? longopts[i].val : ' '), 209 tmp, 210 sopt->help); 211 } 212 else 213 { 214 printf(" %c%c --%-19s %s\n", 215 (longopts[i].val != 0 ? '-' : ' '), 216 (longopts[i].val != 0 ? longopts[i].val : ' '), 217 longopts[i].name, 218 sopt->help); 219 } 220 } 221 #ifndef NDEBUG 222 else 223 printf("--%s Undocumented\n", longopts[i].name); 224 #endif 225 i++; 226 } 227 228 printf("\nFor more information, type `help;' from within Singular or visit\n"); 229 printf("http://www.mathematik.uni-kl.de/~zca/Singular or consult the\n"); 230 printf("Singular manual (available as on-line info or printed manual).\n"); 231 } 232 233 // Prints usage message 234 static void mainUsage(char* argv0) 235 { 236 printf("Use `%s --help' for a complete list of options\n", argv0); 237 } 238 239 #ifndef NDEBUG 240 void mainOptionValues() 241 { 242 int i = 0; 243 struct sing_option *sopt; 244 245 while (longopts[i].name != 0) 246 { 247 sopt = mainGetSingOption(longopts[i].name); 248 if (sopt != NULL) 249 { 250 if (sopt->val == NULL || sopt->val == (char*) 1) 251 Print("// --%-10s %d\n", sopt->name, sopt->val); 252 else 253 Print("// --%-10s %s\n", sopt->name, sopt->val); 254 } 255 else 256 Print("// --%s Undocumented \n", longopts[i].name); 257 i++; 258 } 259 } 260 #endif // NDEBUG 261 262 BOOLEAN mainGetSingOptionValue(const char* name, char** val) 263 { 264 sing_option* sopt = mainGetSingOption(name); 265 if (sopt == NULL) 266 { 267 *val = NULL; 268 return FALSE; 269 } 270 else 271 { 272 *val = sopt->val; 273 return TRUE; 274 } 275 } 276 33 34 #include "feCmdLineOptions.cc" 277 35 /*0 implementation*/ 278 36 int main( /* main entry to Singular */
Note: See TracChangeset
for help on using the changeset viewer.