My Project
Loading...
Searching...
No Matches
feOpt.h File Reference
#include "resources/fegetopt.h"
#include "Singular/feOptTab.h"
#include "Singular/feOpt.inc"

Go to the source code of this file.

Functions

void feOptHelp (const char *name)
 
void feOptDumpVersionTuple (void)
 
static void * feOptValue (feOptIndex opt)
 
int feOptValue (feOptIndex opt, char **val)
 
int feOptValue (feOptIndex opt, int *val)
 
feOptIndex feGetOptIndex (const char *name)
 
feOptIndex feGetOptIndex (int optc)
 
const char * feSetOptValue (feOptIndex opt, int optarg)
 
const char * feSetOptValue (feOptIndex opt, char *optarg)
 
void fePrintOptValues ()
 

Variables

const char SHORT_OPTS_STRING []
 
EXTERN_VAR struct fe_option feOptSpec []
 

Function Documentation

◆ feGetOptIndex() [1/2]

feOptIndex feGetOptIndex ( const char * name)

Definition at line 104 of file feOpt.cc.

105{
106 int opt = 0;
107
108 while (opt != (int) FE_OPT_UNDEF)
109 {
110 if (strcmp(feOptSpec[opt].name, name) == 0)
111 return (feOptIndex) opt;
112 opt = opt + 1;
113 }
114 return FE_OPT_UNDEF;
115}
feOptIndex
Definition feOptGen.h:15
@ FE_OPT_UNDEF
Definition feOptGen.h:15
EXTERN_VAR struct fe_option feOptSpec[]
Definition feOpt.h:17
int name
New type name for int.

◆ feGetOptIndex() [2/2]

feOptIndex feGetOptIndex ( int optc)

Definition at line 117 of file feOpt.cc.

118{
119 int opt = 0;
120
121 if (optc == LONG_OPTION_RETURN) return FE_OPT_UNDEF;
122
123 while (opt != (int) FE_OPT_UNDEF)
124 {
125 if (feOptSpec[opt].val == optc)
126 return (feOptIndex) opt;
127 opt = opt + 1;
128 }
129 return FE_OPT_UNDEF;
130}
#define LONG_OPTION_RETURN
Definition feOptTab.h:4

◆ feOptDumpVersionTuple()

void feOptDumpVersionTuple ( void )

Definition at line 430 of file feOpt.cc.

431{
432 printf("%s\n",VERSION);
433}
#define VERSION

◆ feOptHelp()

void feOptHelp ( const char * name)

Definition at line 379 of file feOpt.cc.

