[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extension to MiNT 1.09



This patch implements a new command for the config file:

include filename

The purpose should be obvious :-)

It always annoyed be that i had to change many files if i want to
change the configuration of mint. Now i have a single file for the
common setup and various mint.cnf for testing.

--- orig/main.c	Fri Aug  6 17:58:20 1993
+++ main.c	Thu Nov 11 20:35:02 1993
@@ -22,6 +22,7 @@
 static void init_intr P_((void));
 static long getmch P_((void));
 static void do_line P_((char *));
+static void do_file P_((int));
 static void shutmedown P_((PROC *));
 void shutdown P_((void));
 static void doset P_((char *,char *));
@@ -1347,6 +1348,18 @@
 		*env_ptr = 0;
 		return;
 	}
+	if (!strcmp (cmd, "include"))
+	  {
+	    int fd = f_open (arg1, 0);
+	    if (fd < 0)
+	      {
+		ALERT ("include: cannot open file %s", arg1);
+		return;
+	      }
+	    do_file (fd);
+	    f_close (fd);
+	    return;
+	  }
 
 	arg2 = line;
 	while (*line && *line != ' ') line++;
@@ -1395,22 +1408,15 @@
 #define BUF 512
 #define LINE 256
 
-void
-load_config()
+static void
+do_file (fd)
+     int fd;
 {
-	int fd;
 	long r;
 	char buf[BUF+1], c;
 	char line[LINE+1];
 	char *from;
 	int count = 0;
-
-	fd = (int) f_open("mint.cnf", 0);
-	if (fd < 0)
-		fd = (int) f_open("\\mint\\mint.cnf", 0);
-	if (fd < 0)
-		fd = (int) f_open("\\multitos\\mint.cnf", 0);
-	if (fd < 0) return;
 	buf[BUF] = 0;
 	from = &buf[BUF];
 	line[LINE] = 0;
@@ -1438,6 +1444,20 @@
 		line[count] = 0;
 		do_line(line);
 	}
+}
+
+void
+load_config()
+{
+	int fd;
+
+	fd = (int) f_open("mint.cnf", 0);
+	if (fd < 0)
+		fd = (int) f_open("\\mint\\mint.cnf", 0);
+	if (fd < 0)
+		fd = (int) f_open("\\multitos\\mint.cnf", 0);
+	if (fd < 0) return;
+	do_file (fd);
 	f_close(fd);
 }