Optimie x86-64 SSE4 memcmp for unaligned data.
[glibc.git] / gshadow / sgetsgent_r.c
blob2292719af96dc159d237a68a5ce4bb00fa1bf449
1 /* Copyright (C) 2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <ctype.h>
20 #include <errno.h>
21 #include <gshadow.h>
22 #include <stdio.h>
23 #include <string.h>
25 /* Define a line parsing function using the common code
26 used in the nss_files module. */
28 #define STRUCTURE sgrp
29 #define ENTNAME sgent
30 struct sgent_data {};
33 #define TRAILING_LIST_MEMBER sg_mem
34 #define TRAILING_LIST_SEPARATOR_P(c) ((c) == ',')
35 #include <nss/nss_files/files-parse.c>
36 LINE_PARSER
38 STRING_FIELD (result->sg_namp, ISCOLON, 0);
39 if (line[0] == '\0'
40 && (result->sg_namp[0] == '+' || result->sg_namp[0] == '-'))
42 result->sg_passwd = NULL;
43 result->sg_adm = NULL;
44 result->sg_mem = NULL;
46 else
48 STRING_FIELD (result->sg_passwd, ISCOLON, 0);
49 STRING_LIST (result->sg_adm, ':');
54 /* Read one shadow entry from the given stream. */
55 int
56 __sgetsgent_r (const char *string, struct sgrp *resbuf, char *buffer,
57 size_t buflen, struct sgrp **result)
59 char *sp;
60 if (string < buffer || string >= buffer + buflen)
62 buffer[buflen - 1] = '\0';
63 sp = strncpy (buffer, string, buflen);
64 if (buffer[buflen - 1] != '\0')
65 return ERANGE;
67 else
68 sp = (char *) string;
70 int parse_result = parse_line (sp, resbuf, (void *) buffer, buflen, &errno);
71 *result = parse_result > 0 ? resbuf : NULL;
73 return *result == NULL ? errno : 0;
75 weak_alias (__sgetsgent_r, sgetsgent_r)