home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 1.2 / amidev_cd_12.iso / reference_library / devices / dev_examples / printer_data.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-20  |  2.4 KB  |  85 lines

  1. /*
  2.  * Printer_Data.c
  3.  *
  4.  * Example getting driver specifics.
  5.  *
  6.  * Compiled with SAS C 5.10a. lc -cfist -v -L Printer_Data
  7.  *
  8.  * Run from CLI only
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <exec/ports.h>
  13. #include <devices/printer.h>
  14. #include <devices/prtbase.h>
  15.  
  16. #include <clib/exec_protos.h>
  17. #include <clib/alib_protos.h>
  18. #include <clib/alib_stdio_protos.h>
  19.  
  20. union printerIO
  21. {
  22.     struct IOStdReq    ios;
  23.     struct IODRPReq    iodrp;
  24.     struct IOPrtCmdReq iopc;
  25. };
  26.  
  27. VOID main(VOID);
  28.  
  29. VOID main(VOID)
  30. {
  31. struct MsgPort  *PrinterMP;
  32. union printerIO *PIO;
  33. struct PrinterData *PD;
  34. struct PrinterExtendedData *PED;
  35.  
  36. /* Create non-public messageport. Could use CreateMsgPort() for this, that's
  37.  * V37 specific however.
  38.  */
  39. if (PrinterMP = (struct MsgPort *)CreatePort(0,0))
  40.     {
  41.     /* Allocate printerIO union */
  42.     if (PIO = (union printerIO *)CreateExtIO(PrinterMP, sizeof(union printerIO)))
  43.         {
  44.         /* Open the printer.device */
  45.         if (!(OpenDevice("printer.device",0,(struct IORequest *)PIO,0)))
  46.             {
  47.  
  48.             /* Now that we've got the device opened, let's see what we've got.
  49.              * First, get a pointer to the printer data.
  50.              */
  51.             PD = (struct PrinterData *)PIO->iodrp.io_Device;
  52.             /* And a pointer to the extended data */
  53.             PED = (struct PrinterExtendedData *)&PD->pd_SegmentData->ps_PED;
  54.  
  55.             /* See the <devices/prtbase.h> include file for more details on
  56.              * the PrinterData and PrinterExtendedData structures.
  57.              */
  58.             printf("Printername: '%s', Version: %ld, Revision: %ld\n",
  59.             PED->ped_PrinterName, PD->pd_SegmentData->ps_Version,
  60.             PD->pd_SegmentData->ps_Revision);
  61.  
  62.             printf("PrinterClass: 0x%lx, ColorClass: 0x%lx\n",
  63.             PED->ped_PrinterClass, PED->ped_ColorClass);
  64.  
  65.             printf("MaxColumns: %ld, NumCharSets: %ld, NumRows: %ld\n",
  66.                 PED->ped_MaxColumns, PED->ped_NumCharSets,PED->ped_NumRows);
  67.  
  68.             printf("MaxXDots: %ld, MaxYDots: %ld, XDotsInch: %ld, YDotsInch: %ld\n",
  69.                 PED->ped_MaxXDots, PED->ped_MaxYDots, PED->ped_XDotsInch, PED->ped_YDotsInch);
  70.  
  71.             CloseDevice((struct IORequest *)PIO);
  72.             }
  73.          else
  74.              printf("Can't open printer.device\n");
  75.         DeleteExtIO((struct IORequest *)PIO);
  76.         }
  77.     else
  78.         printf("Can't CreateExtIO\n");
  79.     DeletePort((struct MsgPort *)PrinterMP);
  80.     }
  81. else
  82.    printf("Can't CreatePort\n");
  83. }
  84.  
  85.