getdomainname()--Retrieve Domain Name
Syntax
#include <sys/types.h> #include <sys/socket.h> int getdomainname(char *name, int length)
Service Program Name: QSOSRV1
Default Public Authority: *USE
Threadsafe: Yes
The getdomainname() function is used to retrieve the name of the domain from the system.
Parameters
- name
- (Output) The name parameter can be one of the following:
- The pointer to a character array where the domain name is to be stored. The
domain name is NULL-terminated unless the length of the domain name exceeds the
length of the name parameter. In that case the domain name is
truncated to the size of the name parameter.
- A NULL string when a sethostname() has not been previously issued since the last initial program load.
- The pointer to a character array where the domain name is to be stored. The
domain name is NULL-terminated unless the length of the domain name exceeds the
length of the name parameter. In that case the domain name is
truncated to the size of the name parameter.
- length
- (Input) The length of the name parameter. Maximum length of domain names is 255.
Authorities
None.
Return Value
getdomainname() returns an integer. Possible values are:
- -1 (unsuccessful)
- 0 (successful)
Error Conditions
When getdomainname() fails, errno can be set to one of the following:
[EFAULT] | Bad address.
The system detected an address which was not valid while attempting to access the name parameter. |
[EINVAL] | Parameter not valid.
The length parameter specifies a negative value. |
[EIO] | Input/output error. |
[EUNKNOWN] | Unknown system state. |
Error Messages
Message ID | Error Message Text |
---|---|
CPE3418 E | Possible APAR condition or hardware failure. |
CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
CPFA081 E | Unable to set return value or error code. |
Usage Notes
- When a process issues a setdomainname(), the name of the domain
can be accessed by any process that issues a getdomainname().
- The name of the domain is reset to NULL when an initial program load is
performed.
Note: The domain name returned by this function is NOT related to the domain name of the domain name server that is configured using the Configure TCP/IP (CFGTCP) menu.
- The domain name is returned in the default coded character set identifier (CCSID) currently in effect for the job.
Related Information
- setdomainname()--Set Domain Name
API introduced: V3R1