Lely core libraries 2.3.4
unistd.h File Reference

This header file is part of the C11 and POSIX compatibility library; it includes <unistd.h>, if it exists, and defines any missing functionality. More...

#include <lely/features.h>
Include dependency graph for unistd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int getopt (int argc, char *const argv[], const char *optstring)
 Parses options passed as arguments to main().
 
unsigned sleep (unsigned seconds)
 Sleeps until the specified number of realtime seconds has elapsed or the calling thread is interrupted.
 

Variables

char * optarg
 A pointer to the argument of the current option.
 
int optind
 The index of the next argument to be parsed by getopt().
 
int opterr
 A flag indicating whether a diagnostic message should be printed if an unknown option character or missing argument is detected by getopt().
 
int optopt
 The last option character to cause an error.
 

Detailed Description

This header file is part of the C11 and POSIX compatibility library; it includes <unistd.h>, if it exists, and defines any missing functionality.

Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file unistd.h.

Function Documentation

◆ getopt()

int getopt ( int  argc,
char *const  argv[],
const char *  optstring 
)

Parses options passed as arguments to main().

Parameters
argcthe argument count as passed to main().
argvthe argument array as passed to main().
optstringa pointer to a string of recognized option characters; if a character is followed by a colon, the option takes an argument. If the first character is a colon, this function returns ':' instead of '?' when a missing argument is detected and does not print a diagnostic message (regardless of the value of opterr).
Returns
the next option character, '?' if an unknown option character or missing argument is detected, or -1 if all the argument is not an option or all options are parsed.

Definition at line 46 of file getopt.c.

◆ sleep()

unsigned sleep ( unsigned  seconds)

Sleeps until the specified number of realtime seconds has elapsed or the calling thread is interrupted.

Returns
0 if the requested time has elapsed, or the remaining number of seconds if not.
See also
nanosleep()

Variable Documentation

◆ opterr

int opterr

A flag indicating whether a diagnostic message should be printed if an unknown option character or missing argument is detected by getopt().

The default value is 1.

Definition at line 52 of file unistd.h.