|
|
1.1 root 1: #include <errno.h>
2:
3: extern int errno;
4:
5:
6: findslot(prefix, min, max, mode)
7: char *prefix;
8: {
9: char filename[40];
10: int n, fd;
11:
12: for (n = min; max < 0 || n <= max;) {
13: sprintf(filename, "%s%02d", prefix, n++);
14: if ((fd = open(filename, mode)) >= 0)
15: return fd;
16: if (errno != ENXIO)
17: return -1;
18: }
19:
20: errno = ENOENT;
21: return -1;
22: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.