Changeset 909


Ignore:
Timestamp:
Jan 6, 2008, 9:02:31 PM (18 years ago)
Author:
Gregg Young
Message:

Added quoting code to commands, associations and avv; Minor clean up and fixed one problem with quoting logic; Added warning re %a for commands to work on selected files.

Location:
trunk/dll
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/assoc.c

    r907 r909  
    630630      {
    631631        ASSOC temp;
    632         CHAR dummy[34];
     632        CHAR dummy[34], *psz[1002];
    633633
    634634        replace = FALSE;
     
    645645        memset(&temp, 0, sizeof(ASSOC));
    646646        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    647         WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
     647        WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
     648        *psz = CheckApp_QuoteAddExe(temp.cl);
     649        memcpy(temp.cl, *psz, strlen(*psz) + 1);
    648650        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    649651        rstrip(temp.sig);
     
    669671          temp.flags |= DIEAFTER;
    670672        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    671           temp.flags |= PROMPT;
     673          temp.flags |= PROMPT;
     674        if (fCancelAction){
     675          fCancelAction = FALSE;
     676          break;
     677        }
     678        else
    672679        info = add_association(&temp);
    673680        if (!info)
     
    719726      {
    720727        ASSOC temp;
    721         CHAR dummy[34];
     728        CHAR dummy[34], *psz[1002];
    722729
    723730        replace = FALSE;
     
    725732        memset(&temp, 0, sizeof(ASSOC));
    726733        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    727         WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
     734        WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
     735        *psz = CheckApp_QuoteAddExe(temp.cl);
     736        memcpy(temp.cl, *psz, strlen(*psz) + 1);
    728737        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    729738        rstrip(temp.sig);
     
    749758          temp.flags |= DIEAFTER;
    750759        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    751           temp.flags |= PROMPT;
    752         info = add_association(&temp);
     760          temp.flags |= PROMPT;
     761        if (fCancelAction){
     762          fCancelAction = FALSE;
     763          break;
     764        }
     765        else
     766          info = add_association(&temp);
    753767        //Add will fail if mask is not changed
    754768        if (info) {
     
    821835      {
    822836        ASSOC temp;
    823         CHAR dummy[34];
     837        CHAR dummy[34], *psz[1002];
    824838
    825839        replace = TRUE;
     
    831845        memset(&temp, 0, sizeof(ASSOC));
    832846        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    833         WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
     847        WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
     848        *psz = CheckApp_QuoteAddExe(temp.cl);
     849        memcpy(temp.cl, *psz, strlen(*psz) + 1);
    834850        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    835851        rstrip(temp.sig);
     
    855871          temp.flags |= DIEAFTER;
    856872        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    857           temp.flags |= PROMPT;
    858         info = add_association(&temp);
     873          temp.flags |= PROMPT;
     874        if (fCancelAction){
     875          fCancelAction = FALSE;
     876          break;
     877        }
     878        else
     879          info = add_association(&temp);
    859880        //Add will fail if mask is not changed
    860881        if (info) {
  • trunk/dll/command.c

    r907 r909  
    568568        if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
    569569          BldQuotedFileName(szfilename, filename);
    570           strcat(szfilename, " %a");
    571570          WinSetDlgItemText(hwnd, CMD_CL, szfilename);
    572571        }
     
    620619      }
    621620      {
    622         COMMAND temp;
     621        COMMAND temp;
     622        char *psz[1002];
     623        APIRET ret;
    623624
    624625        memset(&temp, 0, sizeof(COMMAND));
    625626        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    626         bstrip(temp.cl);
     627        *psz = CheckApp_QuoteAddExe(temp.cl);
     628        memcpy(temp.cl, *psz, strlen(*psz) + 1);
     629        if (!strchr(temp.cl, '%')){
     630          ret = saymsg(MB_YESNO,
     631                       HWND_DESKTOP,
     632                       NullStr,
     633                       GetPString(IDS_TOACTONSELECTEDTEXT));
     634          if (ret == MBID_YES)
     635            strcat(temp.cl, " %a");
     636        }
    627637        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    628638        if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     
    641651          temp.flags |= PROMPT;
    642652        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    643           temp.flags |= ONCE;
    644         info = add_command(&temp);
    645         if (!info)
     653          temp.flags |= ONCE;
     654        if (fCancelAction){
     655          fCancelAction = FALSE;
     656          break;
     657        }
     658        else
     659          info = add_command(&temp);
     660        if (!info)
    646661        {
    647662          WinDismissDlg(hwnd, 0);
     
    698713    case CMD_ADD:
    699714      {
    700         COMMAND temp;
     715        COMMAND temp;
     716        CHAR *psz[1002];
     717        APIRET ret;
    701718
    702719        memset(&temp, 0, sizeof(COMMAND));
    703720        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    704         bstrip(temp.cl);
     721        *psz = CheckApp_QuoteAddExe(temp.cl);
     722        memcpy(temp.cl, *psz, strlen(*psz) + 1);
     723        if (!strchr(temp.cl, '%')){
     724          ret = saymsg(MB_YESNO,
     725                       HWND_DESKTOP,
     726                       NullStr,
     727                       GetPString(IDS_TOACTONSELECTEDTEXT));
     728          if (ret == MBID_YES)
     729            strcat(temp.cl, " %a");
     730        }
    705731        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    706732        if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     
    719745          temp.flags |= PROMPT;
    720746        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    721           temp.flags |= ONCE;
    722         info = add_command(&temp);
     747          temp.flags |= ONCE;
     748        if (fCancelAction){
     749          fCancelAction = FALSE;
     750          break;
     751        }
     752        else
     753          info = add_command(&temp);
    723754        if (!info) {
    724755          saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
     
    781812      break;
    782813    case CMD_REPLACE:
    783       {
    784         CHAR temp[34];
     814      { //Delete first
     815        char *psz[1002];
     816        COMMAND temp;
     817        APIRET ret;
     818
     819        memset(&temp, 0, sizeof(COMMAND));
     820        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
     821        *psz = CheckApp_QuoteAddExe(temp.cl);
     822        memcpy(temp.cl, *psz, strlen(*psz) + 1);
     823        if (fCancelAction){
     824          fCancelAction = FALSE;
     825          break;
     826        }
     827        if (!strchr(temp.cl, '%')){
     828          ret = saymsg(MB_YESNO,
     829                       HWND_DESKTOP,
     830                       NullStr,
     831                       GetPString(IDS_TOACTONSELECTEDTEXT));
     832          if (ret == MBID_YES)
     833            strcat(temp.cl, " %a");
     834        }
     835        //remember item location in the list
    785836        y = (SHORT) WinSendDlgItemMsg(hwnd,
    786                                         CMD_LISTBOX,
    787                                         LM_QUERYSELECTION,
    788                                         MPFROMSHORT(LIT_CURSOR), MPVOID);
    789         WinQueryDlgItemText(hwnd, CMD_TITLE, 34, temp);
    790         bstrip(temp);
    791         if (kill_command(temp))
    792            {
     837                                      CMD_LISTBOX,
     838                                      LM_QUERYSELECTION,
     839                                      MPFROMSHORT(LIT_CURSOR), MPVOID);
     840        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
     841        bstrip(temp.title);
     842        if (kill_command(temp.title)){
    793843          x = (SHORT) WinSendDlgItemMsg(hwnd,
    794844                                        CMD_LISTBOX,
     
    804854                              MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
    805855          }
    806           save_commands();
    807         }
    808       }
    809       {
    810         COMMAND temp;
    811 
    812         memset(&temp, 0, sizeof(COMMAND));
    813         WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    814         bstrip(temp.cl);
    815         WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    816         if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
    817           temp.flags = 0;
    818         else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
    819           temp.flags = FULLSCREEN;
    820         else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED))
    821           temp.flags = MINIMIZED;
    822         else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED))
    823           temp.flags = MAXIMIZED;
    824         else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE))
    825           temp.flags = INVISIBLE;
    826         if (WinQueryButtonCheckstate(hwnd, CMD_KEEP))
    827           temp.flags |= KEEP;
    828         if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT))
    829           temp.flags |= PROMPT;
    830         if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    831           temp.flags |= ONCE;
    832         info = add_command(&temp);
    833         if (!info) {
     856        } // then do an add
     857        if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     858          temp.flags = 0;
     859        else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
     860          temp.flags = FULLSCREEN;
     861        else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED))
     862          temp.flags = MINIMIZED;
     863        else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED))
     864          temp.flags = MAXIMIZED;
     865        else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE))
     866          temp.flags = INVISIBLE;
     867        if (WinQueryButtonCheckstate(hwnd, CMD_KEEP))
     868          temp.flags |= KEEP;
     869        if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT))
     870          temp.flags |= PROMPT;
     871        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
     872          temp.flags |= ONCE;
     873        info = add_command(&temp);
     874        if (!info) {
    834875          saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
    835                  GetPString(IDS_CANTADDCOMMANDTEXT),
    836                  temp.title);
    837         }
     876                 GetPString(IDS_CANTADDCOMMANDTEXT),
     877                 temp.title);
     878          }
     879
    838880        else {
    839881          CHAR env[1002];
     
    844886          if (*env) {
    845887            PrfWriteProfileString(fmprof, FM3Str, temp.cl, env);
    846           }
     888          } //put item back in original place
    847889          x = (SHORT) WinSendDlgItemMsg(hwnd,
    848890                                        CMD_LISTBOX,
     
    850892                                        MPFROM2SHORT(y, 0),
    851893                                        MPFROMP(temp.title));
    852           if (x >= 0) {
     894          if (x >= 0) {
     895            LINKCMDS *temphead = NULL,*last = NULL, *temptail = NULL;
     896            SHORT numitems, sSelect = 0;
     897
    853898            WinSendDlgItemMsg(hwnd,
    854899                              CMD_LISTBOX,
     
    859904                              LM_SELECTITEM,
    860905                              MPFROMSHORT(x), MPFROMSHORT(TRUE));
    861             {
    862             LINKCMDS *temphead = NULL, *info, *last = NULL, *temptail = NULL;
    863         SHORT sSelect, numitems;
    864 
    865         sSelect = 0;
    866         numitems = (SHORT) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
    867                                              LM_QUERYITEMCOUNT,
    868                                              MPVOID, MPVOID);
    869         while (numitems) {
    870           info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
    871                                                 LM_QUERYITEMHANDLE,
    872                                                 MPFROMSHORT(sSelect++),
    873                                                 MPVOID);
    874           if (info) {
    875             if (!temphead) {
    876               temphead = info;
    877               info->prev = NULL;
    878             }
    879             else {
    880               last->next = info;
    881               info->prev = last;
    882             }
    883             temptail = info;
    884             last = info;
    885             info->next = NULL;
    886           }
    887           numitems--;
     906            //then reorder
     907            numitems = (SHORT) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
     908                                                 LM_QUERYITEMCOUNT,
     909                                                 MPVOID, MPVOID);
     910
     911            while (numitems) {
     912
     913
     914              info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
     915                                                    LM_QUERYITEMHANDLE,
     916                                                    MPFROMSHORT(sSelect++),
     917                                                    MPVOID);
     918              if (info) {
     919                if (!temphead) {
     920                  temphead = info;
     921                  info->prev = NULL;
     922                }
     923                else {
     924                  last->next = info;
     925                  info->prev = last;
     926                }
     927                temptail = info;
     928                last = info;
     929                info->next = NULL;
     930              }
     931              numitems--;
     932            }
     933            cmdhead = temphead;
     934            cmdtail = temptail;
     935            save_commands();
     936          }
    888937        }
    889             }
    890             save_commands();
    891           }
    892         }
    893938      }
    894939      break;
  • trunk/dll/fm3dll.str

    r906 r909  
    295295The FM/2 INI file \"%s\" can not be marked read/write.
    296296FM/2: Help
    297 The program "%s" not found.\nAre the Path and Filename correct?\nDo you wish to save it anyway?
     297The program "%s" not found. Are the Path and Filename correct? Do you wish to save it anyway?
    298298"%s" doesn't appear to be executable.\nDo you wish to save it anyway?
    299299"%s" isn't an exe file and has no extension.\nFM2 requires an extension for executing a program
    300 "%s" doesn't appear to be executable. It doesn't have a standard executable file extension\nDo you wish to save it anyway?
     300"%s" doesn't appear to be executable. It doesn't have a standard executable file extension Do you wish to save it anyway?
    301301"%s" has quoting in the program arguments which may or may not be correct.
    302 
     302For a command to act on selected files it must be followed by "%%a". Should I add it?
    303303FM/2: See all files
    304304 <Untitled>
  • trunk/dll/fm3str.h

    r906 r909  
    306306#define IDS_PROGRAMNOTEXE3TEXT                                299
    307307#define IDS_QUOTESINARGSTEXT                                  300
     308#define IDS_TOACTONSELECTEDTEXT                               301
    308309#define IDS_SEEALLTITLETEXT                                   302
    309310#define IDS_UNTITLEDTEXT                                      303
  • trunk/dll/systemf.c

    r907 r909  
    13091309PSZ CheckApp_QuoteAddExe(PSZ pszPgm)
    13101310{
    1311   char szTempPgm[CCHMAXPATH], tempcom[CCHMAXPATH], temparg[CCHMAXPATH];
    1312   char *offset, *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat;
     1311  char szTempPgm[2048], tempcom[2048], temparg[2048];
     1312  char *offset = '\0', *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat;
    13131313  APIRET ret;
    13141314  ULONG ulAppType;
     
    13281328    offsetbtm = strstr(strlwr(pszPgm), ".btm");
    13291329    offsetbat = strstr(strlwr(pszPgm), ".bat");
    1330     if (offsetbat){
    1331       if (strstr(strlwr(pszPgm), "command ") < offsetbat)
    1332         offset = pszPgm;
    1333       else
    1334         offset = offsetbat;
    1335     }
    1336     else if (offsetbtm){
    1337       if (strstr(strlwr(pszPgm), "4os2 ") < offsetbtm)
    1338         offset = pszPgm;
    1339       else
    1340         offset = offsetbtm;
    1341     }
    1342     else if (offsetcmd){
    1343       if (strstr(strlwr(pszPgm), "cmd ") < offsetcmd ||
    1344           strstr(strlwr(pszPgm), "4os2 ") < offsetcmd)
    1345         offset = pszPgm;
    1346       else
    1347         offset = offsetcmd;
    1348     }
    1349     else if (offsetcom)
    1350       offset = offsetcom;
    1351     else if (offsetexe)
     1330    if (offsetexe)
    13521331      offset = offsetexe;
    1353     else {
    1354       offset = pszPgm;
    1355     }
    1356     if (offset - pszPgm != 0){
     1332    else{
     1333      if (offsetcom)
     1334        offset = offsetcom;
     1335      else{
     1336        if (offsetcmd)
     1337          offset = offsetcmd;
     1338        else{
     1339          if (offsetbtm)
     1340            offset = offsetbtm;
     1341          else{
     1342            if (offsetbat)
     1343              offset = offsetexe;
     1344          }
     1345        }
     1346      }
     1347    }
     1348    if (offset){
    13571349      tempcom[offset + 4 - pszPgm] = '\0';
    13581350      strcpy(temparg, &pszPgm[offset + 4 - pszPgm]);
Note: See TracChangeset for help on using the changeset viewer.