initial commit with v2.6.9
[linux-2.6.9-moxart.git] / drivers / block / paride / setup.h
blob85d1c440b2831dd8085e8a8976be410681f517c6
1 /*
2 setup.h (c) 1997-8 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
5 This is a table driven setup function for kernel modules
6 using the module.variable=val,... command line notation.
8 */
10 /* Changes:
12 1.01 GRG 1998.05.05 Allow negative and defaulted values
16 #include <linux/ctype.h>
17 #include <linux/string.h>
19 struct setup_tab_t {
21 char *tag; /* variable name */
22 int size; /* number of elements in array */
23 int *iv; /* pointer to variable */
26 typedef struct setup_tab_t STT;
28 /* t is a table that describes the variables that can be set
29 by gen_setup
30 n is the number of entries in the table
31 ss is a string of the form:
33 <tag>=[<val>,...]<val>
36 static void generic_setup( STT t[], int n, char *ss )
38 { int j,k, sgn;
40 k = 0;
41 for (j=0;j<n;j++) {
42 k = strlen(t[j].tag);
43 if (strncmp(ss,t[j].tag,k) == 0) break;
45 if (j == n) return;
47 if (ss[k] == 0) {
48 t[j].iv[0] = 1;
49 return;
52 if (ss[k] != '=') return;
53 ss += (k+1);
55 k = 0;
56 while (ss && (k < t[j].size)) {
57 if (!*ss) break;
58 sgn = 1;
59 if (*ss == '-') { ss++; sgn = -1; }
60 if (!*ss) break;
61 if (isdigit(*ss))
62 t[j].iv[k] = sgn * simple_strtoul(ss,NULL,0);
63 k++;
64 if ((ss = strchr(ss,',')) != NULL) ss++;
68 /* end of setup.h */