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

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

§ feOptHelp()

void feOptHelp ( const char *  name)

Definition at line 354 of file feOpt.cc.

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

§ fePrintOptValues()

void fePrintOptValues ( )

Definition at line 319 of file feOpt.cc.

320 {
321  int i = 0;
322 
323  while (feOptSpec[i].name != 0)
324  {
325  if (feOptSpec[i].help != NULL && feOptSpec[i].type != feOptUntyped
326 #ifndef SING_NDEBUG
327  && *(feOptSpec[i].help) != '/'
328 #endif
329  )
330  {
331  if (feOptSpec[i].type == feOptString)
332  {
333  if (feOptSpec[i].value == NULL)
334  {
335  Print("// --%-15s\n", feOptSpec[i].name);
336  }
337  else
338  {
339  Print("// --%-15s \"%s\"\n", feOptSpec[i].name, (char*) feOptSpec[i].value);
340  }
341  }
342  else
343  {
344  Print("// --%-15s %d\n", feOptSpec[i].name, (int)(long)feOptSpec[i].value);
345  }
346  }
347  i++;
348  }
349 }
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.