From 73be8d1cfdad2ba046bb0729a415db20ceab73dd Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Wed, 6 Dec 2000 20:25:11 +0000
Subject: [PATCH] Added automatic translation of the config file to the new
 format. Updated documentation.

---
 README                         |  14 +--
 documentation/wine.conf.man.in | 181 ++++++++++++++++-----------------
 documentation/wine.man.in      |  16 +--
 files/profile.c                |  88 +++++++++++++++-
 wine.ini                       |   6 --
 5 files changed, 191 insertions(+), 114 deletions(-)

diff --git a/README b/README
index c6542fc655e..542be0e1272 100644
--- a/README
+++ b/README
@@ -97,14 +97,16 @@ Once Wine has been built correctly, you can do "make install"; this
 will install the wine executable, the Wine man page, and a few other
 needed files.
 
-Wine requires a configuration file named wine.conf. Its default location is
-/usr/local/etc, but you can supply a different name when configuring wine by
-using the --prefix or --sysconfdir options to ./configure. You can also override
-the global configuration file with a .winerc file in your home directory.
+Wine requires a configuration file named wine.conf. Its default
+location is /usr/local/etc, but you can supply a different name when
+configuring wine by using the --prefix or --sysconfdir options to
+./configure. You can also override the global configuration file with
+a file named "config" in your ~/.wine directory.
 
 The format of this file is explained in the man page. The file
-wine.ini contains an example configuration file which has to be adapted
-and copied to one of the two locations mentioned above.
+documentation/samples/config contains an example configuration file
+which has to be adapted and copied to one of the two locations
+mentioned above.
 
 See http://www.winehq.com/config.html for further configuration hints.
 
diff --git a/documentation/wine.conf.man.in b/documentation/wine.conf.man.in
index fbdfb2641a0..9113a9fb8d2 100644
--- a/documentation/wine.conf.man.in
+++ b/documentation/wine.conf.man.in
@@ -1,25 +1,25 @@
 .\" -*- nroff -*-
-.TH WINE.CONF 5 "July 16, 1999" "Version 990704" "Wine Configuration File"
+.TH WINE.CONF 5 "December 5, 2000" "Version 20001202" "Wine Configuration File"
 .SH NAME
 wine.conf \- Wine configuration file
 .SH DESCRIPTION
 .B wine
 expects a configuration file (
 .I @sysconfdir@/wine.conf
-), which should
-conform to the following rules (the format is just like a Windows .ini
-file). Common locations are /usr/local/etc/wine.conf or
-(in some distributions) /etc/wine.conf. The actual directory
-where that file resides may be specified during the execution of the
+), which should conform to the following rules. Common locations are
+/usr/local/etc/wine.conf or (in some distributions)
+/etc/wine.conf. The actual directory where that file resides may be
+specified during the execution of the
 .B configure
-script with the --sysconfdir option. Alternatively, you may have a 
-.I .winerc
-file of this format in your home directory or have the environment variable
-.B WINE_INI
-pointing to a configuration file, or use the --config option on the command 
-line.
-A sample configuration file is available as wine.ini in the base directory
-of the Wine source distribution.
+script with the --sysconfdir option. Alternatively, you may have a
+file named
+.I config
+in this format in your ~/.wine directory or in the directory named in
+the
+.B WINEPREFIX
+environment variable.  A sample configuration file is available as
+.I documentation/samples/config
+in the Wine source distribution.
 .SH CONFIGURATION FILE FORMAT
 All entries are grouped in sections; a section begins with the line
 .br
@@ -28,13 +28,15 @@ All entries are grouped in sections; a section begins with the line
 and continues until the next section starts. Individual entries
 consist of lines of the form
 .br
-.I entry=value
+.I """entry""=""value"""
 .br
-The value can be any text string, optionally included in single or
-double quotes; it can also contain references to environment variables
+The entry and value can be any text strings, included in double
+quotes; it can also contain references to environment variables
 surrounded by
 .I ${}.
-Supported section names and entries are listed below.
+Inside the double quotes, special characters, backslashes and quotes
+must be escaped with backslashes. Supported section names and entries
+are listed below.
 .PP
 .B [Drive X]
 .br
@@ -44,7 +46,7 @@ drive, since most Windows applications require a DOS/MS-Windows based
 disk drive & directory scheme. There is one such section for every
 drive you want to configure.
 .PP
