| 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.
|
| 12 | extern char* optarg;
|
| 13 |
|
| 14 | // Index of the next element to processed in argv.
|
| 15 | extern int optind;
|
| 16 |
|
| 17 | // Enables error message printing if opterr!=0.
|
| 18 | extern int opterr;
|
| 19 |
|
| 20 | extern int optopt;
|
| 21 |
|
| 22 | // The long option descriptor, as described by man page for getopt_long.
|
| 23 | struct 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.
|
| 32 | extern int getopt_long(
|
| 33 | int argc, char* const argv[], const char* optstring, const struct option* longopts, int* longindex);
|
| 34 |
|
| 35 | #endif
|