Functions | Variables
feOpt.h File Reference
#include <Singular/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 []
 
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
struct fe_option feOptSpec[]
char name(const Variable &v)
Definition: factory.h:178

§ 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 }
feOptIndex
Definition: feOptGen.h:15
int val
Definition: fegetopt.h:88
struct fe_option feOptSpec[]
#define LONG_OPTION_RETURN
Definition: feOptTab.h:4

§ feOptDumpVersionTuple()

void feOptDumpVersionTuple ( void  )

Definition at line 407 of file feOpt.cc.

408 {
409  printf("%s\n",VERSION);
410 }
#define VERSION
Definition: mod2.h:19

§ feOptHelp()

void feOptHelp ( const char *  name)

Definition at line 356 of file feOpt.cc.

357 {
358  int i = 0;
359  char tmp[20];
360 #if defined(ESINGULAR)
361  printf("ESingular starts up Singular within emacs;\n");
362 #elif defined(TSINGULAR)
363  printf("TSingular starts up Singular within a terminal window;\n");
364 #endif
365  printf("Singular is a Computer Algebra System (CAS) for Polynomial Computations.\n");
366  printf("Usage: %s [options] [file1 [file2 ...]]\n", name);
367  printf("Options:\n");
368 
369  while (feOptSpec[i].name != 0)
370  {
371  if (feOptSpec[i].help != NULL
372 #ifdef SING_NDEBUG
373  && *(feOptSpec[i].help) != '/'
374 #endif
375  )
376  {
377  if (feOptSpec[i].has_arg > 0)
378  {
379  if (feOptSpec[i].has_arg > 1)
380  sprintf(tmp, "%s[=%s]", feOptSpec[i].name, feOptSpec[i].arg_name);
381  else
382  sprintf(tmp, "%s=%s", feOptSpec[i].name, feOptSpec[i].arg_name);
383 
384  printf(" %c%c --%-20s %s\n",
385  (feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
386  (feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
387  tmp,
388  feOptSpec[i].help);
389  }
390  else
391  {
392  printf(" %c%c --%-20s %s\n",
393  (feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
394  (feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
395  feOptSpec[i].name,
396  feOptSpec[i].help);
397  }
398  }
399  i++;
400  }
401 
402  printf("\nFor more information, type `help;' from within Singular or visit\n");
403  printf("http://www.singular.uni-kl.de or consult the\n");
404  printf("Singular manual (available as on-line info or html manual).\n");
405 }
const char * arg_name
Definition: fegetopt.h:90
int has_arg
Definition: fegetopt.h:87
int val
Definition: fegetopt.h:88
#define SING_NDEBUG
Definition: factoryconf.h:260
struct fe_option feOptSpec[]
int i
Definition: cfEzgcd.cc:123
char name(const Variable &v)
Definition: factory.h:178
#define help
Definition: libparse.cc:1228
#define NULL
Definition: omList.c:10
#define LONG_OPTION_RETURN
Definition: feOptTab.h:4

§ 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 }
void * value
Definition: fegetopt.h:93
struct fe_option feOptSpec[]

§ 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 }
feOptType type
Definition: fegetopt.h:92
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
void * value
Definition: fegetopt.h:93
int val
Definition: fegetopt.h:88
struct fe_option feOptSpec[]
#define NULL
Definition: omList.c:10

§ 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 }
feOptType type
Definition: fegetopt.h:92
#define FALSE
Definition: auxiliary.h:97
#define TRUE
Definition: auxiliary.h:101
void * value
Definition: fegetopt.h:93
int val
Definition: fegetopt.h:88
struct fe_option feOptSpec[]

§ fePrintOptValues()

void fePrintOptValues ( )

Definition at line 321 of file feOpt.cc.

322 {
323  int i = 0;
324 
325  while (feOptSpec[i].name != 0)
326  {
327  if (feOptSpec[i].help != NULL && feOptSpec[i].type != feOptUntyped
328 #ifndef SING_NDEBUG
329  && *(feOptSpec[i].help) != '/'
330 #endif
331  )
332  {
333  if (feOptSpec[i].type == feOptString)
334  {
335  if (feOptSpec[i].value == NULL)
336  {
337  Print("// --%-15s\n", feOptSpec[i].name);
338  }
339  else
340  {
341  Print("// --%-15s \"%s\"\n", feOptSpec[i].name, (char*) feOptSpec[i].value);
342  }
343  }
344  else
345  {
346  Print("// --%-15s %d\n", feOptSpec[i].name, (int)(long)feOptSpec[i].value);
347  }
348  }
349  i++;
350  }
351 }
feOptType type
Definition: fegetopt.h:92
#define Print
Definition: emacs.cc:83
void * value
Definition: fegetopt.h:93
#define SING_NDEBUG
Definition: factoryconf.h:260
struct fe_option feOptSpec[]
int i
Definition: cfEzgcd.cc:123
char name(const Variable &v)
Definition: factory.h:178
#define help
Definition: libparse.cc:1228
#define NULL
Definition: omList.c:10

§ feSetOptValue() [1/2]

const char* feSetOptValue ( feOptIndex  opt,
int  optarg 
)

Definition at line 187 of file feOpt.cc.

188 {
189  if (opt == FE_OPT_UNDEF) return "option undefined";
190 
191  if (feOptSpec[opt].type != feOptUntyped)
192  {
193  if (feOptSpec[opt].type == feOptString)
194  return "option value needs to be an integer";
195 
196  feOptSpec[opt].value = (void*)(long) optarg;
197  }
198  return feOptAction(opt);
199 }
feOptType type
Definition: fegetopt.h:92
void * value
Definition: fegetopt.h:93
static const char * feOptAction(feOptIndex opt)
Definition: feOpt.cc:201
struct fe_option feOptSpec[]

§ feSetOptValue() [2/2]

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

Definition at line 153 of file feOpt.cc.

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

Variable Documentation

§ feOptSpec

struct fe_option feOptSpec[]

§ SHORT_OPTS_STRING

const char SHORT_OPTS_STRING[]

Definition at line 29 of file feOpt.cc.