view th_args.h @ 140:f81c6dc7bd0f

Cosmetics, comments.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 13 Oct 2014 06:35:53 +0300
parents 0f43a94516f4
children 0a4fd9cfb929
line wrap: on
line source

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

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

#ifdef __cplusplus
extern "C" {
#endif

/* Option flags
 */
#define OPT_NONE             (0)    // Simple option with no arguments
#define OPT_ARGREQ           (1)    // Option requires an argument
#define OPT_ARGMASK          (3)    // Mask for option argument flags

#define OPTH_BAILOUT         0x0001 // Bail out on errors

#define OPTH_ONLY_OPTS       0x0010 // Handle only options
#define OPTH_ONLY_OTHER      0x0020 // Handle only "non-options"
#define OPTH_ONLY_MASK       0x00f0 // Mask


/* Option argument structure
 */
typedef struct
{
    int id;
    char optShort;
    char *optLong;
    char *desc;
    int flags;
} optarg_t;


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

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

#ifdef __cplusplus
}
#endif
#endif // TH_ARGS