My Project  debian-1:4.1.2-p1+ds-2
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 []
 
EXTERN_VAR struct fe_option feOptSpec []
 

Function Documentation

◆ feGetOptIndex() [1/2]

feOptIndex feGetOptIndex ( const char *  name)

Definition at line 100 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;

◆ feGetOptIndex() [2/2]

feOptIndex feGetOptIndex ( int  optc)

Definition at line 113 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;

◆ feOptDumpVersionTuple()

void feOptDumpVersionTuple ( void  )

Definition at line 402 of file feOpt.cc.

404 {
405  printf("%s\n",VERSION);

◆ feOptHelp()

void feOptHelp ( const char *  name)

Definition at line 351 of file feOpt.cc.

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

◆ feOptValue() [1/3]

static void* feOptValue ( feOptIndex  opt)
inlinestatic

Definition at line 39 of file feOpt.h.

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

◆ feOptValue() [2/3]

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

Definition at line 43 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;

◆ feOptValue() [3/3]

int feOptValue ( feOptIndex  opt,
int *  val 
)
inline

Definition at line 53 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;

◆ fePrintOptValues()

void fePrintOptValues ( )

Definition at line 316 of file feOpt.cc.

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

◆ feSetOptValue() [1/2]

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

Definition at line 150 of file feOpt.cc.

152 {
153  if (opt == FE_OPT_UNDEF) return "option undefined";
154 
155  if (feOptSpec[opt].type != feOptUntyped)
156  {
157  if (feOptSpec[opt].type != feOptString)
158  {
159  if (optarg != NULL)
160  {
161  errno = 0;
162  feOptSpec[opt].value = (void*) strtol(optarg, NULL, 10);
163  if (errno) return "invalid integer argument";
164  }
165  else
166  {
167  feOptSpec[opt].value = (void*) 0;
168  }
169  }
170  else
171  {
172  assume(feOptSpec[opt].type == feOptString);
173  if (feOptSpec[opt].set && feOptSpec[opt].value != NULL)
174  omFree(feOptSpec[opt].value);
175  if (optarg != NULL)
176  feOptSpec[opt].value = omStrDup(optarg);
177  else
178  feOptSpec[opt].value = NULL;
179  feOptSpec[opt].set = 1;
180  }
181  }
182  return feOptAction(opt);

◆ feSetOptValue() [2/2]

const char* feSetOptValue ( feOptIndex  opt,
int  optarg 
)

Definition at line 184 of file feOpt.cc.

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

Variable Documentation

◆ feOptSpec

EXTERN_VAR struct fe_option feOptSpec[]

Definition at line 16 of file feOpt.h.

◆ SHORT_OPTS_STRING

const char SHORT_OPTS_STRING[]

Definition at line 25 of file feOpt.cc.

feOptAction
static const char * feOptAction(feOptIndex opt)
Definition: feOpt.cc:198
FALSE
#define FALSE
Definition: auxiliary.h:96
omFree
#define omFree(addr)
Definition: omAllocDecl.h:259
VERSION
#define VERSION
Definition: mod2.h:17
fe_option::val
int val
Definition: fegetopt.h:88
feOptIndex
feOptIndex
Definition: feOptGen.h:14
feOptUntyped
Definition: fegetopt.h:77
LONG_OPTION_RETURN
#define LONG_OPTION_RETURN
Definition: feOptTab.h:4
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:261
fe_option::set
int set
Definition: fegetopt.h:94
TRUE
#define TRUE
Definition: auxiliary.h:100
i
int i
Definition: cfEzgcd.cc:125
fe_option::arg_name
const char * arg_name
Definition: fegetopt.h:90
fe_option::type
feOptType type
Definition: fegetopt.h:92
help
#define help
Definition: libparse.cc:1229
Print
#define Print
Definition: emacs.cc:79
FE_OPT_UNDEF
Definition: feOptGen.h:14
name
char name(const Variable &v)
Definition: factory.h:180
assume
#define assume(x)
Definition: mod2.h:384
NULL
#define NULL
Definition: omList.c:11
fe_option::value
void * value
Definition: fegetopt.h:93
feOptSpec
EXTERN_VAR struct fe_option feOptSpec[]
Definition: feOpt.h:16
SING_NDEBUG
#define SING_NDEBUG
Definition: factoryconf.h:258
fe_option::has_arg
int has_arg
Definition: fegetopt.h:87
feOptString
Definition: fegetopt.h:77