-.I format: Path = <rootdirectory>
+.I format: """Path""=""<rootdirectory>"""
 .br
 default: none
 .br
@@ -52,52 +54,52 @@ If you mounted your dos partition as
 .I /dos
 and installed Microsoft Windows in 
 C:\\WINDOWS then you should specify 
-.I Path=/dos
+.I """Path""=""/dos"""
 in the
 .I [Drive C]
 section.
 .PP
-.I format: Type = <type>
+.I format: """Type""=""<type>"""
 .br
-default: hd
+default: "hd"
 .br
 Used to specify the drive type this drive appears as in Windows
-or DOS programs; supported types are floppy, hd, cdrom
-and network.
+or DOS programs; supported types are "floppy", "hd", "cdrom"
+and "network".
 .PP
-.I format: Label = <label>
+.I format: """Label""=""<label>"""
 .br
-default: 'Drive X'
+default: "Drive X"
 .br
 Used to specify the drive label; limited to 11 characters.
 .PP
-.I format: Serial = <serial>
+.I format: """Serial""=""<serial>"""
 .br
-default: 12345678
+default: "12345678"
 .br
 Used to specify the drive serial number, as an 8-character hexadecimal
 number.
 .PP
-.I format: Filesystem = <fstype>
+.I format: """Filesystem""=""<fstype>"""
 .br
-default: win95
+default: "win95"
 .br
 Used to specify the type of the file system Wine should emulate on a given
 directory structure/underlying file system.
 .br
-Supported types are msdos (or fat), win95 (or vfat), unix.
+Supported types are "msdos" (or "fat"), "win95" (or "vfat"), "unix".
 .br
 Recommended:
 .br
-  win95 for ext2fs, VFAT and FAT32
+  "win95" for ext2fs, VFAT and FAT32
 .br
-  msdos for FAT16 (ugly)
+  "msdos" for FAT16 (ugly)
 .br
-You definitely don't want to use "unix" unless you intend to port programs using Winelib.
-.br
-Always try to avoid using FAT16. Use VFAT/FAT32 OS file system driver instead !
+You definitely do not want to use "unix" unless you intend to port
+programs using Winelib.  Always try to avoid using FAT16. Use the
+VFAT/FAT32 OS file system driver instead.
 .PP
-.I format: FailReadOnly=<boolean>
+.I format: """FailReadOnly""=""<boolean>"""
 .br
 Read-only files may not be opened in write mode (the default is to
 allow opening read-only files for writing, because most Windows
@@ -105,64 +107,60 @@ programs always request read-write access, even on CD-ROM drives...).
 .PP
 .B [wine]
 .br
-.I format: windows = <directory>
+.I format: """windows""=""<directory>"""
 .br
-default: C:\\WINDOWS
+default: "C:\\\\WINDOWS"
 .br
-Used to specify a different Windows directory
+Used to specify a different Windows directory; make sure to double the
+backslashes.
 .PP
-.I format: system = <directory>
+.I format: """system""=""<directory>"""
 .br
-default: C:\\WINDOWS\\SYSTEM
+default: "C:\\\\WINDOWS\\\\SYSTEM"
 .br
-Used to specify a different system directory
+Used to specify a different system directory; make sure to double the
+backslashes.
 .PP
-.I format: temp = <directory>
+.I format: """temp""=""<directory>"""
 .br
-default: C:\\TEMP
+default: "C:\\\\TEMP"
 .br
 Used to specify a directory where Windows applications can store 
 temporary files.
 .PP
-.I format: profile = <directory>
+.I format: """profile""=""<directory>"""
 .br
 default: nothing
 .br
-Used to specify a directory where Windows stores special folders and the user-registry files (user.dat or ntuser.dat). 
-Mapped to environment variable %USERPROFILE%. 
-Set this value when running with a native NT or a native win95 directory with per-user settings.
-.PP
-.I format: path = <directories separated by semi-colons>
-.br
-default: C:\\WINDOWS;C:\\WINDOWS\\SYSTEM
-.br
-Used to specify the path which will be used to find executables and .DLL's.
+Used to specify a directory where Windows stores special folders and
+the user-registry files (user.dat or ntuser.dat).  Mapped to
+environment variable %USERPROFILE%.  Set this value when running with
+a native NT or a native win95 directory with per-user settings.
 .PP
