Index: trunk/src/kernel32/oslibdos.cpp
===================================================================
--- trunk/src/kernel32/oslibdos.cpp	(revision 4231)
+++ trunk/src/kernel32/oslibdos.cpp	(revision 4235)
@@ -1,10 +1,11 @@
-/* $Id: oslibdos.cpp,v 1.40 2000-09-04 18:24:42 sandervl Exp $ */
+/* $Id: oslibdos.cpp,v 1.41 2000-09-12 04:27:44 bird Exp $ */
 /*
  * Wrappers for OS/2 Dos* API
  *
  * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
- * Copyright 1999-2000 Edgar Buerkle <Edgar.Buerkle@gmx.net>
- * Copyright 2000 Przemyslaw Dobrowolski <dobrawka@asua.org.pl>
+ * Copyright 1999-2000 Edgar Buerkle (Edgar.Buerkle@gmx.net)
+ * Copyright 2000 Przemyslaw Dobrowolski (dobrawka@asua.org.pl)
  * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
+ * Copyright 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
  *
  * Project Odin Software License can be found in LICENSE.TXT
@@ -40,5 +41,5 @@
 //******************************************************************************
 void OSLibInitWSeBFileIO()
-{ 
+{
  HMODULE hDoscalls;
 
@@ -128,5 +129,5 @@
     case ERROR_BAD_FORMAT: //11
       	return ERROR_BAD_FORMAT_W;
- 
+
     case ERROR_INVALID_ACCESS: //12
      	return ERROR_INVALID_ACCESS_W;
@@ -522,5 +523,5 @@
  APIRET rc;
 
-  switch(method) 
+  switch(method)
   {
     case OSLIB_SETPTR_FILE_CURRENT:
@@ -536,7 +537,7 @@
       return OSLIB_ERROR_INVALID_PARAMETER;
   }
-  
+
   rc = DosSetFilePtr(hFile, offset, os2method, &newoffset);
-  if(rc) 
+  if(rc)
   {
     SetLastError(error2WinError(rc));
@@ -686,8 +687,8 @@
 //******************************************************************************
 //******************************************************************************
-APIRET OSLibDosQueryPathInfo(PSZ   pszPathName,
-                             ULONG ulInfoLevel,
-                             PVOID pInfoBuf,
-                             ULONG cbInfoBuf)
+DWORD OSLibDosQueryPathInfo(CHAR *pszPathName,
+                            ULONG ulInfoLevel,
+                            PVOID pInfoBuf,
+                            ULONG cbInfoBuf)
 {
    APIRET rc = DosQueryPathInfo( pszPathName, ulInfoLevel,
@@ -764,11 +765,11 @@
    if((fuShare & (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W)) == 0 )
 	openMode |= OPEN_SHARE_DENYREADWRITE;
-   else 
+   else
    if((fuShare & (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W)) == (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W))
       	openMode |= OPEN_SHARE_DENYNONE;
-   else 
-   if(fuShare & FILE_SHARE_READ_W)          
+   else
+   if(fuShare & FILE_SHARE_READ_W)
         openMode |= OPEN_SHARE_DENYWRITE;
-   else 
+   else
    if(fuShare & FILE_SHARE_WRITE_W)
  	openMode |= OPEN_SHARE_DENYREAD;
@@ -776,6 +777,6 @@
    if(fuAccess == (GENERIC_READ_W | GENERIC_WRITE_W))
 	openMode |= OPEN_ACCESS_READWRITE;
-   else 
-   if(fuAccess & GENERIC_READ_W)            
+   else
+   if(fuAccess & GENERIC_READ_W)
 	openMode |= OPEN_ACCESS_READONLY;
    else
@@ -784,5 +785,5 @@
 
 #if 0
-   //SvL: Not true; verified in NT! (also messed up access of files on 
+   //SvL: Not true; verified in NT! (also messed up access of files on
    //     readonly volumes)
    //     CreateFile with OPEN_ALWAYS & GENERIC_READ on non-existing file
@@ -798,5 +799,5 @@
 
    int retry = 0;
-   while(retry < 2) 
+   while(retry < 2)
    {
         dprintf(("DosOpen %s openFlag=%x openMode=%x", lpszFile, openFlag, openMode));
@@ -809,5 +810,5 @@
                       openMode,
                       NULL);
-  	if(rc == ERROR_TOO_MANY_OPEN_FILES) 
+  	if(rc == ERROR_TOO_MANY_OPEN_FILES)
         {
    	  ULONG CurMaxFH;
@@ -861,8 +862,8 @@
        	if(fuMode & OF_READWRITE_W)
           	openMode |= OPEN_ACCESS_READWRITE;
-       	else 
+       	else
 	if(fuMode & OF_WRITE_W)
           	openMode |= OPEN_ACCESS_WRITEONLY;
-       	else 
+       	else
 	if(fuMode & OF_CREATE_W)
           	openMode |= OPEN_ACCESS_READWRITE;
@@ -872,11 +873,11 @@
       !(fuMode & (OF_SHARE_DENY_READ_W | OF_SHARE_DENY_NONE_W | OF_SHARE_EXCLUSIVE_W)))
       	openMode |= OPEN_SHARE_DENYWRITE;
-   else 
+   else
    if (fuMode & OF_SHARE_DENY_NONE_W)
       	openMode |= OPEN_SHARE_DENYNONE;
-   else 
+   else
    if (fuMode & OF_SHARE_DENY_READ_W)
       	openMode |= OPEN_SHARE_DENYREAD;
-   else 
+   else
    if (fuMode & OF_SHARE_EXCLUSIVE_W)
       	openMode |= OPEN_SHARE_DENYREADWRITE;
@@ -904,5 +905,5 @@
       	{
           	SetLastError(ERROR_FILE_NOT_FOUND_W);
-      	} 
+      	}
       	else    SetLastError(error2WinError(rc));
 
@@ -928,5 +929,5 @@
    }
    //TODO: Locking region crossing end of file is permitted. Works in OS/2??
-   if(f64BitIO) 
+   if(f64BitIO)
    {
     FILELOCKL lockRangeL;
@@ -937,5 +938,5 @@
  	lockRangeL.lRange.ulHi  = nNumberOfBytesToLockHigh;
 
-   	rc = OdinDosSetFileLocksL(hFile, NULL, &lockRangeL, 
+   	rc = OdinDosSetFileLocksL(hFile, NULL, &lockRangeL,
                                   (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0);
         //SvL: 64 bits values are only supported by JFS
@@ -946,10 +947,10 @@
         }
    }
-   else 
+   else
    {
 oldlock:
     FILELOCK lockRange = { OffsetLow, nNumberOfBytesToLockLow };
 
-   	rc = DosSetFileLocks(hFile, NULL, &lockRange, 
+   	rc = DosSetFileLocks(hFile, NULL, &lockRange,
                              (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0);
    }
@@ -975,5 +976,5 @@
 	dprintf(("OSLibDosUnlockFile: overlapped unlock not yet implemented!!"));
    }
-   if(f64BitIO) 
+   if(f64BitIO)
    {
     FILELOCKL unlockRangeL;
@@ -992,5 +993,5 @@
         }
    }
-   else 
+   else
    {
 oldlock:
@@ -1011,5 +1012,5 @@
 {
   APIRET   rc;
-  
+
    rc = DosResetBuffer(hFile);
    SetLastError(error2WinError(rc));
@@ -1022,6 +1023,6 @@
  APIRET rc;
  ULONG  sizeLow;
-  
-   if(f64BitIO) 
+
+   if(f64BitIO)
    {
      FILESTATUS3L fsts3ConfigInfoL = {{0}};
@@ -1034,5 +1035,5 @@
 	sizeLow = fsts3ConfigInfoL.cbFile.ulLo;
    }
-   else 
+   else
    {
      FILESTATUS3 fsts3ConfigInfo = {{0}};
@@ -1061,19 +1062,19 @@
   DWORD    newoffset;
 
-  switch(method) 
+  switch(method)
   {
     case FILE_BEGIN_W:
       method = FILE_BEGIN;
       break;
-  
+
     case FILE_CURRENT_W:
       method = FILE_CURRENT;
       break;
-  
+
     case FILE_END_W:
       method = FILE_END;
       break;
   }
-  
+
   // PH Note: for a negative 32-bit seek, the OS/2 64-bit version
   // needs to be skipped.
@@ -1088,8 +1089,8 @@
 	newoffset = newoffsetL.ulLo;
    }
-  else 
+  else
     rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset);
-  
-  if(rc) 
+
+  if(rc)
   {
     SetLastError(error2WinError(rc));
@@ -1107,5 +1108,5 @@
  LONGLONG newFilePosL;
  APIRET   rc;
- 
+
    if(f64BitIO) {
 	rc = OdinDosSetFilePtrL(hFile, FilePosL, FILE_CURRENT, &newFilePosL);
@@ -1132,6 +1133,6 @@
 {
  APIRET       rc;
- 
-   if(f64BitIO) 
+
+   if(f64BitIO)
    {
      FILESTATUS4L statusL = { 0 };
@@ -1141,5 +1142,5 @@
                 	      &statusL,
                               sizeof(statusL));
-   	if(rc == NO_ERROR) 
+   	if(rc == NO_ERROR)
    	{
 	  	pInfo->dwFileAttributes = 0;
@@ -1175,5 +1176,5 @@
 	   }
    }
-   else 
+   else
    {
      FILESTATUS4  status  = { 0 };
@@ -1183,5 +1184,5 @@
                 	      &status,
                               sizeof(status));
-   	if(rc == NO_ERROR) 
+   	if(rc == NO_ERROR)
    	{
 	  	pInfo->dwFileAttributes = 0;
@@ -1226,6 +1227,6 @@
 //******************************************************************************
 //******************************************************************************
-BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 
-                         WORD lastaccessdate, WORD lastaccesstime, 
+BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime,
+                         WORD lastaccessdate, WORD lastaccesstime,
                          WORD lastwritedate, WORD lastwritetime)
 {
@@ -1263,6 +1264,6 @@
 //******************************************************************************
 //******************************************************************************
-BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 
-                         WORD *lastaccessdate, WORD *lastaccesstime, 
+BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime,
+                         WORD *lastaccessdate, WORD *lastaccesstime,
                          WORD *lastwritedate, WORD *lastwritetime)
 {
@@ -1866,5 +1867,5 @@
    DosError(FERR_DISABLEHARDERR);
    rc = DosQueryFSAttach(drv, 1, FSAIL_QUERYNAME, fsinfo, &cb);
-   DosError(FERR_ENABLEHARDERR); 
+   DosError(FERR_ENABLEHARDERR);
 
    switch(rc) {
@@ -1880,5 +1881,5 @@
 
    fsname = (char *)&fsinfo->szName[0] + fsinfo->cbName + 1;
-  
+
   /* @@@PH 2000/08/10 CMD.EXE querys with nFileSystemNameSize == 0
    * however does NOT expect to receive an error.
@@ -1896,5 +1897,5 @@
 }
 //******************************************************************************
-typedef struct _FSINFOBUF 
+typedef struct _FSINFOBUF
 {
 	ULONG 		ulVolser;          /* Volume serial number            */
