home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u599.dms / in.adf / Printer / printer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-03  |  1.7 KB  |  71 lines

  1. /*
  2.  *   This program sends a form feed or a line feed to the printer.
  3.  */
  4.  
  5. #include "exec/types.h"
  6. #include "exec/io.h"
  7. #include "exec/memory.h"
  8. #include "libraries/dos.h"
  9. #include "intuition/intuition.h"
  10. #include "print.h"
  11.  
  12. extern struct Window *OpenWindow();
  13. long IntuitionBase=0;
  14. struct Window *window; 
  15.  
  16. main()
  17. {
  18.       ULONG class;
  19.       USHORT gnum;
  20.       char *ff,*lf;
  21.       int l,file;
  22.  
  23.       struct IntuiMessage *message; 
  24.       struct Gadget *gadget_ptr;
  25.  
  26.       if (!(IntuitionBase = OpenLibrary("intuition.library",0))) exit(1);
  27.       if (!(window = OpenWindow(&NewWindowStructure)))
  28.          {
  29.          cleanitup();
  30.          exit(2);
  31.          }
  32.  
  33.       ff = "\f";
  34.       lf = "\n";
  35.       do 
  36.         {
  37.         WaitPort(window->UserPort);
  38.         while( (message = (struct IntuiMessage *)
  39.                              GetMsg(window->UserPort) ) != NULL)
  40.            {
  41.            class = message->Class;
  42.            gadget_ptr = (struct Gadget *) message->IAddress;
  43.            if (class == GADGETUP) gnum = gadget_ptr->GadgetID;
  44.            ReplyMsg(message);
  45.            if ( class == CLOSEWINDOW )
  46.              {
  47.              cleanitup();
  48.              exit(0);
  49.              }
  50.            if (( class == GADGETUP) && (gnum == 4)) 
  51.              {
  52.              file = Open("prt:",MODE_NEWFILE);
  53.              l = Write(file,ff,1);
  54.              Close(file);
  55.          }
  56.            if (( class == GADGETUP) && (gnum == 5)) 
  57.              {
  58.              file = Open("prt:",MODE_NEWFILE);
  59.              l = Write(file,lf,1);
  60.              Close(file);
  61.          }                     
  62.            }
  63.         } while (1);
  64. }
  65.  
  66. cleanitup()    /* release allocated resources */
  67. {
  68.    if (window) CloseWindow(window);
  69.    CloseLibrary(IntuitionBase);
  70. }
  71.