-.I format: symboltablefile = <filename>
+.I format: """path""=""<directories separated by semi-colons>"""
 .br
-default: wine.sym
+default: "C:\\\\WINDOWS;C:\\\\WINDOWS\\\\SYSTEM"
 .br
-Used to specify the path and file name of the symbol table used by the built-in
-debugger.
+Used to specify the path which will be used to find executables and
+dlls. Make sure to double all the backslashes.
 .PP
 .B [DllDefaults]
 .br
-.I format: EXTRA_LD_LIBRARY_PATH=@prefix@/lib/wine[:/more/path/to/search[:...]]
+.I format: """EXTRA_LD_LIBRARY_PATH""=""@prefix@/lib/wine[:/more/path/to/search[:...]]"""
 .br
 The path will be appended to any existing LD_LIBRARY_PATH from the 
 environment for the search of .so libraries.
 .PP
-.I format: DefaultLoadOrder=native,so,builtin
+.I format: """DefaultLoadOrder""=""native,so,builtin"""
 .br
 A comma separated list of module-types to try to load in that specific
 order. The DefaultLoadOrder key is used as a fallback when a module is
 not specified explicitely. If the DefaultLoadOrder key is not found, 
 then the order "native,builtin,so" is used.
 .br
-Case is not (yet) important and only the first letter of each type is
-enough to identify the type n[ative], s[o], b[uiltin]. Also whitespace
-is ignored. Keep everything in lower case to be sure that your entries
-keep the same meaning. See also commandline option
+Case is not important and only the first letter of each type is enough
+to identify the type n[ative], s[o], b[uiltin]. Also whitespace is
+ignored. See also commandline option
 .I --dll
 for details about the allowable types.
 .PP
@@ -175,13 +173,13 @@ an extension.
 .br
 Examples:
 .br
-.I kernel32 = builtin
+.I """kernel32""=""builtin"""
 .br
-.I kernel = builtin
+.I """kernel""=""builtin"""
 .br
-.I comdlg32 = native, builtin
+.I """comdlg32""=""native, builtin"""
 .br
-.I commdlg = native, builtin
+.I """commdlg""=""native, builtin"""
 .br
 Changing the load order of kernel/kernel32 and gdi/gdi32 to
 anything other than builtin will cause wine to fail because wine cannot
@@ -198,7 +196,7 @@ what you are doing.
 .PP
 .B [serialports]
 .br
-.I format: com[12345678] = <devicename>
+.I format: """com[12345678]""=""<devicename>"""
 .br
 default: none
 .br
@@ -206,7 +204,7 @@ Used to specify the devices which are used as COM1 - COM8.
 .PP
 .B [parallelports]
 .br
-.I format: lpt[12345678] = <devicename>
+.I format: """lpt[12345678]""=""<devicename>"""
 .br
 default: none
 .br
@@ -214,65 +212,64 @@ Used to specify the devices which are used as LPT1 - LPT8.
 .PP
 .B [spy]
 .br
-.I format: file = <filename or CON when logging to stdout>
-.br
-default: none
-.br
-Used to specify the file which will be used as
-.B logfile.
-.PP
-.I format: exclude = <message names separated by semicolons>
+.I format: """exclude""=""<message names separated by semicolons>"""
 .br
 default: none
 .br
 Used to specify which messages will be excluded from the logfile.
 .PP
-.I format: include = <message names separated by semicolons>
+.I format: """include""=""<message names separated by semicolons>"""
 .br
 default: none
 .br Used to specify which messages will be included in the logfile.
 .PP
 .B [Tweak.Layout]
 .br
-.I format: WineLook=<Win31|Win95|Win98>
+.I format: """WineLook""=""<Win31|Win95|Win98>"""
 .br
-default: Win31
+default: "Win31"
 .br 
 Use Win95-like window displays or Win3.1-like window displays.
 .PP
 .B [Registry]
 .br
-.I format: LoadGlobalRegistryFiles=<boolean>
+.I format: """LoadGlobalRegistryFiles""=""<boolean>"""
 .br
 Global registries (stored in /etc)
 .PP
