home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 262.lha / IffLibrary_v1.3 / printer.c < prev    next >
C/C++ Source or Header  |  1989-07-04  |  2KB  |  81 lines

  1. #include <graphics/view.h>
  2. #include <graphics/rastport.h>
  3. #include <exec/memory.h>
  4. #include <exec/io.h>
  5. #include <devices/printer.h>
  6.  
  7. extern long DoIO(), OpenDevice();
  8. extern void *AllocMem(), FreeMem();
  9.  
  10. typedef union
  11. {
  12. struct IOStdReq ios;
  13. struct IODRPReq iodrp;
  14. struct IOPrtCmdReq iopc;
  15. } ReqBlock;
  16.  
  17. #define REGS register
  18. #define MEMFLAGS ((long)(MEMF_PUBLIC|MEMF_CLEAR))
  19. #define ALLOC_SIZE ((long)sizeof(ReqBlock))
  20.  
  21. /* pointers to IO request blocks */
  22. static ReqBlock *write_prt;
  23.  
  24. /* convience */
  25. typedef struct MsgPort Port;
  26.  
  27. /* message port, must be created before opening the device */
  28. static  Port *ThisPort;
  29.  
  30. long open_prtdev()
  31. {
  32. extern void *AllocMem(), FreeMem(), DeletePort();
  33. extern Port *CreatePort();
  34. extern long OpenDevice();
  35.  
  36. if( !(ThisPort = CreatePort("pport",0L)) )
  37.    return(1L);
  38.  
  39. /* Allocate memory for IO request blocks */
  40. if( !(write_prt = AllocMem(ALLOC_SIZE,MEMFLAGS)) )
  41.    return(2L);
  42.  
  43. if( OpenDevice("printer.device",0L,write_prt,0L) )
  44.    {
  45.    FreeMem(write_prt,ALLOC_SIZE);
  46.    return(3L);
  47.    }
  48.  
  49. write_prt->ios.io_Message.mn_ReplyPort = ThisPort;
  50. return(0L);
  51. }
  52.  
  53. void close_prtdev()
  54. {
  55. CloseDevice(write_prt);
  56. FreeMem(write_prt,ALLOC_SIZE);
  57. write_prt = 0L;
  58. DeletePort(ThisPort);
  59. }
  60.  
  61. long DumpRPort(rp,vp,sx,sy,sw,sh,dc,dr,s)
  62. REGS struct RastPort *rp;
  63. REGS struct ViewPort *vp;
  64. REGS UWORD sx,sy,sw,sh;
  65. REGS long dc, dr;
  66. REGS UWORD s;
  67. {
  68. write_prt->iodrp.io_Command = PRD_DUMPRPORT;
  69. write_prt->iodrp.io_RastPort = rp;
  70. write_prt->iodrp.io_ColorMap = vp->ColorMap;
  71. write_prt->iodrp.io_Modes = vp->Modes;
  72. write_prt->iodrp.io_SrcX = sx;
  73. write_prt->iodrp.io_SrcY = sy;
  74. write_prt->iodrp.io_SrcWidth = sw;
  75. write_prt->iodrp.io_SrcHeight = sh;
  76. write_prt->iodrp.io_DestCols = dc;
  77. write_prt->iodrp.io_DestRows = dr;
  78. write_prt->iodrp.io_Special = s;
  79. return(DoIO(write_prt));
  80. }
  81.