dedit
a tool for Teeworlds demo file shenanigens
git clone https://jhhm.no/repos/dedit.git
dedit/include/args.h
get raw file: args.h
1/* This file is part of dedit - a tool for editing Teeworlds/DDNet demo files 2 Copyright (C) 2024 JHHM 3 4 Dedit is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 Dedit is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with dedit. If not, see <https://www.gnu.org/licenses/>. */ 16 17#ifndef ARGS_H 18#define ARGS_H 19 20#define ARGTYPELEN 3 21typedef enum 22{ 23 ARGUMENT = 0, 24 COMMAND = 1, 25 OPTION = 2 26} argtype; 27 28typedef struct arg 29{ 30 argtype type; 31 char *flag; 32 int numopt; 33 char **opts; 34 void (*runarg)(struct arg *); 35} arg; 36 37extern int argerr; // TODO should this be external? 38 39extern int ARGC; 40extern arg *ARGS; 41 42void setinfo(char *info); 43void setusage(char *usage); 44 45int addarg(char *value, char *desc, void (*runarg)(struct arg *)); 46int addopt(char *flag, char *full, int numopt, char *value, char *desc, void (*runarg)(struct arg *)); 47 48int parseargs(int argc, char *args[]); 49void freeargs(void); 50void runargs(void); 51 52arg *getarg(int pos); 53arg *getopt(char *flag, int pos); 54 55void printhelp(void); 56 57void paerror(char *str); 58 59#endif // ARGS_H