This is the initial version of wineboot, the next generation. It is a rewrite, using the old code as reference only.
Changelog:
Shachar Shemesh <winecode@sun.consumer.org.il>
configure.ac and programs/Makefile.in
* Added the new directory (programs/wineboot) to the list of
makefiles to create
programs/wineboot/*
* Initial implementation
Bugs:
* At this stage only wininit.ini processing has been written. Lots
more work to do.
* _stricmp is not defined, and is called directly instead of as stricmp.
* As a result of the above, there is a compilation warning when
compiling.
Index: configure.ac =================================================================== RCS file: /home/sun/sources/cvs/wine/configure.ac,v retrieving revision 1.114 diff -u -r1.114 configure.ac --- configure.ac 24 Dec 2002 02:39:47 -0000 1.114 +++ configure.ac 28 Dec 2002 21:01:43 -0000 @@ -1499,6 +1499,7 @@ programs/uninstaller/Makefile programs/view/Makefile programs/wcmd/Makefile +programs/wineboot/Makefile programs/wineconsole/Makefile programs/winedbg/Makefile programs/winefile/Makefile Index: programs/Makefile.in =================================================================== RCS file: /home/sun/sources/cvs/wine/programs/Makefile.in,v retrieving revision 1.32 diff -u -r1.32 Makefile.in --- programs/Makefile.in 2 Dec 2002 21:17:05 -0000 1.32 +++ programs/Makefile.in 28 Dec 2002 21:02:18 -0000 @@ -22,6 +22,7 @@ uninstaller \ view \ wcmd \ + wineboot \ wineconsole \ winedbg \ winefile \
TOPSRCDIR = @top_srcdir@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = wineboot.exe #EXTRALIBS = @CURSESLIBS@ APPMODE = cui IMPORTS = msvcrt #DELAYIMPORTS = comctl32 user32 gdi32 C_SRCS = \ wineboot.c #RC_SRCS = wineboot_res.rc @MAKE_PROG_RULES@ ### Dependencies:
#include <stdio.h> #include "winbase.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(wineboot); const char * const RENAME_FILE="wininit.ini"; const char * const RENAME_FILE_SECTION="[rename]"; #define MAX_LINE_LENGTH (2*MAX_PATH+2) static BOOL GetLine( HANDLE hFile, char *buf, size_t buflen ) { int i=0; buf[0]='\0'; do { DWORD read; if( !ReadFile( hFile, buf, 1, &read, NULL ) || read!=1 ) { return FALSE; } } while( isspace( *buf ) ); while( buf[i]!='\n' && i<=buflen && ReadFile( hFile, buf+i+1, 1, NULL, NULL ) ) { ++i; } if( buf[i]!='\n' ) { return FALSE; } if( i>0 && buf[i-1]=='\r' ) --i; buf[i]='\0'; return TRUE; } /* Performs the rename operations dictated in %SystemRoot%\Wininit.ini. * Returns FALSE if there was an error, or otherwise if all is ok. */ static BOOL wininit() { char buffer[MAX_LINE_LENGTH]; char ini_path[MAX_PATH]; HANDLE hFile; DWORD res; res=GetWindowsDirectoryA( ini_path, sizeof(ini_path) ); if( res==0 ) { WINE_ERR("Couldn't get the windows directory - error %ld\n", GetLastError() ); return FALSE; } if( res>=sizeof(ini_path) ) { WINE_ERR("Windows path too long (%ld)\n", res ); return FALSE; } sprintf( ini_path+res, "\\%s", RENAME_FILE ); hFile=CreateFileA(ini_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile==INVALID_HANDLE_VALUE ) { DWORD err=GetLastError(); if( err==ERROR_FILE_NOT_FOUND ) { /* No file - nothing to do. Great! */ WINE_TRACE("Wininit.ini not present - no renaming to do\n"); return TRUE; } sprintf(buffer, "There was an error in reading wininit.ini file - %ld\n", GetLastError() ); WINE_ERR( buffer ); return FALSE; } printf("Wine is finalizing your software installation. This may take a few minutes,\n"); printf("though it never actually does.\n"); WINE_TRACE("test\n"); while( GetLine( hFile, buffer, sizeof(buffer) ) && _stricmp(buffer,RENAME_FILE_SECTION)!=0 ) ; /* Read the lines until we match the rename section */ while( GetLine( hFile, buffer, sizeof(buffer) ) && buffer[0]!='[' ) { /* First, make sure this is not a comment */ if( buffer[0]!=';' && buffer[0]!='\0' ) { char * value; value=strchr(buffer, '='); if( value==NULL ) { WINE_WARN("Line with no \"=\" in it in wininit.ini - %s\n", buffer); } else { /* split the line into key and value */ *(value++)='\0'; printf("Key - %s\nValue - %s\n", buffer, value); if( _stricmp( "NUL", buffer )==0 ) { WINE_TRACE("Deleting file \"%s\"\n", value ); /* A file to delete */ if( !DeleteFileA( value ) ) WINE_WARN("Error deleting file \"%s\"\n", value); } else { WINE_TRACE("Renaming file \"%s\" to \"%s\"\n", value, buffer ); if( !MoveFileExA(value, buffer, MOVEFILE_COPY_ALLOWED| MOVEFILE_REPLACE_EXISTING) ) { WINE_WARN("Error renaming \"%s\" to \"%s\"\n", value, buffer ); } } } } } CloseHandle( hFile ); if( !DeleteFileA( ini_path ) ) { WINE_ERR("Couldn't erase %s, error %ld\n", ini_path, GetLastError() ); return FALSE; } return TRUE; } int main( int argc, char *argv[] ) { wininit(); return 0; }
Makefile wineboot wineboot.exe.dbg.c wineboot.exe.dbg.o wineboot.exe.so wineboot.exe.spec.c wineboot.exe.spec.o wineboot.o