Changeset 355 for trunk/dll/printer.c


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

Use Runtime_Error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/printer.c

    r123 r355  
    44  $Id$
    55
     6  Print file list
     7
    68  Copyright (c) 1993-98 M. Kimes
    7   Copyright (c) 2004 Steven H.Levine
    8 
    9   Revisions     01 Aug 04 SHL - Rework lstrip/rstrip usage
     9  Copyright (c) 2004, 2006 Steven H.Levine
     10
     11  01 Aug 04 SHL Rework lstrip/rstrip usage
     12  17 Jul 06 SHL Use Runtime_Error
    1013
    1114***********************************************************************/
     
    2730
    2831#pragma data_seg(DATA1)
     32
     33static PSZ pszSrcFile = __FILE__;
     34
    2935#pragma alloc_text(PRINTER,PrinterReady,SayPrinterReady)
    3036#pragma alloc_text(PRINTER2,PrintList)
     
    3440
    3541
    36 BOOL PrinterReady (CHAR *printdevname) {
    37 
     42BOOL PrinterReady (CHAR *printdevname)
     43{
    3844  FILE *          printhandle;
    3945  CHAR            param = 0,
     
    4652    return TRUE;
    4753  DosError(FERR_DISABLEHARDERR);
    48   printhandle = fopen(printdevname,"a+");
    49   if(printhandle) {
     54  printhandle = xfopen(printdevname,"a+",pszSrcFile,__LINE__);
     55  if (printhandle) {
    5056    if(!strnicmp(printdevname,"COM",3) && isdigit(printdevname[3])) {
    5157      fclose(printhandle);
     
    7177
    7278
    73 BOOL SayPrinterReady (HWND hwnd) {
    74 
     79BOOL SayPrinterReady (HWND hwnd)
     80{
    7581  if(!hwnd)
    7682    hwnd = HWND_DESKTOP;
     
    8692
    8793
    88 VOID PrintList (VOID *arg) { /* background-print a list of files */
    89 
     94//=== PrintList - background-print a list of files ===
     95
     96VOID PrintList (VOID *arg)
     97{
    9098  HAB          hab2;
    9199  HMQ          hmq2;
     
    104112  if(!PrintSem) {
    105113    if(DosCreateMutexSem(NULL,&PrintSem,0,FALSE)) {
    106       DosBeep(250,100);
     114      Dos_Error(MB_CANCEL,rc,HWND_DESKTOP,pszSrcFile,__LINE__,"DosCreateMutexSem");
    107115      goto Abort;
    108116    }
     
    130138          if(StopPrinting)
    131139            break;
    132           if(PrinterReady(li->targetpath)) {
     140          if (!PrinterReady(li->targetpath))
     141            Runtime_Error(pszSrcFile, __LINE__, "printer %s error", li->targetpath);
     142          else {
    133143            fpi = _fsopen(li->list[x],"r",SH_DENYWR);
    134             if(fpi) {
     144            if (!fpi)
     145              Runtime_Error(pszSrcFile, __LINE__, "cannot open %s",li->list[x]);
     146            else {
    135147              fpo = _fsopen(li->targetpath,"a+",SH_DENYRW);
    136               if(fpo) {
     148              if(!fpo)
     149                Runtime_Error(pszSrcFile, __LINE__, "cannot open %s",li->targetpath);
     150              else {
    137151                sprintf(s,
    138152                        GetPString(IDS_PRINTINGTEXT),
     
    298312                fclose(fpo);
    299313              }
    300               else
    301                 DosBeep(50,100);
    302314              fclose(fpi);
    303315            }
    304             else
    305               DosBeep(50,100);
    306           }
    307           else {
    308             DosBeep(50,100);
    309             DosBeep(250,100);
    310316          }
    311317          DosReleaseMutexSem(PrintSem);
     
    327333
    328334
    329 MRESULT EXPENTRY PrintDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    330 
     335MRESULT EXPENTRY PrintDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     336{
    331337  LISTINFO *li;
    332338
     
    388394      WinSetDlgItemText(hwnd,PRN_PRINTER,printer);
    389395      WinSendDlgItemMsg(hwnd,PRN_LISTBOX,LM_DELETEALL,MPVOID,MPVOID);
    390       li = WinQueryWindowPtr(hwnd,0);
    391       if(li) {
    392 
     396      li = WinQueryWindowPtr(hwnd,QWL_USER);
     397      if (!li)
     398        Runtime_Error(pszSrcFile, __LINE__, "no data");
     399      else {
    393400        INT x;
    394401
     
    438445      switch(SHORT1FROMMP(mp1)) {
    439446        case DID_OK:
    440           li = WinQueryWindowPtr(hwnd,0);
    441           if(li) {
     447          li = WinQueryWindowPtr(hwnd,QWL_USER);
     448          if (!li)
     449            Runtime_Error(pszSrcFile, __LINE__, "no data");
     450          else {
    442451            prnformat         = WinQueryButtonCheckstate(hwnd,PRN_FORMAT);
    443452            PrfWriteProfileData(fmprof,FM3Str,"Prnformat",
     
    576585                  error = AddToList(szBuffer,&li->list,&numfiles,&numalloc);
    577586                  if(error) {
    578                     DosBeep(250,100);
     587                    Runtime_Error(pszSrcFile, __LINE__, "AddToList");
    579588                    break;
    580589                  }
Note: See TracChangeset for help on using the changeset viewer.