Changeset 906 for trunk/dll/systemf.c


Ignore:
Timestamp:
Jan 6, 2008, 5:21:14 AM (18 years ago)
Author:
Gregg Young
Message:

The basic program quoting code and some mailto cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/systemf.c

    r893 r906  
    636636  BOOL useTermQ = FALSE;
    637637  char szTempdir[CCHMAXPATH];
    638   //char szTempPgm[CCHMAXPATH], tempcom[2048], temparg[2048], buf[10] = " &|<>";
    639   //char *offset, *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat;
    640   //UINT offsetquote;
    641638
    642639  typedef struct {
     
    685682           parguments);
    686683  va_end(parguments);
    687   /*offsetexe = strstr(strlwr(pszPgm), ".exe");
    688   offsetcmd = strstr(strlwr(pszPgm), ".cmd");
    689   offsetcom = strstr(strlwr(pszPgm), ".com");
    690   offsetbtm = strstr(strlwr(pszPgm), ".btm");
    691   offsetbat = strstr(strlwr(pszPgm), ".bat");
    692   if (offsetexe)
    693     offset = offsetexe;
    694   else if (offsetcom)
    695     offset = offsetcom;
    696   else if (offsetcmd)
    697     offset = offsetcmd;
    698   else if (offsetbtm)
    699     offset = offsetbtm;
    700   else if (offsetbat)
    701     offset = offsetbat;
    702   else {
    703     offset = pszPgm;
    704   }
    705   offsetquote = strcspn(pszPgm, buf);
    706   if (pszPgm[0] != '\"' && offsetquote < offset - pszPgm && offsetquote != NULL){
    707     strcpy(tempcom, pszPgm);
    708     tempcom[offset + 4 - pszPgm] = '\0';
    709     strcpy (temparg, &pszPgm[offset + 4 - pszPgm]);
    710     pszDirectory = szTempdir;
    711     strcpy(pszDirectory, tempcom);
    712     offset = strrchr(pszDirectory, '\\');
    713     pszDirectory[offset +1 - pszDirectory] = '\0';
    714     BldQuotedFileName(szTempPgm, tempcom);
    715     strcat(szTempPgm, temparg);
    716     memcpy(pszPgm, szTempPgm, 2048);
    717     //printf("%s\n %s\n%s %s\n %d %d",
    718     //       pszPgm, szTempPgm, tempcom, temparg, offset, offsetquote); fflush(stdout);
    719   } */
     684
    720685  if (pszEnvironment) {
    721686    p = &pszEnvironment[strlen(pszEnvironment)] + 1;
     
    13431308}
    13441309
     1310PSZ CheckApp_QuoteAddExe(PSZ pszPgm)
     1311{
     1312  char szTempPgm[CCHMAXPATH], tempcom[CCHMAXPATH], temparg[CCHMAXPATH];
     1313  char *offset, *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat;
     1314  APIRET ret;
     1315  ULONG ulAppType;
     1316  char *pszChar;
     1317  FILEFINDBUF3 FindBuffer;
     1318  ULONG ulResultBufLen = sizeof(FILEFINDBUF3);
     1319  HDIR hdirFindHandle = HDIR_CREATE;
     1320  ULONG ulFindCount = 1;
     1321  PSZ pszQuotedCompletePgm;
     1322
     1323  bstrip(pszPgm);
     1324  strcpy(tempcom, pszPgm);
     1325  if (tempcom[0] != '\0'){
     1326    offsetexe = strstr(strlwr(pszPgm), ".exe");
     1327    offsetcmd = strstr(strlwr(pszPgm), ".cmd");
     1328    offsetcom = strstr(strlwr(pszPgm), ".com");
     1329    offsetbtm = strstr(strlwr(pszPgm), ".btm");
     1330    offsetbat = strstr(strlwr(pszPgm), ".bat");
     1331    if (offsetbat){
     1332      if (strstr(strlwr(pszPgm), "command ") < offsetbat)
     1333        offset = pszPgm;
     1334      else
     1335        offset = offsetbat;
     1336    }
     1337    else if (offsetbtm){
     1338      if (strstr(strlwr(pszPgm), "4os2 ") < offsetbtm)
     1339        offset = pszPgm;
     1340      else
     1341        offset = offsetbtm;
     1342    }
     1343    else if (offsetcmd){
     1344      if (strstr(strlwr(pszPgm), "cmd ") < offsetcmd ||
     1345          strstr(strlwr(pszPgm), "4os2 ") < offsetcmd)
     1346        offset = pszPgm;
     1347      else
     1348        offset = offsetcmd;
     1349    }
     1350    else if (offsetcom)
     1351      offset = offsetcom;
     1352    else if (offsetexe)
     1353      offset = offsetexe;
     1354    else {
     1355      offset = pszPgm;
     1356    }
     1357    if (offset - pszPgm != 0){
     1358      tempcom[offset + 4 - pszPgm] = '\0';
     1359      strcpy(temparg, &pszPgm[offset + 4 - pszPgm]);
     1360      /*if ((offsetexe  && !offsetcom && !offsetcmd && !offsetbtm && !offsetbat) ||
     1361          (offsetcom  && !offsetexe && !offsetcmd && !offsetbtm && !offsetbat) ||
     1362          (offsetcmd  && !offsetexe && !offsetcom && !offsetbtm && !offsetbat) ||
     1363          (offsetbtm  && !offsetexe && !offsetcom && !offsetcmd && !offsetbat) ||
     1364          (offsetbat  && !offsetexe && !offsetcom && !offsetcmd && !offsetbtm))*/
     1365      remove_first_occurence_of_character("\"", tempcom);
     1366      if (strchr(tempcom, '\"') != strrchr(tempcom, '\"'))
     1367        saymsg(MB_OK, HWND_DESKTOP,
     1368               NullStr,
     1369               GetPString(IDS_QUOTESINARGSTEXT),
     1370               pszPgm);
     1371      else
     1372        remove_first_occurence_of_character("\"", tempcom);
     1373      if ((temparg[0] == '\"' && temparg[1] == ' ') ||
     1374           !strstr(pszPgm, "\\:")||
     1375           strchr(temparg, '\"') == strrchr(temparg, '\"'))
     1376        remove_first_occurence_of_character("\"", temparg);
     1377      if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
     1378        saymsg(MB_OK, HWND_DESKTOP,
     1379               NullStr,
     1380               GetPString(IDS_QUOTESINARGSTEXT),
     1381               pszPgm);
     1382      if (!strstr(strlwr(tempcom), ".exe")) {
     1383        ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
     1384                           ulResultBufLen, &ulFindCount, FIL_STANDARD);
     1385        BldQuotedFileName(szTempPgm, tempcom);
     1386      }
     1387      else{
     1388        BldQuotedFileName(szTempPgm, tempcom);
     1389        ret = DosQueryAppType(tempcom, &ulAppType);
     1390      }
     1391      //printf("%d A", ret); fflush(stdout);
     1392      if (ret) {
     1393        ret = saymsg(MB_YESNO,
     1394                     HWND_DESKTOP,
     1395                     NullStr,
     1396                     GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     1397                     pszPgm);
     1398        if (ret == MBID_YES){
     1399          if (temparg[0] != ' ')
     1400            strcat(szTempPgm, " ");
     1401          strcat(szTempPgm, temparg);
     1402          pszQuotedCompletePgm = szTempPgm;
     1403        }
     1404        else{
     1405          fCancelAction = TRUE;
     1406          pszQuotedCompletePgm = pszPgm;
     1407        }
     1408      }
     1409      else{
     1410        if (temparg[0] != ' ')
     1411          strcat(szTempPgm, " ");
     1412        strcat(szTempPgm, temparg);
     1413        pszQuotedCompletePgm = szTempPgm;
     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(szTempPgm, 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(szTempPgm, " ");
     1459        strcat(szTempPgm, temparg);
     1460        pszQuotedCompletePgm = szTempPgm;
     1461      }
     1462      else {
     1463        ret = saymsg(MB_OK,
     1464                     HWND_DESKTOP,
     1465                     NullStr,
     1466                     GetPString(IDS_PROGRAMNOTEXE2TEXT),
     1467                     pszPgm);
     1468          fCancelAction = TRUE;
     1469          pszQuotedCompletePgm = pszPgm;
     1470      }
     1471    }
     1472    else {
     1473      pszChar = strrchr(tempcom, '.');
     1474      while (pszChar && *pszChar !=' '){
     1475        pszChar++;
     1476      }
     1477      *pszChar = '\0';
     1478      strcpy (temparg, pszPgm + strlen(tempcom));
     1479      while (strchr(tempcom, '\"'))
     1480        remove_first_occurence_of_character("\"", tempcom);
     1481    if ((temparg[0] == '\"' && temparg[1] == ' ') ||
     1482         !strstr(pszPgm, "\\:")||
     1483         strchr(temparg, '\"') == strrchr(temparg, '\"'))
     1484      remove_first_occurence_of_character("\"", temparg);
     1485    if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
     1486      saymsg(MB_OK, HWND_DESKTOP,
     1487             NullStr,
     1488             GetPString(IDS_QUOTESINARGSTEXT),
     1489             pszPgm);
     1490    ret = DosFindFirst(tempcom, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
     1491                         ulResultBufLen, &ulFindCount, FIL_STANDARD);
     1492
     1493    BldQuotedFileName(szTempPgm, tempcom);
     1494    //printf("%d %s ", ret, tempcom); fflush(stdout);
     1495    if (ret) {
     1496      ret = saymsg(MB_YESNO,
     1497                   HWND_DESKTOP,
     1498                   NullStr,
     1499                   GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     1500                   pszPgm);
     1501      if (ret == MBID_YES){
     1502        if (temparg[0] != ' ')
     1503          strcat(szTempPgm, " ");
     1504        strcat(szTempPgm, temparg);
     1505        pszQuotedCompletePgm = szTempPgm;
     1506      }
     1507      else{
     1508        fCancelAction = TRUE;
     1509        pszQuotedCompletePgm = pszPgm;
     1510      }
     1511    }
     1512    ret = saymsg(MB_YESNO,
     1513                   HWND_DESKTOP,
     1514                   NullStr,
     1515                   GetPString(IDS_PROGRAMNOTEXE3TEXT),
     1516                   pszPgm);
     1517      if (ret == MBID_YES){
     1518        if (temparg[0] != ' ')
     1519          strcat(szTempPgm, " ");
     1520        strcat(szTempPgm, temparg);
     1521        pszQuotedCompletePgm = szTempPgm;
     1522      }
     1523      else{
     1524        fCancelAction = TRUE;
     1525        pszQuotedCompletePgm = pszPgm;
     1526      }
     1527    }
     1528    return pszQuotedCompletePgm;
     1529  }
     1530  return pszPgm;
     1531}
     1532
    13451533#pragma alloc_text(SYSTEMF,ShowSession,ExecOnList,runemf2)
Note: See TracChangeset for help on using the changeset viewer.