Changeset 920 for trunk/dll


Ignore:
Timestamp:
Jan 13, 2008, 2:18:17 AM (18 years ago)
Author:
Gregg Young
Message:

Cleanup of NormalizeCmdLine moved to pathutil.c

Location:
trunk/dll
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/assoc.c

    r918 r920  
    1515  19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
    1616  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
    17   06 Jan 08 GKY Use CheckApp_QuoteAddExe to check program strings on entry
     17  06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
    1818
    1919**************************************************************************************/
     
    632632        ASSOC temp;
    633633        CHAR dummy[34];
    634         PSZ psz;
     634        PSZ pszWorkBuf;
    635635        replace = FALSE;
    636636
     
    645645                                          MPFROMSHORT(0), MPFROMSHORT(TRUE));
    646646        }
    647         psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     647        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    648648        memset(&temp, 0, sizeof(ASSOC));
    649649        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    650650        WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
    651         CheckApp_QuoteAddExe(psz, temp.cl);
    652         memcpy(temp.cl, psz, strlen(psz) + 1);
     651        NormalizeCmdLine(pszWorkBuf, temp.cl);
     652        memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
    653653        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    654654        rstrip(temp.sig);
     
    730730        ASSOC temp;
    731731        CHAR dummy[34];
    732         PSZ psz;
     732        PSZ pszWorkBuf;
    733733        replace = FALSE;
    734734
    735         psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     735        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    736736        memset(&temp, 0, sizeof(ASSOC));
    737737        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    738738        WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
    739         CheckApp_QuoteAddExe(psz, temp.cl);
    740         memcpy(temp.cl, psz, strlen(psz) + 1);
     739        NormalizeCmdLine(pszWorkBuf, temp.cl);
     740        memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
    741741        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    742742        rstrip(temp.sig);
     
    840840        ASSOC temp;
    841841        CHAR dummy[34];
    842         PSZ psz;
     842        PSZ pszWorkBuf;
    843843        replace = TRUE;
    844844
     
    847847                                      LM_QUERYSELECTION,
    848848                                      MPFROMSHORT(LIT_CURSOR), MPVOID);
    849         psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     849        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    850850        memset(&temp, 0, sizeof(ASSOC));
    851851        WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
    852852        WinQueryDlgItemText(hwnd, ASS_CL, sizeof(temp.cl), temp.cl);
    853         CheckApp_QuoteAddExe(psz, temp.cl);
    854         memcpy(temp.cl, psz, strlen(psz) + 1);
     853        NormalizeCmdLine(pszWorkBuf, temp.cl);
     854        memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
    855855        WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
    856856        rstrip(temp.sig);
  • trunk/dll/avv.c

    r918 r920  
    2323  16 Jun 07 SHL Update for OpenWatcom
    2424  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
    25   06 Jan 08 GKY Use CheckApp_QuoteAddExe to check program strings on entry
     25  06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
    2626
    2727***********************************************************************/
     
    4040#include "errutil.h"                    // Runtime_Error
    4141#include "fm3dll.h"
     42#include "pathutil.h"                   // NormalizeCmdLine
    4243
    4344#pragma data_seg(DATA1)
     
    9293static PSZ free_and_strdup_quoted_from_window(HWND hwnd, USHORT id, PSZ pszDest)
    9394{ // fixme for command line limit
    94   CHAR sz[256];
    95   PSZ psz;
    96 
    97   psz = xmalloc(256, pszSrcFile, __LINE__);
     95  CHAR szCmdLine[256];
     96  PSZ pszWorkBuf;
     97
     98  pszWorkBuf = xmalloc(256, pszSrcFile, __LINE__);
    9899  xfree(pszDest);
    99   WinQueryDlgItemText(hwnd, id, sizeof(sz), sz);
    100   if (*sz){
    101     CheckApp_QuoteAddExe(psz, sz);
    102     pszDest = xstrdup(psz, pszSrcFile, __LINE__);
     100  WinQueryDlgItemText(hwnd, id, sizeof(szCmdLine), szCmdLine);
     101  if (*szCmdLine){
     102    NormalizeCmdLine(pszWorkBuf, szCmdLine);
     103    pszDest = xstrdup(pszWorkBuf, pszSrcFile, __LINE__);
    103104  }
    104105  else
  • trunk/dll/command.c

    r918 r920  
    2121  19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
    2222  20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
    23   06 Jan 08 GKY Use CheckApp_QuoteAddExe to check program strings on entry
     23  06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
    2424
    2525***********************************************************************/
     
    4040#include "strutil.h"                    // GetPString
    4141#include "fm3dll.h"
    42 
     42#include "pathutil.h"                   // NormalizeCmdLine
    4343
    4444typedef struct
     
    621621      {
    622622        COMMAND temp;
    623         PSZ psz;
     623        PSZ pszWorkBuf;
    624624        APIRET ret;
    625625
    626         psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     626        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    627627        memset(&temp, 0, sizeof(COMMAND));
    628628        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    629         CheckApp_QuoteAddExe(psz, temp.cl);
    630         memcpy(temp.cl, psz, strlen(psz) + 1);
     629        NormalizeCmdLine(pszWorkBuf, temp.cl);
     630        memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
    631631        if (!strchr(temp.cl, '%')){
    632632          ret = saymsg(MB_YESNO,
     
    716716      {
    717717        COMMAND temp;
    718         PSZ psz;
     718        PSZ pszWorkBuf;
    719719        APIRET ret;
    720720
    721         psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     721        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    722722        memset(&temp, 0, sizeof(COMMAND));
    723723        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    724         CheckApp_QuoteAddExe(psz, temp.cl);
    725         memcpy(temp.cl, psz, strlen(psz) + 1);
     724        NormalizeCmdLine(pszWorkBuf, temp.cl);
     725        memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
    726726        if (!strchr(temp.cl, '%')){
    727727          ret = saymsg(MB_YESNO,
     
    816816    case CMD_REPLACE:
    817817      { //Delete first
    818         PSZ psz;
     818        PSZ pszWorkBuf;
    819819        COMMAND temp;
    820820        APIRET ret;
    821821
    822         psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     822        pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    823823        memset(&temp, 0, sizeof(COMMAND));
    824824        WinQueryDlgItemText(hwnd, CMD_CL, sizeof(temp.cl), temp.cl);
    825         CheckApp_QuoteAddExe(psz, temp.cl);
    826         memcpy(temp.cl, psz, strlen(psz) + 1);
     825        NormalizeCmdLine(pszWorkBuf, temp.cl);
     826        memcpy(temp.cl, pszWorkBuf, strlen(pszWorkBuf) + 1);
    827827        if (fCancelAction){
    828828          fCancelAction = FALSE;
  • trunk/dll/dirsize.c

    r907 r920  
    9292  CHAR maskstr[CCHMAXPATH];
    9393  CHAR szBuf[CCHMAXPATH];
     94  CHAR FileSystem[CCHMAXPATH];
    9495  CHAR *pEndMask;
    9596  register char *p;
     
    109110  *pullTotalBytes = 0;                  // In case we fail
    110111
     112  CheckDrive(toupper(*pszFileName), FileSystem, NULL);
     113  /*if (!stricmp(FileSystem, NTFS)) {
     114    saymsg(MB_OK,
     115           HWND_DESKTOP,
     116           NullStr,
     117           GetPString(IDS_NTFSDRIVERFAILSTEXT));
     118    return FALSE;
     119  } */
    111120  ulBufBytes = sizeof(FILEFINDBUF4L) * FilesToGet;
    112121  pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__);
     
    138147   * requesting EASIZE.  sheesh.
    139148   */
    140   if ((!rc && (pffbArray->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) {
     149  if (((!rc || rc == ERROR_NO_MORE_FILES) && (pffbArray->attrFile & FILE_DIRECTORY)) || strlen(pszFileName) < 4) {
    141150    if (*pchStopFlag) {
    142151      free(pffbArray);
  • trunk/dll/fm3dll.h

    r918 r920  
    684684HAPP Exec(HWND hwndNotify, BOOL child, char *startdir, char *env,
    685685          PROGTYPE * progt, ULONG fl, char *formatstring, ...);
    686 PSZ CheckApp_QuoteAddExe(PSZ pszQuotedCompletePgm, PSZ pszPgm);
    687686#define MAXCOMLINESTRG (4096)                   /* used to build command line strings */
    688687#define RUNTYPE_MASK  0xf
  • trunk/dll/fm3dll.str

    r919 r920  
    723723Unknown datatype 0x%04x (%u bytes)
    724724FM/2 Databar
    725 Spare 724
     725The NTFS.IFS fails with a NO_MORE_FILES_ERROR on each subdirectory. We have not found a work around as yet.
    726726Sun
    727727Mon
  • trunk/dll/fm3str.h

    r919 r920  
    717717#define IDS_UNKNOWNBYTESTEXT                                  722
    718718#define IDS_DATABARTITLETEXT                                  723
    719 #define IDS_SPARE_724                                         724       // available
     719#define IDS_NTFSDRIVERFAILSTEXT                               724
    720720#define IDS_SUNDAY                                            725
    721721#define IDS_MONDAY                                            726
  • trunk/dll/newview.c

    r907 r920  
    19621962
    19631963  case UM_SETUP2:
    1964     /*
     1964    /**
    19651965     * calculate width of client in characters, recalc lines if
    19661966     * oldwidth != newwidth, set ad->oldwidth for later comparison
  • trunk/dll/notebook.c

    r919 r920  
    2121  21 Aug 07 GKY Make Subject column in dircnr sizable and movable from the rigth to the left pane
    2222  26 Nov 07 GKY Allow a currently nonvalid path in the ext path field with warning
    23   06 Jan 08 GKY Use CheckApp_QuoteAddExe to check program strings on entry
     23  06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
    2424  10 Jan 08 SHL Remember last settings page
    2525  10 Jan 08 SHL Rework page select logic
     
    194194    {
    195195      CHAR szCLBuf[MAXCOMLINESTRG], szPathBuf[CCHMAXPATH];
    196       PSZ psz;
    197 
    198       psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     196      PSZ pszWorkBuf;
     197
     198      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    199199      WinQueryDlgItemText(hwnd, CFGA_VIRUS, MAXCOMLINESTRG, szCLBuf);
    200200      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    201201      if (strcmp(szCLBuf, virus)){
    202         CheckApp_QuoteAddExe(psz, szCLBuf);
    203         memcpy(virus, psz, strlen(psz) + 1);
     202        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     203        memcpy(virus, pszWorkBuf, strlen(pszWorkBuf) + 1);
    204204        if (!strchr(virus, '%') && strlen(virus) > 3)
    205205          strcat(virus, " %p");
     
    458458    {
    459459      CHAR szCLBuf[MAXCOMLINESTRG];
    460       PSZ psz;
    461 
    462       psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     460      PSZ pszWorkBuf;
     461
     462      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    463463      WinQueryDlgItemText(hwnd, CFGV_VIEWER, MAXCOMLINESTRG, szCLBuf);
    464464      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    465465      if (strcmp(szCLBuf, viewer)){
    466         CheckApp_QuoteAddExe(psz, szCLBuf);
    467         memcpy(viewer, psz, strlen(psz) + 1);
     466        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     467        memcpy(viewer, pszWorkBuf, strlen(pszWorkBuf) + 1);
    468468        if (!strchr(viewer, '%') && strlen(viewer) > 3)
    469469          strcat(viewer, " %a");
     
    472472      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    473473      if (strcmp(szCLBuf, editor)){
    474         CheckApp_QuoteAddExe(psz, szCLBuf);
    475         memcpy(editor, psz, strlen(psz) + 1);
     474        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     475        memcpy(editor, pszWorkBuf, strlen(pszWorkBuf) + 1);
    476476        if (!strchr(editor, '%') && strlen(editor) > 3)
    477477          strcat(editor, " %a");
     
    480480      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    481481      if (strcmp(szCLBuf, binview)){
    482         CheckApp_QuoteAddExe(psz, szCLBuf);
    483         memcpy(binview, psz, strlen(psz) + 1);
     482        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     483        memcpy(binview, pszWorkBuf, strlen(pszWorkBuf) + 1);
    484484        if (!strchr(binview, '%') && strlen(binview) > 3)
    485485          strcat(binview, " %a");
     
    488488      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    489489      if (strcmp(szCLBuf, bined)){
    490         CheckApp_QuoteAddExe(psz, szCLBuf);
    491         memcpy(bined, psz, strlen(psz) + 1);
     490        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     491        memcpy(bined, pszWorkBuf, strlen(pszWorkBuf) + 1);
    492492        if (!strchr(bined, '%') && strlen(bined) > 3)
    493493          strcat(bined, " %a");
     
    652652      // they contain args.
    653653      CHAR szCLBuf[MAXCOMLINESTRG], szPathBuf[CCHMAXPATH];
    654       PSZ  psz;
    655 
    656       psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     654      PSZ  pszWorkBuf;
     655
     656      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    657657      WinQueryDlgItemText(hwnd, CFGH_RUNHTTPWORKDIR, CCHMAXPATH, szPathBuf);
    658658      szPathBuf[CCHMAXPATH - 1] = 0;
     
    670670      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    671671      if (strcmp(szCLBuf, ftprun)){
    672         CheckApp_QuoteAddExe(psz, szCLBuf);
    673         memcpy(ftprun, psz, strlen(psz) + 1);
     672        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     673        memcpy(ftprun, pszWorkBuf, strlen(pszWorkBuf) + 1);
    674674      }
    675675      WinQueryDlgItemText(hwnd, CFGH_HTTPRUN, MAXCOMLINESTRG, szCLBuf);
    676676      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    677677      if (strcmp(szCLBuf, httprun)){
    678         CheckApp_QuoteAddExe(psz, szCLBuf);
    679         memcpy(httprun, psz, strlen(psz) + 1);
     678        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     679        memcpy(httprun, pszWorkBuf, strlen(pszWorkBuf) + 1);
    680680      }
    681681      WinQueryDlgItemText(hwnd, CFGH_MAILRUN, MAXCOMLINESTRG, szCLBuf);
    682682      szCLBuf[MAXCOMLINESTRG - 1] = 0;
    683683      if (strcmp(szCLBuf, mailrun)){
    684         CheckApp_QuoteAddExe(psz, szCLBuf);
    685         memcpy(mailrun, psz, strlen(psz) + 1);
     684        NormalizeCmdLine(pszWorkBuf, szCLBuf);
     685        memcpy(mailrun, pszWorkBuf, strlen(pszWorkBuf) + 1);
    686686      }
    687687      PrfWriteProfileString(fmprof, appname, "HttpRunDir", httprundir);
     
    12631263    {
    12641264      CHAR szCLBuf[MAXCOMLINESTRG];
    1265       PSZ psz;
    1266 
    1267       psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     1265      PSZ pszWorkBuf;
     1266
     1267      pszWorkBuf = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    12681268      WinQueryDlgItemText(hwnd, CFGC_DIRCOMPARE, MAXCOMLINESTRG, szCLBuf);
    12691269        szCLBuf[MAXCOMLINESTRG - 1] = 0;
    12701270        if (strcmp(szCLBuf, dircompare)){
    1271           CheckApp_QuoteAddExe(psz, szCLBuf);
    1272           memcpy(dircompare, psz, strlen(psz) + 1);
     1271          NormalizeCmdLine(pszWorkBuf, szCLBuf);
     1272          memcpy(dircompare, pszWorkBuf, strlen(pszWorkBuf) + 1);
    12731273          if (!strchr(dircompare, '%') && strlen(dircompare) > 3)
    12741274            strcat(dircompare, " %a");
     
    12781278        szCLBuf[MAXCOMLINESTRG - 1] = 0;
    12791279        if (strcmp(szCLBuf, compare)){
    1280           CheckApp_QuoteAddExe(psz, szCLBuf);
    1281           memcpy(compare, psz, strlen(psz) + 1);
     1280          NormalizeCmdLine(pszWorkBuf, szCLBuf);
     1281          memcpy(compare, pszWorkBuf, strlen(pszWorkBuf) + 1);
    12821282          if (!strchr(compare, '%') && strlen(compare) > 3)
    12831283            strcat(compare, " %a");
  • trunk/dll/pathutil.c

    r907 r920  
    1010
    1111  05 Jan 08 SHL Move from arccnrs.c and comp.c to here
     12  06 Jan 08 GKY Add NormalizeCmdLine to check program strings on entry
    1213
    1314***********************************************************************/
     
    1617
    1718#define INCL_WIN
     19#define INCL_DOS
    1820#define INCL_LONGLONG
    1921
    2022#include "pathutil.h"
    2123#include "fm3dll.h"                     // needs_quoting
     24#include "fm3str.h"
     25#include "errutil.h"                    // Dos_Error...
     26#include "strutil.h"                    // GetPString
    2227
    2328// #pragma data_seg(DATA1)
     
    96101}
    97102
     103/** NormalizeCmdLine
     104 * Checks a command line for common errors (missing quotes, missing extension,
     105 * no space between exe and args etc)
     106 * Command line passed as pszCmdLine_
     107 * A pointer to a buffer of the size MAXCOMLINESTRG should be supplied in
     108 * pszWorkBuf. This is where the quoted etc as necessary command
     109 * line string will be returned.
     110 */
     111
     112PCSZ NormalizeCmdLine(PSZ pszWorkBuf, PSZ pszCmdLine_)
     113{
     114  char szCmdLine[MAXCOMLINESTRG], szArgs[MAXCOMLINESTRG];
     115  char *offset = '\0', *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat;
     116  APIRET ret;
     117  ULONG ulAppType;
     118  char *pszChar;
     119  FILEFINDBUF3 FindBuffer;
     120  ULONG ulResultBufLen = sizeof(FILEFINDBUF3);
     121  HDIR hdirFindHandle = HDIR_CREATE;
     122  ULONG ulFindCount = 1;
     123  PSZ pszNewCmdLine = pszWorkBuf;
     124
     125  bstrip(pszCmdLine_);
     126  strcpy(szCmdLine, pszCmdLine_);
     127  if (szCmdLine[0] != '\0') {
     128    offsetexe = strstr(strlwr(pszCmdLine_), ".exe");
     129    offsetcmd = strstr(strlwr(pszCmdLine_), ".cmd");
     130    offsetcom = strstr(strlwr(pszCmdLine_), ".com");
     131    offsetbtm = strstr(strlwr(pszCmdLine_), ".btm");
     132    offsetbat = strstr(strlwr(pszCmdLine_), ".bat");
     133    if (offsetexe)
     134      offset = offsetexe;
     135    else {
     136      if (offsetcom)
     137        offset = offsetcom;
     138      else {
     139        if (offsetcmd)
     140          offset = offsetcmd;
     141        else {
     142          if (offsetbtm)
     143            offset = offsetbtm;
     144          else {
     145            if (offsetbat)
     146              offset = offsetexe;
     147          }
     148        }
     149      }
     150    }
     151    if (offset) {
     152      szCmdLine[offset + 4 - pszCmdLine_] = '\0';
     153      strcpy(szArgs, &pszCmdLine_[offset + 4 - pszCmdLine_]);
     154      while (strchr(szCmdLine, '\"'))
     155           remove_first_occurence_of_character("\"", szCmdLine);
     156      if ((szArgs[0] == '\"' && szArgs[1] == ' ') ||
     157           !strstr(pszCmdLine_, "\\:")||
     158           strchr(szArgs, '\"') == strrchr(szArgs, '\"'))
     159        remove_first_occurence_of_character("\"", szArgs);
     160      if (strchr(szArgs, '\"') != strrchr(szArgs, '\"'))
     161        saymsg(MB_OK, HWND_DESKTOP,
     162               NullStr,
     163               GetPString(IDS_QUOTESINARGSTEXT),
     164               pszCmdLine_);
     165      if (!offsetexe) {
     166        ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
     167                           ulResultBufLen, &ulFindCount, FIL_STANDARD);
     168        if (ret) {
     169          pszChar = szCmdLine;
     170          while (pszChar) {
     171            if (*pszChar == ' ') {
     172              *pszChar = '\0';
     173              strcat(szCmdLine, ".exe");
     174              ret = DosQueryAppType(szCmdLine, &ulAppType);
     175              //printf("%d %s\n", ret, szCmdLine); fflush(stdout);
     176              if (!ret) {
     177                strcpy(szArgs, pszCmdLine_ + strlen(szCmdLine) - 3);
     178                break;
     179              }
     180            }
     181            strcpy(szCmdLine, pszCmdLine_);
     182            pszChar++;
     183          }
     184        }
     185      }
     186      else
     187        ret = DosQueryAppType(szCmdLine, &ulAppType);
     188      BldQuotedFileName(pszNewCmdLine, szCmdLine);
     189      //printf("%d A", ret); fflush(stdout);
     190      if (ret) {
     191        ret = saymsg(MB_YESNO,
     192                     HWND_DESKTOP,
     193                     NullStr,
     194                     GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     195                     pszCmdLine_);
     196        if (ret == MBID_YES){
     197          pszNewCmdLine = pszCmdLine_;
     198      }
     199        else{
     200          fCancelAction = TRUE;
     201          pszNewCmdLine = pszCmdLine_;
     202        }
     203      }
     204      else{
     205        if (szArgs[0] != ' ')
     206          strcat(pszNewCmdLine, " ");
     207        strcat(pszNewCmdLine, szArgs);
     208      }
     209
     210    }
     211    else if (szCmdLine && (!strchr(szCmdLine, '.') ||
     212                         strrchr(szCmdLine, '.' ) < strrchr(szCmdLine, '\\'))) {
     213      if (!strchr(szCmdLine, ' ')) {
     214        while (strchr(szCmdLine, '\"'))
     215          remove_first_occurence_of_character("\"", szCmdLine);
     216        strcat(szCmdLine, ".exe");
     217        ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
     218                           ulResultBufLen, &ulFindCount, FIL_STANDARD);
     219        //printf("%d", ret); fflush(stdout);
     220      }
     221      else {
     222        pszChar = szCmdLine;
     223        while (pszChar) {
     224          while (strchr(szCmdLine, '\"'))
     225            remove_first_occurence_of_character("\"", szCmdLine);
     226          if (*pszChar == ' ') {
     227            *pszChar = '\0';
     228            strcat(szCmdLine, ".exe");
     229            ret = DosQueryAppType(szCmdLine, &ulAppType);
     230            //printf("%d %s\n", ret, szCmdLine); fflush(stdout);
     231            if (!ret) {
     232              break;
     233            }
     234          }
     235          strcpy(szCmdLine, pszCmdLine_);
     236          pszChar++;
     237        }
     238      }
     239      if (!ret){
     240        BldQuotedFileName(pszNewCmdLine, szCmdLine);
     241        strcpy(szArgs, pszCmdLine_ + strlen(szCmdLine) - 3);
     242        if ((szArgs[0] == '\"' && szArgs[1] == ' ') ||
     243             !strstr(pszCmdLine_, "\\:" ) ||
     244             strchr(szArgs, '\"') == strrchr(szArgs, '\"'))
     245          remove_first_occurence_of_character("\"", szArgs);
     246        if (strchr(szArgs, '\"') != strrchr(szArgs, '\"'))
     247          saymsg(MB_OK, HWND_DESKTOP,
     248                 NullStr,
     249                 GetPString(IDS_QUOTESINARGSTEXT),
     250                 pszCmdLine_);
     251        if (szArgs[0] != ' ')
     252          strcat(pszNewCmdLine, " ");
     253        strcat(pszNewCmdLine, szArgs);
     254      }
     255      else {
     256        ret = saymsg(MB_OK,
     257                     HWND_DESKTOP,
     258                     NullStr,
     259                     GetPString(IDS_PROGRAMNOTEXE2TEXT),
     260                     pszCmdLine_);
     261          fCancelAction = TRUE;
     262          pszNewCmdLine = pszCmdLine_;
     263      }
     264    }
     265    else {
     266      pszChar = strrchr(szCmdLine, '.');
     267      while (pszChar && *pszChar !=' ') {
     268        pszChar++;
     269      }
     270      *pszChar = '\0';
     271      strcpy (szArgs, pszCmdLine_ + strlen(szCmdLine));
     272      while (strchr(szCmdLine, '\"'))
     273        remove_first_occurence_of_character("\"", szCmdLine);
     274    if ((szArgs[0] == '\"' && szArgs[1] == ' ') ||
     275         !strstr(pszCmdLine_, "\\:")||
     276         strchr(szArgs, '\"') == strrchr(szArgs, '\"'))
     277      remove_first_occurence_of_character("\"", szArgs);
     278    if (strchr(szArgs, '\"') != strrchr(szArgs, '\"'))
     279      saymsg(MB_OK, HWND_DESKTOP,
     280             NullStr,
     281             GetPString(IDS_QUOTESINARGSTEXT),
     282             pszCmdLine_);
     283    ret = DosFindFirst(szCmdLine, &hdirFindHandle, FILE_NORMAL, &FindBuffer,
     284                         ulResultBufLen, &ulFindCount, FIL_STANDARD);
     285
     286    BldQuotedFileName(pszNewCmdLine, szCmdLine);
     287    //printf("%d %s ", ret, szCmdLine); fflush(stdout);
     288    if (ret) {
     289      ret = saymsg(MB_YESNO,
     290                   HWND_DESKTOP,
     291                   NullStr,
     292                   GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     293                   pszCmdLine_);
     294      if (ret == MBID_YES) {
     295        pszWorkBuf = pszCmdLine_;
     296      }
     297      else {
     298        fCancelAction = TRUE;
     299        pszWorkBuf = pszCmdLine_;
     300      }
     301    }
     302    ret = saymsg(MB_YESNOCANCEL,
     303                   HWND_DESKTOP,
     304                   NullStr,
     305                   GetPString(IDS_PROGRAMNOTEXE3TEXT),
     306                   pszCmdLine_, pszNewCmdLine);
     307      if (ret == MBID_YES){
     308        if (szArgs[0] != ' ')
     309          strcat(pszNewCmdLine, " ");
     310        strcat(pszNewCmdLine, szArgs);
     311      }
     312      if (ret == MBID_CANCEL){
     313        fCancelAction = TRUE;
     314        pszNewCmdLine = pszCmdLine_;
     315      }
     316    }
     317  }
     318  return pszWorkBuf;
     319}
     320
    98321#pragma alloc_text(PATHUTIL,BldFullPathName)
    99322#pragma alloc_text(PATHUTIL,BldQuotedFileName)
    100323#pragma alloc_text(PATHUTIL,BldQuotedFullPathName)
     324#pragma alloc_text(PATHUTIL,NormalizeCmdLine)
  • trunk/dll/pathutil.h

    r907 r920  
    2525PSZ BldQuotedFullPathName(PSZ pszFullPathName, PSZ pszPathName, PSZ pszFileName);
    2626PSZ BldQuotedFileName(PSZ pszQuotedFileName, PSZ pszFileName);
     27PCSZ NormalizeCmdLine(PSZ pszWorkBuf, PSZ pszCmdLine_);
    2728
    2829#endif // PATHUTIL_H
  • trunk/dll/systemf.c

    r918 r920  
    2020  06 Aug 07 GKY Reduce DosSleep times (ticket 148)
    2121  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 entry
    2322
    2423***********************************************************************/
     
    611610            char *formatstring,...)
    612611{
    613   /* example:
     612  /** example:
    614613
    615614   * status = runemf2(SEPARATE | WINDOWED,
     
    625624   */
    626625
    627   /*
     626  /**
    628627   * type bitmapped flag -- see FM3DLL.H
    629628   */
     
    13161315}
    13171316
    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.