|
|
1.1 ! root 1: #include "u.h" ! 2: #include "lib.h" ! 3: #include "mem.h" ! 4: #include "dat.h" ! 5: #include "fns.h" ! 6: #include "io.h" ! 7: ! 8: #include "dosfs.h" ! 9: ! 10: static char *confname[MAXCONF]; ! 11: static char *confval[MAXCONF]; ! 12: static int nconf; ! 13: ! 14: extern char **ini; ! 15: ! 16: char* ! 17: getconf(char *name) ! 18: { ! 19: int i; ! 20: ! 21: for(i = 0; i < nconf; i++) ! 22: if(strcmp(confname[i], name) == 0) ! 23: return confval[i]; ! 24: return 0; ! 25: } ! 26: ! 27: /* ! 28: * read configuration file ! 29: */ ! 30: int ! 31: plan9ini(Dos *dos) ! 32: { ! 33: Dosfile rc; ! 34: int i, n; ! 35: char *cp, *line[MAXCONF]; ! 36: ! 37: if(dosstat(dos, *ini, &rc) <= 0) ! 38: return -1; ! 39: ! 40: cp = BOOTARGS; ! 41: *cp = 0; ! 42: n = dosread(&rc, cp, BOOTARGSLEN-1); ! 43: if(n <= 0) ! 44: return -1; ! 45: cp[n] = 0; ! 46: ! 47: /* ! 48: * Make a working copy. ! 49: * We could change this to pass the parsed strings ! 50: * to the booted programme instead of the raw ! 51: * string, then it only gets done once. ! 52: */ ! 53: memmove(cp+BOOTARGSLEN, cp, n+1); ! 54: n = getfields(cp+BOOTARGSLEN, line, MAXCONF, '\n'); ! 55: for(i = 0; i < n; i++){ ! 56: cp = strchr(line[i], '\r'); ! 57: if(cp) ! 58: *cp = 0; ! 59: cp = strchr(line[i], '='); ! 60: if(cp == 0) ! 61: continue; ! 62: *cp++ = 0; ! 63: if(cp - line[i] >= NAMELEN+1) ! 64: *(line[i]+NAMELEN-1) = 0; ! 65: confname[nconf] = line[i]; ! 66: confval[nconf] = cp; ! 67: nconf++; ! 68: } ! 69: return 0; ! 70: } ! 71: ! 72: static int ! 73: parseether(uchar *to, char *from) ! 74: { ! 75: char nip[4]; ! 76: char *p; ! 77: int i; ! 78: ! 79: p = from; ! 80: while(*p == ' ') ! 81: ++p; ! 82: for(i = 0; i < 6; i++){ ! 83: if(*p == 0) ! 84: return -1; ! 85: nip[0] = *p++; ! 86: if(*p == 0) ! 87: return -1; ! 88: nip[1] = *p++; ! 89: nip[2] = 0; ! 90: to[i] = strtoul(nip, 0, 16); ! 91: if(*p == ':') ! 92: p++; ! 93: } ! 94: return 0; ! 95: } ! 96: ! 97: int ! 98: isaconfig(char *class, int ctlrno, ISAConf *isa) ! 99: { ! 100: char cc[NAMELEN], *p, *q; ! 101: int n; ! 102: ! 103: sprint(cc, "%s%d", class, ctlrno); ! 104: for(n = 0; n < nconf; n++){ ! 105: if(strncmp(confname[n], cc, NAMELEN)) ! 106: continue; ! 107: p = confval[n]; ! 108: while(*p){ ! 109: while(*p == ' ' || *p == '\t') ! 110: p++; ! 111: if(*p == '\0') ! 112: break; ! 113: if(strncmp(p, "type=", 5) == 0){ ! 114: p += 5; ! 115: for(q = isa->type; q < &isa->type[NAMELEN-1]; q++){ ! 116: if(*p == '\0' || *p == ' ' || *p == '\t') ! 117: break; ! 118: *q = *p++; ! 119: } ! 120: *q = '\0'; ! 121: } ! 122: else if(strncmp(p, "port=", 5) == 0) ! 123: isa->port = strtoul(p+5, &p, 0); ! 124: else if(strncmp(p, "irq=", 4) == 0) ! 125: isa->irq = strtoul(p+4, &p, 0); ! 126: else if(strncmp(p, "mem=", 4) == 0) ! 127: isa->mem = strtoul(p+4, &p, 0); ! 128: else if(strncmp(p, "size=", 5) == 0) ! 129: isa->size = strtoul(p+5, &p, 0); ! 130: else if(strncmp(p, "ea=", 3) == 0){ ! 131: if(parseether(isa->ea, p+3) == -1) ! 132: memset(isa->ea, 0, 6); ! 133: } ! 134: while(*p && *p != ' ' && *p != '\t') ! 135: p++; ! 136: } ! 137: return 1; ! 138: } ! 139: return 0; ! 140: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.