Deleted Added
full compact
subr_hints.c (95592) subr_hints.c (95593)
1/*-
2 * Copyright (c) 2000,2001 Peter Wemm <peter@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2000,2001 Peter Wemm <peter@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/subr_hints.c 95592 2002-04-27 22:25:13Z peter $
26 * $FreeBSD: head/sys/kern/subr_hints.c 95593 2002-04-27 22:32:57Z peter $
27 */
28
29#include <sys/param.h>
30#include <sys/lock.h>
31#include <sys/sx.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34
35/*
36 * Access functions for device resources.
37 */
38
39static int checkmethod = 1;
27 */
28
29#include <sys/param.h>
30#include <sys/lock.h>
31#include <sys/sx.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34
35/*
36 * Access functions for device resources.
37 */
38
39static int checkmethod = 1;
40static int use_kenv;
40static char *hintp;
41
42/*
43 * Evil wildcarding resource string lookup.
44 * This walks the supplied env string table and returns a match.
45 * The start point can be remembered for incremental searches.
46 */
47static int
48res_find(int *line, int *startln,
49 const char *name, int *unit, const char *resname, const char *value,
50 const char **ret_name, int *ret_namelen, int *ret_unit,
51 const char **ret_resname, int *ret_resnamelen, const char **ret_value)
52{
41static char *hintp;
42
43/*
44 * Evil wildcarding resource string lookup.
45 * This walks the supplied env string table and returns a match.
46 * The start point can be remembered for incremental searches.
47 */
48static int
49res_find(int *line, int *startln,
50 const char *name, int *unit, const char *resname, const char *value,
51 const char **ret_name, int *ret_namelen, int *ret_unit,
52 const char **ret_resname, int *ret_resnamelen, const char **ret_value)
53{
53 int n = 0, hit, use_kenv, i = 0;
54 int n = 0, hit, i = 0;
54 char r_name[32];
55 int r_unit;
56 char r_resname[32];
57 char r_value[128];
58 const char *s, *cp;
59 char *p;
60
55 char r_name[32];
56 int r_unit;
57 char r_resname[32];
58 char r_value[128];
59 const char *s, *cp;
60 char *p;
61
61 use_kenv = 0;
62 if (checkmethod) {
63 switch (hintmode) {
64 case 0: /* config supplied nothing */
65 break;
66 case 1: /* static hints only */
67 hintp = static_hints;
68 checkmethod = 0;
69 break;

--- 73 unchanged lines hidden (view full) ---

143 if (hit && unit && *unit != r_unit)
144 hit = 0;
145 if (hit && resname && strcmp(resname, r_resname) != 0)
146 hit = 0;
147 if (hit && value && strcmp(value, r_value) != 0)
148 hit = 0;
149 if (hit)
150 break;
62 if (checkmethod) {
63 switch (hintmode) {
64 case 0: /* config supplied nothing */
65 break;
66 case 1: /* static hints only */
67 hintp = static_hints;
68 checkmethod = 0;
69 break;

--- 73 unchanged lines hidden (view full) ---

143 if (hit && unit && *unit != r_unit)
144 hit = 0;
145 if (hit && resname && strcmp(resname, r_resname) != 0)
146 hit = 0;
147 if (hit && value && strcmp(value, r_value) != 0)
148 hit = 0;
149 if (hit)
150 break;
151 if (use_kenv)
151 if (use_kenv) {
152 cp = kenvp[++i];
152 cp = kenvp[++i];
153 else {
153 if (cp == NULL)
154 break;
155 } else {
154 while (*cp != '\0')
155 cp++;
156 cp++;
156 while (*cp != '\0')
157 cp++;
158 cp++;
159 if (*cp == '\0') {
160 cp = NULL;
161 break;
162 }
157 }
163 }
158 if (*cp == '\0') {
159 cp = NULL;
160 break;
161 }
162 }
163 if (use_kenv)
164 sx_sunlock(&kenv_lock);
165 if (cp == NULL)
166 return ENOENT;
167
168 s = cp;
169 /* This is a bit of a hack, but at least is reentrant */

--- 196 unchanged lines hidden ---
164 }
165 if (use_kenv)
166 sx_sunlock(&kenv_lock);
167 if (cp == NULL)
168 return ENOENT;
169
170 s = cp;
171 /* This is a bit of a hack, but at least is reentrant */

--- 196 unchanged lines hidden ---