Lely core libraries  2.3.4
errnum.c File Reference

This file is part of the utilities library; it contains the implementation of the error functions. More...

#include "util.h"
#include <lely/util/errnum.h>
#include <lely/util/util.h>
#include <string.h>
Include dependency graph for errnum.c:

Go to the source code of this file.

Functions

int errno2c (int errnum)
 Transforms a standard C error number to a native error code. More...
 
errnum_t errno2num (int errnum)
 Transforms a standard C error number to a platform-independent error number. More...
 
int errc2no (int errc)
 Transforms a native error code to a standard C error number. More...
 
errnum_t errc2num (int errc)
 Transforms a native error code to a platform-independent error number. More...
 
int errnum2no (errnum_t errnum)
 Transforms a platform-independent error number to a standard C error number. More...
 
int errnum2c (errnum_t errnum)
 Transforms a platform-independent error number to a native error code. More...
 
int get_errc (void)
 Returns the last (thread-specific) native error code set by a system call or library function. More...
 
void set_errc (int errc)
 Sets the current (thread-specific) native error code to errc. More...
 
const char * errno2str_r (int errnum, char *strerrbuf, size_t buflen)
 Returns a string describing a standard C error number. More...
 
const char * errc2str_r (int errc, char *strerrbuf, size_t buflen)
 Returns a string describing a native error code. More...
 

Detailed Description

This file is part of the utilities library; it contains the implementation of the error functions.

See also
lely/util/errnum.h
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 errnum.c.

Function Documentation

◆ errno2c()

int errno2c ( int  errnum)

Transforms a standard C error number to a native error code.

This is equivalent to errnum2c(errno2num(errnum)) on Windows, or errnum on other platforms.

See also
errc2no()

Definition at line 46 of file errnum.c.

◆ errno2num()

errnum_t errno2num ( int  errnum)

Transforms a standard C error number to a platform-independent error number.

See also
errnum2no()

Definition at line 56 of file errnum.c.

◆ errc2no()

int errc2no ( int  errc)

Transforms a native error code to a standard C error number.

This is equivalent to errnum2no(errc2num(errc)) on Windows, or errc on other platforms (provided errc is positive).

See also
errc2no()

Definition at line 299 of file errnum.c.

◆ errc2num()

errnum_t errc2num ( int  errc)

Transforms a native error code to a platform-independent error number.

See also
errnum2c()

Definition at line 309 of file errnum.c.

◆ errnum2no()

int errnum2no ( errnum_t  errnum)

Transforms a platform-independent error number to a standard C error number.

See also
errno2num()

Definition at line 567 of file errnum.c.

◆ errnum2c()

int errnum2c ( errnum_t  errnum)

Transforms a platform-independent error number to a native error code.

See also
err2num()

Definition at line 810 of file errnum.c.

◆ get_errc()

int get_errc ( void  )

Returns the last (thread-specific) native error code set by a system call or library function.

This is equivalent to GetLastError()/WSAGetLastError() on Windows, or errno on other platforms.

This function returns the thread-specific error number.

See also
set_errc()

Definition at line 932 of file errnum.c.

◆ set_errc()

void set_errc ( int  errc)

Sets the current (thread-specific) native error code to errc.

This is equivalent to SetLastError(errc)/WSASetLastError(errc) on Windows, or errno = errc on other platforms.

See also
get_errc()

Definition at line 944 of file errnum.c.

◆ errno2str_r()

const char* errno2str_r ( int  errnum,
char *  strerrbuf,
size_t  buflen 
)

Returns a string describing a standard C error number.

The string is copied to a buffer, if specified, as if by POSIX strerror_r().

Parameters
errnumthe standard C error number.
strerrbufa pointer to the string buffer. If not NULL, at most buflen bytes are copied to the buffer. The string is guaranteed to be null-terminated.
buflenthe number of bytes available at strerrbuf.
Returns
strerrbuf if not NULL, and errno2str(errnum) otherwise.
See also
errno2str()

Definition at line 956 of file errnum.c.

◆ errc2str_r()

const char* errc2str_r ( int  errc,
char *  strerrbuf,
size_t  buflen 
)

Returns a string describing a native error code.

The string is copied to a buffer, if specified..

Parameters
errcthe native error code.
strerrbufa pointer to the string buffer. If not NULL, at most buflen bytes are copied to the buffer. The string is guaranteed to be null-terminated.
buflenthe number of bytes available at strerrbuf.
Returns
strerrbuf if not NULL, and errno2str(errnum) otherwise.
See also
errc2str()

Definition at line 988 of file errnum.c.