My Project  debian-1:4.1.1-p2+ds-4build4
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 101 of file feOpt.cc.

102 {
103  int opt = 0;
104 
105  while (opt != (int) FE_OPT_UNDEF)
106  {
107  if (strcmp(feOptSpec[opt].name, name) == 0)
108  return (feOptIndex) opt;
109  opt = opt + 1;
110  }
111  return FE_OPT_UNDEF;
112 }
char name(const Variable &v)
Definition: factory.h:180
feOptIndex
Definition: feOptGen.h:15
@ FE_OPT_UNDEF
Definition: feOptGen.h:15
struct fe_option feOptSpec[]

◆ feGetOptIndex() [2/2]

feOptIndex feGetOptIndex ( int  optc)

Definition at line 114 of file feOpt.cc.

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

◆ feOptDumpVersionTuple()

void feOptDumpVersionTuple ( void  )

Definition at line 402 of file feOpt.cc.

403 {
404  printf("%s\n",VERSION);
405 }
#define VERSION
Definition: mod2.h:18

◆ feOptHelp()

void feOptHelp ( const char *  name)

Definition at line 351 of file feOpt.cc.

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

◆ 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:98
#define FALSE
Definition: auxiliary.h:94
@ feOptString
Definition: fegetopt.h:77
void * value
Definition: fegetopt.h:93

◆ 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 316 of file feOpt.cc.

317 {
318  int i = 0;
319 
320  while (feOptSpec[i].name != 0)
321  {
322  if (feOptSpec[i].help != NULL && feOptSpec[i].type != feOptUntyped
323 #ifndef SING_NDEBUG
324  && *(feOptSpec[i].help) != '/'
325 #endif
326  )
327  {
328  if (feOptSpec[i].type == feOptString)
329  {
330  if (feOptSpec[i].value == NULL)
331  {
332  Print("// --%-15s\n", feOptSpec[i].name);
333  }
334  else
335  {
336  Print("// --%-15s \"%s\"\n", feOptSpec[i].name, (char*) feOptSpec[i].value);
337  }
338  }
339  else
340  {
341  Print("// --%-15s %d\n", feOptSpec[i].name, (int)(long)feOptSpec[i].value);
342  }
343  }
344  i++;
345  }
346 }
#define Print
Definition: emacs.cc:80
@ feOptUntyped
Definition: fegetopt.h:77

◆ feSetOptValue() [1/2]

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

Definition at line 150 of file feOpt.cc.

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

◆ feSetOptValue() [2/2]

const char* feSetOptValue ( feOptIndex  opt,
int  optarg 
)

Definition at line 184 of file feOpt.cc.

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

Variable Documentation

◆ feOptSpec

struct fe_option feOptSpec[]
extern

◆ SHORT_OPTS_STRING

const char SHORT_OPTS_STRING[]
extern

Definition at line 26 of file feOpt.cc.