Loading...
Searching...
No Matches
feOpt.cc File Reference
`#include <string.h>`
`#include "kernel/mod2.h"`
`#include "factory/factory.h"`
`#include "feOpt.h"`
`#include "misc/options.h"`
`#include "misc/sirandom.h"`
`#include "fehelp.h"`
`#include <flint/flint.h>`
`#include "omalloc/omalloc.h"`
`#include "resources/feResource.h"`
`#include "kernel/oswrapper/feread.h"`
`#include "kernel/oswrapper/timer.h"`
`#include "ipshell.h"`
`#include "tok.h"`
`#include "sdb.h"`
`#include "cntrlc.h"`
`#include <errno.h>`

Go to the source code of this file.

## Macros

#define | FE_OPT_STRUCTURE

## Functions

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

## Variables

const char | SHORT_OPTS_STRING [] = "bdhpqstvxec:r:u:"

## Macro Definition Documentation

## FE_OPT_STRUCTURE

#define FE_OPT_STRUCTURE

Definition at line 15 of file feOpt.cc.

## Function Documentation

## feGetOptIndex() [1/2]

feOptIndex feGetOptIndex | ( | const char * | name | ) |

Definition at line 104 of file feOpt.cc.

{
int opt = 0;
while (opt != (int) FE_OPT_UNDEF)
{
if (strcmp(feOptSpec[opt].name, name) == 0)
return (feOptIndex) opt;
opt = opt + 1;
}
return FE_OPT_UNDEF;
}
name
char name(const Variable &v)
Definition factory.h:189
feOptIndex
feOptIndex
Definition feOptGen.h:15
FE_OPT_UNDEF
@ FE_OPT_UNDEF
Definition feOptGen.h:15
feOptSpec
EXTERN_VAR struct fe_option feOptSpec[]
Definition feOpt.h:17

## feGetOptIndex() [2/2]

feOptIndex feGetOptIndex | ( | int | optc | ) |

Definition at line 117 of file feOpt.cc.

{
int opt = 0;
if (optc == LONG_OPTION_RETURN) return FE_OPT_UNDEF;
while (opt != (int) FE_OPT_UNDEF)
{
if (feOptSpec[opt].val == optc)
return (feOptIndex) opt;
opt = opt + 1;
}
return FE_OPT_UNDEF;
}
LONG_OPTION_RETURN
#define LONG_OPTION_RETURN
Definition feOptTab.h:4

## feOptAction()

const char * feOptAction | ( | feOptIndex | opt | ) |

static

Definition at line 202 of file feOpt.cc.

