view th_args.h @ 0:728243125263

Import.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 20 Mar 2008 00:15:03 +0000
parents
children 69aed051f84d
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 */