-.I format: LoadHomeRegistryFiles=<boolean>
+.I format: """LoadHomeRegistryFiles""=""<boolean>"""
 .br
 Home registries (stored in ~user/.wine/)
 .PP
-.I format: WritetoHomeRegistryFiles=<boolean>
+.I format: """WritetoHomeRegistryFiles""=""<boolean>"""
 .br
-TRY to write all changes to alt registries
+TRY to write all changes to the home registry files
 .PP
-.I format: LoadWindowsRegistryFiles=<boolean>
+.I format: """LoadWindowsRegistryFiles""=""<boolean>"""
 .br
 Load Windows registry from the current Windows directory. 
 .PP
 booleans: Y/y/T/t/1 are true, N/n/F/f/0 are false.
 .br
-Defaults are read all, write to Home
+Defaults are read all, write to home files.
 .PP
 .SH SAMPLE CONFIGURATION FILE
 A sample configuration file is distributed as
-.B wine.ini
-in the top-level directory of the source distribution.
+.B documentation/samples/config
+in the Wine source distribution.
 .SH FILES
-.PD 0
 .TP
 .I @sysconfdir@/wine.conf
 Global configuration file for wine.
 .TP
-.I ~/.winerc
+.I ~/.wine/config
 User-specific configuration file
+.SH ENVIRONMENT VARIABLES
+.TP 
+.I WINEPREFIX
+Specifies the directory that contains the per-user
+.I config
+file, the registry files, and the wineserver socket. The default is
+.I $HOME/.wine.
 .SH "SEE ALSO"
 .BR wine (1)
diff --git a/documentation/wine.man.in b/documentation/wine.man.in
index 65f5f8830e1..13f5c58c1b1 100644
--- a/documentation/wine.man.in
+++ b/documentation/wine.man.in
@@ -108,7 +108,7 @@ file contained in the source distribution.
 .TP
 .I --config filename
 Use the named configuration file rather than the default
-(@sysconfdir@/wine.conf or ~/.winerc).
+(@sysconfdir@/wine.conf or ~/.wine/config).
 .TP
 .I --debugmsg [xxx]#name[,[xxx1]#name1][,<+|->relay=yyy1[:yyy2]]
 Turn debugging messages on or off.  
@@ -181,10 +181,10 @@ Use a desktop window of the given geometry, e.g. "640x480"
 Use the specified X display
 .TP
 .I --dll name[,name[,...]]={native|so|builtin}[,{n|s|b}[,...]][+...]
