Purpose
Converts a domain-specific host name to an operating-system-independent network name.
Library
C Library (libc.a)
Syntax
Description
The host2netname subroutine converts a domain-specific host name to an operating-system-independent network name.
This subroutine is the inverse of the netname2host subroutine.
Parameters
Item | Description |
---|---|
name | Points to the network name (or netname) of the server process owner. The name parameter can be either the host name derived from the host2netname subroutine or the user name derived from the user2netname subroutine. |
host | Points to the name of the machine on which the permissions were created. |
domain | Points to the domain name. |
Return Values
Upon successful completion, this subroutine returns a value of 1. If unsuccessful, it returns a value of 0.
Purpose
Converts a domain-specific host name to an operating-system-independent network name.
Library
Network Services Library (libnsl.a)
Syntax
#include <rpc/rpc.h>
int host2netname( name, host, domain)
char *name;
const char *host;
const char *domain;
Description
Parameters
Item | Description |
---|---|
name | Represents the network name of the host after successful completion. |
host | Specifies the domain-specific host name. |
domain | Specifies the domain name of the host. |
Return Values
Item | Description |
---|---|
1 | successful |
0 | unsuccessful |
Examples
#include <rpc/rpc.h>
int main()
{
char name[255]; /* contains netname of owner of server process */
char host[255]; /* Remote host name on which server resides */
char domain[255];
rpcprog_t PROGNUM = 0x3fffffffL;
rpcvers_t PROGVER = 0x1L;
/* obtain the domainname of the host */
if (getdomainname(domain, 255)) {
fprintf(stderr, "\ngetdomainname() failed\n");
exit(2);
}
/* Obtain network name of remote host */
if (!host2netname(name, host, domain))
{
fprintf(stderr, "\nhost2netname() failed\n");
exit(EXIT_FAILURE);
}
/* Create a client handle for remote host rhost for PROGNUM & PROGVER on tcp transport */
clnt = clnt_create(host, PROGNUM, PROGVER, "tcp");
if (clnt == (CLIENT *) NULL) {
fprintf(stderr,"client_create() error\n");
exit(1);
}
clnt->cl_auth = authdes_seccreate(name, 80, host, (des_block *)NULL);
/*
* Make a call to clnt_call() subroutine
*/
/* Destroy the authentication handle */
auth_destroy(clnt->cl_auth);
/* Destroy the client handle in the end */
clnt_destroy(clnt);
return 0;
}