Changeset 1394 for trunk/dll/pathutil.c


Ignore:
Timestamp:
Feb 5, 2009, 5:17:25 AM (17 years ago)
Author:
Steven Levine
Message:

Ticket 340: Convert GetPString to use STRINGTABLE.

Drop fm3dll.str and mkstr.exe from makefiles and wpi builders

Convert many functions to expect PCSZ arguments.
Correct walk, compare and dirsizes dialog setups to ignore saved dialog size
Drop copyright.c logic from makefile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/pathutil.c

    r1323 r1394  
    77
    88  Copyright (c) 1993-98 M. Kimes
    9   Copyright (c) 2001, 2008 Steven H. Levine
     9  Copyright (c) 2001, 2009 Steven H. Levine
    1010
    1111  05 Jan 08 SHL Move from arccnrs.c and comp.c to here
     
    1313  29 Feb 08 GKY Changes to enable user settable command line length
    1414  15 Oct 08 GKY Fix NormalizeCmdLine to check all 5 executible extensions when no extension provided;
    15                 use searchapath to check for existance of file types not checked by DosQAppType;
    16                 close DosFind.
     15                use searchapath to check for existance of file types not checked by DosQAppType;
     16                close DosFind.
    1717
    1818***********************************************************************/
     
    9898 */
    9999
    100 PSZ BldQuotedFileName(PSZ pszQuotedFileName, PSZ pszFileName)
     100PSZ BldQuotedFileName(PSZ pszQuotedFileName, PCSZ pszFileName)
    101101{
    102102  BOOL q = needs_quoting(pszFileName);
     
    184184               pszCmdLine_);
    185185      if (!offsetexe && !offsetcom) {
    186         FullPath = searchapath("PATH", szCmdLine);
    187         if (*FullPath)
    188           ret = 0;
     186        FullPath = searchapath("PATH", szCmdLine);
     187        if (*FullPath)
     188          ret = 0;
    189189      }
    190190      else
     
    193193      //printf("%d A", ret); fflush(stdout);
    194194      if (ret) {
    195         ret = saymsg(MB_YESNO,
    196                      HWND_DESKTOP,
    197                      NullStr,
    198                      GetPString(IDS_PROGRAMNOTFOUNDTEXT),
    199                      pszCmdLine_);
    200         if (ret == MBID_YES){
    201           if (szArgs[0] != ' ')
    202             strcat(pszNewCmdLine, " ");
    203           strcat(pszNewCmdLine, szArgs);
    204       }
    205         else{
    206           fCancelAction = TRUE;
    207           pszNewCmdLine = pszCmdLine_;
    208         }
     195        ret = saymsg(MB_YESNO,
     196                     HWND_DESKTOP,
     197                     NullStr,
     198                     GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     199                     pszCmdLine_);
     200        if (ret == MBID_YES){
     201          if (szArgs[0] != ' ')
     202            strcat(pszNewCmdLine, " ");
     203          strcat(pszNewCmdLine, szArgs);
     204      }
     205        else{
     206          fCancelAction = TRUE;
     207          pszNewCmdLine = pszCmdLine_;
     208        }
    209209      }
    210210      else{
    211         if (szArgs[0] != ' ')
    212           strcat(pszNewCmdLine, " ");
    213         strcat(pszNewCmdLine, szArgs);
     211        if (szArgs[0] != ' ')
     212          strcat(pszNewCmdLine, " ");
     213        strcat(pszNewCmdLine, szArgs);
    214214      }
    215215
     
    219219                           strrchr(szCmdLine, '.' ) < strrchr(szCmdLine, '\\'))) {
    220220      if (!strchr(szCmdLine, ' ')) {
    221         // strip quotes readded by BuildQuotedFileName
     221        // strip quotes readded by BuildQuotedFileName
    222222        while (strchr(szCmdLine, '\"'))
    223223          remove_first_occurence_of_character("\"", szCmdLine);
    224         ret = DosQueryAppType(szCmdLine, &ulAppType); // exe automatically appended
    225         if (!ret)
    226           strcat(szCmdLine, ".exe");
    227         else {
    228           strcat(szCmdLine, ".com");
    229           ret = DosQueryAppType(szCmdLine, &ulAppType);
    230           if (ret) {
    231             offset = strrchr(szCmdLine, '.' );
    232             *offset = 0;
    233             strcat(szCmdLine, ".cmd");
    234             FullPath = searchapath("PATH", szCmdLine);
    235             if (*FullPath)
    236               ret = 0;
    237             else {
    238               *offset = 0;
    239               strcat(szCmdLine, ".bat");
    240               FullPath = searchapath("PATH", szCmdLine);
    241               if (*FullPath)
    242                 ret = 0;
    243               else {
    244                 *offset = 0;
    245                 strcat(szCmdLine, ".bmt");
    246                 FullPath = searchapath("PATH", szCmdLine);
    247                 if (*FullPath)
    248                   ret = 0;
    249               }
    250             }
    251           }
    252         }
     224        ret = DosQueryAppType(szCmdLine, &ulAppType); // exe automatically appended
     225        if (!ret)
     226          strcat(szCmdLine, ".exe");
     227        else {
     228          strcat(szCmdLine, ".com");
     229          ret = DosQueryAppType(szCmdLine, &ulAppType);
     230          if (ret) {
     231            offset = strrchr(szCmdLine, '.' );
     232            *offset = 0;
     233            strcat(szCmdLine, ".cmd");
     234            FullPath = searchapath("PATH", szCmdLine);
     235            if (*FullPath)
     236              ret = 0;
     237            else {
     238              *offset = 0;
     239              strcat(szCmdLine, ".bat");
     240              FullPath = searchapath("PATH", szCmdLine);
     241              if (*FullPath)
     242                ret = 0;
     243              else {
     244                *offset = 0;
     245                strcat(szCmdLine, ".bmt");
     246                FullPath = searchapath("PATH", szCmdLine);
     247                if (*FullPath)
     248                  ret = 0;
     249              }
     250            }
     251          }
     252        }
    253253        //printf("%d", ret); fflush(stdout);
    254254      }
     
    260260          if (*pszChar == ' ') { //test at every space for the end of the filename
    261261            *pszChar = '\0';
    262             ret = DosQueryAppType(szCmdLine, &ulAppType);
    263             if (!ret) {
    264               strcat(szCmdLine, ".exe");
    265               break;
    266             }
    267             else {
    268               strcat(szCmdLine, ".com");
    269               ret = DosQueryAppType(szCmdLine, &ulAppType);
    270               if (ret) {
    271                 offset = strrchr(szCmdLine, '.' );
    272                 *offset = 0;
    273                 strcat(szCmdLine, ".cmd");
    274                 FullPath = searchapath("PATH", szCmdLine);
    275                 if (*FullPath) {
    276                   ret = 0;
    277                   break;
    278                 }
    279                 else {
    280                   *offset = 0;
    281                   strcat(szCmdLine, ".bat");
    282                   FullPath = searchapath("PATH", szCmdLine);
    283                   if (*FullPath) {
    284                     ret = 0;
    285                     break;
    286                   }
    287                   else {
    288                     *offset = 0;
    289                     strcat(szCmdLine, ".bmt");
    290                     FullPath = searchapath("PATH", szCmdLine);
    291                     if (*FullPath) {
    292                       ret = 0;
    293                       break;
    294                     }
    295                   }
    296                 }
    297               }
    298               else
    299                 break;
    300             }
     262            ret = DosQueryAppType(szCmdLine, &ulAppType);
     263            if (!ret) {
     264              strcat(szCmdLine, ".exe");
     265              break;
     266            }
     267            else {
     268              strcat(szCmdLine, ".com");
     269              ret = DosQueryAppType(szCmdLine, &ulAppType);
     270              if (ret) {
     271                offset = strrchr(szCmdLine, '.' );
     272                *offset = 0;
     273                strcat(szCmdLine, ".cmd");
     274                FullPath = searchapath("PATH", szCmdLine);
     275                if (*FullPath) {
     276                  ret = 0;
     277                  break;
     278                }
     279                else {
     280                  *offset = 0;
     281                  strcat(szCmdLine, ".bat");
     282                  FullPath = searchapath("PATH", szCmdLine);
     283                  if (*FullPath) {
     284                    ret = 0;
     285                    break;
     286                  }
     287                  else {
     288                    *offset = 0;
     289                    strcat(szCmdLine, ".bmt");
     290                    FullPath = searchapath("PATH", szCmdLine);
     291                    if (*FullPath) {
     292                      ret = 0;
     293                      break;
     294                    }
     295                  }
     296                }
     297              }
     298              else
     299                break;
     300            }
    301301            //printf("%d %s\n", ret, szCmdLine); fflush(stdout);
    302302          }
     
    306306      }
    307307      if (!ret){
    308         BldQuotedFileName(pszNewCmdLine, szCmdLine);
    309         strcpy(szArgs, pszCmdLine_ + strlen(szCmdLine) - 3);
    310         if ((szArgs[0] == '\"' && szArgs[1] == ' ') ||
    311              !strstr(pszCmdLine_, "\\:" ) ||
    312              strchr(szArgs, '\"') == strrchr(szArgs, '\"'))
    313           remove_first_occurence_of_character("\"", szArgs);
    314         if (strchr(szArgs, '\"') != strrchr(szArgs, '\"'))
    315           saymsg(MB_OK, HWND_DESKTOP,
    316                 NullStr,
    317                 GetPString(IDS_QUOTESINARGSTEXT),
    318                 pszCmdLine_);
    319         if (szArgs[0] != ' ')
    320           strcat(pszNewCmdLine, " ");
    321         strcat(pszNewCmdLine, szArgs);
     308        BldQuotedFileName(pszNewCmdLine, szCmdLine);
     309        strcpy(szArgs, pszCmdLine_ + strlen(szCmdLine) - 3);
     310        if ((szArgs[0] == '\"' && szArgs[1] == ' ') ||
     311             !strstr(pszCmdLine_, "\\:" ) ||
     312             strchr(szArgs, '\"') == strrchr(szArgs, '\"'))
     313          remove_first_occurence_of_character("\"", szArgs);
     314        if (strchr(szArgs, '\"') != strrchr(szArgs, '\"'))
     315          saymsg(MB_OK, HWND_DESKTOP,
     316                NullStr,
     317                GetPString(IDS_QUOTESINARGSTEXT),
     318                pszCmdLine_);
     319        if (szArgs[0] != ' ')
     320          strcat(pszNewCmdLine, " ");
     321        strcat(pszNewCmdLine, szArgs);
    322322      }
    323323      else { // fail if no extension can be found runemf2 requires one
    324         ret = saymsg(MB_OK,
    325                      HWND_DESKTOP,
    326                      NullStr,
    327                      GetPString(IDS_PROGRAMNOTEXE2TEXT),
    328                      pszCmdLine_);
    329           fCancelAction = TRUE;
    330           pszNewCmdLine = pszCmdLine_;
     324        ret = saymsg(MB_OK,
     325                     HWND_DESKTOP,
     326                     NullStr,
     327                     GetPString(IDS_PROGRAMNOTEXE2TEXT),
     328                     pszCmdLine_);
     329          fCancelAction = TRUE;
     330          pszNewCmdLine = pszCmdLine_;
    331331      }
    332332    }
     
    359359                   pszCmdLine_);
    360360      if (ret == MBID_YES) {
    361         if (szArgs[0] != ' ')
    362           strcat(pszNewCmdLine, " ");
    363         strcat(pszNewCmdLine, szArgs);
     361        if (szArgs[0] != ' ')
     362          strcat(pszNewCmdLine, " ");
     363        strcat(pszNewCmdLine, szArgs);
    364364      }
    365365      else {
     
    370370    else {
    371371      ret = saymsg(MB_YESNOCANCEL,
    372                    HWND_DESKTOP,
    373                    NullStr,
    374                    GetPString(IDS_PROGRAMNOTEXE3TEXT),
    375                    pszCmdLine_, pszNewCmdLine);
    376         if (ret == MBID_YES){
    377           if (szArgs[0] != ' ')
    378             strcat(pszNewCmdLine, " ");
    379           strcat(pszNewCmdLine, szArgs);
    380         }
    381         if (ret == MBID_CANCEL){
    382           fCancelAction = TRUE;
    383           pszNewCmdLine = pszCmdLine_;
    384         }
     372                   HWND_DESKTOP,
     373                   NullStr,
     374                   GetPString(IDS_PROGRAMNOTEXE3TEXT),
     375                   pszCmdLine_, pszNewCmdLine);
     376        if (ret == MBID_YES){
     377          if (szArgs[0] != ' ')
     378            strcat(pszNewCmdLine, " ");
     379          strcat(pszNewCmdLine, szArgs);
     380        }
     381        if (ret == MBID_CANCEL){
     382          fCancelAction = TRUE;
     383          pszNewCmdLine = pszCmdLine_;
     384        }
    385385      }
    386386    }
Note: See TracChangeset for help on using the changeset viewer.