1/*-
2 * Copyright (c) 2004, 2009 Apple Inc.
3 * Copyright (c) 2006 Robert N. M. Watson
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
--- 13 unchanged lines hidden (view full) ---
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#34 $
31 */
32
33#include <config/config.h>
34
35#include <bsm/libbsm.h>
36
37#include <ctype.h>
38#include <errno.h>
--- 77 unchanged lines hidden (view full) ---
116 if (ferror(fp))
117 return (-1);
118 return (0); /* EOF */
119 }
120
121 if (linestr[0] == '#')
122 continue;
123
124 /* Remove trailing new line character and white space. */
125 nl = strchr(linestr, '\0') - 1;
126 while (nl >= linestr && ('\n' == *nl || ' ' == *nl ||
127 '\t' == *nl)) {
128 *nl = '\0';
129 nl--;
130 }
131
132 tokptr = linestr;
133 if ((type = strtok_r(tokptr, delim, &last)) != NULL) {
134 if (strcmp(name, type) == 0) {
135 /* Found matching name. */
136 *str = strtok_r(NULL, delim, &last);
137 if (*str == NULL) {
138 errno = EINVAL;
--- 608 unchanged lines hidden ---
2 * Copyright (c) 2004, 2009 Apple Inc.
3 * Copyright (c) 2006 Robert N. M. Watson
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
--- 13 unchanged lines hidden (view full) ---
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#34 $
31 */
32
33#include <config/config.h>
34
35#include <bsm/libbsm.h>
36
37#include <ctype.h>
38#include <errno.h>
--- 77 unchanged lines hidden (view full) ---
116 if (ferror(fp))
117 return (-1);
118 return (0); /* EOF */
119 }
120
121 if (linestr[0] == '#')
122 continue;
123
124 /* Remove trailing new line character and white space. */
125 nl = strchr(linestr, '\0') - 1;
126 while (nl >= linestr && ('\n' == *nl || ' ' == *nl ||
127 '\t' == *nl)) {
128 *nl = '\0';
129 nl--;
130 }
131
132 tokptr = linestr;
133 if ((type = strtok_r(tokptr, delim, &last)) != NULL) {
134 if (strcmp(name, type) == 0) {
135 /* Found matching name. */
136 *str = strtok_r(NULL, delim, &last);
137 if (*str == NULL) {
138 errno = EINVAL;
--- 608 unchanged lines hidden ---