Changeset 1398 for trunk/dll/pathutil.c


Ignore:
Timestamp:
Feb 21, 2009, 6:43:00 PM (16 years ago)
Author:
Gregg Young
Message:

Move embeded strings to PCSZ variables or string table; Eliminate Error2 functions Runtime_Error with NULL format string returns "No data" error. Change declares from PSZ to PCSZ in functions where the variable isn't changed. Added btm as an executable file type in several additional places. Use fProtectOnly to prevent attempt to execute Dos and Win programs on "Protect only" installs in several additional places.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/pathutil.c

    r1394 r1398  
    3737#include "wrappers.h"                   // xmalloc
    3838#include "fortify.h"
     39#include "stristr.h"                    //stristr
    3940
    4041static PSZ pszSrcFile = __FILE__;
     
    5152 */
    5253
    53 PSZ BldFullPathName(PSZ pszFullPathName, PSZ pszPathName, PSZ pszFileName)
     54PSZ BldFullPathName(PSZ pszFullPathName, PCSZ pszPathName, PCSZ pszFileName)
    5455{
    5556  UINT c = pszPathName ? strlen(pszPathName) : 0;
     
    7071 */
    7172
    72 PSZ BldQuotedFullPathName(PSZ pszFullPathName, PSZ pszPathName, PSZ pszFileName)
     73PSZ BldQuotedFullPathName(PSZ pszFullPathName, PCSZ pszPathName, PCSZ pszFileName)
    7374{
    7475  UINT c = pszPathName ? strlen(pszPathName) : 0;
     
    146147  strcpy(szCmdLine, pszCmdLine_);
    147148  if (szCmdLine[0] != '\0') {
    148     offsetexe = strstr(strlwr(pszCmdLine_), ".exe");
    149     offsetcmd = strstr(strlwr(pszCmdLine_), ".cmd");
    150     offsetcom = strstr(strlwr(pszCmdLine_), ".com");
    151     offsetbtm = strstr(strlwr(pszCmdLine_), ".btm");
    152     offsetbat = strstr(strlwr(pszCmdLine_), ".bat");
     149    offsetexe = stristr(pszCmdLine_, PCSZ_DOTEXE);
     150    offsetcmd = stristr(pszCmdLine_, PCSZ_DOTCMD);
     151    offsetcom = stristr(pszCmdLine_, PCSZ_DOTCOM);
     152    offsetbtm = stristr(pszCmdLine_, PCSZ_DOTBTM);
     153    offsetbat = stristr(pszCmdLine_, PCSZ_DOTBAT);
    153154    if (offsetexe)
    154155      offset = offsetexe;
     
    184185               pszCmdLine_);
    185186      if (!offsetexe && !offsetcom) {
    186         FullPath = searchapath("PATH", szCmdLine);
     187        FullPath = searchapath(PCSZ_PATH, szCmdLine);
    187188        if (*FullPath)
    188189          ret = 0;
     
    224225        ret = DosQueryAppType(szCmdLine, &ulAppType); // exe automatically appended
    225226        if (!ret)
    226           strcat(szCmdLine, ".exe");
     227          strcat(szCmdLine, PCSZ_DOTEXE);
    227228        else {
    228           strcat(szCmdLine, ".com");
     229          strcat(szCmdLine, PCSZ_DOTCOM);
    229230          ret = DosQueryAppType(szCmdLine, &ulAppType);
    230231          if (ret) {
    231232            offset = strrchr(szCmdLine, '.' );
    232233            *offset = 0;
    233             strcat(szCmdLine, ".cmd");
    234             FullPath = searchapath("PATH", szCmdLine);
     234            strcat(szCmdLine, PCSZ_DOTCMD);
     235            FullPath = searchapath(PCSZ_PATH, szCmdLine);
    235236            if (*FullPath)
    236237              ret = 0;
    237238            else {
    238239              *offset = 0;
    239               strcat(szCmdLine, ".bat");
    240               FullPath = searchapath("PATH", szCmdLine);
     240              strcat(szCmdLine, PCSZ_DOTBAT);
     241              FullPath = searchapath(PCSZ_PATH, szCmdLine);
    241242              if (*FullPath)
    242243                ret = 0;
    243244              else {
    244245                *offset = 0;
    245                 strcat(szCmdLine, ".bmt");
    246                 FullPath = searchapath("PATH", szCmdLine);
     246                strcat(szCmdLine, PCSZ_DOTBTM);
     247                FullPath = searchapath(PCSZ_PATH, szCmdLine);
    247248                if (*FullPath)
    248249                  ret = 0;
     
    262263            ret = DosQueryAppType(szCmdLine, &ulAppType);
    263264            if (!ret) {
    264               strcat(szCmdLine, ".exe");
     265              strcat(szCmdLine, PCSZ_DOTEXE);
    265266              break;
    266267            }
    267268            else {
    268               strcat(szCmdLine, ".com");
     269              strcat(szCmdLine, PCSZ_DOTCOM);
    269270              ret = DosQueryAppType(szCmdLine, &ulAppType);
    270271              if (ret) {
    271272                offset = strrchr(szCmdLine, '.' );
    272273                *offset = 0;
    273                 strcat(szCmdLine, ".cmd");
    274                 FullPath = searchapath("PATH", szCmdLine);
     274                strcat(szCmdLine, PCSZ_DOTCMD);
     275                FullPath = searchapath(PCSZ_PATH, szCmdLine);
    275276                if (*FullPath) {
    276277                  ret = 0;
     
    279280                else {
    280281                  *offset = 0;
    281                   strcat(szCmdLine, ".bat");
    282                   FullPath = searchapath("PATH", szCmdLine);
     282                  strcat(szCmdLine, PCSZ_DOTBAT);
     283                  FullPath = searchapath(PCSZ_PATH, szCmdLine);
    283284                  if (*FullPath) {
    284285                    ret = 0;
     
    287288                  else {
    288289                    *offset = 0;
    289                     strcat(szCmdLine, ".bmt");
    290                     FullPath = searchapath("PATH", szCmdLine);
     290                    strcat(szCmdLine, PCSZ_DOTBTM);
     291                    FullPath = searchapath(PCSZ_PATH, szCmdLine);
    291292                    if (*FullPath) {
    292293                      ret = 0;
     
    349350             GetPString(IDS_QUOTESINARGSTEXT),
    350351             pszCmdLine_);
    351     FullPath = searchapath("PATH", szCmdLine);
     352    FullPath = searchapath(PCSZ_PATH, szCmdLine);
    352353    BldQuotedFileName(pszNewCmdLine, szCmdLine);
    353354    //printf("%d %s ", ret, szCmdLine); fflush(stdout);
Note: See TracChangeset for help on using the changeset viewer.