Changeset 358 for trunk/dll/arccnrs.c


Ignore:
Timestamp:
Jul 26, 2006, 11:29:54 PM (19 years ago)
Author:
root
Message:

Use Runtime_Error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r300 r358  
    2424  30 Dec 05 SHL ArcCnrWndProc: correct date/time column display setup
    2525  29 May 06 SHL Comments
     26  14 Jul 06 SHL Use Runtime_Error
    2627
    2728***********************************************************************/
     
    5051
    5152#pragma data_seg(DATA1)
     53
     54static INT DefArcSortFlags;
     55static PSZ pszSrcFile = __FILE__;
     56
    5257#pragma alloc_text(ARCCNRS,ArcCnrWndProc,ArcObjWndProc,ArcClientWndProc)
    5358#pragma alloc_text(ARCCNRS,ArcTextProc,FillArcCnr,ArcFilter)
    5459#pragma alloc_text(ARCCNRS,ArcSort,ArcFrameWndProc,IsArcThere,ArcErrProc)
    5560#pragma alloc_text(STARTUP,StartArcCnr)
    56 
    57 static INT DefArcSortFlags;
    5861
    5962static MRESULT EXPENTRY ArcErrProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     
    159162    HWND hwndCnr = pai1->hwndCnr;
    160163    pdcd = (DIRCNRDATA *)WinQueryWindowPtr(hwndCnr,QWL_USER);
    161     // fixme debug
    162     if (!pdcd)
    163     {
    164       saymsg(0,NULLHANDLE,"*Debug*","dcd NULL %s %u",__FILE__, __LINE__);
     164    if (!pdcd) {
     165      Runtime_Error(pszSrcFile, __LINE__, "no data");
    165166      return ret;
    166167    }
     
    307308  ARC_TYPE     *tinfo;
    308309  ULONG         apptype;
     310  APIRET        rc;
    309311
    310312  if(!arcname || !arcinfo)
     
    334336  lastpai = NULL;
    335337  *pullTotalBytes = 0;
    336   if(info && info->list)
    337   {
     338  if (!info || !info->list)
     339    Runtime_Error(pszSrcFile, __LINE__, "no data");
     340  else {
    338341    WinSendMsg(hwndCnr,
    339342               CM_REMOVERECORD,
     
    385388    }
    386389    else {
    387       fp = fopen(arctemp,"w");
    388       if(fp) {
     390      fp = xfopen(arctemp,"w",pszSrcFile,__LINE__);
     391      if(!fp)
     392        return 0;
     393      else {
    389394        newstdout = -1;
    390395        DosError(FERR_DISABLEHARDERR);
    391         if(!DosDupHandle(fileno(stdout),&newstdout)) {
     396        rc = DosDupHandle(fileno(stdout),&newstdout);
     397        if (rc) {
     398          Dos_Error(MB_CANCEL,rc,hwndCnr,pszSrcFile,__LINE__,"DosDupHandle");
     399          return 0;
     400        }
     401        else {
    392402          oldstdout = fileno(stdout);
    393403          DosError(FERR_DISABLEHARDERR);
    394           if(!DosDupHandle(fileno(fp),&oldstdout)) {
     404          rc = DosDupHandle(fileno(fp),&oldstdout);
     405          if (rc)
     406          {
     407            Dos_Error(MB_CANCEL,rc,hwndCnr,pszSrcFile,__LINE__,"DosDupHandle");
     408            return 0;
     409          }
     410          else {
    395411            runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
    396412                    hwndCnr,NULL,NULL,"%s %s%s%s",info->list,
     
    403419            fclose(fp);
    404420          }
    405           else {
    406             DosBeep(50,100);
    407             return 0;
    408           }
    409         }
    410         else {
    411           DosBeep(50,100);
    412           return 0;
    413         }
    414       }
    415       else {
    416         DosBeep(50,100);
    417         return 0;
     421        }
    418422      }
    419423    }
     
    422426    fp = _fsopen(arctemp,"r",SH_DENYWR);
    423427
    424     if(fp) {
     428    if (fp) {
    425429      gotstart = !info->startlist || !*info->startlist; // If list has no start marker
    426430
     
    557561                             MPFROMLONG(EXTRA_ARCRECORD_BYTES),
    558562                             MPFROMLONG(1L));
    559             if(pai) {
     563            if (!pai) {
     564              Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD");
     565              break;
     566            }
     567            else {
    560568              memset(pai,0,sizeof(ARCITEM));
    561569              pai->hwndCnr = hwndCnr;
    562               if(*fname == '*') {
     570              if (*fname == '*') {
    563571                fname++;
    564572                pai->flags = ARCFLAGS_REALDIR;
     
    576584                                  hptrFile;
    577585              pai->pszDate = pai->szDate;
    578               if(osize)
     586              if (osize)
    579587                pai->cbFile = atol(osize);
    580               if(nsize)
     588              if (nsize)
    581589                pai->cbComp = atol(nsize);
    582               if(info->datetype && fdate && *fdate)
     590              if (info->datetype && fdate && *fdate)
    583591                ArcDateTime(fdate,
    584592                            info->datetype,
     
    592600              ri.cRecordsInsert     = 1L;
    593601              ri.fInvalidateRecord  = FALSE;
    594               if(WinSendMsg(hwndCnr,
     602              if (WinSendMsg(hwndCnr,
    595603                            CM_INSERTRECORD,
    596604                            MPFROMP(pai),
    597605                            MPFROMP(&ri)))
     606              {
    598607                *pullTotalBytes += pai->cbFile;
     608              }
    599609              if(!lastpai)
    600610                lastpai = pai;
    601611              numarcfiles++;
    602               if(!(++counter % 50)) {
     612              if  (!(++counter % 50)) {
    603613                WinSendMsg(hwndCnr,
    604614                           CM_INVALIDATERECORD,
     
    631641          }
    632642        } while(tinfo);
    633         DosBeep(750,50);
     643        DosBeep(750,50);                // fixme to know why?
    634644        {
    635645          CHAR errstr[CCHMAXPATH + 256];
     
    669679    DosForceDelete(arctemp);
    670680  }
    671   else
    672     DosBeep(50,100);
    673681
    674682  return numarcfiles;
     
    11761184{
    11771185  DIRCNRDATA *dcd;
     1186  PSZ psz;
    11781187
    11791188  switch(msg) {
     
    12221231
    12231232        if(pdt->hwndClient && pdt->pditem && pdt->hstrSelectedRMF &&
    1224            pdt->hstrRenderToName) {
    1225 
    1226           if(pdt->usOperation != DO_COPY && pdt->usOperation != DO_MOVE) {
    1227             pdt->fsReply = DMFL_RENDERRETRY;
    1228             return (MRESULT)FALSE;
    1229           }
    1230           *filename = 0;
    1231           len = DrgQueryStrName(pdt->hstrSelectedRMF,
    1232                                 CCHMAXPATH,filename);
    1233           filename[len] = 0;
    1234           if(!strnicmp(filename,"OS2FILE,",8)) {
    1235             // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"RMF = \"%s\"",filename);
    1236             pdt->fsReply = DMFL_RENDERRETRY;
    1237             return (MRESULT)FALSE;
    1238           }
    1239           *filename = 0;
    1240           len = DrgQueryStrName(pdt->hstrRenderToName,
    1241                                 CCHMAXPATH,filename);
    1242           filename[len] = 0;
    1243           if(len && *filename) {
    1244             PostMsg(hwnd,UM_RENDER,MPFROMP(pdt),MPFROMP(strdup(filename)));
    1245             return (MRESULT)TRUE;
    1246           }
    1247           else {
    1248             // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"No render-to name given.");
    1249             pdt->fsReply = DMFL_RENDERRETRY;
    1250             return (MRESULT)FALSE;
    1251           }
     1233           pdt->hstrRenderToName)
     1234        {
     1235          if (pdt->usOperation == DO_COPY || pdt->usOperation == DO_MOVE) {
     1236            *filename = 0;
     1237            len = DrgQueryStrName(pdt->hstrSelectedRMF,CCHMAXPATH,filename);
     1238            filename[len] = 0;
     1239            if (!strnicmp(filename,"OS2FILE,",8)) {
     1240              // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"RMF = \"%s\"",filename);
     1241            }
     1242            else {
     1243              *filename = 0;
     1244              len = DrgQueryStrName(pdt->hstrRenderToName,CCHMAXPATH,filename);
     1245              filename[len] = 0;
     1246              if(len && *filename) {
     1247                psz = xstrdup(filename,pszSrcFile,__LINE__);
     1248                if (psz) {
     1249                  PostMsg(hwnd,UM_RENDER,MPFROMP(pdt),MPFROMP(psz));
     1250                  return (MRESULT)TRUE;
     1251                }
     1252              }
     1253              else {
     1254                // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"No render-to name given.");
     1255              }
     1256            }
     1257          }
     1258          pdt->fsReply = DMFL_RENDERRETRY;
    12521259        }
    12531260      }
     
    14181425
    14191426        if(s) {
    1420           if(!dcd->info->extract) {
    1421             DosBeep(50,100);
     1427          if (!dcd->info->extract) {
     1428            Runtime_Error(pszSrcFile, __LINE__, "no extract");
    14221429            free(s);
    14231430            return 0;
     
    14831490                CHAR        szBuffer[1025],*p;
    14841491
    1485                 if(!li->list[1] && !stricmp(li->list[0],dcd->arcname)) {
    1486                   DosBeep(250,100);
     1492                if (!li->list[1] && !stricmp(li->list[0],dcd->arcname)) {
     1493                  Runtime_Error(pszSrcFile, __LINE__, "arc to self");
    14871494                  break;
    14881495                }
     
    16561663                    li->type != IDM_MCIPLAY &&
    16571664                    !li->info->exwdirs)) {
    1658                   DosBeep(250,100);
     1665                  Runtime_Error(pszSrcFile, __LINE__, "no cmd for request");
    16591666                  break;
    16601667                }
     
    17591766                      p++;
    17601767                    }
    1761                     p = malloc(strlen(temp) + strlen(li->targetpath) + 2);
    1762                     if(p) {
     1768                    p = xmalloc(strlen(temp) + strlen(li->targetpath) + 2,pszSrcFile,__LINE__);
     1769                    if (p) {
    17631770                      strcpy(p,li->targetpath);
    17641771                      if(p[strlen(p) - 1] != '\\')
     
    17691776                    }
    17701777                  }
    1771                   if(fFolderAfterExtract) {
     1778                  if (fFolderAfterExtract) {
    17721779
    17731780                    CHAR   objectpath[CCHMAXPATH],*p;
     
    18181825
    18191826                  for(x = 0;li->list[x];x++) {
    1820                     if(!li->info->exwdirs) {
     1827                    if (!li->info->exwdirs) {
    18211828                      temp = li->list[x];
    18221829                      p = strrchr(li->list[x],'\\');
    1823                       if(p) {
     1830                      if (p) {
    18241831                        p++;
    1825                         li->list[x] = strdup(p);
    1826                         if(li->list[x])
     1832                        li->list[x] = xstrdup(p,pszSrcFile,__LINE__);
     1833                        if (!li->list[x])
     1834                          li->list[x] = temp;
     1835                        else {
    18271836                          free(temp);
    1828                         else
    1829                           li->list[x] = temp;
     1837                        }
    18301838                      }
    18311839                    }
     
    18341842                            NullStr : "\\",li->list[x]);
    18351843                    temp = li->list[x];
    1836                     li->list[x] = strdup(cl);
    1837                     if(li->list[x])
     1844                    li->list[x] = xstrdup(cl,pszSrcFile,__LINE__);
     1845                    if (!li->list[x])
     1846                      li->list[x] = temp;
     1847                    else
    18381848                      free(temp);
    1839                     else
    1840                       li->list[x] = temp;
    18411849                  }
    18421850                  if(li->type == IDM_VIEW || li->type == IDM_EDIT) {
     
    18611869                    FILE *fp;
    18621870
    1863                     fp = fopen("$FM2PLAY.$$$","w");
    1864                     if(fp) {
     1871                    fp = xfopen("$FM2PLAY.$$$","w",pszSrcFile,__LINE__);
     1872                    if (fp) {
    18651873                      fprintf(fp,"%s",";AV/2-built FM2Play listfile\n");
    18661874                      for(x = 0;li->list[x];x++)
     
    18751883                  else if(li->type == IDM_PRINT) {
    18761884                    strcpy(li->targetpath,printer);
    1877                     if(_beginthread(PrintList,
    1878                                     NULL,
    1879                                     65536,
    1880                                     (PVOID)li) != -1)
     1885                    if (_beginthread(PrintList,NULL,65536,(PVOID)li) != -1) {
     1886                      Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    18811887                      li = NULL;
     1888                    }
    18821889                  }
    18831890                  else if(li->type == IDM_VIEWARCHIVE) {
     
    19291936                        else
    19301937                          viewtype = 0;
    1931                         temp = strdup(li->list[x]);
    1932                         if(temp) {
    1933                           if(!PostMsg(WinQueryWindow(li->hwnd,QW_PARENT),
    1934                                          UM_LOADFILE,
    1935                                          MPFROMLONG(4L +
     1938                        temp = xstrdup(li->list[x],pszSrcFile,__LINE__);
     1939                        if (temp) {
     1940                          if (!PostMsg(WinQueryWindow(li->hwnd,QW_PARENT),
     1941                                       UM_LOADFILE,
     1942                                       MPFROMLONG(4L +
    19361943                                         (li->type == IDM_VIEWTEXT ||
    19371944                                          li->type == IDM_VIEWBINARY) +
    19381945                                          viewtype),
    1939                                          MPFROMP(temp)))
     1946                                       MPFROMP(temp)))
    19401947                            free(temp);
    19411948                        }
     
    19801987                  }
    19811988                }
    1982                 if(numfiles && list2) {
     1989                if (!numfiles || !list2)
     1990                  Runtime_Error(pszSrcFile, __LINE__, "no files or list");
     1991                else {
    19831992                  WinSendMsg(dcd->hwndCnr,WM_COMMAND,
    19841993                             MPFROM2SHORT(IDM_COLLECTOR,0),MPVOID);
     
    19932002                    FreeList(list2);
    19942003                }
    1995                 else
    1996                   DosBeep(250,100);
    19972004              }
    19982005              break;
     
    23292336           */
    23302337          {
    2331             APIRET rc;
    23322338            CHAR  *p,*pp;
    23332339            ULONG  z,was;
     2340            APIRET rc;
    23342341
    23352342            rc = DosCreateDir(dcd->workdir,0);
     
    24532460                     MPFROMP(ArcSort),
    24542461                     MPFROMP(dcd));
    2455           if(_beginthread(MakeObjWin,
    2456                           NULL,
    2457                           245760,
    2458                           (PVOID)dcd) == -1) {
    2459             PostMsg(hwnd,
    2460                     WM_CLOSE,
    2461                     MPVOID,
    2462                     MPVOID);
     2462          if(_beginthread(MakeObjWin,NULL,245760,(PVOID)dcd) == -1) {
     2463            Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     2464            PostMsg(hwnd,WM_CLOSE,MPVOID,MPVOID);
    24632465            return 0;
    24642466          }
     
    24982500        MakeFullName(s);
    24992501        if(*s) {
    2500           while((p = strchr(s,'/')) != NULL)
     2502          while ((p = strchr(s,'/')) != NULL)
    25012503            *p = '\\';
    2502           while(strlen(s) > 3 && s[strlen(s) - 1] == '\\')
     2504          while (strlen(s) > 3 && s[strlen(s) - 1] == '\\')
    25032505            s[strlen(s) - 1] = 0;
    2504           if(stricmp(s,dcd->directory)) {
    2505             if(IsFullName(s)) {
    2506               if(driveflags[toupper(*s) - 'A'] &
    2507                  (DRIVE_NOTWRITEABLE | DRIVE_IGNORE | DRIVE_INVALID)) {
    2508                 DosBeep(250,100);
     2506          if (stricmp(s,dcd->directory)) {
     2507            if (IsFullName(s)) {
     2508              if (driveflags[toupper(*s) - 'A'] &
     2509                  (DRIVE_NOTWRITEABLE | DRIVE_IGNORE | DRIVE_INVALID)) {
     2510                Runtime_Error(pszSrcFile, __LINE__, "drive %s bad", s);
    25092511                WinSetDlgItemText(dcd->hwndClient,
    25102512                                  ARC_EXTRACTDIR,
     
    26892691                      mp1,
    26902692                      mp2)) {
     2693            Runtime_Error(pszSrcFile, __LINE__, "post");
    26912694            FreeListInfo((LISTINFO *)mp1);
    2692             DosBeep(50,100);
    26932695          }
    26942696          else
     
    31003102              LISTINFO *li;
    31013103
    3102               li = malloc(sizeof(LISTINFO));
    3103               if(li) {
    3104                 memset(li,0,sizeof(LISTINFO));
     3104              li = xmallocz(sizeof(LISTINFO),pszSrcFile,__LINE__);
     3105              if (li) {
    31053106                li->type = SHORT1FROMMP(mp1);
    31063107                li->hwnd = hwnd;
    31073108                li->list = BuildArcList(hwnd);
    3108                 if(li->type == IDM_REFRESH) {
     3109                if (li->type == IDM_REFRESH) {
    31093110
    31103111                  CHAR s[CCHMAXPATH],*p;
    31113112                  INT  x,y;
    31123113
    3113                   for(x = 0;li->list && li->list[x];x++) {
     3114                  for (x = 0;li->list && li->list[x];x++) {
    31143115                    sprintf(s,"%s%s%s",dcd->workdir,
    31153116                            (dcd->workdir[strlen(dcd->workdir) - 1] == '\\') ?
    31163117                            NullStr : "\\",li->list[x]);
    3117                     if(IsFile(s) != 1) {
     3118                    if (IsFile(s) != 1) {
    31183119                      free(li->list[x]);
    31193120                      li->list[x] = NULL;
    3120                       for(y = x;li->list[y];y++)
     3121                      for (y = x;li->list[y];y++)
    31213122                        li->list[y] = li->list[y + 1];
    3122                       li->list = realloc(li->list,y * sizeof(CHAR *));
     3123                      li->list = xrealloc(li->list,y * sizeof(CHAR *),pszSrcFile,__LINE__);
    31233124                      x--;
    31243125                    }
    31253126                    else {
    3126                       p = strdup(s);
    3127                       if(p) {
     3127                      p = xstrdup(s,pszSrcFile,__LINE__);
     3128                      if (p) {
    31283129                        free(li->list[x]);
    31293130                        li->list[x] = p;
    31303131                      }
    31313132                    }
    3132                   }
     3133                  } // for
    31333134                }
    31343135                strcpy(li->arcname,dcd->arcname);
     
    31683169                  if(!PostMsg(dcd->hwndObject,UM_ACTION,MPFROMP(li),
    31693170                                 MPVOID)) {
     3171                    Runtime_Error(pszSrcFile, __LINE__, "post");
    31703172                    FreeListInfo(li);
    3171                     DosBeep(50,100);
    31723173                  }
    31733174                  else if(fUnHilite && SHORT1FROMMP(mp1) != IDM_EDIT)
     
    33273328              LISTINFO *li;
    33283329
    3329 DosBeep(500,100);
     3330              DosBeep(500,100);                 // fixme to know why beep?
    33303331              li = DoFileDrop(hwnd,
    33313332                              dcd->arcname,
     
    33333334                              mp1,
    33343335                              mp2);
    3335 DosBeep(50,100);
     3336              DosBeep(50,100);                  // fixme to know why beep?
    33363337              if(li) {
    33373338                li->type = (li->type == DO_MOVE) ?
     
    34613462                   (pci->flags & (ARCFLAGS_REALDIR | ARCFLAGS_PSEUDODIR)))
    34623463                  break;
    3463                 s = strdup(pci->szFileName);
    3464                 if(s) {
     3464                s = xstrdup(pci->szFileName,pszSrcFile,__LINE__);
     3465                if (s) {
    34653466                  if(!PostMsg(dcd->hwndObject,UM_ENTER,
    34663467                                 MPFROMP(s),MPVOID)) {
     3468                    Runtime_Error(pszSrcFile, __LINE__, "post");
    34673469                    free(s);
    3468                     DosBeep(50,100);
    34693470                  }
    34703471                }
    3471                 else
    3472                   DosBeep(50,100);
    34733472              }
    34743473            }
     
    36103609        idinc = 0;
    36113610      WinSetWindowUShort(hwndFrame,QWS_ID,id);
    3612       dcd = malloc(sizeof(DIRCNRDATA));
    3613       if(dcd) {
    3614         memset(dcd,0,sizeof(DIRCNRDATA));
     3611      dcd = xmallocz(sizeof(DIRCNRDATA),pszSrcFile,__LINE__);
     3612      if (!dcd) {
     3613        PostMsg(hwndClient,WM_CLOSE,MPVOID,MPVOID);
     3614        hwndFrame = (HWND)0;
     3615      }
     3616      else {
    36153617        dcd->size = sizeof(DIRCNRDATA);
    36163618        dcd->id = id;
     
    36953697                                       NULL,
    36963698                                       NULL);
    3697         if(dcd->hwndCnr) {
     3699        if (!dcd->hwndCnr) {
     3700          PostMsg(hwndClient,
     3701                  WM_CLOSE,
     3702                  MPVOID,
     3703                  MPVOID);
     3704          free(dcd);
     3705          hwndFrame = (HWND)0;
     3706        }
     3707        else {
    36983708          WinSetWindowPtr(dcd->hwndCnr,
    36993709                          QWL_USER,
     
    37023712            CHAR s[CCHMAXPATH + 8];
    37033713
    3704             sprintf(s,
    3705                     "AV/2: %s",
    3706                     dcd->arcname);
     3714            sprintf(s,"AV/2: %s",dcd->arcname);
    37073715            WinSetWindowText(hwndFrame,s);
    3708             WinSetWindowText(WinWindowFromID(hwndFrame,
    3709                                              FID_TITLEBAR),
    3710                              s);
     3716            WinSetWindowText(WinWindowFromID(hwndFrame,FID_TITLEBAR),s);
    37113717          }
    37123718          dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
     
    37853791            }
    37863792          }
    3787           if(FrameFlags & FCF_TASKLIST) {
     3793          if (FrameFlags & FCF_TASKLIST) {
    37883794
    37893795            SWP   swp,swpD;
     
    38163822          }
    38173823        }
    3818         else {
    3819           PostMsg(hwndClient,
    3820                   WM_CLOSE,
    3821                   MPVOID,
    3822                   MPVOID);
    3823           free(dcd);
    3824           hwndFrame = (HWND)0;
    3825         }
    3826       }
    3827       else {
    3828         PostMsg(hwndClient,
    3829                 WM_CLOSE,
    3830                 MPVOID,
    3831                 MPVOID);
    3832         hwndFrame = (HWND)0;
    38333824      }
    38343825    }
Note: See TracChangeset for help on using the changeset viewer.