Changeset 920 for trunk/dll/systemf.c
- Timestamp:
- Jan 13, 2008, 2:18:17 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/systemf.c
r918 r920 20 20 06 Aug 07 GKY Reduce DosSleep times (ticket 148) 21 21 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat 22 06 Jan 08 GKY Add CheckApp_QuoteAddExe to check program strings on entry23 22 24 23 ***********************************************************************/ … … 611 610 char *formatstring,...) 612 611 { 613 /* example:612 /** example: 614 613 615 614 * status = runemf2(SEPARATE | WINDOWED, … … 625 624 */ 626 625 627 /* 626 /** 628 627 * type bitmapped flag -- see FM3DLL.H 629 628 */ … … 1316 1315 } 1317 1316 1318 PSZ CheckApp_QuoteAddExe(PSZ pszQuotedCompletePgm, PSZ pszPgm) 1319 { 1320 char tempcom[MAXCOMLINESTRG], temparg[MAXCOMLINESTRG]; 1321 char *offset = '\0', *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat; 1322 APIRET ret; 1323 ULONG ulAppType; 1324 char *pszChar; 1325 FILEFINDBUF3 FindBuffer; 1326 ULONG ulResultBufLen = sizeof(FILEFINDBUF3); 1327 HDIR hdirFindHandle = HDIR_CREATE; 1328 ULONG ulFindCount = 1; 1329 PSZ pszTempPgm = pszQuotedCompletePgm; 1330 1331 bstrip(pszPgm); 1332 strcpy(tempcom, pszPgm); 1333 if (tempcom[0] != '\0') { 1334 offsetexe = strstr(strlwr(pszPgm), ".exe"); 1335 offsetcmd = strstr(strlwr(pszPgm), ".cmd"); 1336 offsetcom = strstr(strlwr(pszPgm), ".com"); 1337 offsetbtm = strstr(strlwr(pszPgm), ".btm"); 1338 offsetbat = strstr(strlwr(pszPgm), ".bat"); 1339 if (offsetexe) 1340 offset = offsetexe; 1341 else { 1342 if (offsetcom) 1343 offset = offsetcom; 1344 else { 1345 if (offsetcmd) 1346 offset = offsetcmd; 1347 else { 1348 if (offsetbtm) 1349 offset = offsetbtm; 1350 else { 1351 if (offsetbat) 1352 offset = offsetexe; 1353 } 1354 } 1355 } 1356 } 1357 if (offset) { 1358 tempcom[offset + 4 - pszPgm] = '\0'; 1359 strcpy(temparg, &pszPgm[offset + 4 - pszPgm]); 1360 while (strchr(tempcom, '\"')) 1361 remove_first_occurence_of_character("\"", tempcom); 1362 if ((temparg[0] == '\"' && temparg[1] == ' ') || 1363 !strstr(pszPgm, "\\:")|| 1364 strchr(temparg, '\"') == strrchr(temparg, '\"')) 1365 remove_first_occurence_of_character("\"", temparg); 1366 if (strchr(temparg, '\"') != strrchr(temparg, '\"')) 1367 saymsg(MB_OK, HWND_DESKTOP, 1368 NullStr, 1369 GetPString(IDS_QUOTESINARGSTEXT), 1370 pszPgm); 1371 if (!offsetexe) { 1372 ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 1373 ulResultBufLen, &ulFindCount, FIL_STANDARD); 1374 if (ret) { 1375 pszChar = tempcom; 1376 while (pszChar) { 1377 if (*pszChar == ' ') { 1378 *pszChar = '\0'; 1379 strcat(tempcom, ".exe"); 1380 ret = DosQueryAppType(tempcom, &ulAppType); 1381 //printf("%d %s\n", ret, tempcom); fflush(stdout); 1382 if (!ret) { 1383 strcpy(temparg, pszPgm + strlen(tempcom) - 3); 1384 break; 1385 } 1386 } 1387 strcpy(tempcom, pszPgm); 1388 pszChar++; 1389 } 1390 } 1391 } 1392 else 1393 ret = DosQueryAppType(tempcom, &ulAppType); 1394 BldQuotedFileName(pszTempPgm, tempcom); 1395 //printf("%d A", ret); fflush(stdout); 1396 if (ret) { 1397 ret = saymsg(MB_YESNO, 1398 HWND_DESKTOP, 1399 NullStr, 1400 GetPString(IDS_PROGRAMNOTFOUNDTEXT), 1401 pszPgm); 1402 if (ret == MBID_YES){ 1403 pszTempPgm = pszPgm; 1404 } 1405 else{ 1406 fCancelAction = TRUE; 1407 pszTempPgm = pszPgm; 1408 } 1409 } 1410 else{ 1411 if (temparg[0] != ' ') 1412 strcat(pszTempPgm, " "); 1413 strcat(pszTempPgm, temparg); 1414 } 1415 1416 } 1417 else if (tempcom && (!strchr(tempcom, '.') || 1418 strrchr(tempcom, '.' ) < strrchr(tempcom, '\\'))) { 1419 if (!strchr(tempcom, ' ')) { 1420 while (strchr(tempcom, '\"')) 1421 remove_first_occurence_of_character("\"", tempcom); 1422 strcat(tempcom, ".exe"); 1423 ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 1424 ulResultBufLen, &ulFindCount, FIL_STANDARD); 1425 //printf("%d", ret); fflush(stdout); 1426 } 1427 else { 1428 pszChar = tempcom; 1429 while (pszChar) { 1430 while (strchr(tempcom, '\"')) 1431 remove_first_occurence_of_character("\"", tempcom); 1432 if (*pszChar == ' ') { 1433 *pszChar = '\0'; 1434 strcat(tempcom, ".exe"); 1435 ret = DosQueryAppType(tempcom, &ulAppType); 1436 //printf("%d %s\n", ret, tempcom); fflush(stdout); 1437 if (!ret) { 1438 break; 1439 } 1440 } 1441 strcpy(tempcom, pszPgm); 1442 pszChar++; 1443 } 1444 } 1445 if (!ret){ 1446 BldQuotedFileName(pszTempPgm, tempcom); 1447 strcpy(temparg, pszPgm + strlen(tempcom) - 3); 1448 if ((temparg[0] == '\"' && temparg[1] == ' ') || 1449 !strstr(pszPgm, "\\:" ) || 1450 strchr(temparg, '\"') == strrchr(temparg, '\"')) 1451 remove_first_occurence_of_character("\"", temparg); 1452 if (strchr(temparg, '\"') != strrchr(temparg, '\"')) 1453 saymsg(MB_OK, HWND_DESKTOP, 1454 NullStr, 1455 GetPString(IDS_QUOTESINARGSTEXT), 1456 pszPgm); 1457 if (temparg[0] != ' ') 1458 strcat(pszTempPgm, " "); 1459 strcat(pszTempPgm, temparg); 1460 } 1461 else { 1462 ret = saymsg(MB_OK, 1463 HWND_DESKTOP, 1464 NullStr, 1465 GetPString(IDS_PROGRAMNOTEXE2TEXT), 1466 pszPgm); 1467 fCancelAction = TRUE; 1468 pszTempPgm = pszPgm; 1469 } 1470 } 1471 else { 1472 pszChar = strrchr(tempcom, '.'); 1473 while (pszChar && *pszChar !=' ') { 1474 pszChar++; 1475 } 1476 *pszChar = '\0'; 1477 strcpy (temparg, pszPgm + strlen(tempcom)); 1478 while (strchr(tempcom, '\"')) 1479 remove_first_occurence_of_character("\"", tempcom); 1480 if ((temparg[0] == '\"' && temparg[1] == ' ') || 1481 !strstr(pszPgm, "\\:")|| 1482 strchr(temparg, '\"') == strrchr(temparg, '\"')) 1483 remove_first_occurence_of_character("\"", temparg); 1484 if (strchr(temparg, '\"') != strrchr(temparg, '\"')) 1485 saymsg(MB_OK, HWND_DESKTOP, 1486 NullStr, 1487 GetPString(IDS_QUOTESINARGSTEXT), 1488 pszPgm); 1489 ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer, 1490 ulResultBufLen, &ulFindCount, FIL_STANDARD); 1491 1492 BldQuotedFileName(pszTempPgm, tempcom); 1493 //printf("%d %s ", ret, tempcom); fflush(stdout); 1494 if (ret) { 1495 ret = saymsg(MB_YESNO, 1496 HWND_DESKTOP, 1497 NullStr, 1498 GetPString(IDS_PROGRAMNOTFOUNDTEXT), 1499 pszPgm); 1500 if (ret == MBID_YES) { 1501 pszQuotedCompletePgm = pszPgm; 1502 } 1503 else { 1504 fCancelAction = TRUE; 1505 pszQuotedCompletePgm = pszPgm; 1506 } 1507 } 1508 ret = saymsg(MB_YESNOCANCEL, 1509 HWND_DESKTOP, 1510 NullStr, 1511 GetPString(IDS_PROGRAMNOTEXE3TEXT), 1512 pszPgm, pszTempPgm); 1513 if (ret == MBID_YES){ 1514 if (temparg[0] != ' ') 1515 strcat(pszTempPgm, " "); 1516 strcat(pszTempPgm, temparg); 1517 } 1518 if (ret == MBID_CANCEL){ 1519 fCancelAction = TRUE; 1520 pszTempPgm = pszPgm; 1521 } 1522 } 1523 } 1524 else 1525 pszTempPgm = pszPgm; 1526 return pszQuotedCompletePgm; 1527 } 1528 1529 #pragma alloc_text(SYSTEMF,ShowSession,ExecOnList,runemf2,CheckApp_QuoteAddExe) 1317 #pragma alloc_text(SYSTEMF,ShowSession,ExecOnList,runemf2)
Note:
See TracChangeset
for help on using the changeset viewer.