mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 05:05:00 +00:00
LibC: Make getopt
available from getopt.h
This commit is contained in:
parent
aae106e37b
commit
f8bd607733
3 changed files with 31 additions and 21 deletions
29
Userland/Libraries/LibC/bits/getopt.h
Normal file
29
Userland/Libraries/LibC/bits/getopt.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023, the SerenityOS contributors.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
// If opterr is set (the default), print error messages to stderr.
|
||||
extern int opterr;
|
||||
// On errors, optopt is set to the erroneous *character*.
|
||||
extern int optopt;
|
||||
// Index of the next argument to process upon a getopt*() call.
|
||||
extern int optind;
|
||||
// If set, reset the internal state kept by getopt*(). You may also want to set
|
||||
// optind to 1 in that case.
|
||||
extern int optreset;
|
||||
// After parsing an option that accept an argument, set to point to the argument
|
||||
// value.
|
||||
extern char* optarg;
|
||||
|
||||
int getopt(int argc, char* const* argv, char const* short_options);
|
||||
int getsubopt(char** optionp, char* const* tokens, char** valuep);
|
||||
|
||||
__END_DECLS
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <bits/getopt.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
@ -21,11 +22,6 @@ struct option {
|
|||
int val;
|
||||
};
|
||||
|
||||
extern int opterr;
|
||||
extern int optopt;
|
||||
extern int optind;
|
||||
extern int optreset;
|
||||
extern char* optarg;
|
||||
int getopt_long(int argc, char* const* argv, char const* short_options, const struct option* long_options, int* out_long_option_index);
|
||||
|
||||
__END_DECLS
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <Kernel/API/POSIX/unistd.h>
|
||||
#include <bits/getopt.h>
|
||||
#include <fd_set.h>
|
||||
#include <limits.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
@ -162,20 +163,4 @@ enum {
|
|||
|
||||
long sysconf(int name);
|
||||
|
||||
// If opterr is set (the default), print error messages to stderr.
|
||||
extern int opterr;
|
||||
// On errors, optopt is set to the erroneous *character*.
|
||||
extern int optopt;
|
||||
// Index of the next argument to process upon a getopt*() call.
|
||||
extern int optind;
|
||||
// If set, reset the internal state kept by getopt*(). You may also want to set
|
||||
// optind to 1 in that case.
|
||||
extern int optreset;
|
||||
// After parsing an option that accept an argument, set to point to the argument
|
||||
// value.
|
||||
extern char* optarg;
|
||||
|
||||
int getopt(int argc, char* const* argv, char const* short_options);
|
||||
int getsubopt(char** optionp, char* const* tokens, char** valuep);
|
||||
|
||||
__END_DECLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue