1 | #ifndef FEOPTS_H |
---|
2 | #define FEOPTS_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id$ */ |
---|
7 | /* |
---|
8 | * ABSTRACT: Declarations for working with Options |
---|
9 | */ |
---|
10 | |
---|
11 | #include <kernel/fegetopt.h> |
---|
12 | |
---|
13 | extern const char SHORT_OPTS_STRING[]; |
---|
14 | #define LONG_OPTION_RETURN 13 |
---|
15 | |
---|
16 | /* specifies format of options */ |
---|
17 | extern struct fe_option feOptSpec[]; |
---|
18 | |
---|
19 | #ifndef GENERATE_OPTION_INDEX |
---|
20 | |
---|
21 | /* provides feOptIndex enum type for fast accesses to feOptSpec */ |
---|
22 | #if ! defined(GENTABLE) && ! defined(GENERATE_DEPEND) |
---|
23 | #ifdef ESINGULAR |
---|
24 | #include <Singular/feOptES.inc> |
---|
25 | #elif defined(TSINGULAR) |
---|
26 | #include <Singular/feOptTS.inc> |
---|
27 | #else |
---|
28 | #include <Singular/feOpt.inc> |
---|
29 | #endif |
---|
30 | #else |
---|
31 | typedef enum {FE_OPT_UNDEF} feOptIndex; |
---|
32 | #endif |
---|
33 | |
---|
34 | #ifdef __cplusplus |
---|
35 | extern "C" { |
---|
36 | #endif |
---|
37 | |
---|
38 | void* feGetOptValue(feOptIndex opt); |
---|
39 | |
---|
40 | |
---|
41 | #ifdef __cplusplus |
---|
42 | } |
---|
43 | |
---|
44 | inline void* feOptValue(feOptIndex opt) |
---|
45 | { |
---|
46 | return feOptSpec[(int)opt].value; |
---|
47 | } |
---|
48 | inline int feOptValue(feOptIndex opt, char** val) |
---|
49 | { |
---|
50 | if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type == feOptString) |
---|
51 | { |
---|
52 | *val = (char*) feOptSpec[(int)opt].value; |
---|
53 | return TRUE; |
---|
54 | } |
---|
55 | *val = NULL; |
---|
56 | return FALSE; |
---|
57 | } |
---|
58 | inline int feOptValue(feOptIndex opt, int* val) |
---|
59 | { |
---|
60 | if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type != feOptString) |
---|
61 | { |
---|
62 | *val = (int) ((long)(feOptSpec[(int)opt].value)); |
---|
63 | return TRUE; |
---|
64 | } |
---|
65 | *val = 0; |
---|
66 | return FALSE; |
---|
67 | } |
---|
68 | |
---|
69 | // maps name to otions |
---|
70 | feOptIndex feGetOptIndex(const char* name); |
---|
71 | feOptIndex feGetOptIndex(int optc); |
---|
72 | |
---|
73 | // Setting option values: |
---|
74 | // Return: NULL -- everything ok |
---|
75 | // "error-string" on error |
---|
76 | |
---|
77 | // opt->type must be feOptInt or feOptBool |
---|
78 | const char* feSetOptValue(feOptIndex opt, int optarg); |
---|
79 | // for opt->type != feOptString, optarg is converted |
---|
80 | // to an int |
---|
81 | const char* feSetOptValue(feOptIndex opt, char* optarg); |
---|
82 | |
---|
83 | void fePrintOptValues(); |
---|
84 | |
---|
85 | #endif /* __cplusplus */ |
---|
86 | |
---|
87 | #endif /* ! GENERATE_OPTION_INDEX */ |
---|
88 | |
---|
89 | #endif /* FEOPTS_H */ |
---|