|
|
@ -20,6 +20,8 @@ read http://www.purposeful.co.uk/tfl/
|
|
|
|
#ifndef GOPT_H_INCLUDED
|
|
|
|
#ifndef GOPT_H_INCLUDED
|
|
|
|
#define GOPT_H_INCLUDED
|
|
|
|
#define GOPT_H_INCLUDED
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <Export.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define GOPT_ONCE 0
|
|
|
|
#define GOPT_ONCE 0
|
|
|
|
#define GOPT_REPEAT 1
|
|
|
|
#define GOPT_REPEAT 1
|
|
|
|
#define GOPT_NOARG 0
|
|
|
|
#define GOPT_NOARG 0
|
|
|
@ -31,29 +33,29 @@ read http://www.purposeful.co.uk/tfl/
|
|
|
|
#define gopt_longs( ... ) (const char**)(const char*[]){ __VA_ARGS__, NULL }
|
|
|
|
#define gopt_longs( ... ) (const char**)(const char*[]){ __VA_ARGS__, NULL }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void *gopt_sort( int *argc, const char **argv, const void *opt_specs );
|
|
|
|
DFHACK_EXPORT void *gopt_sort( int *argc, const char **argv, const void *opt_specs );
|
|
|
|
/* returns a pointer for use in the following calls
|
|
|
|
/* returns a pointer for use in the following calls
|
|
|
|
* prints to stderr and call exit() on error
|
|
|
|
* prints to stderr and call exit() on error
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
size_t gopt( const void *opts, int key );
|
|
|
|
DFHACK_EXPORT size_t gopt( const void *opts, int key );
|
|
|
|
/* returns the number of times the option was specified
|
|
|
|
/* returns the number of times the option was specified
|
|
|
|
* which will be 0 or 1 unless GOPT_REPEAT was used
|
|
|
|
* which will be 0 or 1 unless GOPT_REPEAT was used
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
size_t gopt_arg( const void *opts, int key, const char **arg );
|
|
|
|
DFHACK_EXPORT size_t gopt_arg( const void *opts, int key, const char **arg );
|
|
|
|
/* returns the number of times the option was specified
|
|
|
|
/* returns the number of times the option was specified
|
|
|
|
* writes a pointer to the option argument from the first (or only) occurance to *arg
|
|
|
|
* writes a pointer to the option argument from the first (or only) occurance to *arg
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
const char *gopt_arg_i( const void *opts, int key, size_t i );
|
|
|
|
DFHACK_EXPORT const char *gopt_arg_i( const void *opts, int key, size_t i );
|
|
|
|
/* returns a pointer to the ith (starting at zero) occurance
|
|
|
|
/* returns a pointer to the ith (starting at zero) occurance
|
|
|
|
* of the option, or NULL if it was not specified that many times
|
|
|
|
* of the option, or NULL if it was not specified that many times
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
size_t gopt_args( const void *opts, int key, const char **args, size_t args_len );
|
|
|
|
DFHACK_EXPORT size_t gopt_args( const void *opts, int key, const char **args, size_t args_len );
|
|
|
|
/* returns the number of times the option was specified
|
|
|
|
/* returns the number of times the option was specified
|
|
|
|
* writes pointers to the option arguments in the order of occurance to args[].
|
|
|
|
* writes pointers to the option arguments in the order of occurance to args[].
|
|
|
|
* writes at most args_len pointers
|
|
|
|
* writes at most args_len pointers
|
|
|
|
* if the return value is less than args_len, also writes a null pointer
|
|
|
|
* if the return value is less than args_len, also writes a null pointer
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void gopt_free( void *opts );
|
|
|
|
DFHACK_EXPORT void gopt_free( void *opts );
|
|
|
|
/* releases memory allocated in the corresponding call to gopt_sort()
|
|
|
|
/* releases memory allocated in the corresponding call to gopt_sort()
|
|
|
|
* opts can no longer be used
|
|
|
|
* opts can no longer be used
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|