@@ -1902,5 +1903,5 @@
 } FSINFOBUF;
 //******************************************************************************
-DWORD OSLibDosQueryVolumeSerialAndName(int drive, LPDWORD lpVolumeSerialNumber, 
+DWORD OSLibDosQueryVolumeSerialAndName(int drive, LPDWORD lpVolumeSerialNumber,
                                        LPSTR lpVolumeNameBuffer, DWORD nVolumeNameSize)
 {
@@ -1926,5 +1927,5 @@
          *lpVolumeSerialNumber = fsi.ulVolser;
    }
-   if(lpVolumeNameBuffer) 
+   if(lpVolumeNameBuffer)
    {
    	if(nVolumeNameSize > fsi.vol.cch) {
@@ -1948,8 +1949,8 @@
    if(lpRootPathName == 0)
       diskNum = 0;
-   else 
+   else
    if('A' <= *lpRootPathName && *lpRootPathName <= 'Z' )
       diskNum = *lpRootPathName - 'A' + 1;
-   else 
+   else
    if('a' <= *lpRootPathName && *lpRootPathName <= 'z' )
       diskNum = *lpRootPathName - 'a' + 1;
@@ -1986,9 +1987,9 @@
            phfWrite,
            dwSize));
-  
+
   // select default buffer size
   if (dwSize == 0)
     dwSize = 4096;
-  
+
   rc = DosCreatePipe(phfRead,
                      phfWrite,
@@ -2002,2 +2003,18 @@
   return NO_ERROR;
 }
+
+/**
+ * Pure wrapper for DosQueryModulName which returns the OS/2 returncode.
+ * @returns     Returncode from DosQueryModuleName.
+ * @param       hModule     Handle of the module which name we query.
+ * @param       cchName     Length of the output name buffer.
+ * @param       pszname     Pointer to the output name buffer.
+ * @status      Completely implemented.
+ * @author      knut st. osmundsen (knut.stange.osmundsen@mynd.no)
+ */
+ULONG OSLibDosQueryModuleName(ULONG hModule, int cchName, char *pszName)
+{
+    return DosQueryModuleName(hModule, cchName, pszName);
+}
+
+
Index: trunk/src/kernel32/oslibdos.h
===================================================================
--- trunk/src/kernel32/oslibdos.h	(revision 4231)
+++ trunk/src/kernel32/oslibdos.h	(revision 4235)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.h,v 1.21 2000-09-04 18:24:43 sandervl Exp $ */
+/* $Id: oslibdos.h,v 1.22 2000-09-12 04:27:45 bird Exp $ */
 
 /*
@@ -85,4 +85,17 @@
 DWORD OSLibDosSearchPath(DWORD cmd, char *path, char *name, char *full_name, DWORD length_fullname);
 
+#ifndef FIL_QUERYFULLNAME
+    #define FIL_QUERYFULLNAME  5
+#else
+    #if FIL_QUERYFULLNAME != 5
+        #error "Hmm! FIL_QUERYFULLNAME isn't 5"
+    #endif
+#endif
+
+DWORD OSLibDosQueryPathInfo(CHAR *pszPathName,
+                            ULONG ulInfoLevel,
+                            PVOID pInfoBuf,
+                            ULONG cbInfoBuf);
+
 DWORD OSLibDosCreateFile(CHAR *lpFileName, DWORD dwAccess,
                          DWORD dwShare, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
@@ -109,10 +122,10 @@
 BOOL  OSLibDosGetFileInformationByHandle(DWORD hFile, BY_HANDLE_FILE_INFORMATION* pHFI);
 
-BOOL  OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 
-                          WORD lastaccessdate, WORD lastaccesstime, 
+BOOL  OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime,
+                          WORD lastaccessdate, WORD lastaccesstime,
                           WORD lastwritedate, WORD lastwritetime);
 
-BOOL  OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 
-                          WORD *lastaccessdate, WORD *lastaccesstime, 
+BOOL  OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime,
+                          WORD *lastaccessdate, WORD *lastaccesstime,
                           WORD *lastwritedate, WORD *lastwritetime);
 
@@ -264,2 +277,6 @@
 
 #endif
+
+ULONG OSLibDosQueryModuleName(ULONG hModule, int cchName, char *pszName);
+
+
Index: trunk/src/kernel32/oslibmisc.cpp
===================================================================
--- trunk/src/kernel32/oslibmisc.cpp	(revision 4231)
+++ trunk/src/kernel32/oslibmisc.cpp	(revision 4235)
@@ -1,3 +1,3 @@
-/* $Id: oslibmisc.cpp,v 1.10 2000-08-11 10:56:18 sandervl Exp $ */
+/* $Id: oslibmisc.cpp,v 1.11 2000-09-12 04:27:45 bird Exp $ */
 /*
  * Misc OS/2 util. procedures
@@ -134,5 +134,5 @@
 //******************************************************************************
 ULONG OSLibAllocSel(ULONG size, USHORT *selector)
-{ 
+{
    return (Dos16AllocSeg(size, selector, SEG_NONSHARED) == 0);
 }
@@ -174,29 +174,42 @@
    }
 }
-//******************************************************************************
-//Get PIB data
-//******************************************************************************
-ULONG OSLibGetPIB(int piboff)
-{
- PTIB   ptib;
- PPIB   ppib;
- APIRET rc;
-
-   rc = DosGetInfoBlocks(&ptib, &ppib);
-   if(rc) {
-	return 0;
-   }
-   switch(piboff) 
-   {
-   	case PIB_TASKHNDL:
-		return ppib->pib_hmte;
-	case PIB_TASKTYPE:
-		if(ppib->pib_ultype == 3) {
-			return TASKTYPE_PM;
-		}
-		else	return TASKTYPE_VIO;
-	default: 
-		return 0;
-   }
+
+/**
+ * Gets a PIB data.
+ * @returns     Requested PIB data.
+ *              0 may indicate error or that the PIB data you requested actually is 0.
+ * @param       iPIB    PIB data index. (one of the PIB_* defines in oslibmisc.h)
+ * @author
+ * @remark      Spooky error handling.
+ */
+ULONG OSLibGetPIB(int iPIB)
+{
+     PTIB   ptib;
+     PPIB   ppib;
+     APIRET rc;
+
+    rc = DosGetInfoBlocks(&ptib, &ppib);
+    if (rc)
+    {
+	    dprintf(("KERNEL32: OSLibGetPIB(%d): DosGetInfoBlocks failed with rc=%d\n", iPIB, rc));
+        return 0;
+    }
+
+    switch(iPIB)
+    {
+    case PIB_TASKHNDL:
+        return ppib->pib_hmte;
+
+    case PIB_TASKTYPE:
+        return (ppib->pib_ultype == 3) ? TASKTYPE_PM : TASKTYPE_VIO;
+
+    case PIB_PCHCMD:
+        return (ULONG)ppib->pib_pchcmd;
+
+    default:
+        dprintf(("KERNEL32: OSLibGetPIB(%d): Invalid PIB data index\n.", iPIB));
+        DebugInt3();
+        return 0;
+    }
 }
 //******************************************************************************
@@ -221,13 +234,13 @@
   /* @@@PH what does this function do ? Strip the path from a FQFN name ? */
   char *pszFilename;
-  
+
   pszFilename = strrchr(path, '\\');                 /* find rightmost slash */
   if (pszFilename != NULL)
     return (++pszFilename);              /* return pointer to next character */
-  
+
   pszFilename = strrchr(path, '/');                  /* find rightmost slash */
   if (pszFilename != NULL)
     return (++pszFilename);              /* return pointer to next character */
-  
+
   return (path);                                     /* default return value */
 }
