Changeset 917 for trunk/dll/systemf.c
- Timestamp:
- Jan 11, 2008, 10:41:56 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/systemf.c
r911 r917 45 45 #define MAXSTRG (4096) /* used to build command line strings */ 46 46 47 //== ShowSession() bring session for foreground == 47 /** 48 * Bring session foreground 49 * @return TRUE if OK, else FALSE 50 */ 48 51 49 52 BOOL ShowSession(HWND hwnd, PID pid) … … 68 71 } 69 72 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 */ 71 79 72 80 int ExecOnList(HWND hwnd, char *command, int flags, char *tpath, … … 597 605 } 598 606 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 */ 600 610 601 611 int runemf2(int type, HWND hwnd, PCSZ pszCallingFile, UINT uiLineNumber, 602 612 char *pszDirectory, char *pszEnvironment, 603 613 char *formatstring,...) 604 614 { … … 677 687 *pszPgm = 0; 678 688 va_start(parguments, 679 689 formatstring); 680 690 vsprintf(pszPgm, 681 691 formatstring, 682 692 parguments); 683 693 va_end(parguments); 684 694 … … 836 846 if (ret) { 837 847 Dos_Error(MB_ENTER,ret,hwnd,pszSrcFile,__LINE__, 838 839 848 GetPString(IDS_DOSEXECPGMFAILEDTEXT), pszPgm, 849 pszCallingFile, __LINE__); 840 850 } 841 851 } … … 925 935 *pszDirectory) 926 936 switch_to(szSavedir); 927 if (rc) {937 if (rc) { 928 938 Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__, 929 939 GetPString(IDS_DOSQAPPTYPEFAILEDTEXT), … … 1109 1119 if (ret && ret != ERROR_SMG_START_IN_BACKGROUND) { 1110 1120 Dos_Error(MB_CANCEL,ret,hwnd,pszSrcFile,__LINE__, 1111 1112 1121 GetPString(IDS_DOSSTARTSESSIONFAILEDTEXT),pszPgm,pszArgs, 1122 pszCallingFile, __LINE__); 1113 1123 } 1114 1124 else if (type & WAIT) { … … 1310 1320 PSZ CheckApp_QuoteAddExe(PSZ pszPgm) 1311 1321 { 1322 // 11 Jan 08 SHL fixme to not return quoted string on stack 1323 // 11 Jan 08 SHL fixme to have javadoc comments 1312 1324 char szTempPgm[2048], tempcom[2048], temparg[2048]; 1313 1325 char *offset = '\0', *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat; … … 1323 1335 bstrip(pszPgm); 1324 1336 strcpy(tempcom, pszPgm); 1325 if (tempcom[0] != '\0') {1337 if (tempcom[0] != '\0') { 1326 1338 offsetexe = strstr(strlwr(pszPgm), ".exe"); 1327 1339 offsetcmd = strstr(strlwr(pszPgm), ".cmd"); … … 1331 1343 if (offsetexe) 1332 1344 offset = offsetexe; 1333 else {1345 else { 1334 1346 if (offsetcom) 1335 1336 else {1337 1338 1339 else{1340 1341 1342 else{1343 1344 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) { 1350 1362 tempcom[offset + 4 - pszPgm] = '\0'; 1351 1363 strcpy(temparg, &pszPgm[offset + 4 - pszPgm]); 1352 1364 while (strchr(tempcom, '\"')) 1353 1365 remove_first_occurence_of_character("\"", tempcom); 1354 1366 if ((temparg[0] == '\"' && temparg[1] == ' ') || 1355 1356 1357 1367 !strstr(pszPgm, "\\:")|| 1368 strchr(temparg, '\"') == strrchr(temparg, '\"')) 1369 remove_first_occurence_of_character("\"", temparg); 1358 1370 if (strchr(temparg, '\"') != strrchr(temparg, '\"')) 1359 1360 1361 1362 1371 saymsg(MB_OK, HWND_DESKTOP, 1372 NullStr, 1373 GetPString(IDS_QUOTESINARGSTEXT), 1374 pszPgm); 1363 1375 if (!offsetexe) { 1364 1365 1366 if (ret){1367 1368 while (pszChar){1369 if (*pszChar == ' '){1370 1371 1372 1373 1374 if (!ret){1375 1376 1377 1378 1379 1380 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 } 1383 1395 } 1384 1396 else 1385 1397 ret = DosQueryAppType(tempcom, &ulAppType); 1386 1398 BldQuotedFileName(szTempPgm, tempcom); 1387 1399 //printf("%d A", ret); fflush(stdout); 1388 1400 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; 1407 1418 } 1408 1419 1409 1420 } 1410 1421 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); 1454 1430 } 1455 1431 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; 1463 1474 } 1464 1475 } 1465 1476 else { 1466 1477 pszChar = strrchr(tempcom, '.'); 1467 while (pszChar && *pszChar !=' ') {1468 1478 while (pszChar && *pszChar !=' ') { 1479 pszChar++; 1469 1480 } 1470 1481 *pszChar = '\0'; 1471 1482 strcpy (temparg, pszPgm + strlen(tempcom)); 1472 1483 while (strchr(tempcom, '\"')) 1473 1484 remove_first_occurence_of_character("\"", tempcom); 1474 1485 if ((temparg[0] == '\"' && temparg[1] == ' ') || 1475 1476 1486 !strstr(pszPgm, "\\:")|| 1487 strchr(temparg, '\"') == strrchr(temparg, '\"')) 1477 1488 remove_first_occurence_of_character("\"", temparg); 1478 1489 if (strchr(temparg, '\"') != strrchr(temparg, '\"')) 1479 1490 saymsg(MB_OK, HWND_DESKTOP, 1480 1481 1482 1491 NullStr, 1492 GetPString(IDS_QUOTESINARGSTEXT), 1493 pszPgm); 1483 1494 ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 1484 1495 ulResultBufLen, &ulFindCount, FIL_STANDARD); 1485 1496 1486 1497 BldQuotedFileName(szTempPgm, tempcom); … … 1488 1499 if (ret) { 1489 1500 ret = saymsg(MB_YESNO, 1490 1491 1492 1493 1494 if (ret == MBID_YES) {1495 1496 } 1497 else {1498 1499 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; 1500 1511 } 1501 1512 } 1502 1513 ret = saymsg(MB_YESNOCANCEL, 1503 1504 1505 1506 1507 if (ret == MBID_YES) {1508 1509 1510 1511 1512 } 1513 if (ret == MBID_CANCEL) {1514 1515 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; 1516 1527 } 1517 1528 else 1518 1529 pszQuotedCompletePgm = pszPgm; 1519 1530 } 1520 1531 return pszQuotedCompletePgm;
Note:
See TracChangeset
for help on using the changeset viewer.