Date: Fri, 13 Aug 1999 20:28:30 +0900 (JST) From: hosokawa@itc.keio.ac.jp (HOSOKAWA Tatsumi) To: imp@village.org Cc: mobile@FreeBSD.ORG, hosokawa@itc.keio.ac.jp Subject: Re: How about /etc/defaults/pccard.conf ? Message-ID: <199908131128.UAA00641@afs.ntc.mita.keio.ac.jp> In-Reply-To: Your message of "Thu, 12 Aug 1999 11:06:00 JST". <199908120206.UAA01021@harmony.village.org>
index | next in thread | previous in thread | raw e-mail
In article <199908120206.UAA01021@harmony.village.org>
imp@village.org writes:
>> In message <199908120100.KAA15437@afs.ntc.mita.keio.ac.jp> HOSOKAWA
>> Tatsumi writes:
>> : # /etc/pccard.conf
>> :
>> : # io 0x240-0x320
>> : # irq 10 11
>> :
>> : # ---- local card entries -----
>> : # .....
>> :
>> : include "/etc/defaults/pccard.conf"
>> :
>> : ------
>> :
>> : # /etc/defaults/pccard.conf
>> :
>> : include "/etc/defaults/pccard/resource.conf"
>> : include "/etc/defaults/pccard/ethernet.conf"
>> : include "/etc/defaults/pccard/serial.conf"
>> : include "/etc/defaults/pccard/misc.conf"
>>
>> I like this.
Thanks. "include" patch for usr.sbin/pccard/pccardd follows.
I want to commit it soon.
Index: cardd.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/cardd.h,v
retrieving revision 1.14
diff -u -r1.14 cardd.h
--- cardd.h 1999/08/01 18:04:24 1.14
+++ cardd.h 1999/08/13 11:20:16
@@ -161,3 +161,5 @@
#define MEMBLKS ((MEMEND-MEMSTART)/MEMUNIT)
#define MEM2BIT(x) (((x)-MEMSTART)/MEMUNIT)
#define BIT2MEM(x) (((x)*MEMUNIT)+MEMSTART)
+
+#define MAXINCLUDES 10
Index: file.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/file.c,v
retrieving revision 1.20
diff -u -r1.20 file.c
--- file.c 1999/08/01 18:04:24 1.20
+++ file.c 1999/08/13 11:20:21
@@ -36,6 +36,8 @@
#include "cardd.h"
static FILE *in;
+static int includes = 0;
+static FILE *files[MAXINCLUDES] = {NULL, };
static int pushc, pusht;
static int lineno;
static char *filename;
@@ -54,6 +56,7 @@
"remove", /* 11 */
"iosize", /* 12 */
"debuglevel", /* 13 */
+ "include", /* 14 */
0
};
@@ -70,6 +73,7 @@
#define KWD_REMOVE 11
#define KWD_IOSIZE 12
#define KWD_DEBUGLEVEL 13
+#define KWD_INCLUDE 14
struct flags {
char *name;
@@ -88,6 +92,7 @@
static struct allocblk *memblk_tok(int);
static struct driver *new_driver(char *);
static int iosize_tok(void);
+static void file_include(char *);
static void addcmd(struct cmd **);
static void parse_card(void);
@@ -99,6 +104,7 @@
void
readfile(char *name)
{
+ int i;
struct card *cp;
in = fopen(name, "r");
@@ -106,6 +112,13 @@
logerr(name);
die("readfile");
}
+ for (i = 0; i < MAXINCLUDES; i++) {
+ if (files[i]) {
+ fclose(files[i]);
+ files[i] = NULL;
+ }
+ }
+ files[includes = 0] = in;
parsefile();
for (cp = cards; cp; cp = cp->next) {
if (cp->config == 0)
@@ -119,7 +132,9 @@
{
int i;
int irq_init = 0;
+ int io_init = 0;
struct allocblk *bp;
+ char *incl;
pushc = 0;
lineno = 1;
@@ -136,15 +151,18 @@
case KWD_IO:
/* reserved I/O blocks */
while ((bp = ioblk_tok(0)) != 0) {
- if (bp->size == 0 || bp->addr == 0) {
- free(bp);
- continue;
+ if (!io_init) {
+ if (bp->size == 0 || bp->addr == 0) {
+ free(bp);
+ continue;
+ }
+ bit_nset(io_avail, bp->addr,
+ bp->addr + bp->size - 1);
+ bp->next = pool_ioblks;
+ pool_ioblks = bp;
}
- bit_nset(io_avail, bp->addr,
- bp->addr + bp->size - 1);
- bp->next = pool_ioblks;
- pool_ioblks = bp;
}
+ io_init = 1;
pusht = 1;
break;
case KWD_IRQ:
@@ -152,6 +170,7 @@
while ((i = irq_tok(0)) > 0)
if (!irq_init)
pool_irq[i] = 1;
+ irq_init = 1;
pusht = 1;
break;
case KWD_MEMORY:
@@ -177,6 +196,10 @@
if (i > 0)
debug_level = i;
break;
+ case KWD_INCLUDE:
+ incl = newstr(next_tok());
+ file_include(incl);
+ break;
default:
error("syntax error");
pusht = 0;
@@ -671,6 +694,12 @@
}
break;
case EOF:
+ if (includes) {
+ fclose(in);
+ includes--;
+ in = files[includes];
+ return _next_tok(); /* recursive */
+ }
if (p != buf) {
*p++ = 0;
return (buf);
@@ -703,4 +732,23 @@
*p++ = c;
*p = 0;
return (newstr(buf));
+}
+
+/*
+ * Include configuration file
+ */
+static void
+file_include(char *filename)
+{
+ FILE *fp;
+
+ includes++;
+ if (includes >= MAXINCLUDES) {
+ error("include nesting overflow");
+ }
+ if (!(fp = fopen(filename, "r"))) {
+ error("can't open include file");
+ includes--;
+ }
+ in = files[includes] = fp;
}
--
HOSOKAWA, Tatsumi
Assistant Manager
Information Technology Center, Keio University
<hosokawa@itc.keio.ac.jp>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908131128.UAA00641>
