view src/dmargs.h @ 2576:812b16ee49db

I had been living under apparent false impression that "realfft.c" on which the FFT implementation in DMLIB was basically copied from was released in public domain at some point, but it could very well be that it never was. Correct license is (or seems to be) GNU GPL. Thus I removing the code from DMLIB, and profusely apologize to the author, Philip Van Baren. It was never my intention to distribute code based on his original work under a more liberal license than originally intended.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 Mar 2022 16:32:50 +0200
parents c6ee41fd98dd
children 9807ae37ad69
line wrap: on
line source

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

#include "dmlib.h"

#ifdef __cplusplus
extern "C" {
#endif

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

/** @def Option processing 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;           ///< Option ID (should be unique for each option)
    char o_short;     ///< Short option name (one character, can be 0 for none)
    char *o_long;     ///< Long option name (can be NULL for none)
#ifdef DM_USE_OPT_ARG
    char *o_arg;      ///< Option argument name (can be NULL for none/default)
#endif
    char *desc;       ///< Option description
    int flags;        ///< Flags (see OPT_*)
} DMOptArg;


BOOL     dmArgsProcess(int argc, char *argv[],
         const DMOptArg *opts, const int nopts,
         BOOL (*handle_option)(int id, char *, char *),
         BOOL (*handle_other)(char *), const int flags);

void     dmArgsPrintHelp(FILE *fh, const DMOptArg *opts,
         const int nopts, const int flags, const int width);

void     dmPrintWrap(FILE *fh, const int spad,
         const int rpad, const int width, const char *str);

#ifdef __cplusplus
}
#endif
#endif // DMARGS_H