winedos / Migrate dosconf.c to winedos

Jukka Heinonen jhei at iki.fi
Mon Apr 21 07:17:54 CDT 2003


This (boring) patch moves msdos/dosconf.c to winedos.
I don't know if DOS emulation is going to need config.sys
handling, but it really belongs to winedos and not ntdll.




Changelog:
  Move dosconf.c to winedos.



If this patch is applied, file msdos/dosconf.c can be deleted.




Index: dlls/winedos/dosexe.h
===================================================================
RCS file: /home/wine/wine/dlls/winedos/dosexe.h,v
retrieving revision 1.23
diff -u -r1.23 dosexe.h
--- dlls/winedos/dosexe.h	4 Mar 2003 02:16:20 -0000	1.23
+++ dlls/winedos/dosexe.h	21 Apr 2003 12:00:44 -0000
@@ -52,6 +52,25 @@
   DWORD offset;
 } SEGPTR48, FARPROC48;
 
+#define DOSCONF_MEM_HIGH        0x0001
+#define DOSCONF_MEM_UMB         0x0002
+#define DOSCONF_NUMLOCK         0x0004
+#define DOSCONF_KEYB_CONV       0x0008
+
+typedef struct {
+    char lastdrive;
+    int brk_flag;
+    int files;
+    int stacks_nr;
+    int stacks_sz;
+    int buf;
+    int buf2;
+    int fcbs;
+    int flags;
+    char *shell;
+    char *country;
+} DOSCONF;
+
 typedef void (*DOSRELAY)(CONTEXT86*,void*);
 typedef void (WINAPI *RMCBPROC)(CONTEXT86*);
 typedef void (WINAPI *INTPROC)(CONTEXT86*);
@@ -112,6 +131,9 @@
 
 /* dosaspi.c */
 void WINAPI DOSVM_ASPIHandler(CONTEXT86*);
+
+/* dosconf.c */
+DOSCONF *DOSCONF_GetConfig( void );
 
 /* fpu.c */
 extern void WINAPI DOSVM_Int34Handler(CONTEXT86*);




Index: dlls/winedos/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/winedos/Makefile.in,v
retrieving revision 1.22
diff -u -r1.22 Makefile.in
--- dlls/winedos/Makefile.in	15 Dec 2002 01:18:40 -0000	1.22
+++ dlls/winedos/Makefile.in	21 Apr 2003 12:00:46 -0000
@@ -13,6 +13,7 @@
 	devices.c \
 	dma.c \
 	dosaspi.c \
+	dosconf.c \	
 	dosvm.c \
 	fpu.c \
 	himem.c \




Index: dlls/winedos/int21.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int21.c,v
retrieving revision 1.28
diff -u -r1.28 int21.c
--- dlls/winedos/int21.c	8 Apr 2003 19:41:03 -0000	1.28
+++ dlls/winedos/int21.c	21 Apr 2003 12:00:48 -0000
@@ -1602,8 +1602,55 @@
         break;
 
     case 0x32: /* GET DOS DRIVE PARAMETER BLOCK FOR SPECIFIC DRIVE */
-    case 0x33: /* MULTIPLEXED */
         INT_Int21Handler( context );
+        break;
+
+    case 0x33: /* MULTIPLEXED */
+        switch (AL_reg(context))
+        {
+        case 0x00: /* GET CURRENT EXTENDED BREAK STATE */
+            TRACE("GET CURRENT EXTENDED BREAK STATE\n");
+            SET_DL( context, DOSCONF_GetConfig()->brk_flag );
+            break;
+
+        case 0x01: /* SET EXTENDED BREAK STATE */
+            TRACE("SET CURRENT EXTENDED BREAK STATE\n");
+            DOSCONF_GetConfig()->brk_flag = (DL_reg(context) > 0) ? 1 : 0;
+            break;
+
+        case 0x02: /* GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE*/
+            TRACE("GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE\n");
+            /* ugly coding in order to stay reentrant */
+            if (DL_reg(context))
+            {
+                SET_DL( context, DOSCONF_GetConfig()->brk_flag );
+                DOSCONF_GetConfig()->brk_flag = 1;
+            }
+            else
+            {
+                SET_DL( context, DOSCONF_GetConfig()->brk_flag );
+                DOSCONF_GetConfig()->brk_flag = 0;
+            }
+            break;
+
+        case 0x05: /* GET BOOT DRIVE */
+            TRACE("GET BOOT DRIVE\n");
+            SET_DL( context, 3 );
+            /* c: is Wine's bootdrive (a: is 1)*/
+            break;
+
+        case 0x06: /* GET TRUE VERSION NUMBER */
+            TRACE("GET TRUE VERSION NUMBER\n");
+            SET_BL( context, HIBYTE(HIWORD(GetVersion16())) ); /* major */
+            SET_BH( context, LOBYTE(HIWORD(GetVersion16())) ); /* minor */
+            SET_DL( context, 0x00 ); /* revision */
+            SET_DH( context, 0x08 ); /* DOS is in ROM */
+            break;
+
+        default:
+            INT_BARF( context, 0x21 );
+            break;
+        }
         break;
 
     case 0x34: /* GET ADDRESS OF INDOS FLAG */




