OILS / vendor / souffle / utility / GetOptLong.h View on Github | oilshell.org

35 lines, 15 significant
1/*
2 * Souffle - A Datalog Compiler
3 * Copyright (c) 2022, The Souffle Developers. All rights reserved
4 * Licensed under the Universal Permissive License v 1.0 as shown at:
5 * - https://opensource.org/licenses/UPL
6 * - <souffle root>/licenses/SOUFFLE-UPL.txt
7 */
8#ifndef GET_OPT_LONG_H
9#define GET_OPT_LONG_H
10
11// Points to the argument of the last option found.
12extern char* optarg;
13
14// Index of the next element to processed in argv.
15extern int optind;
16
17// Enables error message printing if opterr!=0.
18extern int opterr;
19
20extern int optopt;
21
22// The long option descriptor, as described by man page for getopt_long.
23struct option {
24 const char* name; // name of the long option.
25 int has_arg; // 0=no argument, 1=requires argument, 2=optional argument.
26 int* flag; // if non-null, the variable pointed by `flag` is set to `val` when getopt_long finds this
27 // option.
28 int val; // value to return or to load in the variable pointed by `flag` when this option is found.
29};
30
31// A limited implementation of POSIX getopt_long.
32extern int getopt_long(
33 int argc, char* const argv[], const char* optstring, const struct option* longopts, int* longindex);
34
35#endif