Ignore:
Timestamp:
Dec 9, 2000, 8:19:42 PM (25 years ago)
Author:
umoeller
Message:

Major updates; timers, LVM, miscellaneous.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dosh2.c

    r8 r14  
    3030 *      This file Copyright (C) 1997-2000 Ulrich M”ller,
    3131 *                                        Dmitry A. Steklenev.
    32  *      This file is part of the XWorkplace source package.
    33  *      XWorkplace is free software; you can redistribute it and/or modify
     32 *      This file is part of the "XWorkplace helpers" source package.
     33 *      This is free software; you can redistribute it and/or modify
    3434 *      it under the terms of the GNU General Public License as published
    3535 *      by the Free Software Foundation, in version 2 as it comes in the
     
    4646    // as unsigned char
    4747
     48#define INCL_DOSMODULEMGR
     49#define INCL_DOSPROCESS
     50#define INCL_DOSSESMGR
     51#define INCL_DOSQUEUES
     52#define INCL_DOSMISC
     53#define INCL_DOSDEVICES
    4854#define INCL_DOSDEVIOCTL
    49 #define INCL_DOS
    5055#define INCL_DOSERRORS
    51 // #define INCL_GPI
    5256#include <os2.h>
     57
    5358#include <stdlib.h>
    5459#include <string.h>
     
    6873
    6974/* ******************************************************************
    70  *                                                                  *
    71  *   Miscellaneous                                                  *
    72  *                                                                  *
     75 *
     76 *   Miscellaneous
     77 *
    7378 ********************************************************************/
    7479
     
    109114                           BOOL fFullyQualified)    // in: if TRUE, pcszFile must be fully q'fied
    110115{
     116    APIRET  arc = NO_ERROR;
    111117    CHAR    szPath[CCHMAXPATH+4] = " :";
    112118    CHAR    szComponent[CCHMAXPATH];
     
    120126             || (*(pcszFile + 2) != '\\')
    121127           )
    122             return (ERROR_CURRENT_DIRECTORY);
     128            arc = ERROR_CURRENT_DIRECTORY;
    123129    }
    124130
     
    127133    {
    128134        CHAR cDrive = toupper(*pcszFile);
     135        double d;
    129136        // drive specified:
    130137        strcpy(szPath, pcszFile);
    131138        szPath[0] = toupper(*pcszFile);
    132         if (doshQueryDiskFree(cDrive - 'A' + 1) == -1)
    133             return (ERROR_INVALID_DRIVE);
     139        arc = doshQueryDiskFree(cDrive - 'A' + 1, &d);
    134140    }
    135141    else
     
    138144        ULONG   ulDriveNum = 0,
    139145                ulDriveMap = 0;
    140         DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
     146        arc = DosQueryCurrentDisk(&ulDriveNum, &ulDriveMap);
    141147        szPath[0] = ((UCHAR)ulDriveNum) + 'A' - 1;
    142148        szPath[1] = ':';
     
    144150    }
    145151
    146     fIsFAT = doshIsFileOnFAT(szPath);
    147 
    148     pszInvalid = (fIsFAT)
    149                     ? "<>|+=:;,\"/[] "  // invalid characters in FAT
    150                     : "<>|:\"/";        // invalid characters in IFS's
    151 
    152     // now separate path components
    153     p1 = &szPath[2];       // advance past ':'
    154 
    155     do {
    156 
    157         if (*p1 == '\\')
    158             p1++;
    159 
    160         p2 = strchr(p1, '\\');
    161         if (p2 == NULL)
    162             p2 = p1 + strlen(p1);
    163 
    164         if (p1 != p2)
    165         {
    166             LONG    lDotOfs = -1,
    167                     lAfterDot = -1;
    168             ULONG   cbFile,
    169                     ul;
    170             PSZ     pSource = szComponent;
    171 
    172             strncpy(szComponent, p1, p2-p1);
    173             szComponent[p2-p1] = 0;
    174             cbFile = strlen(szComponent);
    175 
    176             // now check each path component
    177             for (ul = 0; ul < cbFile; ul++)
     152    if (arc == NO_ERROR)
     153    {
     154        fIsFAT = doshIsFileOnFAT(szPath);
     155
     156        pszInvalid = (fIsFAT)
     157                        ? "<>|+=:;,\"/[] "  // invalid characters in FAT
     158                        : "<>|:\"/";        // invalid characters in IFS's
     159
     160        // now separate path components
     161        p1 = &szPath[2];       // advance past ':'
     162
     163        do {
     164
     165            if (*p1 == '\\')
     166                p1++;
     167
     168            p2 = strchr(p1, '\\');
     169            if (p2 == NULL)
     170                p2 = p1 + strlen(p1);
     171
     172            if (p1 != p2)
    178173            {
     174                LONG    lDotOfs = -1,
     175                        lAfterDot = -1;
     176                ULONG   cbFile,
     177                        ul;
     178                PSZ     pSource = szComponent;
     179
     180                strncpy(szComponent, p1, p2-p1);
     181                szComponent[p2-p1] = 0;
     182                cbFile = strlen(szComponent);
     183
     184                // now check each path component
     185                for (ul = 0; ul < cbFile; ul++)
     186                {
     187                    if (fIsFAT)
     188                    {
     189                        // on FAT: only 8 characters allowed before dot
     190                        if (*pSource == '.')
     191                        {
     192                            lDotOfs = ul;
     193                            lAfterDot = 0;
     194                            if (ul > 7)
     195                                return (ERROR_FILENAME_EXCED_RANGE);
     196                        }
     197                    }
     198                    // and check for invalid characters
     199                    if (strchr(pszInvalid, *pSource) != NULL)
     200                        return (ERROR_INVALID_NAME);
     201
     202                    pSource++;
     203
     204                    // on FAT, allow only three chars after dot
     205                    if (fIsFAT)
     206                        if (lAfterDot != -1)
     207                        {
     208                            lAfterDot++;
     209                            if (lAfterDot > 3)
     210                                return (ERROR_FILENAME_EXCED_RANGE);
     211                        }
     212                }
     213
     214                // we are still missing the case of a FAT file
     215                // name without extension; if so, check whether
     216                // the file stem is <= 8 chars
    179217                if (fIsFAT)
    180                 {
    181                     // on FAT: only 8 characters allowed before dot
    182                     if (*pSource == '.')
    183                     {
    184                         lDotOfs = ul;
    185                         lAfterDot = 0;
    186                         if (ul > 7)
     218                    if (lDotOfs == -1)  // dot not found:
     219                        if (cbFile > 8)
    187220                            return (ERROR_FILENAME_EXCED_RANGE);
    188                     }
    189                 }
    190                 // and check for invalid characters
    191                 if (strchr(pszInvalid, *pSource) != NULL)
    192                     return (ERROR_INVALID_NAME);
    193 
    194                 pSource++;
    195 
    196                 // on FAT, allow only three chars after dot
    197                 if (fIsFAT)
    198                     if (lAfterDot != -1)
    199                     {
    200                         lAfterDot++;
    201                         if (lAfterDot > 3)
    202                             return(ERROR_FILENAME_EXCED_RANGE);
    203                     }
    204221            }
    205222
    206             // we are still missing the case of a FAT file
    207             // name without extension; if so, check whether
    208             // the file stem is <= 8 chars
    209             if (fIsFAT)
    210                 if (lDotOfs == -1)  // dot not found:
    211                     if (cbFile > 8)
    212                         return (ERROR_FILENAME_EXCED_RANGE);
    213         }
    214 
    215         // go for next component
    216         p1 = p2+1;
    217     } while (*p2);
    218 
    219     return (NO_ERROR);
     223            // go for next component
     224            p1 = p2+1;
     225        } while (*p2);
     226    }
     227
     228    return (arc);
    220229}
    221230
     
    340349
    341350/* ******************************************************************
    342  *                                                                  *
    343  *   Environment helpers                                            *
    344  *                                                                  *
     351 *
     352 *   Environment helpers
     353 *
    345354 ********************************************************************/
    346355
     
    716725
    717726/* ******************************************************************
    718  *                                                                  *
    719  *   Module handling helpers                                        *
    720  *                                                                  *
     727 *
     728 *   Module handling helpers
     729 *
    721730 ********************************************************************/
    722731
     
    773782
    774783/********************************************************************
    775  *                                                                  *
    776  *   Executable functions                                           *
    777  *                                                                  *
     784 *
     785 *   Executable functions
     786 *
    778787 ********************************************************************/
    779788
     
    12191228
    12201229/********************************************************************
    1221  *                                                                  *
    1222  *   Partition functions                                            *
    1223  *                                                                  *
     1230 *
     1231 *   Partition functions
     1232 *
    12241233 ********************************************************************/
    12251234
Note: See TracChangeset for help on using the changeset viewer.