Index: msdos/int21.c
===================================================================
RCS file: /home/wine/wine/msdos/int21.c,v
retrieving revision 1.91
diff -u -r1.91 int21.c
--- msdos/int21.c	30 Mar 2003 03:04:37 -0000	1.91
+++ msdos/int21.c	21 Apr 2003 12:00:50 -0000
@@ -133,13 +133,6 @@
 
 extern char TempDirectory[];
 
-static void INT21_ReadConfigSys(void)
-{
-    static int done;
-    if (!done) DOSCONF_ReadConfig();
-    done = 1;
-}
-
 static BOOL INT21_CreateHeap(void)
 {
     if (!(DosHeapHandle = GlobalAlloc16(GMEM_FIXED,sizeof(struct DosHeap))))
@@ -963,55 +956,6 @@
         TRACE("GET DOS DRIVE PARAMETER BLOCK FOR DRIVE %s\n",
 	      INT21_DriveName( DL_reg(context)));
         GetDrivePB(context, DOS_GET_DRIVE( DL_reg(context) ) );
-        break;
-
-    case 0x33: /* MULTIPLEXED */
-        switch (AL_reg(context))
-        {
-	      case 0x00: /* GET CURRENT EXTENDED BREAK STATE */
-		TRACE("GET CURRENT EXTENDED BREAK STATE\n");
-                INT21_ReadConfigSys();
-                SET_DL( context, DOSCONF_config.brk_flag );
-		break;
-
-	      case 0x01: /* SET EXTENDED BREAK STATE */
-		TRACE("SET CURRENT EXTENDED BREAK STATE\n");
-                INT21_ReadConfigSys();
-		DOSCONF_config.brk_flag = (DL_reg(context) > 0);
-		break;
-
-	      case 0x02: /* GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE*/
-		TRACE("GET AND SET EXTENDED CONTROL-BREAK CHECKING STATE\n");
-                INT21_ReadConfigSys();
-		/* ugly coding in order to stay reentrant */
-		if (DL_reg(context))
-		{
-		    SET_DL( context, DOSCONF_config.brk_flag );
-		    DOSCONF_config.brk_flag = 1;
-		}
-		else
-		{
-		    SET_DL( context, DOSCONF_config.brk_flag );
-		    DOSCONF_config.brk_flag = 0;
-		}
-		break;
-
-	      case 0x05: /* GET BOOT DRIVE */
-		TRACE("GET BOOT DRIVE\n");
-		SET_DL( context, 3 );
-		/* c: is Wine's bootdrive (a: is 1)*/
-		break;
-
-	      case 0x06: /* GET TRUE VERSION NUMBER */
-		TRACE("GET TRUE VERSION NUMBER\n");
-		SET_BX( context, (HIWORD(GetVersion16() >> 8)) | (HIWORD(GetVersion16() << 8)) );
-		SET_DX( context, 0x00 );
-		break;
-
-	      default:
-                INT_BARF( context, 0x21 );
-		break;
-        }
         break;
 
     case 0x36: /* GET FREE DISK SPACE */




Index: include/miscemu.h
===================================================================
RCS file: /home/wine/wine/include/miscemu.h,v
retrieving revision 1.68
diff -u -r1.68 miscemu.h
--- include/miscemu.h	22 Mar 2003 21:12:27 -0000	1.68
+++ include/miscemu.h	21 Apr 2003 12:00:52 -0000
@@ -25,9 +25,6 @@
 #include "selectors.h"
 #include "wine/windef16.h"
 
-/* msdos/dosconf.c */
-extern int DOSCONF_ReadConfig(void);
-
 /* msdos/dosmem.c */
 #include "pshpack1.h"
 




Index: include/msdos.h
===================================================================
RCS file: /home/wine/wine/include/msdos.h,v
retrieving revision 1.12
diff -u -r1.12 msdos.h
--- include/msdos.h	7 Dec 2002 23:46:41 -0000	1.12
+++ include/msdos.h	21 Apr 2003 12:00:54 -0000
@@ -211,25 +211,4 @@
 #define EL_Serial            0x04
 #define EL_Memory            0x05
 
-#define DOSCONF_MEM_HIGH        0x0001
-#define DOSCONF_MEM_UMB         0x0002
-#define DOSCONF_NUMLOCK         0x0004
-#define DOSCONF_KEYB_CONV       0x0008
-
-typedef struct {
-        char lastdrive;
-        int brk_flag;
-        int files;
-        int stacks_nr;
-        int stacks_sz;
-        int buf;
-        int buf2;
-        int fcbs;
-        int flags;
-        char *shell;
-        char *country;
-} DOSCONF;
-
-extern DOSCONF DOSCONF_config;
-
 #endif /* __WINE_MSDOS_H */




Index: dlls/ntdll/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/Makefile.in,v
retrieving revision 1.55
diff -u -r1.55 Makefile.in
--- dlls/ntdll/Makefile.in	12 Apr 2003 00:10:13 -0000	1.55
+++ dlls/ntdll/Makefile.in	21 Apr 2003 12:00:56 -0000
@@ -45,7 +45,6 @@
 	$(TOPOBJDIR)/misc/registry.c \
 	$(TOPOBJDIR)/misc/system.c \
 	$(TOPOBJDIR)/misc/version.c \
-	$(TOPOBJDIR)/msdos/dosconf.c \
 	$(TOPOBJDIR)/msdos/dosmem.c \
 	$(TOPOBJDIR)/msdos/dpmi.c \
 	$(TOPOBJDIR)/msdos/int21.c \




--- /dev/null	Thu Jan  1 02:00:00 1970
+++ dlls/winedos/dosconf.c	Mon Apr 21 14:38:58 2003
@@ -0,0 +1,500 @@
+/*
+ * DOS CONFIG.SYS parser
+ *
+ * Copyright 1998 Andreas Mohr
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "winbase.h"
+#include "winreg.h"
+
+#include "file.h"
+#include "dosexe.h"
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(profile);
+
+
+static int DOSCONF_Device(char **confline);
+static int DOSCONF_Dos(char **confline);
+static int DOSCONF_Fcbs(char **confline);
+static int DOSCONF_Break(char **confline);
+static int DOSCONF_Files(char **confline);
+static int DOSCONF_Install(char **confline);
+static int DOSCONF_Lastdrive(char **confline);
+static int DOSCONF_Menu(char **confline);
+static int DOSCONF_Include(char **confline);
+static int DOSCONF_Country(char **confline);
+static int DOSCONF_Numlock(char **confline);
+static int DOSCONF_Switches(char **confline);
+static int DOSCONF_Shell(char **confline);
+static int DOSCONF_Stacks(char **confline);
+static int DOSCONF_Buffers(char **confline);
+static void DOSCONF_Parse(char *menuname);
+
+static DOSCONF DOSCONF_config =
+{
+    'E',  /* lastdrive */
+    0,    /* brk_flag */
+    8,    /* files */
+    9,    /* stacks_nr */
+    256,  /* stacks_sz */
+    15,   /* buf */
+    1,    /* buf2 */
+    4,    /* fcbs */
+    0,    /* flags */
+    NULL, /* shell */
+    NULL  /* country */
+};
+
+static BOOL DOSCONF_loaded = FALSE;
+
+typedef struct {
+    const char *tag_name;
+    int (*tag_handler)(char **p);
+} TAG_ENTRY;
+
+
+/*
+ * see
+ * http://egeria.cm.cf.ac.uk/User/P.L.Poulain/project/internal/allinter.htm
+ * or
+ * http://www.csulb.edu/~murdock/dosindex.html
+ */
+
+static const TAG_ENTRY DOSCONF_tag_entries[] =
+{
+    { ";", NULL },
+    { "REM ", NULL },
+    { "DEVICE", DOSCONF_Device },
+    { "[", DOSCONF_Menu },
+    { "SUBMENU", NULL },
+    { "MENUDEFAULT", DOSCONF_Menu },
+    { "INCLUDE", DOSCONF_Include },
+    { "INSTALL", DOSCONF_Install },
+    { "DOS", DOSCONF_Dos },
+    { "FCBS", DOSCONF_Fcbs },
+    { "BREAK", DOSCONF_Break },
+    { "FILES", DOSCONF_Files },
+    { "SHELL", DOSCONF_Shell },
+    { "STACKS", DOSCONF_Stacks },
+    { "BUFFERS", DOSCONF_Buffers },
+    { "COUNTRY", DOSCONF_Country },
+    { "NUMLOCK", DOSCONF_Numlock },
+    { "SWITCHES", DOSCONF_Switches },
+    { "LASTDRIVE", DOSCONF_Lastdrive }
+};
+
+static FILE *DOSCONF_fd = NULL;
+
+static char *DOSCONF_menu_default = NULL;
+static int   DOSCONF_menu_in_listing = 0; /* we are in the [menu] section */
+static int   DOSCONF_menu_skip = 0;	  /* the current menu gets skipped */
+
+static void DOSCONF_skip(char **pconfline)
+{
+    char *p;
+
+    p = *pconfline;
+    while ( (*p == ' ') || (*p == '\t') ) p++;
+    *pconfline = p;
+}
+
+static int DOSCONF_JumpToEntry(char **pconfline, char separator)
+{
+    char *p;
+
+    p = *pconfline;
+    while ( (*p != separator) && (*p != '\0') ) p++;
+
+    if (*p != separator)
+	return 0;
+    else 
+        p++;
+
+    while ( (*p == ' ') || (*p == '\t') ) p++;
+    *pconfline = p;
+    return 1;
+}
+
+static int DOSCONF_Device(char **confline)
+{
+    int loadhigh = 0;
+
+    *confline += 6; /* strlen("DEVICE") */
+    if (!(strncasecmp(*confline, "HIGH", 4)))
+    {
+	loadhigh = 1;
+	*confline += 4;
+	/* FIXME: get DEVICEHIGH parameters if avail ? */
+    }
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE("Loading device '%s'\n", *confline);
+#if 0
+    DOSMOD_LoadDevice(*confline, loadhigh);
+#endif
+    return 1;
+}
+
+static int DOSCONF_Dos(char **confline)
+{
+    *confline += 3; /* strlen("DOS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    while (**confline != '\0')
+    {
+	if (!(strncasecmp(*confline, "HIGH", 4)))
+	{
+	    DOSCONF_config.flags |= DOSCONF_MEM_HIGH;
+	    *confline += 4;
+	}
+	else if (!(strncasecmp(*confline, "UMB", 3)))
+	{
+	    DOSCONF_config.flags |= DOSCONF_MEM_UMB;
+	    *confline += 3;
+	}
+        else 
+        {
+            (*confline)++;
+        }
+
+	DOSCONF_JumpToEntry(confline, ',');
+    }
+    TRACE( "DOSCONF_Dos: HIGH is %d, UMB is %d\n",
+           (DOSCONF_config.flags & DOSCONF_MEM_HIGH) != 0, 
+           (DOSCONF_config.flags & DOSCONF_MEM_UMB) != 0 );
+    return 1;
+}
+
+static int DOSCONF_Fcbs(char **confline)
+{
+    *confline += 4; /* strlen("FCBS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.fcbs = atoi(*confline);
+    if (DOSCONF_config.fcbs > 255)
+    {
+        WARN( "The FCBS value in the config.sys file is too high! Setting to 255.\n" );
+        DOSCONF_config.fcbs = 255;
+    }
+    TRACE( "DOSCONF_Fcbs returning %d\n", DOSCONF_config.fcbs );
+    return 1;
+}
+
+static int DOSCONF_Break(char **confline)
+{
+    *confline += 5; /* strlen("BREAK") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    if (!(strcasecmp(*confline, "ON")))
+        DOSCONF_config.brk_flag = 1;
+    TRACE( "BREAK is %d\n", DOSCONF_config.brk_flag );
+    return 1;
+}
+
+static int DOSCONF_Files(char **confline)
+{
+    *confline += 5; /* strlen("FILES") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.files = atoi(*confline);
+    if (DOSCONF_config.files > 255)
+    {
+    	WARN( "The FILES value in the config.sys file is too high! Setting to 255.\n" );
+        DOSCONF_config.files = 255;
+    }
+    if (DOSCONF_config.files < 8)
+    {
+    	WARN( "The FILES value in the config.sys file is too low! Setting to 8.\n" );
+        DOSCONF_config.files = 8;
+    }
+    TRACE( "DOSCONF_Files returning %d\n", DOSCONF_config.files );
+    return 1;
+}
+
+static int DOSCONF_Install(char **confline)
+{
+#if 0
+    int loadhigh = 0;
+#endif
+
+    *confline += 7; /* strlen("INSTALL") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE( "Installing '%s'\n", *confline );
+#if 0
+    DOSMOD_Install(*confline, loadhigh);
+#endif
+    return 1;
+}
+
+static int DOSCONF_Lastdrive(char **confline)
+{
+    *confline += 9; /* strlen("LASTDRIVE") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.lastdrive = toupper(**confline);
+    TRACE( "Lastdrive %c\n", DOSCONF_config.lastdrive );
+    return 1;
+}
+
+static int DOSCONF_Country(char **confline)
+{
+    *confline += 7; /* strlen("COUNTRY") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE( "Country '%s'\n", *confline );
+    if (DOSCONF_config.country == NULL)
+        DOSCONF_config.country = malloc(strlen(*confline) + 1);
+    strcpy(DOSCONF_config.country, *confline);
+    return 1;
+}
+
+static int DOSCONF_Numlock(char **confline)
+{
+    *confline += 7; /* strlen("NUMLOCK") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    if (!(strcasecmp(*confline, "ON")))
+        DOSCONF_config.flags |= DOSCONF_NUMLOCK;
+    TRACE( "NUMLOCK is %d\n", 
+           (DOSCONF_config.flags & DOSCONF_NUMLOCK) != 0 );
+    return 1;
+}
+
+static int DOSCONF_Switches(char **confline)
+{
+    char *p;
+
+    *confline += 8; /* strlen("SWITCHES") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    p = strtok(*confline, "/");
+    do
+    {
+	if ( toupper(*p) == 'K')
+	    DOSCONF_config.flags |= DOSCONF_KEYB_CONV;
+    }
+    while ((p = strtok(NULL, "/")));
+    TRACE( "'Force conventional keyboard' is %d\n",
+           (DOSCONF_config.flags & DOSCONF_KEYB_CONV) != 0 );
+    return 1;
+}
+
+static int DOSCONF_Shell(char **confline)
+{
+    *confline += 5; /* strlen("SHELL") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    TRACE( "Shell '%s'\n", *confline );
+    if (DOSCONF_config.shell == NULL)
+        DOSCONF_config.shell = malloc(strlen(*confline) + 1);
+    strcpy(DOSCONF_config.shell, *confline);
+    return 1;
+}
+
+static int DOSCONF_Stacks(char **confline)
+{
+
+    *confline += 6; /* strlen("STACKS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    DOSCONF_config.stacks_nr = atoi(strtok(*confline, ","));
+    DOSCONF_config.stacks_sz = atoi((strtok(NULL, ",")));
+    TRACE( "%d stacks of size %d\n",
+           DOSCONF_config.stacks_nr, DOSCONF_config.stacks_sz );
+    return 1;
+}
+
+static int DOSCONF_Buffers(char **confline)
+{
+    char *p;
+
+    *confline += 7; /* strlen("BUFFERS") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    p = strtok(*confline, ",");
+    DOSCONF_config.buf = atoi(p);
+    if ((p = strtok(NULL, ",")))
+        DOSCONF_config.buf2 = atoi(p);
+    TRACE( "%d primary buffers, %d secondary buffers\n",
+           DOSCONF_config.buf, DOSCONF_config.buf2 );
+    return 1;
+}
+
+static int DOSCONF_Menu(char **confline)
+{
+    if (!(strncasecmp(*confline, "[MENU]", 6)))
+    {
+	DOSCONF_menu_in_listing = 1;
+    }
+    else if ((!(strncasecmp(*confline, "[COMMON]", 8)))
+             || (!(strncasecmp(*confline, "[WINE]", 6))))
+    {
+	DOSCONF_menu_skip = 0;
+    }
+    else if (**confline == '[')
+    {
+	(*confline)++;
+	if ((DOSCONF_menu_default)
+            && (!(strncasecmp(*confline, DOSCONF_menu_default, 
+                              strlen(DOSCONF_menu_default)))))
+        {
+            free(DOSCONF_menu_default);
+            DOSCONF_menu_default = NULL;
+            DOSCONF_menu_skip = 0;
+        }
+        else
+	    DOSCONF_menu_skip = 1;
+	DOSCONF_menu_in_listing = 0;
+    }
+    else if (!(strncasecmp(*confline, "menudefault", 11)) 
+             && (DOSCONF_menu_in_listing))
+    {
+	if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+        *confline = strtok(*confline, ",");
+        DOSCONF_menu_default = malloc(strlen(*confline) + 1);
+	strcpy(DOSCONF_menu_default, *confline);
+    }
+
+    return 1;
+}
+
+static int DOSCONF_Include(char **confline)
+{
+    fpos_t oldpos;
+    char *temp;
+
+    *confline += 7; /* strlen("INCLUDE") */
+    if (!(DOSCONF_JumpToEntry(confline, '='))) return 0;
+    fgetpos(DOSCONF_fd, &oldpos);
+    fseek(DOSCONF_fd, 0, SEEK_SET);
+    TRACE( "Including menu '%s'\n", *confline );
+    temp = malloc(strlen(*confline) + 1);
+    strcpy(temp, *confline);
+    DOSCONF_Parse(temp);
+    free(temp);
+    fsetpos(DOSCONF_fd, &oldpos);
+    return 1;
+}
+
+static void DOSCONF_Parse(char *menuname)
+{
+    char confline[256];
+    char *p, *trail;
+    int i;
+
+    if (menuname != NULL) /* we need to jump to a certain sub menu */
+    {
+	while (fgets(confline, 255, DOSCONF_fd))
+	{
+	     p = confline;
+	     DOSCONF_skip(&p);
+	     if (*p == '[')
+	     {
+		p++;
+		if (!(trail = strrchr(p, ']')))
+		    return;
+		if (!(strncasecmp(p, menuname, (int)trail - (int)p)))
+		    break;
+	     }
+	}
+    }
+
+    while (fgets(confline, 255, DOSCONF_fd))
+    {
+	p = confline;
+	DOSCONF_skip(&p);
+
+	if ((menuname) && (*p == '['))
+	    /*
+             * we were handling a specific sub menu, 
+             * but now next menu begins 
+             */
+	    break;
+
+	if ((trail = strrchr(confline, '\n')))
+            *trail = '\0';
+	if ((trail = strrchr(confline, '\r')))
+            *trail = '\0';
+	if (!(DOSCONF_menu_skip))
+	{
+	    for (i = 0; i < sizeof(DOSCONF_tag_entries) / sizeof(TAG_ENTRY); 
+                 i++)
+		if (!(strncasecmp(p, DOSCONF_tag_entries[i].tag_name,
+                                  strlen(DOSCONF_tag_entries[i].tag_name))))
+                {
+		    TRACE( "tag '%s'\n", DOSCONF_tag_entries[i].tag_name );
+		    if (DOSCONF_tag_entries[i].tag_handler != NULL)
+                        DOSCONF_tag_entries[i].tag_handler(&p);
+                    break;
+		}
+	}
+	else
+        { 
+            /* the current menu gets skipped */
+            DOSCONF_Menu(&p);
+        }
+    }
+}
+
+DOSCONF *DOSCONF_GetConfig(void)
+{
+    HKEY hkey;
+    CHAR filename[MAX_PATH];
+
+    if (DOSCONF_loaded)
+        return &DOSCONF_config;
+
+    /* default value */
+    strcpy( filename, "*" );
+
+    if (!RegOpenKeyA(HKEY_LOCAL_MACHINE, 
+                     "Software\\Wine\\Wine\\Config\\wine", 
+                     &hkey))
+    {
+        DWORD type;
+        DWORD count = sizeof(filename);
+
+        RegQueryValueExA(hkey, "config.sys", 0, &type, filename, &count);
+        RegCloseKey(hkey);
+    }
+
+    if (strcmp(filename, "*") && *filename != '\0')
+    {
+        CHAR fullname[MAX_PATH];
+
+        if (wine_get_unix_file_name(filename, fullname, sizeof(fullname)))
+            DOSCONF_fd = fopen(fullname, "r");
+
+        if (DOSCONF_fd)
+        {
+            DOSCONF_Parse(NULL);
+            fclose(DOSCONF_fd);
+            DOSCONF_fd = NULL;
+        }
+        else
+        {
+            WARN( "Couldn't open config.sys file given as %s in"
+                  " configuration file, section [wine]!\n", 
+                  filename );
+        }
+    }
+
+    DOSCONF_loaded = TRUE;
+    return &DOSCONF_config;
+}



-- 
Jukka Heinonen <http://www.iki.fi/jhei/>



More information about the wine-patches mailing list