4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
35 /* add sitedep() and sysmatch() to list when ifdefs are removed below */
36 static int get_tokens(), siteindep();
38 /* field array indexes for LIMIT parameters */
45 static char * _Lwords
[] = {"service", "max", "system", "mode"};
60 * scan the Limits file and get the limit for the given service.
61 * return SUCCESS if the limit was found, else return FAIL.
64 scanlimit(service
, limitval
)
66 struct limits
*limitval
;
69 char *tokens
[NUMFLDS
]; /* fields found in LIMITS */
70 char msgbuf
[BUFSIZ
]; /* place to build messages */
71 FILE *Fp
= NULL
; /* file pointer for LIMITS */
74 if ((Fp
= fopen(LIMITS
, "r")) == NULL
) {
75 DEBUG(5, "cannot open %s\n", LIMITS
);
76 sprintf(msgbuf
, "fopen of %s failed with errno=%%d\n", LIMITS
);
77 DEBUG(5, msgbuf
, errno
);
84 /* The following #if (0 == 1) and #endif lines should be deleted when
85 * we expand the functionality of the Limits file to include the
86 * limit per site, and the mode for uucico.
89 if (strcmp(service
, "uucico") == SAME
)
93 while ((getuline(Fp
, buf
) > 0) && ((SIflag
&& SDflag
) == FALSE
)) {
94 if (get_tokens(buf
, tokens
) == FAIL
)
97 if (SIflag
== FALSE
) {
98 if (siteindep(tokens
, service
, limitval
) == SUCCESS
)
102 /* The following #if (0 == 1) and #endif lines should be deleted when
103 * we expand the functionality of the Limits file to include the
104 * limit per site, and the mode for uucico.
107 if (SDflag
== FALSE
) {
108 if (sitedep(tokens
, limitval
) == SUCCESS
)
115 if ((SIflag
&& SDflag
) == TRUE
)
121 * parse a line in LIMITS and return a vector
125 * SUCCESS - token pairs name match with the key words
128 get_tokens (line
,flds
)
134 struct name_value pair
;
136 /* initialize defaults in case parameter is not specified */
137 for (i
=0;i
<NUMFLDS
;i
++)
140 for (p
=line
;p
&& *p
;) {
141 p
= next_token (p
, &pair
);
143 for (i
=0; i
<NUMFLDS
; i
++) {
144 if (EQUALS(pair
.name
, _Lwords
[i
])) {
145 flds
[i
] = pair
.value
;
148 if (i
== NUMFLDS
-1) /* pair.name is not key */
155 * this function can only handle the following format
157 * service=uucico max=5
161 * FAIL - service's value does not match or wrong format
164 siteindep(flds
, service
, limitval
)
167 struct limits
*limitval
;
170 if (!EQUALS(flds
[U_SERVICE
], service
) || (flds
[U_MAX
] == CNULL
))
172 if (sscanf(flds
[U_MAX
],"%d",&limitval
->totalmax
)==0)
173 limitval
->totalmax
= -1; /* type conflict*/
177 /* The following #if (0 == 1) and #endif lines should be deleted when
178 * we expand the functionality of the Limits file to include the
179 * limit per site, and the mode for uucico.
183 * this function can only handle the following format
185 * service=uucico system=ihnp1:ihnp3 [max=5] [mode=master]
189 * FAIL - not uucico, no system name in Limits,
190 * system's name does not match
193 sitedep(flds
, limitval
)
195 struct limits
*limitval
;
198 if (!EQUALS(flds
[U_SERVICE
],"uucico"))
200 if ((flds
[U_SYSTEM
] == CNULL
) || (sysmatch(flds
[U_SYSTEM
]) != 0))
202 if (flds
[U_MAX
] == CNULL
)
203 limitval
->sitemax
= 1; /* default value */
204 else if (sscanf(flds
[U_MAX
],"%d",&limitval
->sitemax
)==0)
205 limitval
->sitemax
= -1; /* type conflict*/
207 if (flds
[U_MODE
] == CNULL
)
208 strcpy(limitval
->mode
,"master:slave");
210 strncpy(limitval
->mode
,flds
[U_MODE
],strlen(flds
[U_MODE
]));
215 * this function checks if system in system's list
216 * system=ihnp1:ihnp3:...
228 p
= nextarg(p
, &arg
);
229 if (EQUALS(arg
, Rmtname
))