getspent_r.c revision c8bbac97a5d079949a9aca961e2cf4459478ecf5
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "synonyms.h"
#include <mtlib.h>
#include <shadow.h>
#include <stdlib.h>
#include <string.h>
#include <nss_dbdefs.h>
#include <stdio.h>
#include <synch.h>
int str2spwd(const char *, int, void *,
char *, int);
static DEFINE_NSS_DB_ROOT(db_root);
static DEFINE_NSS_GETENT(context);
static void
{
p->name = NSS_DBNAM_SHADOW;
}
struct spwd *
{
}
void
setspent(void)
{
}
void
endspent(void)
{
}
struct spwd *
{
char *nam;
/* In getXXent_r(), protect the unsuspecting caller from +/- entries */
do {
/* No key to fill in */
}
struct spwd *
{
/* ... but in fgetXXent_r, the caller deserves any +/- entry he gets */
/* No key to fill in */
_nss_XbyY_fgets(f, &arg);
}
typedef const char *constp;
static int /* 1 means success and more input, 0 means error or no more */
{
char *endfield;
if (p == 0 || p >= limit) {
return (0);
}
if (*p == ':') {
p++;
*nextp = p;
return (p < limit);
}
}
/*
* We want to use strtol() and we have a readonly non-zero-terminated
* string, so first we copy and terminate the interesting bit.
* Ugh. (It's convenient to terminate with a colon rather than \0).
*/
/* Error -- field is too big to be a legit number */
return (0);
}
p = limit;
} else {
}
if (uns) {
if (*endfield != ':') {
/* Error -- expected <integer><colon> */
return (0);
}
} else {
if (*endfield != ':') {
/* Error -- expected <integer><colon> */
return (0);
}
*((int *)valp) = (int)x;
}
*nextp = p;
return (p < limit);
}
/*
* str2spwd() -- convert a string to a shadow passwd entry. The parser is
* more liberal than the passwd or group parsers; since it's legitimate
* for almost all the fields here to be blank, the parser lets one omit
* any number of blank fields at the end of the entry. The acceptable
* forms for '+' and '-' entries are the same as those for normal entries.
* === Is this likely to do more harm than good?
*
* Return values: 0 = success, 1 = parse error, 2 = erange ...
* The structure pointer passed in is a structure in the caller's space
* wherein the field pointers would be set to areas in the buffer if
* need be. instring and buffer should be separate areas.
*/
int
{
char *bufp;
int black_magic;
++p >= limit ||
p = 0;
} else {
p++;
}
return (NSS_STR_PARSE_ERANGE);
}
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
*bufp++ = '\0';
if (instr == 0) {
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
*bufp++ = '\0';
p = bufp;
} /* else p was set when we copied name and passwd into the buffer */
return (NSS_STR_PARSE_SUCCESS);
return (NSS_STR_PARSE_SUCCESS);
return (NSS_STR_PARSE_SUCCESS);
return (NSS_STR_PARSE_SUCCESS);
return (NSS_STR_PARSE_SUCCESS);
return (NSS_STR_PARSE_SUCCESS);
return (NSS_STR_PARSE_SUCCESS);
if (p != limit) {
/* Syntax error -- garbage at end of line */
return (NSS_STR_PARSE_PARSE);
}
return (NSS_STR_PARSE_SUCCESS);
}