From 2fb91e19a02ff8a3e43145d582cfebaf3a60f1d9 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sat, 5 Oct 2013 16:10:30 -0400 Subject: Sanitize the registered function interface. Expand the characters which are legal in a function name, and check the name for validity. Create a type for the function pointer. Convert the last argument from a boolean to flags, to allow for expansion. --- gnumake.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'gnumake.h') diff --git a/gnumake.h b/gnumake.h index dbf303b..94d725e 100644 --- a/gnumake.h +++ b/gnumake.h @@ -26,6 +26,7 @@ typedef struct unsigned long lineno; } gmk_floc; +typedef char *(*gmk_func_ptr)(const char *nm, unsigned int argc, char **argv); #ifdef _WIN32 # ifdef GMK_BUILDING_MAKE @@ -60,14 +61,19 @@ GMK_EXPORT char *gmk_expand (const char *str); MIN_ARGS is the minimum number of arguments the function requires. MAX_ARGS is the maximum number of arguments (or 0 if there's no maximum). - MIN_ARGS and MAX_ARGS must be >= 0 and <= 255. + MIN_ARGS and MAX_ARGS may not exceed 255. - If EXPAND_ARGS is 0, the arguments to the function will not be expanded - before FUNC is called. If EXPAND_ARGS is non-0, they will be expanded. + The FLAGS value may be GMK_FUNC_DEFAULT, or one or more of the following + flags OR'd together: + + GMK_FUNC_NOEXPAND: the arguments to the function will be not be expanded + before FUNC is called. */ -GMK_EXPORT void gmk_add_function (const char *name, - char *(*func)(const char *nm, - int argc, char **argv), - int min_args, int max_args, int expand_args); +GMK_EXPORT void gmk_add_function (const char *name, gmk_func_ptr func, + unsigned int min_args, unsigned int max_args, + unsigned int flags); + +#define GMK_FUNC_DEFAULT 0x00 +#define GMK_FUNC_NOEXPAND 0x01 #endif /* _GNUMAKE_H_ */ -- cgit v1.2.3