380{
381 int i = 0;
382 char tmp[60];
383#if defined(ESINGULAR)
384 printf("ESingular starts up Singular within emacs;\n");
385#elif defined(TSINGULAR)
386 printf("TSingular starts up Singular within a terminal window;\n");
387#endif
388 printf("Singular is a Computer Algebra System (CAS) for Polynomial Computations.\n");
389 printf("Usage: %s [options] [file1 [file2 ...]]\n", name);
390 printf("Options:\n");
391
392 while (feOptSpec[i].name != 0)
393 {
394 if (feOptSpec[i].help != NULL
395#ifdef SING_NDEBUG
396 && *(feOptSpec[i].help) != '/'
397#endif
398 )
399 {
400 if (feOptSpec[i].has_arg > 0)
401 {
402 if (feOptSpec[i].has_arg > 1)
403 snprintf(tmp,60, "%s[=%s]", feOptSpec[i].name, feOptSpec[i].arg_name);
404 else
405 snprintf(tmp,60, "%s=%s", feOptSpec[i].name, feOptSpec[i].arg_name);
406
407 printf(" %c%c --%-20s %s\n",
408 (feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
409 (feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
410 tmp,
411 feOptSpec[i].help);
412 }
413 else
414 {
415 printf(" %c%c --%-20s %s\n",
416 (feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
417 (feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
419 feOptSpec[i].help);
420 }
421 }
422 i++;
423 }
424
425 printf("\nFor more information, type `help;' from within Singular or visit\n");
426 printf("https://www.singular.uni-kl.de or consult the\n");
427 printf("Singular manual (available as on-line info or html manual).\n");
428}
int i
Definition cfEzgcd.cc:132
#define SING_NDEBUG
#define help
Definition libparse.cc:1230
#define NULL
Definition omList.c:12

◆ feOptValue() [1/3]

static void * feOptValue ( feOptIndex opt)
inlinestatic

Definition at line 40 of file feOpt.h.

41{
42 return feOptSpec[(int)opt].value;
43}

◆ feOptValue() [2/3]

int feOptValue ( feOptIndex opt,
char ** val )
inline

Definition at line 44 of file feOpt.h.

45{
46 if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type == feOptString)
47 {
48 *val = (char*) feOptSpec[(int)opt].value;
49 return TRUE;
50 }
51 *val = NULL;
52 return FALSE;
53}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
@ feOptString
Definition fegetopt.h:77

◆ feOptValue() [3/3]

int feOptValue ( feOptIndex opt,
int * val )
inline

Definition at line 54 of file feOpt.h.

55{
56 if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type != feOptString)
57 {
58 *val = (int) ((long)(feOptSpec[(int)opt].value));
59 return TRUE;
60 }
61 *val = 0;
62 return FALSE;
63}

◆ fePrintOptValues()

void fePrintOptValues ( )

Definition at line 344 of file feOpt.cc.

345{
346 int i = 0;
347
348 while (feOptSpec[i].name != 0)
349 {
350 if (feOptSpec[i].help != NULL && feOptSpec[i].type != feOptUntyped
351#ifndef SING_NDEBUG
352 && *(feOptSpec[i].help) != '/'
353#endif
354 )
355 {
356 if (feOptSpec[i].type == feOptString)
357 {
358 if (feOptSpec[i].value == NULL)
359 {
360 Print("// --%-15s\n", feOptSpec[i].name);
361 }
362 else
363 {
364 Print("// --%-15s \"%s\"\n", feOptSpec[i].name, (char*) feOptSpec[i].value);
365 }
366 }
367 else
368 {
369 Print("// --%-15s %d\n", feOptSpec[i].name, (int)(long)feOptSpec[i].value);
370 }
371 }
372 i++;
373 }
374}
#define Print
Definition emacs.cc:80
@ feOptUntyped
Definition fegetopt.h:77

◆ feSetOptValue() [1/2]

const char * feSetOptValue ( feOptIndex opt,
char * optarg )

Definition at line 154 of file feOpt.cc.

155{
156 if (opt == FE_OPT_UNDEF) return "option undefined";
157
158 if (feOptSpec[opt].type != feOptUntyped)
159 {
160 if (feOptSpec[opt].type != feOptString)
161 {
162 if (optarg != NULL)
163 {
164 errno = 0;
165 feOptSpec[opt].value = (void*) strtol(optarg, NULL, 10);
166 if (errno) return "invalid integer argument";
167 }
168 else
169 {
170 feOptSpec[opt].value = (void*) 0;
171 }
172 }
173 else
174 {
175 assume(feOptSpec[opt].type == feOptString);
176 if (feOptSpec[opt].set && feOptSpec[opt].value != NULL)
177 omFree(feOptSpec[opt].value);
178 if (optarg != NULL)
179 feOptSpec[opt].value = omStrDup(optarg);
180 else
181 feOptSpec[opt].value = NULL;
182 feOptSpec[opt].set = 1;
183 }
184 }
185 return feOptAction(opt);
186}
static const char * feOptAction(feOptIndex opt)
Definition feOpt.cc:202
#define assume(x)
Definition mod2.h:389
#define omStrDup(s)
#define omFree(addr)

◆ feSetOptValue() [2/2]

const char * feSetOptValue ( feOptIndex opt,
int optarg )

Definition at line 188 of file feOpt.cc.

189{
190 if (opt == FE_OPT_UNDEF) return "option undefined";
191
192 if (feOptSpec[opt].type != feOptUntyped)
193 {
194 if (feOptSpec[opt].type == feOptString)
195 return "option value needs to be an integer";
196
197 feOptSpec[opt].value = (void*)(long) optarg;
198 }
199 return feOptAction(opt);
200}

Variable Documentation

◆ feOptSpec

EXTERN_VAR struct fe_option feOptSpec[]

Definition at line 17 of file feOpt.h.

◆ SHORT_OPTS_STRING

const char SHORT_OPTS_STRING[]
extern

Definition at line 29 of file feOpt.cc.