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