Changeset 358 for trunk/dll/arccnrs.c
- Timestamp:
- Jul 26, 2006, 11:29:54 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/arccnrs.c
r300 r358 24 24 30 Dec 05 SHL ArcCnrWndProc: correct date/time column display setup 25 25 29 May 06 SHL Comments 26 14 Jul 06 SHL Use Runtime_Error 26 27 27 28 ***********************************************************************/ … … 50 51 51 52 #pragma data_seg(DATA1) 53 54 static INT DefArcSortFlags; 55 static PSZ pszSrcFile = __FILE__; 56 52 57 #pragma alloc_text(ARCCNRS,ArcCnrWndProc,ArcObjWndProc,ArcClientWndProc) 53 58 #pragma alloc_text(ARCCNRS,ArcTextProc,FillArcCnr,ArcFilter) 54 59 #pragma alloc_text(ARCCNRS,ArcSort,ArcFrameWndProc,IsArcThere,ArcErrProc) 55 60 #pragma alloc_text(STARTUP,StartArcCnr) 56 57 static INT DefArcSortFlags;58 61 59 62 static MRESULT EXPENTRY ArcErrProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) … … 159 162 HWND hwndCnr = pai1->hwndCnr; 160 163 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"); 165 166 return ret; 166 167 } … … 307 308 ARC_TYPE *tinfo; 308 309 ULONG apptype; 310 APIRET rc; 309 311 310 312 if(!arcname || !arcinfo) … … 334 336 lastpai = NULL; 335 337 *pullTotalBytes = 0; 336 if(info && info->list) 337 { 338 if (!info || !info->list) 339 Runtime_Error(pszSrcFile, __LINE__, "no data"); 340 else { 338 341 WinSendMsg(hwndCnr, 339 342 CM_REMOVERECORD, … … 385 388 } 386 389 else { 387 fp = fopen(arctemp,"w"); 388 if(fp) { 390 fp = xfopen(arctemp,"w",pszSrcFile,__LINE__); 391 if(!fp) 392 return 0; 393 else { 389 394 newstdout = -1; 390 395 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 { 392 402 oldstdout = fileno(stdout); 393 403 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 { 395 411 runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT, 396 412 hwndCnr,NULL,NULL,"%s %s%s%s",info->list, … … 403 419 fclose(fp); 404 420 } 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 } 418 422 } 419 423 } … … 422 426 fp = _fsopen(arctemp,"r",SH_DENYWR); 423 427 424 if (fp) {428 if (fp) { 425 429 gotstart = !info->startlist || !*info->startlist; // If list has no start marker 426 430 … … 557 561 MPFROMLONG(EXTRA_ARCRECORD_BYTES), 558 562 MPFROMLONG(1L)); 559 if(pai) { 563 if (!pai) { 564 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD"); 565 break; 566 } 567 else { 560 568 memset(pai,0,sizeof(ARCITEM)); 561 569 pai->hwndCnr = hwndCnr; 562 if (*fname == '*') {570 if (*fname == '*') { 563 571 fname++; 564 572 pai->flags = ARCFLAGS_REALDIR; … … 576 584 hptrFile; 577 585 pai->pszDate = pai->szDate; 578 if (osize)586 if (osize) 579 587 pai->cbFile = atol(osize); 580 if (nsize)588 if (nsize) 581 589 pai->cbComp = atol(nsize); 582 if (info->datetype && fdate && *fdate)590 if (info->datetype && fdate && *fdate) 583 591 ArcDateTime(fdate, 584 592 info->datetype, … … 592 600 ri.cRecordsInsert = 1L; 593 601 ri.fInvalidateRecord = FALSE; 594 if (WinSendMsg(hwndCnr,602 if (WinSendMsg(hwndCnr, 595 603 CM_INSERTRECORD, 596 604 MPFROMP(pai), 597 605 MPFROMP(&ri))) 606 { 598 607 *pullTotalBytes += pai->cbFile; 608 } 599 609 if(!lastpai) 600 610 lastpai = pai; 601 611 numarcfiles++; 602 if (!(++counter % 50)) {612 if (!(++counter % 50)) { 603 613 WinSendMsg(hwndCnr, 604 614 CM_INVALIDATERECORD, … … 631 641 } 632 642 } while(tinfo); 633 DosBeep(750,50); 643 DosBeep(750,50); // fixme to know why? 634 644 { 635 645 CHAR errstr[CCHMAXPATH + 256]; … … 669 679 DosForceDelete(arctemp); 670 680 } 671 else672 DosBeep(50,100);673 681 674 682 return numarcfiles; … … 1176 1184 { 1177 1185 DIRCNRDATA *dcd; 1186 PSZ psz; 1178 1187 1179 1188 switch(msg) { … … 1222 1231 1223 1232 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; 1252 1259 } 1253 1260 } … … 1418 1425 1419 1426 if(s) { 1420 if (!dcd->info->extract) {1421 DosBeep(50,100);1427 if (!dcd->info->extract) { 1428 Runtime_Error(pszSrcFile, __LINE__, "no extract"); 1422 1429 free(s); 1423 1430 return 0; … … 1483 1490 CHAR szBuffer[1025],*p; 1484 1491 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"); 1487 1494 break; 1488 1495 } … … 1656 1663 li->type != IDM_MCIPLAY && 1657 1664 !li->info->exwdirs)) { 1658 DosBeep(250,100);1665 Runtime_Error(pszSrcFile, __LINE__, "no cmd for request"); 1659 1666 break; 1660 1667 } … … 1759 1766 p++; 1760 1767 } 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) { 1763 1770 strcpy(p,li->targetpath); 1764 1771 if(p[strlen(p) - 1] != '\\') … … 1769 1776 } 1770 1777 } 1771 if (fFolderAfterExtract) {1778 if (fFolderAfterExtract) { 1772 1779 1773 1780 CHAR objectpath[CCHMAXPATH],*p; … … 1818 1825 1819 1826 for(x = 0;li->list[x];x++) { 1820 if (!li->info->exwdirs) {1827 if (!li->info->exwdirs) { 1821 1828 temp = li->list[x]; 1822 1829 p = strrchr(li->list[x],'\\'); 1823 if (p) {1830 if (p) { 1824 1831 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 { 1827 1836 free(temp); 1828 else 1829 li->list[x] = temp; 1837 } 1830 1838 } 1831 1839 } … … 1834 1842 NullStr : "\\",li->list[x]); 1835 1843 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 1838 1848 free(temp); 1839 else1840 li->list[x] = temp;1841 1849 } 1842 1850 if(li->type == IDM_VIEW || li->type == IDM_EDIT) { … … 1861 1869 FILE *fp; 1862 1870 1863 fp = fopen("$FM2PLAY.$$$","w");1864 if (fp) {1871 fp = xfopen("$FM2PLAY.$$$","w",pszSrcFile,__LINE__); 1872 if (fp) { 1865 1873 fprintf(fp,"%s",";AV/2-built FM2Play listfile\n"); 1866 1874 for(x = 0;li->list[x];x++) … … 1875 1883 else if(li->type == IDM_PRINT) { 1876 1884 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)); 1881 1887 li = NULL; 1888 } 1882 1889 } 1883 1890 else if(li->type == IDM_VIEWARCHIVE) { … … 1929 1936 else 1930 1937 viewtype = 0; 1931 temp = strdup(li->list[x]);1932 if (temp) {1933 if (!PostMsg(WinQueryWindow(li->hwnd,QW_PARENT),1934 1935 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 + 1936 1943 (li->type == IDM_VIEWTEXT || 1937 1944 li->type == IDM_VIEWBINARY) + 1938 1945 viewtype), 1939 1946 MPFROMP(temp))) 1940 1947 free(temp); 1941 1948 } … … 1980 1987 } 1981 1988 } 1982 if(numfiles && list2) { 1989 if (!numfiles || !list2) 1990 Runtime_Error(pszSrcFile, __LINE__, "no files or list"); 1991 else { 1983 1992 WinSendMsg(dcd->hwndCnr,WM_COMMAND, 1984 1993 MPFROM2SHORT(IDM_COLLECTOR,0),MPVOID); … … 1993 2002 FreeList(list2); 1994 2003 } 1995 else1996 DosBeep(250,100);1997 2004 } 1998 2005 break; … … 2329 2336 */ 2330 2337 { 2331 APIRET rc;2332 2338 CHAR *p,*pp; 2333 2339 ULONG z,was; 2340 APIRET rc; 2334 2341 2335 2342 rc = DosCreateDir(dcd->workdir,0); … … 2453 2460 MPFROMP(ArcSort), 2454 2461 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); 2463 2465 return 0; 2464 2466 } … … 2498 2500 MakeFullName(s); 2499 2501 if(*s) { 2500 while ((p = strchr(s,'/')) != NULL)2502 while ((p = strchr(s,'/')) != NULL) 2501 2503 *p = '\\'; 2502 while (strlen(s) > 3 && s[strlen(s) - 1] == '\\')2504 while (strlen(s) > 3 && s[strlen(s) - 1] == '\\') 2503 2505 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); 2509 2511 WinSetDlgItemText(dcd->hwndClient, 2510 2512 ARC_EXTRACTDIR, … … 2689 2691 mp1, 2690 2692 mp2)) { 2693 Runtime_Error(pszSrcFile, __LINE__, "post"); 2691 2694 FreeListInfo((LISTINFO *)mp1); 2692 DosBeep(50,100);2693 2695 } 2694 2696 else … … 3100 3102 LISTINFO *li; 3101 3103 3102 li = malloc(sizeof(LISTINFO)); 3103 if(li) { 3104 memset(li,0,sizeof(LISTINFO)); 3104 li = xmallocz(sizeof(LISTINFO),pszSrcFile,__LINE__); 3105 if (li) { 3105 3106 li->type = SHORT1FROMMP(mp1); 3106 3107 li->hwnd = hwnd; 3107 3108 li->list = BuildArcList(hwnd); 3108 if (li->type == IDM_REFRESH) {3109 if (li->type == IDM_REFRESH) { 3109 3110 3110 3111 CHAR s[CCHMAXPATH],*p; 3111 3112 INT x,y; 3112 3113 3113 for (x = 0;li->list && li->list[x];x++) {3114 for (x = 0;li->list && li->list[x];x++) { 3114 3115 sprintf(s,"%s%s%s",dcd->workdir, 3115 3116 (dcd->workdir[strlen(dcd->workdir) - 1] == '\\') ? 3116 3117 NullStr : "\\",li->list[x]); 3117 if (IsFile(s) != 1) {3118 if (IsFile(s) != 1) { 3118 3119 free(li->list[x]); 3119 3120 li->list[x] = NULL; 3120 for (y = x;li->list[y];y++)3121 for (y = x;li->list[y];y++) 3121 3122 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__); 3123 3124 x--; 3124 3125 } 3125 3126 else { 3126 p = strdup(s);3127 if (p) {3127 p = xstrdup(s,pszSrcFile,__LINE__); 3128 if (p) { 3128 3129 free(li->list[x]); 3129 3130 li->list[x] = p; 3130 3131 } 3131 3132 } 3132 } 3133 } // for 3133 3134 } 3134 3135 strcpy(li->arcname,dcd->arcname); … … 3168 3169 if(!PostMsg(dcd->hwndObject,UM_ACTION,MPFROMP(li), 3169 3170 MPVOID)) { 3171 Runtime_Error(pszSrcFile, __LINE__, "post"); 3170 3172 FreeListInfo(li); 3171 DosBeep(50,100);3172 3173 } 3173 3174 else if(fUnHilite && SHORT1FROMMP(mp1) != IDM_EDIT) … … 3327 3328 LISTINFO *li; 3328 3329 3329 DosBeep(500,100); 3330 DosBeep(500,100); // fixme to know why beep? 3330 3331 li = DoFileDrop(hwnd, 3331 3332 dcd->arcname, … … 3333 3334 mp1, 3334 3335 mp2); 3335 DosBeep(50,100); 3336 DosBeep(50,100); // fixme to know why beep? 3336 3337 if(li) { 3337 3338 li->type = (li->type == DO_MOVE) ? … … 3461 3462 (pci->flags & (ARCFLAGS_REALDIR | ARCFLAGS_PSEUDODIR))) 3462 3463 break; 3463 s = strdup(pci->szFileName);3464 if (s) {3464 s = xstrdup(pci->szFileName,pszSrcFile,__LINE__); 3465 if (s) { 3465 3466 if(!PostMsg(dcd->hwndObject,UM_ENTER, 3466 3467 MPFROMP(s),MPVOID)) { 3468 Runtime_Error(pszSrcFile, __LINE__, "post"); 3467 3469 free(s); 3468 DosBeep(50,100);3469 3470 } 3470 3471 } 3471 else3472 DosBeep(50,100);3473 3472 } 3474 3473 } … … 3610 3609 idinc = 0; 3611 3610 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 { 3615 3617 dcd->size = sizeof(DIRCNRDATA); 3616 3618 dcd->id = id; … … 3695 3697 NULL, 3696 3698 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 { 3698 3708 WinSetWindowPtr(dcd->hwndCnr, 3699 3709 QWL_USER, … … 3702 3712 CHAR s[CCHMAXPATH + 8]; 3703 3713 3704 sprintf(s, 3705 "AV/2: %s", 3706 dcd->arcname); 3714 sprintf(s,"AV/2: %s",dcd->arcname); 3707 3715 WinSetWindowText(hwndFrame,s); 3708 WinSetWindowText(WinWindowFromID(hwndFrame, 3709 FID_TITLEBAR), 3710 s); 3716 WinSetWindowText(WinWindowFromID(hwndFrame,FID_TITLEBAR),s); 3711 3717 } 3712 3718 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr, … … 3785 3791 } 3786 3792 } 3787 if (FrameFlags & FCF_TASKLIST) {3793 if (FrameFlags & FCF_TASKLIST) { 3788 3794 3789 3795 SWP swp,swpD; … … 3816 3822 } 3817 3823 } 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;3833 3824 } 3834 3825 }
Note:
See TracChangeset
for help on using the changeset viewer.