{
// do some special actions
switch(opt)
{
case FE_OPT_BATCH:
if (feOptSpec[FE_OPT_BATCH].value)
fe_fgets_stdin=fe_fgets_dummy;
return NULL;
case FE_OPT_HELP:
feOptHelp(feArgv0);
return NULL;
case FE_OPT_PROFILE:
traceit=1024;
return NULL;
case FE_OPT_QUIET:
if (feOptSpec[FE_OPT_QUIET].value)
si_opt_2 &= ~(Sy_bit(0)|Sy_bit(V_LOAD_LIB));
else
si_opt_2 |= Sy_bit(V_LOAD_LIB)|Sy_bit(0);
return NULL;
case FE_OPT_NO_TTY:
if (feOptSpec[FE_OPT_NO_TTY].value)
fe_fgets_stdin=fe_fgets;
return NULL;
case FE_OPT_SDB:
#ifdef HAVE_SDB
if (feOptSpec[FE_OPT_SDB].value)
sdb_flags = 1;
else
sdb_flags = 0;
#endif
return NULL;
case FE_OPT_VERSION:
{
char *s=versionString();
printf("%s",s);
omFree(s);
return NULL;
}
case FE_OPT_ECHO:
si_echo = (int) ((long)(feOptSpec[FE_OPT_ECHO].value));
if (si_echo < 0 || si_echo > 9)
return "argument of option is not in valid range 0..9";
return NULL;
case FE_OPT_RANDOM:
siRandomStart = (unsigned int) ((unsigned long)
(feOptSpec[FE_OPT_RANDOM].value));
siSeed=siRandomStart;
factoryseed(siRandomStart);
return NULL;
case FE_OPT_EMACS:
if (feOptSpec[FE_OPT_EMACS].value)
{
// print EmacsDir and InfoFile so that Emacs
// mode can pcik it up
Warn("EmacsDir: %s", (feResource('e' /*"EmacsDir"*/) != NULL ?
feResource('e' /*"EmacsDir"*/) : ""));
Warn("InfoFile: %s", (feResource('i' /*"InfoFile"*/) != NULL ?
feResource('i' /*"InfoFile"*/) : ""));
}
return NULL;
case FE_OPT_NO_WARN:
if (feOptSpec[FE_OPT_NO_WARN].value)
feWarn = FALSE;
else
feWarn = TRUE;
return NULL;
case FE_OPT_NO_OUT:
if (feOptSpec[FE_OPT_NO_OUT].value)
feOut = FALSE;
else
feOut = TRUE;
return NULL;
case FE_OPT_MIN_TIME:
{
double mintime = atof((char*) feOptSpec[FE_OPT_MIN_TIME].value);
if (mintime <= 0) return "invalid float argument";
SetMinDisplayTime(mintime);
return NULL;
}
case FE_OPT_BROWSER:
feHelpBrowser((char*) feOptSpec[FE_OPT_BROWSER].value, 1);
case FE_OPT_TICKS_PER_SEC:
{
int ticks = (int) ((long)(feOptSpec[FE_OPT_TICKS_PER_SEC].value));
if (ticks <= 0)
return "integer argument must be larger than 0";
SetTimerResolution(ticks);
return NULL;
}
case FE_OPT_DUMP_VERSIONTUPLE:
{
feOptDumpVersionTuple();
return NULL;
}
case FE_OPT_FLINT_THREADS:
{
long nthreads = (long)feOptSpec[FE_OPT_FLINT_THREADS].value;
#ifdef HAVE_FLINT
#if __FLINT_RELEASE >= 20503
nthreads = FLINT_MAX(nthreads, WORD(1));
flint_set_num_threads(nthreads);
int * cpu_affinities = new int[nthreads];
for (slong i = 0; i < nthreads; i++)
cpu_affinities[i] = (int)i;
flint_set_thread_affinity(cpu_affinities, nthreads);
delete[] cpu_affinities;
return NULL;
#endif
#endif
#ifdef HAVE_NTL
#if NTL_MAJOR_VERSION>=10
#ifdef NTL_THREAD_BOOST
SetNumThreads(nthreads);
#endif
#endif
#endif
}
default:
return NULL;
}
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
i
int i
Definition cfEzgcd.cc:132
factoryseed
void factoryseed(int s)
random seed initializer
Definition cf_random.cc:186
siRandomStart
VAR int siRandomStart
Definition cntrlc.cc:99
Warn
#define Warn
Definition emacs.cc:77
slong
#define slong
s
const CanonicalForm int s
Definition facAbsFact.cc:51
feOptDumpVersionTuple
void feOptDumpVersionTuple(void)
Definition feOpt.cc:430
feOptHelp
void feOptHelp(const char *name)
Definition feOpt.cc:379
feArgv0
VAR char * feArgv0
Definition feResource.cc:19
feResource
static char * feResource(feResourceConfig config, int warn)
Definition feResource.cc:233
si_echo
VAR int si_echo
Definition febase.cc:35
feHelpBrowser
const char * feHelpBrowser(char *which, int warn)
Definition fehelp.cc:249
fe_fgets_dummy
char * fe_fgets_dummy(const char *, char *, int)
Definition feread.cc:455
fe_fgets_stdin
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
Definition feread.cc:32
fe_fgets
char * fe_fgets(const char *pr, char *s, int size)
Definition feread.cc:309
versionString
char * versionString()
Definition misc_ip.cc:769
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
NULL
#define NULL
Definition omList.c:12
si_opt_2
VAR unsigned si_opt_2
Definition options.c:6
Sy_bit
#define Sy_bit(x)
Definition options.h:31
V_LOAD_LIB
#define V_LOAD_LIB
Definition options.h:47
feWarn
VAR BOOLEAN feWarn
Definition reporter.cc:49
feOut
VAR BOOLEAN feOut
Definition reporter.cc:50
traceit
EXTERN_VAR int traceit
Definition reporter.h:24
sdb_flags
VAR int sdb_flags
Definition sdb.cc:31
siSeed
VAR int siSeed
Definition sirandom.c:30
SetMinDisplayTime
void SetMinDisplayTime(double mtime)
Definition timer.cc:27
mintime
STATIC_VAR double mintime
Definition timer.cc:20
SetTimerResolution
void SetTimerResolution(int res)
Definition timer.cc:22

## feOptDumpVersionTuple()

void feOptDumpVersionTuple | ( | void |  | ) |

Definition at line 430 of file feOpt.cc.

{
printf("%s\n",VERSION);
}
VERSION
#define VERSION
Definition factoryconf.h:277

## feOptHelp()

void feOptHelp | ( | const char * | name | ) |

Definition at line 379 of file feOpt.cc.

{
int i = 0;
char tmp[60];
#if defined(ESINGULAR)
printf("ESingular starts up Singular within emacs;\n");
#elif defined(TSINGULAR)
printf("TSingular starts up Singular within a terminal window;\n");
#endif
printf("Singular is a Computer Algebra System (CAS) for Polynomial Computations.\n");
printf("Usage: %s [options] [file1 [file2 ...]]\n", name);
printf("Options:\n");
while (feOptSpec[i].name != 0)
{
if (feOptSpec[i].help != NULL
#ifdef SING_NDEBUG
&& *(feOptSpec[i].help) != '/'
#endif
)
{
if (feOptSpec[i].has_arg > 0)
{
if (feOptSpec[i].has_arg > 1)
snprintf(tmp,60, "%s[=%s]", feOptSpec[i].name, feOptSpec[i].arg_name);
else
snprintf(tmp,60, "%s=%s", feOptSpec[i].name, feOptSpec[i].arg_name);
printf(" %c%c --%-20s %s\n",
(feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
(feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
tmp,
feOptSpec[i].help);
}
else
{
printf(" %c%c --%-20s %s\n",
(feOptSpec[i].val != LONG_OPTION_RETURN ? '-' : ' '),
(feOptSpec[i].val != LONG_OPTION_RETURN ? feOptSpec[i].val : ' '),
feOptSpec[i].name,
feOptSpec[i].help);
}
}
i++;
}
printf("\nFor more information, type `help;' from within Singular or visit\n");
printf("https://www.singular.uni-kl.de or consult the\n");
printf("Singular manual (available as on-line info or html manual).\n");
}
SING_NDEBUG
#define SING_NDEBUG
Definition factoryconf.h:257
help
#define help
Definition libparse.cc:1230

## fePrintOptValues()

void fePrintOptValues | ( |  | ) |

Definition at line 344 of file feOpt.cc.

{
int i = 0;
while (feOptSpec[i].name != 0)
{
if (feOptSpec[i].help != NULL && feOptSpec[i].type != feOptUntyped
#ifndef SING_NDEBUG
&& *(feOptSpec[i].help) != '/'
#endif
)
{
if (feOptSpec[i].type == feOptString)
{
if (feOptSpec[i].value == NULL)
{
Print("// --%-15s\n", feOptSpec[i].name);
}
else
{
Print("// --%-15s \"%s\"\n", feOptSpec[i].name, (char*) feOptSpec[i].value);
}
}
else
{
Print("// --%-15s %d\n", feOptSpec[i].name, (int)(long)feOptSpec[i].value);
}
}
i++;
}
}
Print
#define Print
Definition emacs.cc:80
feOptUntyped
@ feOptUntyped
Definition fegetopt.h:77
feOptString
@ feOptString
Definition fegetopt.h:77

## feSetOptValue() [1/2]

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

Definition at line 154 of file feOpt.cc.

{
if (opt == FE_OPT_UNDEF) return "option undefined";
if (feOptSpec[opt].type != feOptUntyped)
{
if (feOptSpec[opt].type != feOptString)
{
if (optarg != NULL)
{
errno = 0;
feOptSpec[opt].value = (void*) strtol(optarg, NULL, 10);
if (errno) return "invalid integer argument";
}
else
{
feOptSpec[opt].value = (void*) 0;
}
}
else
{
assume(feOptSpec[opt].type == feOptString);
if (feOptSpec[opt].set && feOptSpec[opt].value != NULL)
omFree(feOptSpec[opt].value);
if (optarg != NULL)
feOptSpec[opt].value = omStrDup(optarg);
else
feOptSpec[opt].value = NULL;
feOptSpec[opt].set = 1;
}
}
return feOptAction(opt);
}
feOptAction
static const char * feOptAction(feOptIndex opt)
Definition feOpt.cc:202
assume
#define assume(x)
Definition mod2.h:389
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263

## feSetOptValue() [2/2]

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

Definition at line 188 of file feOpt.cc.

{
if (opt == FE_OPT_UNDEF) return "option undefined";
if (feOptSpec[opt].type != feOptUntyped)
{
if (feOptSpec[opt].type == feOptString)
return "option value needs to be an integer";
feOptSpec[opt].value = (void*)(long) optarg;
}
return feOptAction(opt);
}

## Variable Documentation

## SHORT_OPTS_STRING

const char SHORT_OPTS_STRING[] = "bdhpqstvxec:r:u:"

Definition at line 29 of file feOpt.cc.