cuserid() — Return character login of the user

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2

both  

Format

#define _XOPEN_SOURCE
#include <stdio.h>

char *cuserid(char *s);

General description

The cuserid() function generates a character representation of the name associated with the real or effective user ID of the process.

If s is a NULL pointer, this representation is generated in an area that may be overwritten by subsequent calls to cuserid(). A pointer to the area is returned. If s is not a NULL pointer, s is assumed to point to an array of at least {L_cuserid} bytes; the representation is deposited in this array. The symbolic constant {L_cuserid} is defined in <stdio.h> and has a value greater than 0.

Note:

This function and constant L_cuserid are kept for historical reasons. They were part of the Legacy Feature in Single UNIX Specification, Version 2, but have been withdrawn and are not supported as part of Single UNIX Specification, Version 3. New applications should use getpwuid() instead of cuserid().

If it is necessary to continue using this function in an application written for Single UNIX Specification, Version 3, define the feature test macro _UNIX03_WITHDRAWN before including any standard system headers. The macro exposes all interfaces and symbols removed in Single UNIX Specification, Version 3.

Returned value

If s is not a NULL pointer, cuserid() returns s.

If s is not a NULL pointer and the login name cannot be found, the NULL byte '\0' will be placed at *s.

If s is a NULL pointer and the login name cannot be found, cuserid() returns a NULL pointer.

If s is a NULL pointer and the login name can be found, cuserid() returns the address of a buffer local to the calling thread containing the login name.

Related information