-Selects the override type and load order of dll used in the loading process
-for any dll. The default is set in @sysconfdir@/wine.conf or ~/.winerc. There
-are currently three types of libraries that can be loaded into a process' address
-space: Native windows dlls (
+Selects the override type and load order of dll used in the loading
+process for any dll. The default is set in the configuration
+file. There are currently three types of libraries that can be loaded
+into a process' address space: Native windows dlls (
 .I native
 ), native ELF libraries (
 .I so
@@ -357,8 +357,8 @@ expects a configuration file (
 man page. A sample configuration file is wine.ini in the base directory of the 
 .B wine 
 source archive. Alternatively a configuration file with the name
-.I .winerc 
-in the home directory of the user running 
+.I config
+in the ~/.wine directory of the user running 
 .B wine 
 can be used. The third option is to specify the name of the 
 configuration file with the 
@@ -460,7 +460,7 @@ shared libraries
 Global configuration file for 
 .B wine.
 .TP
-.I ~/.winerc
+.I ~/.wine/config
 User-specific configuration file
 .TP 
 .I ~/.wine
diff --git a/files/profile.c b/files/profile.c
index c93833277b2..71dc7f9bd35 100644
--- a/files/profile.c
+++ b/files/profile.c
@@ -6,6 +6,7 @@
  */
 
 #include <ctype.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -269,6 +270,78 @@ static PROFILESECTION *PROFILE_Load( FILE *file )
     return first_section;
 }
 
+/* convert the .winerc file to the new format */
+static int convert_config( FILE *in, const char *output_name )
+{
+    char buffer[PROFILE_MAX_LINE_LEN];
+    char *p, *p2;
+    FILE *out;
+
+    /* create the output file, only if it doesn't exist already */
+    int fd = open( output_name, O_WRONLY|O_CREAT|O_EXCL, 0666 );
+    if (fd == -1) return 0;
+
+    out = fdopen( fd, "w" );
+    fprintf( out, "WINE REGISTRY Version 2\n" );
+    fprintf( out, ";; All keys relative to \\\\Machine\\\\Software\\\\Wine\\\\Wine\\\\Config\n\n" );
+    while (fgets( buffer, PROFILE_MAX_LINE_LEN, in ))
+    {
+        if (buffer[strlen(buffer)-1] == '\n') buffer[strlen(buffer)-1] = 0;
+        p = buffer;
+        while (*p && PROFILE_isspace(*p)) p++;
+        if (*p == '[')  /* section start */
+        {
+            if ((p2 = strrchr( p, ']' )))
+            {
+                *p2 = '\0';
+                p++;
+                fprintf( out, "[%s]\n", p );
+            }
+            continue;
+        }
+
+        if (*p == ';' || *p == '#')
+        {
+            fprintf( out, "%s\n", p );
+            continue;
+        }
+
+        p2=p+strlen(p) - 1;
+        while ((p2 > p) && ((*p2 == '\n') || PROFILE_isspace(*p2))) *p2--='\0';
+
+        if ((p2 = strchr( p, '=' )) != NULL)
+        {
+            char *p3 = p2 - 1;
+            while ((p3 > p) && PROFILE_isspace(*p3)) *p3-- = '\0';
+            *p2++ = '\0';
+            while (*p2 && PROFILE_isspace(*p2)) p2++;
+        }
+
+        if (!*p)
+        {
+            fprintf( out, "\n" );
+            continue;
+        }
+        fputc( '"', out );
+        while (*p)
+        {
+            if (*p == '\\') fputc( '\\', out );
+            fputc( *p, out );
+            p++;
+        }
+        fprintf( out, "\" = \"" );
+        while (*p2)
+        {
+            if (*p2 == '\\') fputc( '\\', out );
+            fputc( *p2, out );
+            p2++;
+        }
+        fprintf( out, "\"\n" );
+    }
+    fclose( out );
+    return 1;
+}
+
 
 /***********************************************************************
  *           PROFILE_RegistryLoad
@@ -1040,8 +1113,8 @@ int PROFILE_LoadWineIni(void)
 
     if (disp == REG_OPENED_EXISTING_KEY) return 1;  /* loaded by the server */
 
-    MESSAGE( "Can't open configuration file %s or $HOME%s\n",
-	     WINE_INI_GLOBAL, PROFILE_WineIniName );
+    MESSAGE( "Can't open configuration file %s or %s/config\n",
+	     WINE_INI_GLOBAL, get_config_dir() );
     return 0;
 
  found:
@@ -1054,6 +1127,17 @@ int PROFILE_LoadWineIni(void)
         return 1;
     }
 
+    /* convert to the new format */
+    sprintf( buffer, "%s/config", get_config_dir() );
+    if (convert_config( f, buffer ))
+    {
+        MESSAGE( "The '%s' configuration file has been converted\n"
+                 "to the new format and saved as '%s'.\n", PROFILE_WineIniUsed, buffer );
+        MESSAGE( "You should verify that the contents of the new file are correct,\n"
+                 "and then remove the old one and restart Wine.\n" );
+        ExitProcess(0);
+    }
+
     PROFILE_RegistryLoad( wine_profile_key, f );
     fclose( f );
     return 1;
diff --git a/wine.ini b/wine.ini
index 8881cbe43bf..294d219d6f3 100644
--- a/wine.ini
+++ b/wine.ini
@@ -173,8 +173,6 @@ LoadHomeRegistryFiles=Y
 LoadWindowsRegistryFiles=Y
 ; TRY to write all changes to home registries
 WritetoHomeRegistryFiles=Y
-; Use new file format
-UseNewFormat=Y
 ; Registry periodic save timeout in seconds
 ; PeriodicSave=600
 ; Save only modified keys
@@ -184,10 +182,6 @@ SaveOnlyUpdatedKeys=Y
 ;; WineLook=xxx  (supported styles are 'Win31'(default), 'Win95', 'Win98')
 WineLook=Win95
 
-[programs]
-Default=
-Startup=
-
 [Console]
 ;Drivers=tty
 ;XtermProg=nxterm
-- 
GitLab