Changeset 14803


Ignore:
Timestamp:
Sep 12, 2000, 6:27:45 AM (25 years ago)
Author:
bird
Message:

Added/extended some OSLib calls.

Location:
tags/trunk/src/kernel32
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/kernel32/oslibdos.cpp

    r14758 r14803  
    1 /* $Id: oslibdos.cpp,v 1.40 2000-09-04 18:24:42 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.41 2000-09-12 04:27:44 bird Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
    44 *
    55 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
    6  * Copyright 1999-2000 Edgar Buerkle <Edgar.Buerkle@gmx.net>
    7  * Copyright 2000 Przemyslaw Dobrowolski <dobrawka@asua.org.pl>
     6 * Copyright 1999-2000 Edgar Buerkle (Edgar.Buerkle@gmx.net)
     7 * Copyright 2000 Przemyslaw Dobrowolski (dobrawka@asua.org.pl)
    88 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
     9 * Copyright 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    910 *
    1011 * Project Odin Software License can be found in LICENSE.TXT
     
    4041//******************************************************************************
    4142void OSLibInitWSeBFileIO()
    42 { 
     43{
    4344 HMODULE hDoscalls;
    4445
     
    128129    case ERROR_BAD_FORMAT: //11
    129130        return ERROR_BAD_FORMAT_W;
    130  
     131
    131132    case ERROR_INVALID_ACCESS: //12
    132133        return ERROR_INVALID_ACCESS_W;
     
    522523 APIRET rc;
    523524
    524   switch(method) 
     525  switch(method)
    525526  {
    526527    case OSLIB_SETPTR_FILE_CURRENT:
     
    536537      return OSLIB_ERROR_INVALID_PARAMETER;
    537538  }
    538  
     539
    539540  rc = DosSetFilePtr(hFile, offset, os2method, &newoffset);
    540   if(rc) 
     541  if(rc)
    541542  {
    542543    SetLastError(error2WinError(rc));
     
    686687//******************************************************************************
    687688//******************************************************************************
    688 APIRET OSLibDosQueryPathInfo(PSZ   pszPathName,
    689                              ULONG ulInfoLevel,
    690                              PVOID pInfoBuf,
    691                              ULONG cbInfoBuf)
     689DWORD OSLibDosQueryPathInfo(CHAR *pszPathName,
     690                            ULONG ulInfoLevel,
     691                            PVOID pInfoBuf,
     692                            ULONG cbInfoBuf)
    692693{
    693694   APIRET rc = DosQueryPathInfo( pszPathName, ulInfoLevel,
     
    764765   if((fuShare & (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W)) == 0 )
    765766        openMode |= OPEN_SHARE_DENYREADWRITE;
    766    else 
     767   else
    767768   if((fuShare & (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W)) == (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W))
    768769        openMode |= OPEN_SHARE_DENYNONE;
    769    else 
    770    if(fuShare & FILE_SHARE_READ_W)         
     770   else
     771   if(fuShare & FILE_SHARE_READ_W)
    771772        openMode |= OPEN_SHARE_DENYWRITE;
    772    else 
     773   else
    773774   if(fuShare & FILE_SHARE_WRITE_W)
    774775        openMode |= OPEN_SHARE_DENYREAD;
     
    776777   if(fuAccess == (GENERIC_READ_W | GENERIC_WRITE_W))
    777778        openMode |= OPEN_ACCESS_READWRITE;
    778    else 
    779    if(fuAccess & GENERIC_READ_W)           
     779   else
     780   if(fuAccess & GENERIC_READ_W)
    780781        openMode |= OPEN_ACCESS_READONLY;
    781782   else
     
    784785
    785786#if 0
    786    //SvL: Not true; verified in NT! (also messed up access of files on 
     787   //SvL: Not true; verified in NT! (also messed up access of files on
    787788   //     readonly volumes)
    788789   //     CreateFile with OPEN_ALWAYS & GENERIC_READ on non-existing file
     
    798799
    799800   int retry = 0;
    800    while(retry < 2) 
     801   while(retry < 2)
    801802   {
    802803        dprintf(("DosOpen %s openFlag=%x openMode=%x", lpszFile, openFlag, openMode));
     
    809810                      openMode,
    810811                      NULL);
    811         if(rc == ERROR_TOO_MANY_OPEN_FILES) 
     812        if(rc == ERROR_TOO_MANY_OPEN_FILES)
    812813        {
    813814          ULONG CurMaxFH;
     
    861862        if(fuMode & OF_READWRITE_W)
    862863                openMode |= OPEN_ACCESS_READWRITE;
    863         else 
     864        else
    864865        if(fuMode & OF_WRITE_W)
    865866                openMode |= OPEN_ACCESS_WRITEONLY;
    866         else 
     867        else
    867868        if(fuMode & OF_CREATE_W)
    868869                openMode |= OPEN_ACCESS_READWRITE;
     
    872873      !(fuMode & (OF_SHARE_DENY_READ_W | OF_SHARE_DENY_NONE_W | OF_SHARE_EXCLUSIVE_W)))
    873874        openMode |= OPEN_SHARE_DENYWRITE;
    874    else 
     875   else
    875876   if (fuMode & OF_SHARE_DENY_NONE_W)
    876877        openMode |= OPEN_SHARE_DENYNONE;
    877    else 
     878   else
    878879   if (fuMode & OF_SHARE_DENY_READ_W)
    879880        openMode |= OPEN_SHARE_DENYREAD;
    880    else 
     881   else
    881882   if (fuMode & OF_SHARE_EXCLUSIVE_W)
    882883        openMode |= OPEN_SHARE_DENYREADWRITE;
     
    904905        {
    905906                SetLastError(ERROR_FILE_NOT_FOUND_W);
    906         } 
     907        }
    907908        else    SetLastError(error2WinError(rc));
    908909
     
    928929   }
    929930   //TODO: Locking region crossing end of file is permitted. Works in OS/2??
    930    if(f64BitIO) 
     931   if(f64BitIO)
    931932   {
    932933    FILELOCKL lockRangeL;
     
    937938        lockRangeL.lRange.ulHi  = nNumberOfBytesToLockHigh;
    938939
    939         rc = OdinDosSetFileLocksL(hFile, NULL, &lockRangeL, 
     940        rc = OdinDosSetFileLocksL(hFile, NULL, &lockRangeL,
    940941                                  (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0);
    941942        //SvL: 64 bits values are only supported by JFS
     
    946947        }
    947948   }
    948    else 
     949   else
    949950   {
    950951oldlock:
    951952    FILELOCK lockRange = { OffsetLow, nNumberOfBytesToLockLow };
    952953
    953         rc = DosSetFileLocks(hFile, NULL, &lockRange, 
     954        rc = DosSetFileLocks(hFile, NULL, &lockRange,
    954955                             (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0);
    955956   }
     
    975976        dprintf(("OSLibDosUnlockFile: overlapped unlock not yet implemented!!"));
    976977   }
    977    if(f64BitIO) 
     978   if(f64BitIO)
    978979   {
    979980    FILELOCKL unlockRangeL;
     
    992993        }
    993994   }
    994    else 
     995   else
    995996   {
    996997oldlock:
     
    10111012{
    10121013  APIRET   rc;
    1013  
     1014
    10141015   rc = DosResetBuffer(hFile);
    10151016   SetLastError(error2WinError(rc));
     
    10221023 APIRET rc;
    10231024 ULONG  sizeLow;
    1024  
    1025    if(f64BitIO) 
     1025
     1026   if(f64BitIO)
    10261027   {
    10271028     FILESTATUS3L fsts3ConfigInfoL = {{0}};
     
    10341035        sizeLow = fsts3ConfigInfoL.cbFile.ulLo;
    10351036   }
    1036    else 
     1037   else
    10371038   {
    10381039     FILESTATUS3 fsts3ConfigInfo = {{0}};
     
    10611062  DWORD    newoffset;
    10621063
    1063   switch(method) 
     1064  switch(method)
    10641065  {
    10651066    case FILE_BEGIN_W:
    10661067      method = FILE_BEGIN;
    10671068      break;
    1068  
     1069
    10691070    case FILE_CURRENT_W:
    10701071      method = FILE_CURRENT;
    10711072      break;
    1072  
     1073
    10731074    case FILE_END_W:
    10741075      method = FILE_END;
    10751076      break;
    10761077  }
    1077  
     1078
    10781079  // PH Note: for a negative 32-bit seek, the OS/2 64-bit version
    10791080  // needs to be skipped.
     
    10881089        newoffset = newoffsetL.ulLo;
    10891090   }
    1090   else 
     1091  else
    10911092    rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset);
    1092  
    1093   if(rc) 
     1093
     1094  if(rc)
    10941095  {
    10951096    SetLastError(error2WinError(rc));
     
    11071108 LONGLONG newFilePosL;
    11081109 APIRET   rc;
    1109  
     1110
    11101111   if(f64BitIO) {
    11111112        rc = OdinDosSetFilePtrL(hFile, FilePosL, FILE_CURRENT, &newFilePosL);
     
    11321133{
    11331134 APIRET       rc;
    1134  
    1135    if(f64BitIO) 
     1135
     1136   if(f64BitIO)
    11361137   {
    11371138     FILESTATUS4L statusL = { 0 };
     
    11411142                              &statusL,
    11421143                              sizeof(statusL));
    1143         if(rc == NO_ERROR) 
     1144        if(rc == NO_ERROR)
    11441145        {
    11451146                pInfo->dwFileAttributes = 0;
     
    11751176           }
    11761177   }
    1177    else 
     1178   else
    11781179   {
    11791180     FILESTATUS4  status  = { 0 };
     
    11831184                              &status,
    11841185                              sizeof(status));
    1185         if(rc == NO_ERROR) 
     1186        if(rc == NO_ERROR)
    11861187        {
    11871188                pInfo->dwFileAttributes = 0;
     
    12261227//******************************************************************************
    12271228//******************************************************************************
    1228 BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 
    1229                          WORD lastaccessdate, WORD lastaccesstime, 
     1229BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime,
     1230                         WORD lastaccessdate, WORD lastaccesstime,
    12301231                         WORD lastwritedate, WORD lastwritetime)
    12311232{
     
    12631264//******************************************************************************
    12641265//******************************************************************************
    1265 BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 
    1266                          WORD *lastaccessdate, WORD *lastaccesstime, 
     1266BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime,
     1267                         WORD *lastaccessdate, WORD *lastaccesstime,
    12671268                         WORD *lastwritedate, WORD *lastwritetime)
    12681269{
     
    18661867   DosError(FERR_DISABLEHARDERR);
    18671868   rc = DosQueryFSAttach(drv, 1, FSAIL_QUERYNAME, fsinfo, &cb);
    1868    DosError(FERR_ENABLEHARDERR); 
     1869   DosError(FERR_ENABLEHARDERR);
    18691870
    18701871   switch(rc) {
     
    18801881
    18811882   fsname = (char *)&fsinfo->szName[0] + fsinfo->cbName + 1;
    1882  
     1883
    18831884  /* @@@PH 2000/08/10 CMD.EXE querys with nFileSystemNameSize == 0
    18841885   * however does NOT expect to receive an error.
     
    18961897}
    18971898//******************************************************************************
    1898 typedef struct _FSINFOBUF 
     1899typedef struct _FSINFOBUF
    18991900{
    19001901        ULONG           ulVolser;          /* Volume serial number            */
     
    19021903} FSINFOBUF;
    19031904//******************************************************************************
    1904 DWORD OSLibDosQueryVolumeSerialAndName(int drive, LPDWORD lpVolumeSerialNumber, 
     1905DWORD OSLibDosQueryVolumeSerialAndName(int drive, LPDWORD lpVolumeSerialNumber,
    19051906                                       LPSTR lpVolumeNameBuffer, DWORD nVolumeNameSize)
    19061907{
     
    19261927         *lpVolumeSerialNumber = fsi.ulVolser;
    19271928   }
    1928    if(lpVolumeNameBuffer) 
     1929   if(lpVolumeNameBuffer)
    19291930   {
    19301931        if(nVolumeNameSize > fsi.vol.cch) {
     
    19481949   if(lpRootPathName == 0)
    19491950      diskNum = 0;
    1950    else 
     1951   else
    19511952   if('A' <= *lpRootPathName && *lpRootPathName <= 'Z' )
    19521953      diskNum = *lpRootPathName - 'A' + 1;
    1953    else 
     1954   else
    19541955   if('a' <= *lpRootPathName && *lpRootPathName <= 'z' )
    19551956      diskNum = *lpRootPathName - 'a' + 1;
     
    19861987           phfWrite,
    19871988           dwSize));
    1988  
     1989
    19891990  // select default buffer size
    19901991  if (dwSize == 0)
    19911992    dwSize = 4096;
    1992  
     1993
    19931994  rc = DosCreatePipe(phfRead,
    19941995                     phfWrite,
     
    20022003  return NO_ERROR;
    20032004}
     2005
     2006/**
     2007 * Pure wrapper for DosQueryModulName which returns the OS/2 returncode.
     2008 * @returns     Returncode from DosQueryModuleName.
     2009 * @param       hModule     Handle of the module which name we query.
     2010 * @param       cchName     Length of the output name buffer.
     2011 * @param       pszname     Pointer to the output name buffer.
     2012 * @status      Completely implemented.
     2013 * @author      knut st. osmundsen (knut.stange.osmundsen@mynd.no)
     2014 */
     2015ULONG OSLibDosQueryModuleName(ULONG hModule, int cchName, char *pszName)
     2016{
     2017    return DosQueryModuleName(hModule, cchName, pszName);
     2018}
     2019
     2020
  • TabularUnified tags/trunk/src/kernel32/oslibdos.h

    r14758 r14803  
    1 /* $Id: oslibdos.h,v 1.21 2000-09-04 18:24:43 sandervl Exp $ */
     1/* $Id: oslibdos.h,v 1.22 2000-09-12 04:27:45 bird Exp $ */
    22
    33/*
     
    8585DWORD OSLibDosSearchPath(DWORD cmd, char *path, char *name, char *full_name, DWORD length_fullname);
    8686
     87#ifndef FIL_QUERYFULLNAME
     88    #define FIL_QUERYFULLNAME  5
     89#else
     90    #if FIL_QUERYFULLNAME != 5
     91        #error "Hmm! FIL_QUERYFULLNAME isn't 5"
     92    #endif
     93#endif
     94
     95DWORD OSLibDosQueryPathInfo(CHAR *pszPathName,
     96                            ULONG ulInfoLevel,
     97                            PVOID pInfoBuf,
     98                            ULONG cbInfoBuf);
     99
    87100DWORD OSLibDosCreateFile(CHAR *lpFileName, DWORD dwAccess,
    88101                         DWORD dwShare, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
     
    109122BOOL  OSLibDosGetFileInformationByHandle(DWORD hFile, BY_HANDLE_FILE_INFORMATION* pHFI);
    110123
    111 BOOL  OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 
    112                           WORD lastaccessdate, WORD lastaccesstime, 
     124BOOL  OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime,
     125                          WORD lastaccessdate, WORD lastaccesstime,
    113126                          WORD lastwritedate, WORD lastwritetime);
    114127
    115 BOOL  OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 
    116                           WORD *lastaccessdate, WORD *lastaccesstime, 
     128BOOL  OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime,
     129                          WORD *lastaccessdate, WORD *lastaccesstime,
    117130                          WORD *lastwritedate, WORD *lastwritetime);
    118131
     
    264277
    265278#endif
     279
     280ULONG OSLibDosQueryModuleName(ULONG hModule, int cchName, char *pszName);
     281
     282
  • TabularUnified tags/trunk/src/kernel32/oslibmisc.cpp

    r14564 r14803  
    1 /* $Id: oslibmisc.cpp,v 1.10 2000-08-11 10:56:18 sandervl Exp $ */
     1/* $Id: oslibmisc.cpp,v 1.11 2000-09-12 04:27:45 bird Exp $ */
    22/*
    33 * Misc OS/2 util. procedures
     
    134134//******************************************************************************
    135135ULONG OSLibAllocSel(ULONG size, USHORT *selector)
    136 { 
     136{
    137137   return (Dos16AllocSeg(size, selector, SEG_NONSHARED) == 0);
    138138}
     
    174174   }
    175175}
    176 //******************************************************************************
    177 //Get PIB data
    178 //******************************************************************************
    179 ULONG OSLibGetPIB(int piboff)
    180 {
    181  PTIB   ptib;
    182  PPIB   ppib;
    183  APIRET rc;
    184 
    185    rc = DosGetInfoBlocks(&ptib, &ppib);
    186    if(rc) {
    187         return 0;
    188    }
    189    switch(piboff)
    190    {
    191         case PIB_TASKHNDL:
    192                 return ppib->pib_hmte;
    193         case PIB_TASKTYPE:
    194                 if(ppib->pib_ultype == 3) {
    195                         return TASKTYPE_PM;
    196                 }
    197                 else    return TASKTYPE_VIO;
    198         default:
    199                 return 0;
    200    }
     176
     177/**
     178 * Gets a PIB data.
     179 * @returns     Requested PIB data.
     180 *              0 may indicate error or that the PIB data you requested actually is 0.
     181 * @param       iPIB    PIB data index. (one of the PIB_* defines in oslibmisc.h)
     182 * @author
     183 * @remark      Spooky error handling.
     184 */
     185ULONG OSLibGetPIB(int iPIB)
     186{
     187     PTIB   ptib;
     188     PPIB   ppib;
     189     APIRET rc;
     190
     191    rc = DosGetInfoBlocks(&ptib, &ppib);
     192    if (rc)
     193    {
     194            dprintf(("KERNEL32: OSLibGetPIB(%d): DosGetInfoBlocks failed with rc=%d\n", iPIB, rc));
     195        return 0;
     196    }
     197
     198    switch(iPIB)
     199    {
     200    case PIB_TASKHNDL:
     201        return ppib->pib_hmte;
     202
     203    case PIB_TASKTYPE:
     204        return (ppib->pib_ultype == 3) ? TASKTYPE_PM : TASKTYPE_VIO;
     205
     206    case PIB_PCHCMD:
     207        return (ULONG)ppib->pib_pchcmd;
     208
     209    default:
     210        dprintf(("KERNEL32: OSLibGetPIB(%d): Invalid PIB data index\n.", iPIB));
     211        DebugInt3();
     212        return 0;
     213    }
    201214}
    202215//******************************************************************************
     
    221234  /* @@@PH what does this function do ? Strip the path from a FQFN name ? */
    222235  char *pszFilename;
    223  
     236
    224237  pszFilename = strrchr(path, '\\');                 /* find rightmost slash */
    225238  if (pszFilename != NULL)
    226239    return (++pszFilename);              /* return pointer to next character */
    227  
     240
    228241  pszFilename = strrchr(path, '/');                  /* find rightmost slash */
    229242  if (pszFilename != NULL)
    230243    return (++pszFilename);              /* return pointer to next character */
    231  
     244
    232245  return (path);                                     /* default return value */
    233246}
     
    255268 ULONG        ulInfoLen  = 0;
    256269 APIRET       rc         = NO_ERROR;  /* Return code                         */
    257  
     270
    258271    rc = DosQueryCtryInfo(sizeof(CtryInfo), &Country,
    259272                          &CtryInfo, &ulInfoLen);
    260  
     273
    261274    if (rc != NO_ERROR) {
    262275        return -1;
  • TabularUnified tags/trunk/src/kernel32/oslibmisc.h

    r14564 r14803  
    1 /* $Id: oslibmisc.h,v 1.6 2000-08-11 10:56:18 sandervl Exp $ */
     1/* $Id: oslibmisc.h,v 1.7 2000-09-12 04:27:45 bird Exp $ */
    22/*
    33 * Misc util. procedures
     
    3030ULONG OSLibGetTIB(int tiboff);
    3131
    32 #define PIB_TASKHNDL    0
     32#define PIB_HMTE        0
     33#define PIB_TASKHNDL    PIB_HMTE
    3334#define PIB_TASKTYPE    1
     35#define PIB_PCHCMD      2
    3436
    35 #define TASKTYPE_PM     0
    36 #define TASKTYPE_VIO    1
     37#define TASKTYPE_PM         0
     38#define TASKTYPE_VIO    1
    3739
    38 ULONG OSLibGetPIB(int piboff);
     40ULONG OSLibGetPIB(int iPIB);
    3941
    4042ULONG OSLibAllocThreadLocalMemory(int nrdwords);
Note: See TracChangeset for help on using the changeset viewer.