[nfs] : optimize code format
This commit is contained in:
parent
e8ec10d5e7
commit
3b548038e1
|
@ -1,4 +1,4 @@
|
||||||
/* @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC */
|
/* @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC */
|
||||||
/*
|
/*
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||||
* unrestricted use provided that this legend is included on all tape
|
* unrestricted use provided that this legend is included on all tape
|
||||||
|
@ -41,17 +41,17 @@ static char sccsid[] = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
|
||||||
* returns client handle. Default options are set, which the user can
|
* returns client handle. Default options are set, which the user can
|
||||||
* change using the rpc equivalent of ioctl()'s.
|
* change using the rpc equivalent of ioctl()'s.
|
||||||
*/
|
*/
|
||||||
CLIENT *clnt_create (const char *hostname, const unsigned long prog,
|
CLIENT *clnt_create(const char *hostname, const unsigned long prog,
|
||||||
const unsigned long vers, const char *proto)
|
const unsigned long vers, const char *proto)
|
||||||
{
|
{
|
||||||
int sock;
|
int sock;
|
||||||
struct sockaddr_in server;
|
struct sockaddr_in server;
|
||||||
struct addrinfo hint, *res = NULL;
|
struct addrinfo hint, *res = NULL;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
CLIENT *client;
|
CLIENT *client;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
memset(&hint, 0, sizeof(hint));
|
memset(&hint, 0, sizeof(hint));
|
||||||
ret = getaddrinfo(hostname, NULL, &hint, &res);
|
ret = getaddrinfo(hostname, NULL, &hint, &res);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
|
@ -62,26 +62,26 @@ CLIENT *clnt_create (const char *hostname, const unsigned long prog,
|
||||||
memcpy(&server, res->ai_addr, sizeof(struct sockaddr_in));
|
memcpy(&server, res->ai_addr, sizeof(struct sockaddr_in));
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
|
|
||||||
sock = -1;
|
sock = -1;
|
||||||
if (strcmp(proto, "udp") == 0)
|
if (strcmp(proto, "udp") == 0)
|
||||||
{
|
{
|
||||||
tv.tv_sec = 5;
|
tv.tv_sec = 5;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
client = clntudp_create(&server, prog, vers, tv, &sock);
|
client = clntudp_create(&server, prog, vers, tv, &sock);
|
||||||
if (client == NULL) return NULL;
|
if (client == NULL) return NULL;
|
||||||
tv.tv_sec = 1;
|
tv.tv_sec = 1;
|
||||||
clnt_control(client, CLSET_TIMEOUT, (char*)&tv);
|
clnt_control(client, CLSET_TIMEOUT, (char *)&tv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rt_kprintf("unknow protocol\n");
|
rt_kprintf("unknow protocol\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (client);
|
return (client);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clnt_perror(CLIENT *rpch, const char *s)
|
void clnt_perror(CLIENT *rpch, const char *s)
|
||||||
{
|
{
|
||||||
rt_kprintf("rpc client error:%s\n", s);
|
rt_kprintf("rpc client error:%s\n", s);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue