-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathc_environ.c
80 lines (68 loc) · 2.02 KB
/
c_environ.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/************************************************************************
* (C)opyright 1991-1999 BinTec Communications AG, All Rights Reserved
*
* Title: <one line description>
* Author: <username>
* $RCSfile: c_environ.c,v $
* $Revision: 56 $
* $Date: 2005-11-21 20:44:57 +0100 (Mon, 21 Nov 2005) $
* $State: Exp $
*
* Type: streams driver/module | application | library
* Products: ALL | XS,XM,XL,XP,BGO,BGP,XCM
* Interfaces: IPI, DLPI
* Libraries: -
* Switches: -
* Description: --
*-----------------------------------------------------------------------
* Current Log:
* -
***********************************************************************/
#include "capiconf.h"
/****************************************************************************
* This implementation includes the following function calls:
int capi_read_environ( char **ppHost, int *pPort);
****************************************************************************/
#if 1 /* print error */
static int c_eviron_tracelevel = 1;
# define cTRACE(l, c) if ((l) <= c_eviron_tracelevel) { c; }
#else
# define cTRACE(l, c) /* do nothing */
#endif
/****************************************************************************
*
* capi_read_environ()
*
****************************************************************************/
int capi_read_environ(char **ppHost,
int *pPort)
{
char *cp;
char *ep;
int port = CAPI_PORT_DEFAULT;
/*
* is CAPI_PORT_ENV available ???
*/
if( pPort ) {
*pPort = port;
if ((cp = getenv(CAPI_PORT_ENV)) != NULL) {
port = strtol( cp, &ep, 0);
if (*ep) goto error;
*pPort = port;
}
}
/*
* is CAPI_HOST_ENV available ???
*/
if( ppHost ) {
if ((cp = getenv(CAPI_HOST_ENV)) == NULL) {
cTRACE( 1, fprintf( stderr,
"libcapi: environment variable CAPI_HOST missing!\n"));
goto error;
}
*ppHost = cp;
}
return(0);
error:
return(-1);
}