spBase
読み取り中…
検索中…
一致する文字列を見つけられません
spOption.h
[詳解]
1
4#ifndef __SPOPTION_H
5#define __SPOPTION_H
6
7#include <stdarg.h>
8
9#include <sp/spDefs.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
20#define SP_USAGE_LABEL_STRING "???"
21
22#define SP_MAX_SETUP_LINE 512
23#define SP_MAX_SETUP_NAME 128
24/*#define SP_MAX_SETUP_VALUE 256*/
25#define SP_MAX_SETUP_VALUE 8192
26
27#define SP_UNKNOWN (-1)
28
29#define SP_MAX_EXIT_CALLBACK 16
30typedef void (*spExitFunc)(int status);
31
32typedef void (*spExitCallbackFunc)(void *);
34typedef unsigned short spOptionType;
36#define SP_TYPE_NONE 0
37#define SP_TYPE_BOOL 1
38#define SP_TYPE_STRING 2
39#define SP_TYPE_INT 3
40#define SP_TYPE_SHORT 4
41#define SP_TYPE_LONG 5
42#define SP_TYPE_FLOAT 6
43#define SP_TYPE_DOUBLE 7
44#define SP_TYPE_CHAR 8
45#define SP_TYPE_STRING_A 9 /* string array */
46#define SP_TYPE_ENUM 10
47#define SP_TYPE_USER 16
48#define SP_TYPE_BOOLEAN SP_TYPE_BOOL
49#define SP_TYPE_STRING_S SP_TYPE_STRING_A
50
51#define SP_TYPE_EDITABLE (1<<8)
52#define SP_TYPE_LIST (1<<9)
53#define SP_TYPE_COMBO (1<<10)
54#define SP_TYPE_TOGGLE (1<<11)
55#define SP_TYPE_SHOW_TIP (1<<12)
56#define SP_TYPE_NO_GUI (1<<13)
57#define SP_TYPE_INPUT_ONLY (1<<14) /* 0.8.19+ */
58#define SP_TYPE_OUTPUT_ONLY (1<<15) /* 0.8.19+ */
59
60#define SpNullOption(flag, subflag, type) {flag, subflag, NULL, NULL, type, NULL, NULL}
61
62typedef struct _spOptions *spOptions;
67typedef struct _spOption {
68 const char *flag;
69 const char *subflag;
70 const char *desc;
71 const char *label;
73 void *value;
74 const char *def_value;
75} spOption;
76
77#if defined(MACOS)
78#pragma import on
79#endif
80
83extern void spIgnoreUnknownOption(spOptions options, spBool flag);
84extern int spGetNumOption(spOptions options);
85extern spOption *spGetOptionList(spOptions options);
86extern char *xspCutOptionValue(const char *value, int index);
87extern int spConvertOptionValue(spOption *option, const char *value);
88extern spOptions spAllocOptions(int num_option, spOption *option_list);
89extern spOptions spCopyOptions(int num_option, spOption *option_list);
90extern spOptions spInitOptions(int num_option, spOption *option_list);
91extern void _spFreeOptionsAndValues(spOptions options, spBool free_values);
92extern void _spFreeOptions(spOptions options);
93extern spOptions _spGetOptions(int argc, char **argv, int num_option, spOption *option_list,
94 int num_file, const char **labels);
96extern void spSetSection(spOptions options, int section);
98extern void spSetSetup(const char *filename);
102extern spBool spAddExitCallback(spExitCallbackFunc callback, void *data);
104extern spBool spRemoveExitCallback(spExitCallbackFunc callback, void *data);
106extern void spExit(int status);
108extern char *spGetOptionValue(int argc, char **argv, spOptions options);
110extern void spGetOptionsValue(int argc, char **argv, spOptions options);
111extern void spUpdateOptionsValue(int argc, char **argv, spOptions options);
113extern void spCheckNumFile(spOptions options);
115extern const char *spGetFile(spOptions options);
116extern char *xspGetOptionLabel(spOption *option, int index);
117extern void spSetOptionDescOffset(int offset);
119extern void spSetHelpMessage(spBool *flag, const char *format, ...);
120extern void spPrintHelpHeader(const char *format, ...);
122extern void spPrintHelp(const char *format, ...);
124extern void spPrintError(const char *format, ...);
126extern void spPrintMan(spOptions options, const char *description, const char *author);
128extern spBool spReadSetup(const char *filename, spOptions options);
130extern spBool spWriteSetup(const char *filename, spOptions options);
131extern spBool spGetOptionValueString(spOption *option, char *buf, int buf_size); /* 0.8.18+ */
132extern spBool spPrintOption(spOption *option);
133extern spBool spPrintOptions(spOptions options);
134extern void spPrintUsageHeader(void);
135extern void spPrintUsage(void);
137extern void spUsage(void);
138
139 /*----@addtogroup spOptionGroup----*/
140
141#if defined(_WIN32)
142extern void spSetHInstanceWin(void *hinstance, unsigned long reason);
143extern void *spGetHInstanceWin(void);
144#endif
145
146/* Do not use the following function. This is for internal use. */
147extern spBool spSetExitFunc(spExitFunc func);
148extern spBool spEmitExitCallback(void);
149
150#if defined(MACOS)
151#pragma import off
152#endif
153
155 /*----@addtogroup spOptionGroup----*/
156
157#define spFreeOptions(options) {_spFreeOptions(options); (options) = NULL;}
158#define spFreeOptionsAndValues(options, free_values) {_spFreeOptionsAndValues(options, free_values); (options) = NULL;}
160#define spGetOptions(argc, argv, option, file_label) \
161_spGetOptions(argc, argv, spArraySize(option), option, spArraySize(file_label), file_label)
162
163/*#define spEqType(type1, type2) (((0xff & type1) == (0xff & type2)) ? 1 : 0)*/
165#define spStrToBool(value) (((*(value) == 'T') || spStrEq(value, "1") || spStrEq(value, "ON") || spStrEq(value, "On")) ? SP_TRUE : SP_FALSE)
167#define spBoolToStr(value) (((value) == SP_TRUE) ? "True" : "False")
168
169 /*----@addtogroup spOptionGroup----*/
170
171#ifdef __cplusplus
172} /* Close scope of 'extern "C"' declaration */
173#endif
174
175#endif /* __SPOPTION_H */
int spBool
Definition spDefs.h:248
void spSetSection(spOptions options, int section)
char * spGetOptionValue(int argc, char **argv, spOptions options)
spBool spWriteSetup(const char *filename, spOptions options)
void spSetSetup(const char *filename)
unsigned short spOptionType
Definition spOption.h:34
void spUsage(void)
spBool spWriteGlobalSetup(void)
void spCheckNumFile(spOptions options)
spBool spAddExitCallback(spExitCallbackFunc callback, void *data)
void(* spExitCallbackFunc)(void *)
Definition spOption.h:32
struct _spOptions * spOptions
Definition spOption.h:62
void spGetOptionsValue(int argc, char **argv, spOptions options)
const char * spGetFile(spOptions options)
void spSetHelpMessage(spBool *flag, const char *format,...)
spBool spRemoveExitCallback(spExitCallbackFunc callback, void *data)
void spPrintError(const char *format,...)
spBool spReadSetup(const char *filename, spOptions options)
void spExit(int status)
spBool spEqType(spOptionType type1, spOptionType type2)
void spPrintHelp(const char *format,...)
Definition spOption.h:67
void * value
Definition spOption.h:73
const char * desc
Definition spOption.h:70
const char * label
Definition spOption.h:71
const char * subflag
Definition spOption.h:69
const char * def_value
Definition spOption.h:74
const char * flag
Definition spOption.h:68
spOptionType type
Definition spOption.h:72