nss_dbdefs.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <nss_dbdefs.h>
#include <limits.h>
/*
* ALIGN? is there an official definition of this?
* We use sizeof(long) to cover what we want
* for both the 32-bit world and 64-bit world.
*/
{
nss_XbyY_buf_t *b;
/* Use one malloc for dbargs, result struct and buffer */
b = (nss_XbyY_buf_t *)
if (b == 0) {
return (0);
}
b->buflen = buffer_size;
return (b);
}
void
{
if (b != 0) {
free(b);
}
}
/* === Comment: used by fget{gr,pw,sp}ent */
/* ==== Should do ye olde syslog()ing of suspiciously long lines */
void
{
/* End of file */
b->returnval = 0;
b->erange = 0;
return;
}
/* len >= 0 (otherwise we would have got EOF) */
/* Line too long for buffer; too bad */
;
}
b->returnval = 0;
b->erange = 1;
return;
}
/* case where the file is not terminated with a Newline */
len++;
}
if (parsestat == NSS_STR_PARSE_ERANGE) {
b->returnval = 0;
b->erange = 1;
} else if (parsestat == NSS_STR_PARSE_SUCCESS) {
}
}
/*
* parse the aliases string into the buffer and if successful return
* a char ** pointer to the beginning of the aliases.
*
* CAUTION: (instr, instr+lenstr) and (buffer, buffer+buflen) are
* non-intersecting memory areas. Since this is an internal interface,
* we should be able to live with that.
*/
char **
/* "instr" is the beginning of the aliases string */
/* "buffer" has the return val for success */
/* "buflen" is the length of the buffer available for aliases */
{
/*
* Build the alias-list in the start of the buffer, and copy
* the strings to the end of the buffer.
*/
const char
char **alias_start = aliasp;
int nstrings = 0;
for (;;) {
const char *str_start;
instr++;
}
break;
}
instr++;
}
++nstrings;
/* Has to be room for the pointer to */
/* the alias we're about to add, */
/* as well as the final NULL ptr. */
return (0);
}
}
*aliasp++ = 0;
return (alias_start);
}