File: optparse.h

package info (click to toggle)
wayback 0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 212 kB
  • sloc: ansic: 1,308; makefile: 6
file content (29 lines) | stat: -rw-r--r-- 610 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * Option parsing
 *
 * SPDX-License-Identifier: MIT
 */

#ifndef OPTPARSE_IMPORTED
#define OPTPARSE_IMPORTED
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

struct optcmd
{
	const char *name;
	const char *description;
	const bool req_operand;
	const bool ignore;
};

#define IGNORE_OPT(s, req_op)                                                                      \
	{ .name = s, .description = "", .req_operand = req_op, .ignore = true }

int optparse(int argc, char *argv[], const struct optcmd opts[], uint32_t optlen);

#endif