Changeset 888 for trunk/dll/notebook.c


Ignore:
Timestamp:
Dec 22, 2007, 11:02:11 PM (18 years ago)
Author:
Gregg Young
Message:

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/notebook.c

    r878 r888  
    138138    case CFGA_FIND:
    139139      {
    140         CHAR filename[CCHMAXPATH + 9];
     140        CHAR filename[CCHMAXPATH + 9], szfilename[CCHMAXPATH + 9];
    141141        USHORT id;
    142142        HWND hwndFocus;
     
    148148          switch (id) {
    149149          case CFGA_VIRUS:
    150             if (insert_filename(hwnd, filename, 2, FALSE) && *filename)
    151               WinSetDlgItemText(hwnd, id, filename);
     150            if (insert_filename(hwnd, filename, 2, FALSE) && *filename){
     151              BldQuotedFileName(szfilename, filename);
     152              strcat(szfilename, " %p");
     153              WinSetDlgItemText(hwnd, id, szfilename);
     154            }
    152155            break;
    153156          case CFGA_EXTRACTPATH:
     
    194197      *szDefArc = 0;
    195198    PrfWriteProfileString(fmprof, appname, "DefArc", szDefArc);
    196     WinQueryDlgItemText(hwnd, CFGA_VIRUS, CCHMAXPATH, virus);
    197     virus[CCHMAXPATH - 1] = 0;
    198     bstrip(virus);
     199    {
     200      CHAR szBuf[CCHMAXPATH], buf[10] = "\"%-/";
     201
     202      WinQueryDlgItemText(hwnd, CFGA_VIRUS, CCHMAXPATH, szBuf);
     203      szBuf[CCHMAXPATH - 1] = 0;
     204      bstrip(szBuf);
     205      if (!strcspn(szBuf, buf))
     206        BldQuotedFileName(virus, szBuf);
     207      else
     208        memcpy(virus, szBuf, strlen(szBuf) + 1);
     209      if (!strchr(virus, '%') && strlen(virus) > 3)
     210        strcat(virus, " %p");
     211    }
    199212    if (!*virus)
    200213      strcpy(virus, "OS2SCAN.EXE %p /SUB /A");
     
    414427    case CFGV_FIND:
    415428      {
    416         CHAR filename[CCHMAXPATH + 9];
     429        CHAR filename[CCHMAXPATH + 9], szfilename[CCHMAXPATH + 9];
    417430        USHORT id;
    418431        HWND hwndFocus;
     
    427440          case CFGV_VIEWER:
    428441          case CFGV_EDITOR:
    429             if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
    430               strcat(filename, " %a");
    431               WinSetDlgItemText(hwnd, id, filename);
     442            if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
     443              BldQuotedFileName(szfilename, filename);
     444              strcat(szfilename, " %a");
     445              WinSetDlgItemText(hwnd, id, szfilename);
    432446            }
    433447            break;
    434448          case CFGV_HTTPRUN:
    435449          case CFGV_FTPRUN:
    436             if (insert_filename(hwnd, filename, 2, FALSE) && *filename)
    437               WinSetDlgItemText(hwnd, id, filename);
     450            if (insert_filename(hwnd, filename, 2, FALSE) && *filename){
     451              BldQuotedFileName(szfilename, filename);
     452              WinSetDlgItemText(hwnd, id, szfilename);
     453            }
    438454            break;
    439455          default:
     
    448464
    449465  case WM_CLOSE:
    450     WinQueryDlgItemText(hwnd, CFGV_VIEWER, CCHMAXPATH, viewer);
    451     viewer[CCHMAXPATH - 1] = 0;
    452     bstrip(viewer);
    453     WinQueryDlgItemText(hwnd, CFGV_EDITOR, CCHMAXPATH, editor);
    454     editor[CCHMAXPATH - 1] = 0;
    455     bstrip(editor);
    456     WinQueryDlgItemText(hwnd, CFGV_BINVIEW, CCHMAXPATH, binview);
    457     binview[CCHMAXPATH - 1] = 0;
    458     bstrip(binview);
    459     WinQueryDlgItemText(hwnd, CFGV_BINED, CCHMAXPATH, bined);
    460     bined[CCHMAXPATH - 1] = 0;
    461     bstrip(bined);
    462     WinQueryDlgItemText(hwnd, CFGV_FTPRUN, CCHMAXPATH, ftprun);
    463     ftprun[CCHMAXPATH - 1] = 0;
    464     bstrip(ftprun);
    465     WinQueryDlgItemText(hwnd, CFGV_HTTPRUN, CCHMAXPATH, httprun);
    466     httprun[CCHMAXPATH - 1] = 0;
    467     bstrip(httprun);
    468     PrfWriteProfileString(fmprof, appname, "Viewer", viewer);
    469     PrfWriteProfileString(fmprof, appname, "Editor", editor);
    470     PrfWriteProfileString(fmprof, appname, "BinView", binview);
    471     PrfWriteProfileString(fmprof, appname, "BinEd", bined);
    472     PrfWriteProfileString(fmprof, appname, "FTPRun", ftprun);
    473     PrfWriteProfileString(fmprof, appname, "HTTPRun", httprun);
    474     fUseNewViewer = WinQueryButtonCheckstate(hwnd, CFGV_USENEWVIEWER);
    475     PrfWriteProfileData(fmprof, appname, "UseNewViewer", &fUseNewViewer,
    476                         sizeof(BOOL));
    477     fGuessType = WinQueryButtonCheckstate(hwnd, CFGV_GUESSTYPE);
    478     PrfWriteProfileData(fmprof, appname, "GuessType", &fGuessType,
    479                         sizeof(BOOL));
    480     fViewChild = WinQueryButtonCheckstate(hwnd, CFGV_VIEWCHILD);
    481     PrfWriteProfileData(fmprof, appname, "ViewChild", &fViewChild,
    482                         sizeof(BOOL));
    483     fCheckMM = WinQueryButtonCheckstate(hwnd, CFGV_CHECKMM);
    484     PrfWriteProfileData(fmprof, appname, "CheckMM", &fCheckMM, sizeof(BOOL));
    485     break;
     466    {
     467      CHAR szBuf[CCHMAXPATH], buf[10] = "\"%-/";
     468
     469      WinQueryDlgItemText(hwnd, CFGV_VIEWER, CCHMAXPATH, szBuf);
     470      szBuf[CCHMAXPATH - 1] = 0;
     471      bstrip(szBuf);
     472      if (!strcspn(szBuf, buf))
     473        BldQuotedFileName(viewer, szBuf);
     474      else
     475        memcpy(viewer, szBuf, strlen(szBuf) + 1);
     476      if (!strchr(viewer, '%') && strlen(viewer) > 3)
     477        strcat(viewer, " %a");
     478      WinQueryDlgItemText(hwnd, CFGV_EDITOR, CCHMAXPATH, szBuf);
     479      szBuf[CCHMAXPATH - 1] = 0;
     480      bstrip(szBuf);
     481      if (!strcspn(szBuf, buf))
     482        BldQuotedFileName(editor, szBuf);
     483      else
     484        memcpy(editor, szBuf, strlen(szBuf) + 1);
     485      if (!strchr(editor, '%') && strlen(editor) > 3)
     486        strcat(editor, " %a");
     487      WinQueryDlgItemText(hwnd, CFGV_BINVIEW, CCHMAXPATH, szBuf);
     488      szBuf[CCHMAXPATH - 1] = 0;
     489      bstrip(szBuf);
     490      if (!strcspn(szBuf, buf))
     491        BldQuotedFileName(binview, szBuf);
     492      else
     493        memcpy(binview, szBuf, strlen(szBuf) + 1);
     494      if (!strchr(binview, '%') && strlen(binview) > 3)
     495        strcat(binview, " %a");
     496      WinQueryDlgItemText(hwnd, CFGV_BINED, CCHMAXPATH, szBuf);
     497      szBuf[CCHMAXPATH - 1] = 0;
     498      bstrip(szBuf);
     499      if (!strcspn(szBuf, buf))
     500        BldQuotedFileName(bined, szBuf);
     501      else
     502        memcpy(bined, szBuf, strlen(szBuf) + 1);
     503      if (!strchr(bined, '%') && strlen(bined) > 3)
     504        strcat(bined, " %a");
     505      WinQueryDlgItemText(hwnd, CFGV_FTPRUN, CCHMAXPATH, szBuf);
     506      szBuf[CCHMAXPATH - 1] = 0;
     507      bstrip(szBuf);
     508      if (!strchr(szBuf, '"'))
     509        BldQuotedFileName(ftprun, szBuf);
     510      else
     511        memcpy(ftprun, szBuf, strlen(szBuf) + 1);
     512      WinQueryDlgItemText(hwnd, CFGV_HTTPRUN, CCHMAXPATH, szBuf);
     513      szBuf[CCHMAXPATH - 1] = 0;
     514      bstrip(szBuf);
     515      if (!strchr(szBuf, '"'))
     516        BldQuotedFileName(httprun, szBuf);
     517      else
     518        memcpy(httprun, szBuf, strlen(szBuf) + 1);
     519      PrfWriteProfileString(fmprof, appname, "Viewer", viewer);
     520      PrfWriteProfileString(fmprof, appname, "Editor", editor);
     521      PrfWriteProfileString(fmprof, appname, "BinView", binview);
     522      PrfWriteProfileString(fmprof, appname, "BinEd", bined);
     523
     524      PrfWriteProfileString(fmprof, appname, "FTPRun", ftprun);
     525      PrfWriteProfileString(fmprof, appname, "HTTPRun", httprun);
     526      fUseNewViewer = WinQueryButtonCheckstate(hwnd, CFGV_USENEWVIEWER);
     527      PrfWriteProfileData(fmprof, appname, "UseNewViewer", &fUseNewViewer,
     528                          sizeof(BOOL));
     529      fGuessType = WinQueryButtonCheckstate(hwnd, CFGV_GUESSTYPE);
     530      PrfWriteProfileData(fmprof, appname, "GuessType", &fGuessType,
     531                          sizeof(BOOL));
     532      fViewChild = WinQueryButtonCheckstate(hwnd, CFGV_VIEWCHILD);
     533      PrfWriteProfileData(fmprof, appname, "ViewChild", &fViewChild,
     534                          sizeof(BOOL));
     535      fCheckMM = WinQueryButtonCheckstate(hwnd, CFGV_CHECKMM);
     536      PrfWriteProfileData(fmprof, appname, "CheckMM", &fCheckMM, sizeof(BOOL));
     537      break;
     538    }
    486539  }
    487540  return WinDefDlgProc(hwnd, msg, mp1, mp2);
     
    9961049    case CFGC_FIND:
    9971050      {
    998         CHAR filename[CCHMAXPATH + 9];
     1051        CHAR filename[CCHMAXPATH + 9], szfilename[CCHMAXPATH + 9];
    9991052        USHORT id;
    10001053        HWND hwndFocus;
     
    10071060          case CFGC_COMPARE:
    10081061          case CFGC_DIRCOMPARE:
    1009             if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
    1010               strcat(filename, " %a");
    1011               WinSetDlgItemText(hwnd, id, filename);
     1062            if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
     1063              BldQuotedFileName(szfilename, filename);
     1064              strcat(szfilename, " %a");
     1065              WinSetDlgItemText(hwnd, id, szfilename);
    10121066            }
    10131067            break;
     
    10231077
    10241078  case WM_CLOSE:
    1025     WinQueryDlgItemText(hwnd, CFGC_DIRCOMPARE, CCHMAXPATH, dircompare);
    1026     dircompare[CCHMAXPATH - 1] = 0;
    1027     bstrip(dircompare);
    1028     PrfWriteProfileString(fmprof, appname, "DirCompare", dircompare);
    1029     WinQueryDlgItemText(hwnd, CFGC_COMPARE, CCHMAXPATH, compare);
    1030     compare[CCHMAXPATH - 1] = 0;
    1031     bstrip(compare);
    1032     PrfWriteProfileString(fmprof, appname, "Compare", compare);
    1033     break;
     1079    {
     1080      CHAR szBuf[CCHMAXPATH], buf[10] = "\"%-/";
     1081
     1082      WinQueryDlgItemText(hwnd, CFGC_DIRCOMPARE, CCHMAXPATH, szBuf);
     1083        szBuf[CCHMAXPATH - 1] = 0;
     1084        bstrip(szBuf);
     1085        if (!strcspn(szBuf, buf))
     1086          BldQuotedFileName(dircompare, szBuf);
     1087        else
     1088          memcpy(dircompare, szBuf, strlen(szBuf) + 1);
     1089        if (!strchr(dircompare, '%') && strlen(dircompare) > 3)
     1090          strcat(dircompare, " %a");
     1091      PrfWriteProfileString(fmprof, appname, "DirCompare", dircompare);
     1092      WinQueryDlgItemText(hwnd, CFGC_COMPARE, CCHMAXPATH, szBuf);
     1093        szBuf[CCHMAXPATH - 1] = 0;
     1094        bstrip(szBuf);
     1095        if (!strcspn(szBuf, buf))
     1096          BldQuotedFileName(compare, szBuf);
     1097        else
     1098          memcpy(compare, szBuf, strlen(szBuf) + 1);
     1099        if (!strchr(compare, '%') && strlen(compare) > 3)
     1100          strcat(compare, " %a");
     1101      PrfWriteProfileString(fmprof, appname, "Compare", compare);
     1102      break;
     1103    }
    10341104  }
    10351105  return WinDefDlgProc(hwnd, msg, mp1, mp2);
Note: See TracChangeset for help on using the changeset viewer.