source: git/Singular/feOpt.h @ e8a9f3

spielwiese
Last change on this file since e8a9f3 was e8a9f3, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
CHG: minor fixes + cleanup of *.inc generation in Singular/
  • Property mode set to 100644
File size: 1.9 KB
Line 
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
13extern const char SHORT_OPTS_STRING[];
14#define LONG_OPTION_RETURN 13
15
16/* specifies format of options */
17extern 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
24# ifdef ESINGULAR
25#  include <Singular/feOptES.inc>
26# elif defined(TSINGULAR)
27#  include <Singular/feOptTS.inc>
28# else
29#  include <Singular/feOpt.inc>
30# endif
31
32#else
33typedef enum {FE_OPT_UNDEF}  feOptIndex;
34#endif
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40void* feGetOptValue(feOptIndex opt);
41
42
43#ifdef __cplusplus
44}
45
46inline void* feOptValue(feOptIndex opt)
47{
48  return feOptSpec[(int)opt].value;
49}
50inline int feOptValue(feOptIndex opt, char** val)
51{
52  if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type == feOptString)
53  {
54    *val = (char*) feOptSpec[(int)opt].value;
55    return TRUE;
56  }
57  *val = NULL;
58  return FALSE;
59}
60inline int feOptValue(feOptIndex opt, int* val)
61{
62  if (opt != FE_OPT_UNDEF && feOptSpec[(int)opt].type != feOptString)
63  {
64    *val = (int) ((long)(feOptSpec[(int)opt].value));
65    return TRUE;
66  }
67  *val = 0;
68  return FALSE;
69}
70
71// maps name to otions
72feOptIndex feGetOptIndex(const char* name);
73feOptIndex feGetOptIndex(int optc);
74
75// Setting option values:
76// Return: NULL -- everything ok
77//         "error-string" on error
78
79// opt->type must be feOptInt or feOptBool
80const char* feSetOptValue(feOptIndex opt, int optarg);
81// for opt->type != feOptString, optarg is converted
82// to an int
83const char* feSetOptValue(feOptIndex opt, char* optarg);
84
85void fePrintOptValues();
86
87#endif /* __cplusplus */
88
89#endif /* ! GENERATE_OPTION_INDEX */
90
91#endif /*  FEOPTS_H */
Note: See TracBrowser for help on using the repository browser.