[c06a32] | 1 | #ifndef FEOPTS_H |
---|
| 2 | #define FEOPTS_H |
---|
| 3 | /**************************************** |
---|
| 4 | * Computer Algebra System SINGULAR * |
---|
| 5 | ****************************************/ |
---|
[a3bc95e] | 6 | /* $Id: feOpt.h,v 1.7 2001-10-09 16:35:58 Singular Exp $ */ |
---|
[c06a32] | 7 | /* |
---|
| 8 | * ABSTRACT: Declarations for working with Options |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | #include "fegetopt.h" |
---|
| 12 | |
---|
| 13 | extern const char SHORT_OPTS_STRING[]; |
---|
[a3bc95e] | 14 | #define LONG_OPTION_RETURN 13 |
---|
[c06a32] | 15 | |
---|
[2272c33] | 16 | /* specifies format of options */ |
---|
[c06a32] | 17 | extern struct fe_option feOptSpec[]; |
---|
| 18 | |
---|
| 19 | #ifndef GENERATE_OPTION_INDEX |
---|
| 20 | |
---|
[2272c33] | 21 | /* provides feOptIndex enum type for fast accesses to feOptSpec */ |
---|
[b7b08c] | 22 | #if ! defined(GENTABLE) && ! defined(GENERATE_DEPEND) |
---|
[c06a32] | 23 | #ifdef ESINGULAR |
---|
| 24 | #include "feOptES.inc" |
---|
[ef0124] | 25 | #elif defined(TSINGULAR) |
---|
| 26 | #include "feOptTS.inc" |
---|
[c06a32] | 27 | #else |
---|
| 28 | #include "feOpt.inc" |
---|
| 29 | #endif |
---|
| 30 | #else |
---|
| 31 | typedef enum {FE_OPT_UNDEF} feOptIndex; |
---|
| 32 | #endif |
---|
| 33 | |
---|
[2272c33] | 34 | #ifdef __cplusplus |
---|
| 35 | extern "C" { |
---|
| 36 | #endif |
---|
| 37 | |
---|
| 38 | void* feGetOptValue(feOptIndex opt); |
---|
[a3bc95e] | 39 | |
---|
[2272c33] | 40 | |
---|
| 41 | #ifdef __cplusplus |
---|
| 42 | } |
---|
| 43 | |
---|
[c06a32] | 44 | inline void* feOptValue(feOptIndex opt) |
---|
| 45 | { |
---|
| 46 | return feOptSpec[(int)opt].value; |
---|
| 47 | } |
---|
| 48 | inline int feOptValue(feOptIndex opt, char** val) |
---|
| 49 | { |
---|
[a3bc95e] | 50 | if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type == feOptString) |
---|
[c06a32] | 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 | { |
---|
[a3bc95e] | 60 | if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type != feOptString) |
---|
[c06a32] | 61 | { |
---|
| 62 | *val = (int) feOptSpec[(int)opt].value; |
---|
| 63 | return TRUE; |
---|
| 64 | } |
---|
| 65 | *val = 0; |
---|
| 66 | return FALSE; |
---|
| 67 | } |
---|
[a3bc95e] | 68 | |
---|
[c06a32] | 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 | char* feSetOptValue(feOptIndex opt, int optarg); |
---|
| 79 | // for opt->type != feOptString, optarg is converted |
---|
| 80 | // to an int |
---|
| 81 | char* feSetOptValue(feOptIndex opt, char* optarg); |
---|
| 82 | |
---|
| 83 | void fePrintOptValues(); |
---|
| 84 | |
---|
[2272c33] | 85 | #endif /* __cplusplus */ |
---|
| 86 | |
---|
| 87 | #endif /* ! GENERATE_OPTION_INDEX */ |
---|
[c06a32] | 88 | |
---|
[2272c33] | 89 | #endif /* FEOPTS_H */ |
---|