Freeciv-3.3
|
#include "support.h"
Go to the source code of this file.
Functions | |
char * | get_option_malloc (const char *option_name, char **argv, int *i, int argc, bool gc) |
bool | is_option (const char *option_name, char *option) |
int | get_tokens (const char *str, char **tokens, size_t num_tokens, const char *delimiterset) |
void | free_tokens (char **tokens, size_t ntokens) |
void | cmdline_option_values_free (void) |
Free memory allocated for commandline option values.
Definition at line 97 of file fc_cmdline.c.
Referenced by client_exit(), main(), main(), rup_parse_cmdline(), and server_quit().
Frees a set of tokens created by get_tokens().
Definition at line 203 of file fc_cmdline.c.
Referenced by aicmd_command(), cmdlevel_command(), create_command(), delegate_command(), fcdb_command(), lua_command(), mapimg_command(), mapimg_define(), mapimg_define_arg(), packet_handlers_get(), playercolor_command(), playernation_command(), property_filter_new(), set_command(), and vote_command().
Return a char* to the parameter of the option or nullptr. i can be increased to get next string in the array argv[]. It is an error for the option to exist but be an empty string. This doesn't use log_*() because it is used before logging is set up.
The argv strings are assumed to be in the local encoding; the returned string is in the internal encoding.
Definition at line 50 of file fc_cmdline.c.
Referenced by client_main(), fcmp_parse_cmdline(), main(), main(), parse_options(), re_parse_cmdline(), and rup_parse_cmdline().
Splits the string into tokens. The individual tokens are returned. The delimiterset can freely be chosen.
i.e. "34 abc 54 87" with a delimiterset of " " will yield tokens={"34", "abc", "54", "87"}
Part of the input string can be quoted (single or double) to embedded delimiter into tokens. For example, command 'a name' hard "1,2,3,4,5" 99 create 'Mack "The Knife"' will yield 5 and 2 tokens respectively using the delimiterset " ,".
Tokens which aren't used aren't modified (and memory is not allocated). If the string would yield more tokens only the first num_tokens are extracted.
The user has the responsibility to free the memory allocated by tokens using free_tokens().
Definition at line 166 of file fc_cmdline.c.
Referenced by aicmd_command(), cmdlevel_command(), create_command(), debug_command(), delegate_command(), detach_command(), fcdb_command(), lock_command(), lua_command(), mapimg_command(), mapimg_define(), mapimg_define_arg(), observe_command(), packet_handlers_get(), playercolor_command(), playernation_command(), property_filter_new(), set_command(), take_command(), team_command(), timeout_command(), unlock_command(), and vote_command().
Is option some form of option_name. option_name must be full length long version such as "--help"
Definition at line 112 of file fc_cmdline.c.
Referenced by client_main(), fcmp_parse_cmdline(), main(), main(), parse_options(), parse_options(), re_parse_cmdline(), and rup_parse_cmdline().