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]
22 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/types.h>
32 #include <nss_dbdefs.h>
34 static int str2bootent(const char *, int, void *, char *, int);
36 static DEFINE_NSS_DB_ROOT(db_root
);
39 _nss_initf_bootparams(nss_db_params_t
*p
)
41 p
->name
= NSS_DBNAM_BOOTPARAMS
;
42 p
->default_config
= NSS_DEFCONF_BOOTPARAMS
;
47 char *name
, /* lookup key */
48 char *linebuf
, /* buffer to put the answer in */
49 int linelen
/* max # of bytes to put into linebuf */
55 NSS_XbyY_INIT(&arg
, linebuf
, linebuf
, linelen
, str2bootent
);
57 res
= nss_search(&db_root
, _nss_initf_bootparams
,
58 NSS_DBOP_BOOTPARAMS_BYNAME
, &arg
);
59 (void) NSS_XbyY_FINI(&arg
);
60 return (arg
.status
= res
);
64 * Return values: 0 = success, 1 = parse error, 2 = erange ...
65 * The structure pointer passed in is a buffer in the caller's space.
66 * instring and buffer should be separate areas.
67 * The calling routine does all the real parsing; we just check limits and
68 * store the entry in the buffer we were passed by the caller.
69 * NOTE: we expect the data we're passed (in instr) has had the host's name
70 * stripped off the begining.
77 void *ent
, /* really (char *) */
82 const char *p
, *limit
;
84 if ((instr
>= buffer
&& (buffer
+ buflen
) > instr
) ||
85 (buffer
>= instr
&& (instr
+ lenstr
) > buffer
)) {
86 return (NSS_STR_PARSE_PARSE
);
91 /* Skip over leading whitespace */
92 while (p
< limit
&& isspace(*p
)) {
96 /* Syntax error -- no data! */
97 return (NSS_STR_PARSE_PARSE
);
99 lenstr
-= (p
- instr
);
100 if (buflen
<= lenstr
) { /* not enough buffer */
101 return (NSS_STR_PARSE_ERANGE
);
103 (void) memcpy(buffer
, p
, lenstr
);
104 buffer
[lenstr
] = '\0';
106 return (NSS_STR_PARSE_SUCCESS
);