gwenhywfar 5.11.2beta
funcs.h
Go to the documentation of this file.
1/***************************************************************************
2 begin : Wed Feb 15 2022
3 copyright : (C) 2022 by Ralf Habacker
4 email : ralf.habacker@freenet.de
5
6 ***************************************************************************
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 * *
23 ***************************************************************************/
24
25#ifndef GWENHYWFAR_Funcs_H
26#define GWENHYWFAR_Funcs_H
27
29#include <gwenhywfar/db.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35
42typedef struct {
43 const char *name;
44 int (*func1)(void);
45 int (*func2)(int, char**);
46 int (*func3)(GWEN_DB_NODE*, int, char**);
47 const char *description;
49
50/* Defines a command without parameters but with description */
51#define GWEN_FUNCS_ENTRY_HELP(a,b,c) { a, b, NULL, NULL, c }
52
53/* Defines a command with argc/argv parameter and description */
54#define GWEN_FUNNCS_ENTRY_ARGS_HELP(a,b,c) { a, 0, b, NULL, c }
55
56/* Defines a command with DB_NODE type and argc/argv parameter and description */
57#define GWEN_FUNCS_ENTRY_DB_NODE_ARGS_HELP(a,b,c) { a, NULL, NULL, b, c }
58
59/* Defines the end of the command table */
60#define GWEN_FUNCS_ENTRY_END() { NULL, NULL, NULL, NULL, NULL }
61
62/* Defines one of the above commands without description */
63#define GWEN_FUNCS_ENTRY(a,b) { a, b, NULL, NULL, NULL }
64#define GWEN_FUNCS_ENTRY_ARGS(a,b) { a, 0, b, NULL, NULL }
65#define GWEN_FUNCS_ENTRY_DB_NODE_ARGS(a,b) { a, NULL, NULL, b, NULL }
66
67/* Shortcuts */
68#define GWEN_FE_DAH GWEN_FUNCS_ENTRY_DB_NODE_ARGS_HELP
69#define GWEN_FE_DA GWEN_FUNCS_ENTRY_DB_NODE_ARGS
70#define GWEN_FE_D GWEN_FUNCS_ENTRY_DB_NODE
71#define GWEN_FE_END GWEN_FUNCS_ENTRY_END
72
73/* Checks if a command variant exists */
80
81/* Functions to call a specified command */
83int GWEN_Funcs_Call(const GWEN_FUNCS *func);
85int GWEN_Funcs_Call_Args(const GWEN_FUNCS *func, int argc, char **argv);
87int GWEN_Funcs_Call_DB_NODE_Args(const GWEN_FUNCS *func, GWEN_DB_NODE *node, int argc, char **argv);
88
94void GWEN_Funcs_Usage(const GWEN_FUNCS* funcs);
95
101
107const GWEN_FUNCS* GWEN_Funcs_Find(const GWEN_FUNCS* funcs, const char *name);
108
109#ifdef __cplusplus
110}
111#endif
112
113
114#endif /* GWENHYWFAR_Funcs_H */
115
116
117
struct GWEN_DB_NODE GWEN_DB_NODE
Definition db.h:228
GWENHYWFAR_API int GWEN_Funcs_Call_DB_NODE_Args(const GWEN_FUNCS *func, GWEN_DB_NODE *node, int argc, char **argv)
GWENHYWFAR_API int GWEN_Funcs_Has_Call_Args(const GWEN_FUNCS *func)
GWENHYWFAR_API int GWEN_Funcs_Call(const GWEN_FUNCS *func)
GWENHYWFAR_API int GWEN_Funcs_Has_Call(const GWEN_FUNCS *func)
GWENHYWFAR_API int GWEN_Funcs_Call_Args(const GWEN_FUNCS *func, int argc, char **argv)
GWENHYWFAR_API const GWEN_FUNCS * GWEN_Funcs_Find(const GWEN_FUNCS *funcs, const char *name)
GWENHYWFAR_API int GWEN_Funcs_Has_Call_DB_NODE_Args(const GWEN_FUNCS *func)
GWENHYWFAR_API void GWEN_Funcs_Usage_With_Help(const GWEN_FUNCS *funcs)
GWENHYWFAR_API void GWEN_Funcs_Usage(const GWEN_FUNCS *funcs)
#define GWENHYWFAR_API
const char * description
Definition funcs.h:47
const char * name
Definition funcs.h:43