Changeset 917 for trunk/dll/systemf.c


Ignore:
Timestamp:
Jan 11, 2008, 10:41:56 PM (18 years ago)
Author:
Steven Levine
Message:

Correct/enhance settings notebook navigation, ticket #188 (Steven)
Reopen settings notebook to last selected page unless overridden, ticket #188 (Steven)
More Compare Directory overflow tweaks (Steven)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/systemf.c

    r911 r917  
    4545#define MAXSTRG (4096)                  /* used to build command line strings */
    4646
    47 //== ShowSession() bring session for foreground ==
     47/**
     48 * Bring session foreground
     49 * @return TRUE if OK, else FALSE
     50 */
    4851
    4952BOOL ShowSession(HWND hwnd, PID pid)
     
    6871}
    6972
    70 //== ExecOnList() Invoke runemf2 for command and file/directory list ==
     73/**
     74 * Invoke runemf2 for command and file/directory list
     75 * @return command return code or
     76 *         -1 if runtime error or
     77 *         -2 if user cancels command line edit dialog
     78 */
    7179
    7280int ExecOnList(HWND hwnd, char *command, int flags, char *tpath,
     
    597605}
    598606
    599 //== runemf2() run requested app, return -1 if problem starting else return app rc ==
     607/** Run requested app
     608 * @return application return code or -1 if problem starting app
     609 */
    600610
    601611int runemf2(int type, HWND hwnd, PCSZ pszCallingFile, UINT uiLineNumber,
    602             char *pszDirectory, char *pszEnvironment,
     612            char *pszDirectory, char *pszEnvironment,
    603613            char *formatstring,...)
    604614{
     
    677687  *pszPgm = 0;
    678688  va_start(parguments,
    679            formatstring);
     689           formatstring);
    680690  vsprintf(pszPgm,
    681691           formatstring,
    682            parguments);
     692           parguments);
    683693  va_end(parguments);
    684694
     
    836846        if (ret) {
    837847          Dos_Error(MB_ENTER,ret,hwnd,pszSrcFile,__LINE__,
    838                     GetPString(IDS_DOSEXECPGMFAILEDTEXT), pszPgm,
    839                     pszCallingFile, __LINE__);
     848                    GetPString(IDS_DOSEXECPGMFAILEDTEXT), pszPgm,
     849                    pszCallingFile, __LINE__);
    840850        }
    841851      }
     
    925935          *pszDirectory)
    926936        switch_to(szSavedir);
    927       if (rc){
     937      if (rc) {
    928938        Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,
    929939                  GetPString(IDS_DOSQAPPTYPEFAILEDTEXT),
     
    11091119      if (ret && ret != ERROR_SMG_START_IN_BACKGROUND) {
    11101120        Dos_Error(MB_CANCEL,ret,hwnd,pszSrcFile,__LINE__,
    1111                   GetPString(IDS_DOSSTARTSESSIONFAILEDTEXT),pszPgm,pszArgs,
    1112                   pszCallingFile, __LINE__);
     1121                  GetPString(IDS_DOSSTARTSESSIONFAILEDTEXT),pszPgm,pszArgs,
     1122                  pszCallingFile, __LINE__);
    11131123      }
    11141124      else if (type & WAIT) {
     
    13101320PSZ CheckApp_QuoteAddExe(PSZ pszPgm)
    13111321{
     1322  // 11 Jan 08 SHL fixme to not return quoted string on stack
     1323  // 11 Jan 08 SHL fixme to have javadoc comments
    13121324  char szTempPgm[2048], tempcom[2048], temparg[2048];
    13131325  char *offset = '\0', *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat;
     
    13231335  bstrip(pszPgm);
    13241336  strcpy(tempcom, pszPgm);
    1325   if (tempcom[0] != '\0'){
     1337  if (tempcom[0] != '\0') {
    13261338    offsetexe = strstr(strlwr(pszPgm), ".exe");
    13271339    offsetcmd = strstr(strlwr(pszPgm), ".cmd");
     
    13311343    if (offsetexe)
    13321344      offset = offsetexe;
    1333     else{
     1345    else {
    13341346      if (offsetcom)
    1335         offset = offsetcom;
    1336       else{
    1337         if (offsetcmd)
    1338           offset = offsetcmd;
    1339         else{
    1340           if (offsetbtm)
    1341             offset = offsetbtm;
    1342           else{
    1343             if (offsetbat)
    1344               offset = offsetexe;
    1345           }
    1346         }
    1347       }
    1348     }
    1349     if (offset){
     1347        offset = offsetcom;
     1348      else {
     1349        if (offsetcmd)
     1350          offset = offsetcmd;
     1351        else {
     1352          if (offsetbtm)
     1353            offset = offsetbtm;
     1354          else {
     1355            if (offsetbat)
     1356              offset = offsetexe;
     1357          }
     1358        }
     1359      }
     1360    }
     1361    if (offset) {
    13501362      tempcom[offset + 4 - pszPgm] = '\0';
    13511363      strcpy(temparg, &pszPgm[offset + 4 - pszPgm]);
    13521364      while (strchr(tempcom, '\"'))
    1353            remove_first_occurence_of_character("\"", tempcom);
     1365           remove_first_occurence_of_character("\"", tempcom);
    13541366      if ((temparg[0] == '\"' && temparg[1] == ' ') ||
    1355            !strstr(pszPgm, "\\:")||
    1356            strchr(temparg, '\"') == strrchr(temparg, '\"'))
    1357         remove_first_occurence_of_character("\"", temparg);
     1367           !strstr(pszPgm, "\\:")||
     1368           strchr(temparg, '\"') == strrchr(temparg, '\"'))
     1369        remove_first_occurence_of_character("\"", temparg);
    13581370      if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
    1359         saymsg(MB_OK, HWND_DESKTOP,
    1360                NullStr,
    1361                GetPString(IDS_QUOTESINARGSTEXT),
    1362                pszPgm);
     1371        saymsg(MB_OK, HWND_DESKTOP,
     1372               NullStr,
     1373               GetPString(IDS_QUOTESINARGSTEXT),
     1374               pszPgm);
    13631375      if (!offsetexe) {
    1364         ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
    1365                            ulResultBufLen, &ulFindCount, FIL_STANDARD);
    1366         if (ret){
    1367           pszChar = tempcom;
    1368           while (pszChar){
    1369             if (*pszChar == ' '){
    1370               *pszChar = '\0';
    1371               strcat(tempcom, ".exe");
    1372               ret = DosQueryAppType(tempcom, &ulAppType);
    1373               //printf("%d %s\n", ret, tempcom); fflush(stdout);
    1374               if (!ret){
    1375                 strcpy(temparg, pszPgm + strlen(tempcom) - 3);
    1376                 break;
    1377               }
    1378             }
    1379             strcpy(tempcom, pszPgm);
    1380             pszChar++;
    1381           }
    1382         }
     1376        ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
     1377                           ulResultBufLen, &ulFindCount, FIL_STANDARD);
     1378        if (ret) {
     1379          pszChar = tempcom;
     1380          while (pszChar) {
     1381            if (*pszChar == ' ') {
     1382              *pszChar = '\0';
     1383              strcat(tempcom, ".exe");
     1384              ret = DosQueryAppType(tempcom, &ulAppType);
     1385              //printf("%d %s\n", ret, tempcom); fflush(stdout);
     1386              if (!ret) {
     1387                strcpy(temparg, pszPgm + strlen(tempcom) - 3);
     1388                break;
     1389              }
     1390            }
     1391            strcpy(tempcom, pszPgm);
     1392            pszChar++;
     1393          }
     1394        }
    13831395      }
    13841396      else
    1385         ret = DosQueryAppType(tempcom, &ulAppType);
     1397        ret = DosQueryAppType(tempcom, &ulAppType);
    13861398      BldQuotedFileName(szTempPgm, tempcom);
    13871399      //printf("%d A", ret); fflush(stdout);
    13881400      if (ret) {
    1389         ret = saymsg(MB_YESNO,
    1390                      HWND_DESKTOP,
    1391                      NullStr,
    1392                      GetPString(IDS_PROGRAMNOTFOUNDTEXT),
    1393                      pszPgm);
    1394         if (ret == MBID_YES){
    1395           pszQuotedCompletePgm = pszPgm;
    1396         }
    1397         else{
    1398           fCancelAction = TRUE;
    1399           pszQuotedCompletePgm = pszPgm;
    1400         }
    1401       }
    1402       else{
    1403         if (temparg[0] != ' ')
    1404           strcat(szTempPgm, " ");
    1405         strcat(szTempPgm, temparg);
    1406         pszQuotedCompletePgm = szTempPgm;
     1401        ret = saymsg(MB_YESNO,
     1402                     HWND_DESKTOP,
     1403                     NullStr,
     1404                     GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     1405                     pszPgm);
     1406        if (ret == MBID_YES)
     1407          pszQuotedCompletePgm = pszPgm;
     1408        else {
     1409          fCancelAction = TRUE;
     1410          pszQuotedCompletePgm = pszPgm;
     1411        }
     1412      }
     1413      else {
     1414        if (temparg[0] != ' ')
     1415          strcat(szTempPgm, " ");
     1416        strcat(szTempPgm, temparg);
     1417        pszQuotedCompletePgm = szTempPgm;
    14071418      }
    14081419
    14091420    }
    14101421    else if (tempcom && (!strchr(tempcom, '.') ||
    1411                          strrchr(tempcom, '.' ) < strrchr(tempcom, '\\'))){
    1412       if (!strchr(tempcom, ' ')){
    1413         while (strchr(tempcom, '\"'))
    1414           remove_first_occurence_of_character("\"", tempcom);
    1415         strcat(tempcom, ".exe");
    1416         ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
    1417                            ulResultBufLen, &ulFindCount, FIL_STANDARD);
    1418         //printf("%d", ret); fflush(stdout);
    1419       }
    1420       else{
    1421         pszChar = tempcom;
    1422         while (pszChar){
    1423           while (strchr(tempcom, '\"'))
    1424             remove_first_occurence_of_character("\"", tempcom);
    1425           if (*pszChar == ' '){
    1426             *pszChar = '\0';
    1427             strcat(tempcom, ".exe");
    1428             ret = DosQueryAppType(tempcom, &ulAppType);
    1429             //printf("%d %s\n", ret, tempcom); fflush(stdout);
    1430             if (!ret){
    1431               break;
    1432             }
    1433           }
    1434           strcpy(tempcom, pszPgm);
    1435           pszChar++;
    1436         }
    1437       }
    1438       if (!ret){
    1439         BldQuotedFileName(szTempPgm, tempcom);
    1440         strcpy(temparg, pszPgm + strlen(tempcom) - 3);
    1441         if ((temparg[0] == '\"' && temparg[1] == ' ') ||
    1442              !strstr(pszPgm, "\\:" ) ||
    1443              strchr(temparg, '\"') == strrchr(temparg, '\"'))
    1444           remove_first_occurence_of_character("\"", temparg);
    1445         if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
    1446           saymsg(MB_OK, HWND_DESKTOP,
    1447                  NullStr,
    1448                  GetPString(IDS_QUOTESINARGSTEXT),
    1449                  pszPgm);
    1450         if (temparg[0] != ' ')
    1451           strcat(szTempPgm, " ");
    1452         strcat(szTempPgm, temparg);
    1453         pszQuotedCompletePgm = szTempPgm;
     1422                         strrchr(tempcom, '.' ) < strrchr(tempcom, '\\'))) {
     1423      if (!strchr(tempcom, ' ')) {
     1424        while (strchr(tempcom, '\"'))
     1425          remove_first_occurence_of_character("\"", tempcom);
     1426        strcat(tempcom, ".exe");
     1427        ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
     1428                           ulResultBufLen, &ulFindCount, FIL_STANDARD);
     1429        //printf("%d", ret); fflush(stdout);
    14541430      }
    14551431      else {
    1456         ret = saymsg(MB_OK,
    1457                      HWND_DESKTOP,
    1458                      NullStr,
    1459                      GetPString(IDS_PROGRAMNOTEXE2TEXT),
    1460                      pszPgm);
    1461           fCancelAction = TRUE;
    1462           pszQuotedCompletePgm = pszPgm;
     1432        pszChar = tempcom;
     1433        while (pszChar) {
     1434          while (strchr(tempcom, '\"'))
     1435            remove_first_occurence_of_character("\"", tempcom);
     1436          if (*pszChar == ' ') {
     1437            *pszChar = '\0';
     1438            strcat(tempcom, ".exe");
     1439            ret = DosQueryAppType(tempcom, &ulAppType);
     1440            //printf("%d %s\n", ret, tempcom); fflush(stdout);
     1441            if (!ret) {
     1442              break;
     1443            }
     1444          }
     1445          strcpy(tempcom, pszPgm);
     1446          pszChar++;
     1447        }
     1448      }
     1449      if (!ret) {
     1450        BldQuotedFileName(szTempPgm, tempcom);
     1451        strcpy(temparg, pszPgm + strlen(tempcom) - 3);
     1452        if ((temparg[0] == '\"' && temparg[1] == ' ') ||
     1453             !strstr(pszPgm, "\\:" ) ||
     1454             strchr(temparg, '\"') == strrchr(temparg, '\"'))
     1455          remove_first_occurence_of_character("\"", temparg);
     1456        if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
     1457          saymsg(MB_OK, HWND_DESKTOP,
     1458                 NullStr,
     1459                 GetPString(IDS_QUOTESINARGSTEXT),
     1460                 pszPgm);
     1461        if (temparg[0] != ' ')
     1462          strcat(szTempPgm, " ");
     1463        strcat(szTempPgm, temparg);
     1464        pszQuotedCompletePgm = szTempPgm;
     1465      }
     1466      else {
     1467        ret = saymsg(MB_OK,
     1468                     HWND_DESKTOP,
     1469                     NullStr,
     1470                     GetPString(IDS_PROGRAMNOTEXE2TEXT),
     1471                     pszPgm);
     1472          fCancelAction = TRUE;
     1473          pszQuotedCompletePgm = pszPgm;
    14631474      }
    14641475    }
    14651476    else {
    14661477      pszChar = strrchr(tempcom, '.');
    1467       while (pszChar && *pszChar !=' '){
    1468         pszChar++;
     1478      while (pszChar && *pszChar !=' ') {
     1479        pszChar++;
    14691480      }
    14701481      *pszChar = '\0';
    14711482      strcpy (temparg, pszPgm + strlen(tempcom));
    14721483      while (strchr(tempcom, '\"'))
    1473         remove_first_occurence_of_character("\"", tempcom);
     1484        remove_first_occurence_of_character("\"", tempcom);
    14741485    if ((temparg[0] == '\"' && temparg[1] == ' ') ||
    1475         !strstr(pszPgm, "\\:")||
    1476         strchr(temparg, '\"') == strrchr(temparg, '\"'))
     1486        !strstr(pszPgm, "\\:")||
     1487        strchr(temparg, '\"') == strrchr(temparg, '\"'))
    14771488      remove_first_occurence_of_character("\"", temparg);
    14781489    if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
    14791490      saymsg(MB_OK, HWND_DESKTOP,
    1480              NullStr,
    1481              GetPString(IDS_QUOTESINARGSTEXT),
    1482              pszPgm);
     1491             NullStr,
     1492             GetPString(IDS_QUOTESINARGSTEXT),
     1493             pszPgm);
    14831494    ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
    1484                         ulResultBufLen, &ulFindCount, FIL_STANDARD);
     1495                        ulResultBufLen, &ulFindCount, FIL_STANDARD);
    14851496
    14861497    BldQuotedFileName(szTempPgm, tempcom);
     
    14881499    if (ret) {
    14891500      ret = saymsg(MB_YESNO,
    1490                    HWND_DESKTOP,
    1491                    NullStr,
    1492                    GetPString(IDS_PROGRAMNOTFOUNDTEXT),
    1493                    pszPgm);
    1494       if (ret == MBID_YES){
    1495         pszQuotedCompletePgm = pszPgm;
    1496       }
    1497       else{
    1498         fCancelAction = TRUE;
    1499         pszQuotedCompletePgm = pszPgm;
     1501                   HWND_DESKTOP,
     1502                   NullStr,
     1503                   GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     1504                   pszPgm);
     1505      if (ret == MBID_YES) {
     1506        pszQuotedCompletePgm = pszPgm;
     1507      }
     1508      else {
     1509        fCancelAction = TRUE;
     1510        pszQuotedCompletePgm = pszPgm;
    15001511      }
    15011512    }
    15021513    ret = saymsg(MB_YESNOCANCEL,
    1503                    HWND_DESKTOP,
    1504                    NullStr,
    1505                    GetPString(IDS_PROGRAMNOTEXE3TEXT),
    1506                    pszPgm, szTempPgm);
    1507       if (ret == MBID_YES){
    1508         if (temparg[0] != ' ')
    1509           strcat(szTempPgm, " ");
    1510         strcat(szTempPgm, temparg);
    1511         pszQuotedCompletePgm = szTempPgm;
    1512       }
    1513       if (ret == MBID_CANCEL){
    1514         fCancelAction = TRUE;
    1515         pszQuotedCompletePgm = pszPgm;
     1514                   HWND_DESKTOP,
     1515                   NullStr,
     1516                   GetPString(IDS_PROGRAMNOTEXE3TEXT),
     1517                   pszPgm, szTempPgm);
     1518      if (ret == MBID_YES) {
     1519        if (temparg[0] != ' ')
     1520          strcat(szTempPgm, " ");
     1521        strcat(szTempPgm, temparg);
     1522        pszQuotedCompletePgm = szTempPgm;
     1523      }
     1524      if (ret == MBID_CANCEL) {
     1525        fCancelAction = TRUE;
     1526        pszQuotedCompletePgm = pszPgm;
    15161527      }
    15171528      else
    1518         pszQuotedCompletePgm = pszPgm;
     1529        pszQuotedCompletePgm = pszPgm;
    15191530    }
    15201531    return pszQuotedCompletePgm;
Note: See TracChangeset for help on using the changeset viewer.