From 6124167a92cbcf43b8f15500761db30dd1bc2665 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 24 Apr 2014 11:26:03 +0200 Subject: m + mark pure functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- .gitignore | 1 + src/argparser.c | 2 +- src/argparser.h | 90 ++++++++++++++++++++++++++++----------------------------- 3 files changed, 47 insertions(+), 46 deletions(-) diff --git a/.gitignore b/.gitignore index d69fc4d..3fcf0ff 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ obj/ *.gz *.bz2 *.xz +*.su diff --git a/src/argparser.c b/src/argparser.c index 7bbcb26..802561d 100644 --- a/src/argparser.c +++ b/src/argparser.c @@ -168,7 +168,7 @@ void args_init(char* description, char* usage, char* longdescription, char* prog /** * Disposes of all resources, run this when you are done */ -void args_dispose() +void args_dispose(void) { if (args_files != null) free(args_files); diff --git a/src/argparser.h b/src/argparser.h index eb073cd..9eb1de4 100644 --- a/src/argparser.h +++ b/src/argparser.h @@ -211,13 +211,13 @@ char* (*args_abbreviations)(char*, char**, long); * @param alternative Whether to use single dash/plus long options * @param abbreviations Abbreviated option expander, `null` for disabled */ -extern void args_init(char* description, char* usage, char* longdescription, char* program, long usestderr, long alternative, char* (*abbreviations)(char*, char**, long)); +void args_init(char* description, char* usage, char* longdescription, char* program, long usestderr, long alternative, char* (*abbreviations)(char*, char**, long)); /** * Disposes of all resources, run this when you are done */ -extern void args_dispose(void); +void args_dispose(void); /** @@ -228,7 +228,7 @@ extern void args_dispose(void); * @param count The number of elements in `options` * @return The only possible expansion, otherwise `null` */ -extern char* args_standard_abbreviations(char* argument, char** options, long count); +char* args_standard_abbreviations(char* argument, char** options, long count) __attribute__((pure)); /** @@ -239,7 +239,7 @@ extern char* args_standard_abbreviations(char* argument, char** options, long co * @param alternatives... The alternative names, end with `null` * @return The created option */ -extern args_Option args_new_argumentless(void (*trigger)(char*, char*), int standard, char* alternatives, ...); +args_Option args_new_argumentless(void (*trigger)(char*, char*), int standard, char* alternatives, ...); /** * Creates, but does not add, a option that takes one argument per use @@ -250,7 +250,7 @@ extern args_Option args_new_argumentless(void (*trigger)(char*, char*), int stan * @param alternatives... The alternative names, end with `null` * @return The created option */ -extern args_Option args_new_argumented(void (*trigger)(char*, char*, char*), char* argument, int standard, char* alternatives, ...); +args_Option args_new_argumented(void (*trigger)(char*, char*, char*), char* argument, int standard, char* alternatives, ...); /** * Creates, but does not add, a option that optionally takes one argument per use @@ -262,7 +262,7 @@ extern args_Option args_new_argumented(void (*trigger)(char*, char*, char*), cha * @param alternatives... The alternative names, end with `null` * @return The created option */ -extern args_Option args_new_optargumented(long (*stickless)(char*), void (*trigger)(char*, char*, char*), char* argument, int standard, char* alternatives, ...); +args_Option args_new_optargumented(long (*stickless)(char*), void (*trigger)(char*, char*, char*), char* argument, int standard, char* alternatives, ...); /** * Creates, but does not add, a option that takes all following arguments @@ -273,7 +273,7 @@ extern args_Option args_new_optargumented(long (*stickless)(char*), void (*trigg * @param alternatives... The alternative names, end with `null` * @return The created option */ -extern args_Option args_new_variadic(void (*trigger)(char*, char*), char* argument, int standard, char* alternatives, ...); +args_Option args_new_variadic(void (*trigger)(char*, char*), char* argument, int standard, char* alternatives, ...); /** @@ -281,14 +281,14 @@ extern args_Option args_new_variadic(void (*trigger)(char*, char*), char* argume * * @return All options */ -extern args_Option* args_get_options(void); +args_Option* args_get_options(void) __attribute__((pure)); /** * Gets the number of elements in the array returned by `args_get_options` * * @return The number of elements in the array returned by `args_get_options` */ -extern long args_get_options_count(void); +long args_get_options_count(void) __attribute__((pure)); /** * Gets the option with a specific index @@ -296,7 +296,7 @@ extern long args_get_options_count(void); * @param index The option's index * @return The option */ -extern args_Option args_options_get(long index); +args_Option args_options_get(long index) __attribute__((pure)); /** * Gets the type of a option with a specific index @@ -304,7 +304,7 @@ extern args_Option args_options_get(long index); * @param index The option's index * @return The option's type */ -extern long args_options_get_type(long index); +long args_options_get_type(long index) __attribute__((pure)); /** * Gets the number of alternative option names for a option with a specific index @@ -312,7 +312,7 @@ extern long args_options_get_type(long index); * @param index The option's index * @return The option's number of alternative option names */ -extern long args_options_get_alternatives_count(long index); +long args_options_get_alternatives_count(long index) __attribute__((pure)); /** * Gets the alternative option names for a option with a specific index @@ -320,7 +320,7 @@ extern long args_options_get_alternatives_count(long index); * @param index The option's index * @return The option's alternative option names */ -extern char** args_options_get_alternatives(long index); +char** args_options_get_alternatives(long index) __attribute__((pure)); /** * Gets the argument name for a option with a specific index @@ -328,7 +328,7 @@ extern char** args_options_get_alternatives(long index); * @param index The option's index * @return The option's argument name */ -extern char* args_options_get_argument(long index); +char* args_options_get_argument(long index) __attribute__((pure)); /** * Gets the standard option name for a option with a specific index @@ -336,7 +336,7 @@ extern char* args_options_get_argument(long index); * @param index The option's index * @return The option's standard option name */ -extern char* args_options_get_standard(long index); +char* args_options_get_standard(long index) __attribute__((pure)); /** * Trigger an option @@ -368,7 +368,7 @@ long args_optmap_stickless(char* name, char* argument); * @param index The option's index * @return The option's help text */ -extern char* args_options_get_help(long index); +char* args_options_get_help(long index) __attribute__((pure)); /** @@ -376,14 +376,14 @@ extern char* args_options_get_help(long index); * * @return The available options */ -extern char** args_get_opts(void); +char** args_get_opts(void) __attribute__((pure)); /** * Gets the number of available options * * @return The number of available options */ -extern long args_get_opts_count(void); +long args_get_opts_count(void) __attribute__((pure)); /** * Gets whether an option is available @@ -391,14 +391,14 @@ extern long args_get_opts_count(void); * @param name The option * @return Whether an option is available */ -extern long args_opts_contains(char* name); +long args_opts_contains(char* name) __attribute__((pure)); /** * Initialise an option * * @param name The option */ -extern void args_opts_new(char* name); +void args_opts_new(char* name); /** * Appends a value to an option @@ -406,14 +406,14 @@ extern void args_opts_new(char* name); * @param name The option * @param value The new value */ -extern void args_opts_append(char* name, char* value); +void args_opts_append(char* name, char* value); /** * Removes all values from an option * * @param name The option */ -extern void args_opts_clear(char* name); +void args_opts_clear(char* name); /** * Gets the values for an option @@ -421,7 +421,7 @@ extern void args_opts_clear(char* name); * @param name The option * @return The values */ -extern char** args_opts_get(char* name); +char** args_opts_get(char* name) __attribute__((pure)); /** * Gets the number of values for an option @@ -429,7 +429,7 @@ extern char** args_opts_get(char* name); * @param name The option * @return The number of values */ -extern long args_opts_get_count(char* name); +long args_opts_get_count(char* name) __attribute__((pure)); /** * Sets the values for an option @@ -437,7 +437,7 @@ extern long args_opts_get_count(char* name); * @param name The option * @param count The values */ -extern void args_opts_put(char* name, char** values); +void args_opts_put(char* name, char** values); /** * Sets the number of values for an option @@ -445,7 +445,7 @@ extern void args_opts_put(char* name, char** values); * @param name The option * @param count The number of values */ -extern void args_opts_put_count(char* name, long count); +void args_opts_put_count(char* name, long count); /** * Checks whether an option is used @@ -453,7 +453,7 @@ extern void args_opts_put_count(char* name, long count); * @param name The option * @return Whether the option is used */ -extern long args_opts_used(char* name); +long args_opts_used(char* name) __attribute__((pure)); /** @@ -461,14 +461,14 @@ extern long args_opts_used(char* name); * * @return All alternativ names that exists for all options */ -extern char** args_get_optmap(void); +char** args_get_optmap(void) __attribute__((pure)); /** * Gets the number of elements returned by `args_get_optmap` * * @return The number of elements returned by `args_get_optmap` */ -extern long args_get_optmap_count(void); +long args_get_optmap_count(void) __attribute__((pure)); /** * Maps alternative name for a option @@ -476,7 +476,7 @@ extern long args_get_optmap_count(void); * @param name The option's alternative name * @param index The option's index */ -extern void args_optmap_put(char* name, long index); +void args_optmap_put(char* name, long index); /** * Gets the option with a specific alternative name @@ -484,7 +484,7 @@ extern void args_optmap_put(char* name, long index); * @param name The option's alternative name * @return The option */ -extern args_Option args_optmap_get(char* name); +args_Option args_optmap_get(char* name) __attribute__((pure)); /** * Gets the index of a option with a specific alternative name @@ -492,7 +492,7 @@ extern args_Option args_optmap_get(char* name); * @param name The option's alternative name * @return The option's index, negative if not found */ -extern long args_optmap_get_index(char* name); +long args_optmap_get_index(char* name) __attribute__((pure)); /** * Checks whether an options with a specific alternative name exists @@ -500,7 +500,7 @@ extern long args_optmap_get_index(char* name); * @param name One of the names of the option * @return Whether the option exists */ -extern long args_optmap_contains(char* name); +long args_optmap_contains(char* name) __attribute__((pure)); /** * Gets the type of a option with a specific alternative name @@ -508,7 +508,7 @@ extern long args_optmap_contains(char* name); * @param name The option's alternative name * @return The option's type */ -extern long args_optmap_get_type(char* name); +long args_optmap_get_type(char* name) __attribute__((pure)); /** * Gets the standard option name for a option with a specific alternative name @@ -516,7 +516,7 @@ extern long args_optmap_get_type(char* name); * @param name The option's alternative name * @return The option's standard option name */ -extern char* args_optmap_get_standard(char* name); +char* args_optmap_get_standard(char* name) __attribute__((pure)); /** @@ -525,7 +525,7 @@ extern char* args_optmap_get_standard(char* name); * @param option The option * @param help Help text, multi-line, `null` if hidden */ -extern void args_add_option(args_Option option, char* help); +void args_add_option(args_Option option, char* help); /** * Gets the name of the parent process @@ -533,7 +533,7 @@ extern void args_add_option(args_Option option, char* help); * @param levels The number of parents to walk, 0 for self, and 1 for direct parent * @return The name of the parent process, `null` if not found */ -extern char* args_parent_name(long levels); +char* args_parent_name(long levels); /** * Checks the correctness of the number of used non-option arguments @@ -541,7 +541,7 @@ extern char* args_parent_name(long levels); * @param min The minimum number of files * @return Whether the usage was correct */ -extern long args_test_files_min(long min); +long args_test_files_min(long min) __attribute__((pure)); /** * Checks the correctness of the number of used non-option arguments @@ -549,7 +549,7 @@ extern long args_test_files_min(long min); * @param max The maximum number of files * @return Whether the usage was correct */ -extern long args_test_files_max(long max); +long args_test_files_max(long max) __attribute__((pure)); /** * Checks the correctness of the number of used non-option arguments @@ -558,7 +558,7 @@ extern long args_test_files_max(long max); * @param max The maximum number of files * @return Whether the usage was correct */ -extern long args_test_files(long min, long max); +long args_test_files(long min, long max) __attribute__((pure)); /** * Checks for out of context option usage @@ -567,7 +567,7 @@ extern long args_test_files(long min, long max); * @param allowed_count The number of elements in `allowed` * @return Whether only allowed options was used */ -extern long args_test_allowed(char** allowed, long allowed_count); +long args_test_allowed(char** allowed, long allowed_count); /** * Checks for option conflicts @@ -576,19 +576,19 @@ extern long args_test_allowed(char** allowed, long allowed_count); * @param exclusives_count The number of elements in `exclusives` * @return Whether at most one exclusive option was used */ -extern long args_test_exclusiveness(char** exclusives, long exclusives_count); +long args_test_exclusiveness(char** exclusives, long exclusives_count); /** * Maps up options that are alternatives to the first alternative for each option */ -extern void args_support_alternatives(void); +void args_support_alternatives(void); /** * Prints a colourful help message * * @param [use_colours] `-1` for no colours, `1` for colours, and `0` for if not piped */ -extern void args_help(); +void args_help(); /** * Parse arguments @@ -597,5 +597,5 @@ extern void args_help(); * @param argv The command line arguments, it should include the execute file at index 0 * @return Whether no unrecognised option is used */ -extern long args_parse(int argc, char** argv); +long args_parse(int argc, char** argv); -- cgit v1.2.3-70-g09d2