Inital commit

This commit is contained in:
2020-10-10 10:13:09 +02:00
commit cfb70ba379
3 changed files with 587 additions and 0 deletions

68
argpopt.h Normal file
View File

@ -0,0 +1,68 @@
/**
* Sigstoped
* Copyright (C) 2020 Carl Klemm
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include<argp.h>
#include<string>
struct Config
{
char** inFileNames = NULL;
std::string outputFileName = "out.png";
bool verbose = false;
};
const char *argp_program_version = "0.1";
const char *argp_program_bug_address = "<carl@uvos.xyz>";
static char doc[] = "Program to determine the lubricant thikness on a curved surface";
static char args_doc[] = "";
static struct argp_option options[] =
{
{"verbose", 'v', 0, 0, "Enable verbose logging" },
{"output", 'o', "File Name", 0, "Output image file name" },
{ 0 }
};
error_t parse_opt (int key, char *arg, struct argp_state *state)
{
Config* config = reinterpret_cast<Config*>(state->input);
switch (key)
{
case 'v':
config->verbose = false;
break;
case 'o':
config->outputFileName.assign(arg);
break;
case ARGP_KEY_NO_ARGS:
argp_usage(state);
case ARGP_KEY_ARG:
config->inFileNames = &state->argv[state->next-1];
state->next = state->argc;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp argp = { options, parse_opt, args_doc, doc };