#ifndef __GETOPT_H__
#define __GETOPT_H__

#include <glib.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct getopt_option getopt_option_t;
struct getopt_option
{
    char *sname;
    char *lname;
    char *svalue;
    
    char *help;
    int type;
    int found;
	
    int spacer;
    int description;
};

typedef struct getopt getopt_t;
struct getopt
{
    char        *exename;
    GHashTable  *lopts;
    GHashTable  *sopts;
    GPtrArray   *extraargs;
    GPtrArray   *options;
};

getopt_t *
getopt_create (void);

void 
getopt_destroy (getopt_t *gopt);

int 
getopt_parse (getopt_t *gopt, int argc, char *argv[], int showErrors);

/* set extraargs=NULL, to print default usage */
void 
getopt_do_usage (getopt_t *gopt, const char *extraargs);

void
getopt_add_description (getopt_t *gopt, const char *s);

void 
getopt_add_spacer (getopt_t *gopt, const char *s);

void
getopt_add_help (getopt_t *gopt, const char *help);

void
getopt_add_bool (getopt_t *gopt, char sopt, const char *lname, int def, const char *help);

void
getopt_add_int (getopt_t *gopt, char sopt, const char *lname, const char *def, const char *help);

void
getopt_add_long (getopt_t *gopt, char sopt, const char *lname, const char *def, const char *help);

void
getopt_add_double (getopt_t *gopt, char sopt, const char *lname, const char *def, const char *help);

void
getopt_add_string (getopt_t *gopt, char sopt, const char *lname, const char *def, const char *help);

int
getopt_get_bool (getopt_t *getopt, const char *lname);

int
getopt_get_int (getopt_t *getopt, const char *lname);

long
getopt_get_long (getopt_t *getopt, const char *lname);

double
getopt_get_double (getopt_t *getopt, const char *lname);

const char *
getopt_get_string (getopt_t *gopt, const char *lname);

int
getopt_has_flag (getopt_t *gopt, const char *lname);

#ifdef __cplusplus
}
#endif

#endif // __GETOPT_H__
