add fully matched Parameter.c

This commit is contained in:
Ash Wolf 2022-10-10 04:01:30 +01:00
parent af15bf78ad
commit 7d4bee5f8f
3 changed files with 1180 additions and 76 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.o

1148
Parameter.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -86,7 +86,7 @@ typedef struct GENERIC_T {
char flags; char flags;
char *myname; char *myname;
PARAM_T *next; PARAM_T *next;
void (*parse)(); // TODO missing sig int (*parse)(const char *opt, void *var, const char *pstr, int flags);
void *var; void *var;
char *help; char *help;
} GENERIC_T; } GENERIC_T;
@ -95,7 +95,7 @@ typedef struct SETTING_T {
char flags; char flags;
char *myname; char *myname;
PARAM_T *next; PARAM_T *next;
void (*parse)(); // TODO missing sig int (*parse)(const char *a, const char *b); // TODO name these args
char *valuename; char *valuename;
} SETTING_T; } SETTING_T;
typedef struct TOGGLE_T { typedef struct TOGGLE_T {
@ -256,8 +256,8 @@ enum {
PARAMWHICH_FilePath = 2, PARAMWHICH_FilePath = 2,
PARAMWHICH_Number = 3, PARAMWHICH_Number = 3,
PARAMWHICH_String = 4, PARAMWHICH_String = 4,
PARAMWHICH_5 = 5, PARAMWHICH_Id = 5,
PARAMWHICH_6 = 6, PARAMWHICH_Sym = 6,
PARAMWHICH_OnOff = 7, PARAMWHICH_OnOff = 7,
PARAMWHICH_OffOn = 8, PARAMWHICH_OffOn = 8,
PARAMWHICH_Mask = 9, PARAMWHICH_Mask = 9,
@ -266,14 +266,29 @@ enum {
PARAMWHICH_SetString = 0xC, PARAMWHICH_SetString = 0xC,
PARAMWHICH_Generic = 0xD, PARAMWHICH_Generic = 0xD,
PARAMWHICH_IfArg = 0xE, PARAMWHICH_IfArg = 0xE,
PARAMWHICH_Setting = 0xF PARAMWHICH_Setting = 0xF,
PARAMWHICH_MAX = 0x10
}; };
enum { enum {
PARAMFLAGS_1 = 1, PARAMFLAGS_1 = 1,
PARAMFLAGS_2 = 2, PARAMFLAGS_2 = 2,
PARAMFLAGS_3 = 3, PARAMFLAGS_3 = 3,
PARAMFLAGS_4 = 4, PARAMFLAGS_4 = 4,
PARAMFLAGS_8 = 8 PARAMFLAGS_8 = 8,
PARAMFLAGS_10 = 0x10,
PARAMFLAGS_12 = 0x12
};
enum {
PARAMPARSEFLAGS_0 = 0,
PARAMPARSEFLAGS_1 = 1,
PARAMPARSEFLAGS_2 = 2,
PARAMPARSEFLAGS_4 = 4,
PARAMPARSEFLAGS_8 = 8,
PARAMPARSEFLAGS_10 = 0x10,
PARAMPARSEFLAGS_20 = 0x20,
PARAMPARSEFLAGS_40 = 0x40,
PARAMPARSEFLAGS_80 = 0x80,
PARAMPARSEFLAGS_100 = 0x100
}; };
enum { enum {
SLFLAGS_1 = 1, SLFLAGS_1 = 1,
@ -1745,85 +1760,24 @@ extern void CLPProgress(short errid, ...);
extern void CLPStatus(short errid, ...); extern void CLPStatus(short errid, ...);
extern void CLPFatalError(const char *format, ...); extern void CLPFatalError(const char *format, ...);
extern char curopt[1024];
/********************************/ /********************************/
/* Utils.c */ /* Utils.c */
extern int my_tolower(char c); // something is weird with these parameters
extern int my_isdigit(char c); // they're supposed to be just "char"...
extern int my_isalpha(char c); extern int my_tolower(unsigned char c);
extern int my_isalnum(char c); extern int my_isdigit(unsigned char c);
extern int my_isxdigit(char c); extern int my_isalpha(unsigned char c);
extern int my_isalnum(unsigned char c);
extern int my_isxdigit(unsigned char c);
extern char *Utils_SpellList(char *list, char *buffer, char opts); extern char *Utils_SpellList(char *list, char *buffer, char opts);
extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky); extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky);
/********************************/ /********************************/
/* Parameter.c */ /* Parameter.c */
//static int Param_None();
//static void DescHelpParam_None(PARAM_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_None();
//static void DescHelpParam_Number(NUM_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_Number();
//static int Param_Number(NUM_T *p, const char *pstr);
//static void DescHelpParam_FTypeCreator(FTYPE_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_FTypeCreator();
//static int Param_FTypeCreator(FTYPE_T *p, const char *pstr);
//static void DescHelpParam_String(STRING_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_String();
//static int Param_String(STRING_T *p, const char *pstr);
//static void DescHelpParam_ID_or_SYM(STRING_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_ID_or_SYM();
//static int Param_ID_or_SYM(STRING_T *p, const char *pstr);
//static void DescHelpParam_OnOff(ONOFF_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_OnOff();
//static int Param_OnOff(ONOFF_T *p, const char *pstr);
//static void DescHelpParam_OffOn(ONOFF_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_OffOn();
//static int Param_OffOn(OFFON_T *p, const char *pstr);
//static void DescHelpParam_FilePath(FILEPATH_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_FilePath();
//static int Param_FilePath(FILEPATH_T *p, const char *pstr);
//static void DescHelpParam_Mask(MASK_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_Mask(MASK_T *p);
//static int Param_Mask(MASK_T *p, const char *pstr, int flags);
//static void DescHelpParam_Toggle(TOGGLE_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_Toggle(TOGGLE_T *p);
//static int Param_Toggle(TOGGLE_T *p, const char *pstr);
//static void DescHelpParam_Set(SET_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_Set(SET_T *p);
//static int Param_Set(SET_T *p, const char *pstr, int flags);
//static void DescHelpParam_SetString(SETSTRING_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_SetString(SETSTRING_T *p);
//static int Param_SetString(SETSTRING_T *p, const char *pstr, int flags);
//static void DescHelpParam_Generic(GENERIC_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_Generic(GENERIC_T *p);
//static int Param_Generic(GENERIC_T *p, const char *pstr, int flags);
//static void DescHelpParam_Setting(SETTING_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_Setting(SETTING_T *p);
//static int Param_Setting(SETTING_T *p, const char *pstr, int flags);
//static void DescHelpParam_IfArg(IFARG_T *p, const char **desc, const char **help, const char **defaul);
//static int CompareParam_IfArg(IFARG_T *p);
//static int Param_IfArg(IFARG_T *p, const char *pstr, int flags);
//static int Param_Parse(PARAM_T *param, const char *cparam, int flags);
extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul); extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul);
extern int Param_Compare(PARAM_T *param); extern int Param_Compare(PARAM_T *param);
//static void Param_PushParam(const char *param);
//static void Param_PopParam();
//static Boolean Param_IsNonTextFile(const char *fname, Boolean warn);
//static int Param_GetArgument(PARAM_T *param, const char *cparam, int exec);
extern int Params_Parse(PARAM_T *param, int flags); extern int Params_Parse(PARAM_T *param, int flags);
extern void Param_Error(short id, ...); extern void Param_Error(short id, ...);
extern void Param_Warning(short id, ...); extern void Param_Warning(short id, ...);