view th_args.h @ 377:9ad157feb99a

Sync th-libs.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 03 Oct 2011 00:04:33 +0300
parents 59992d930e70
children
line wrap: on
line source

/*
 * Simple commandline argument processing function
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2002-2008 Tecnic Software productions (TNSP)
 *
 * Please read file 'COPYING' for information on license and distribution.
 */
#ifndef _TH_ARGS
#define _TH_ARGS

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include "th_util.h"


/* Option flags
 */
#define OPT_NONE       (0)    /* Simple option with no arguments */
#define OPT_ARGREQ     (1)    /* Option's argument is required */
#define OPT_ARGOPT     (3)    /* Option's argument is optional */
#define OPT_ARGMASK    (3)    /* Mask for option argument flags */
#define OPT_REQUIRED   (4)    /* This option is required to be given */


typedef struct {
    int optID;
    char optShort;
    char *optLong;
    char *optDesc;
    int optFlags;
} optarg_t;


BOOL th_args_process(int argc, char *argv[],
     optarg_t argList[], int argListN,
     BOOL (*handleOpt)(int, char *, char *),
     BOOL (*handleFile)(char *), BOOL);

void th_args_help(FILE *, optarg_t optList[], int optListN, char *, char *);

#ifdef __cplusplus
}
#endif
#endif /* _TH_ARGS */