@@ -255,8 +268,8 @@
  ULONG        ulInfoLen  = 0;
  APIRET       rc         = NO_ERROR;  /* Return code                         */
- 
+
     rc = DosQueryCtryInfo(sizeof(CtryInfo), &Country,
                           &CtryInfo, &ulInfoLen);
- 
+
     if (rc != NO_ERROR) {
         return -1;
Index: trunk/src/kernel32/oslibmisc.h
===================================================================
--- trunk/src/kernel32/oslibmisc.h	(revision 4231)
+++ trunk/src/kernel32/oslibmisc.h	(revision 4235)
@@ -1,3 +1,3 @@
-/* $Id: oslibmisc.h,v 1.6 2000-08-11 10:56:18 sandervl Exp $ */
+/* $Id: oslibmisc.h,v 1.7 2000-09-12 04:27:45 bird Exp $ */
 /*
  * Misc util. procedures
@@ -30,11 +30,13 @@
 ULONG OSLibGetTIB(int tiboff);
 
-#define PIB_TASKHNDL	0
+#define PIB_HMTE        0
+#define PIB_TASKHNDL	PIB_HMTE
 #define PIB_TASKTYPE    1
+#define PIB_PCHCMD      2
 
-#define TASKTYPE_PM	0
-#define TASKTYPE_VIO	1
+#define TASKTYPE_PM	    0
+#define TASKTYPE_VIO    1
 
-ULONG OSLibGetPIB(int piboff);
+ULONG OSLibGetPIB(int iPIB);
 
 ULONG OSLibAllocThreadLocalMemory(int nrdwords);
