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 <Singular/fegetopt.h> |
---|
12 | |
---|
13 | #include <Singular/feOptTab.h> |
---|
14 | |
---|
15 | extern const char SHORT_OPTS_STRING[]; |
---|
16 | |
---|
17 | /* specifies format of options */ |
---|
18 | extern struct fe_option feOptSpec[]; |
---|
19 | |
---|
20 | /* provides feOptIndex enum type for fast accesses to feOptSpec */ |
---|
21 | #if ! defined(GENERATE_DEPEND) |
---|
22 | |
---|
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 | |
---|
31 | #else |
---|
32 | typedef enum {FE_OPT_UNDEF} feOptIndex; |
---|
33 | #endif |
---|
34 | |
---|
35 | |
---|
36 | #ifdef __cplusplus |
---|
37 | extern "C" { |
---|
38 | #endif |
---|
39 | |
---|
40 | void feOptHelp(const char* name); |
---|
41 | |
---|
42 | void* feGetOptValue(feOptIndex opt); |
---|
43 | |
---|
44 | |
---|
45 | #ifdef __cplusplus |
---|
46 | } |
---|
47 | |
---|
48 | inline void* feOptValue(feOptIndex opt) |
---|
49 | { |
---|
50 | return feOptSpec[(int)opt].value; |
---|
51 | } |
---|
52 | inline int feOptValue(feOptIndex opt, char** val) |
---|
53 | { |
---|
54 | if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type == feOptString) |
---|
55 | { |
---|
56 | *val = (char*) feOptSpec[(int)opt].value; |
---|
57 | return TRUE; |
---|
58 | } |
---|
59 | *val = NULL; |
---|
60 | return FALSE; |
---|
61 | } |
---|
62 | inline int feOptValue(feOptIndex opt, int* val) |
---|
63 | { |
---|
64 | if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type != feOptString) |
---|
65 | { |
---|
66 | *val = (int) ((long)(feOptSpec[(int)opt].value)); |
---|
67 | return TRUE; |
---|
68 | } |
---|
69 | *val = 0; |
---|
70 | return FALSE; |
---|
71 | } |
---|
72 | |
---|
73 | // maps name to otions |
---|
74 | feOptIndex feGetOptIndex(const char* name); |
---|
75 | feOptIndex feGetOptIndex(int optc); |
---|
76 | |
---|
77 | // Setting option values: |
---|
78 | // Return: NULL -- everything ok |
---|
79 | // "error-string" on error |
---|
80 | |
---|
81 | // opt->type must be feOptInt or feOptBool |
---|
82 | const char* feSetOptValue(feOptIndex opt, int optarg); |
---|
83 | // for opt->type != feOptString, optarg is converted |
---|
84 | // to an int |
---|
85 | const char* feSetOptValue(feOptIndex opt, char* optarg); |
---|
86 | |
---|
87 | void fePrintOptValues(); |
---|
88 | |
---|
89 | #endif /* __cplusplus */ |
---|
90 | |
---|
91 | #endif /* FEOPTS_H */ |
---|