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