Add proper per-file copyright notices/licenses and top-level license.
[bluesky.git] / TBBT / trace_play / sfs_c_clnt.c
1 #ifndef lint
2 static char sfs_c_clntSid[] = "@(#)sfs_c_clnt.c 2.1     97/10/23";
3 #endif
4
5 /*
6  *   Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
7  *      All rights reserved.
8  *              Standard Performance Evaluation Corporation (SPEC)
9  *              6585 Merchant Place, Suite 100
10  *              Warrenton, VA 20187
11  *
12  *      This product contains benchmarks acquired from several sources who
13  *      understand and agree with SPEC's goal of creating fair and objective
14  *      benchmarks to measure computer performance.
15  *
16  *      This copyright notice is placed here only to protect SPEC in the
17  *      event the source is misused in any manner that is contrary to the
18  *      spirit, the goals and the intent of SPEC.
19  *
20  *      The source code is provided to the user or company under the license
21  *      agreement for the SPEC Benchmark Suite for this product.
22  */
23
24 /*****************************************************************
25  *                                                               *
26  *      Copyright 1991,1992  Legato Systems, Inc.                *
27  *      Copyright 1991,1992  Auspex Systems, Inc.                *
28  *      Copyright 1991,1992  Data General Corporation            *
29  *      Copyright 1991,1992  Digital Equipment Corporation       *
30  *      Copyright 1991,1992  Interphase Corporation              *
31  *      Copyright 1991,1992  Sun Microsystems, Inc.              *
32  *                                                               *
33  *****************************************************************/
34
35 /*
36  * -------------------------  Include Files  -------------------------
37  */
38
39 /*
40  * ANSI C headers
41  */
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45 #include <errno.h>
46 #include <math.h>
47 #include <signal.h>
48
49 #include <sys/types.h>
50 #include <sys/stat.h> 
51  
52 #include <unistd.h>
53
54 #include "sfs_c_def.h"
55 #include "sfs_m_def.h"
56
57 #if !defined(_XOPEN_SOURCE)
58 #include <sys/socket.h>
59 #else
60 #define AF_INET         2
61 #endif
62
63 CLIENT *
64 lad_clnt_create(int prot, struct hostent *hostent, uint32_t program,
65                 uint32_t version, int sock, struct timeval *wait)
66 {
67         struct sockaddr_in      sin;
68         CLIENT                  *client_ptr;
69         uint_t                  sendsz = 0;
70         uint_t                  recvsz = 0;
71
72         /* set up the socket address for the remote call */
73         (void) memset((char *) &sin, '\0',  sizeof(sin));
74         (void) memmove((char *) &sin.sin_addr,
75                         hostent->h_addr,
76                         hostent->h_length);
77         sin.sin_family = AF_INET;
78
79         switch (prot) {
80         case 0:                 /* UDP */
81                 if (sendsz == 0)
82                         client_ptr = sfs_cudp_create(&sin, program, version,
83                                                 *wait, &sock);
84                 else
85                         client_ptr = sfs_cudp_bufcreate(&sin, program, version,
86                                                 *wait, &sock,
87                                                 sendsz, recvsz);
88                 break;
89         case 1:                 /* TCP */
90                 sendsz = NFS_MAXDATA + 1024;
91                 recvsz = NFS_MAXDATA + 1024;
92
93                 client_ptr = sfs_ctcp_create(&sin, program, version, &sock,
94                                                 sendsz, recvsz);
95                 break;
96         }
97
98         if (client_ptr == ((CLIENT *) NULL)) {
99                 char    buf[128];
100
101                 (void) sprintf(buf, "%s: server not responding",
102                             sfs_Myname);
103                 clnt_pcreateerror(buf);
104                 return((CLIENT *) NULL);
105         }
106
107         return (client_ptr);
108 }