home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / dev / rkrm.lha / RKRM / Printer / Printer_Data.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-03  |  3.8 KB  |  110 lines

  1. /*
  2.  * Copyright (c) 1992 Commodore-Amiga, Inc.
  3.  * 
  4.  * This example is provided in electronic form by Commodore-Amiga, Inc. for 
  5.  * use with the "Amiga ROM Kernel Reference Manual: Devices", 3rd Edition, 
  6.  * published by Addison-Wesley (ISBN 0-201-56775-X).
  7.  * 
  8.  * The "Amiga ROM Kernel Reference Manual: Devices" contains additional 
  9.  * information on the correct usage of the techniques and operating system 
  10.  * functions presented in these examples.  The source and executable code 
  11.  * of these examples may only be distributed in free electronic form, via 
  12.  * bulletin board or as part of a fully non-commercial and freely 
  13.  * redistributable diskette.  Both the source and executable code (including 
  14.  * comments) must be included, without modification, in any copy.  This 
  15.  * example may not be published in printed form or distributed with any
  16.  * commercial product.  However, the programming techniques and support
  17.  * routines set forth in these examples may be used in the development
  18.  * of original executable software products for Commodore Amiga computers.
  19.  * 
  20.  * All other rights reserved.
  21.  * 
  22.  * This example is provided "as-is" and is subject to change; no
  23.  * warranties are made.  All use is at your own risk. No liability or
  24.  * responsibility is assumed.
  25.  *
  26.  ****************************************************************************
  27.  *
  28.  * Printer_Data.c
  29.  *
  30.  * Example getting driver specifics.
  31.  *
  32.  * Compiled with SAS C 5.10a. lc -cfist -v -L Printer_Data
  33.  *
  34.  * Run from CLI only.  Note: under 1.3, opening the printer 
  35.  * device will cause an Enforcer hit.
  36.  *
  37.  */
  38.  
  39. #include <exec/types.h>
  40. #include <exec/ports.h>
  41. #include <devices/printer.h>
  42. #include <devices/prtbase.h>
  43.  
  44. #include <clib/exec_protos.h>
  45. #include <clib/alib_protos.h>
  46. #include <clib/alib_stdio_protos.h>
  47.  
  48. union printerIO
  49. {
  50.     struct IOStdReq    ios;
  51.     struct IODRPReq    iodrp;
  52.     struct IOPrtCmdReq iopc;
  53. };
  54.  
  55. VOID main(VOID);
  56.  
  57. VOID main(VOID)
  58. {
  59. struct MsgPort  *PrinterMP;
  60. union printerIO *PIO;
  61. struct PrinterData *PD;
  62. struct PrinterExtendedData *PED;
  63.  
  64. /* Create non-public messageport. Could use CreateMsgPort() for this, that's
  65.  * V37 specific however.
  66.  */
  67. if (PrinterMP = (struct MsgPort *)CreatePort(0,0))
  68.     {
  69.     /* Allocate printerIO union */
  70.     if (PIO = (union printerIO *)CreateExtIO(PrinterMP, sizeof(union printerIO)))
  71.         {
  72.         /* Open the printer.device */
  73.         if (!(OpenDevice("printer.device",0,(struct IORequest *)PIO,0)))
  74.             {
  75.  
  76.             /* Now that we've got the device opened, let's see what we've got.
  77.              * First, get a pointer to the printer data.
  78.              */
  79.             PD = (struct PrinterData *)PIO->iodrp.io_Device;
  80.             /* And a pointer to the extended data */
  81.             PED = (struct PrinterExtendedData *)&PD->pd_SegmentData->ps_PED;
  82.  
  83.             /* See the <devices/prtbase.h> include file for more details on
  84.              * the PrinterData and PrinterExtendedData structures.
  85.              */
  86.             printf("Printername: '%s', Version: %ld, Revision: %ld\n",
  87.             PED->ped_PrinterName, PD->pd_SegmentData->ps_Version,
  88.             PD->pd_SegmentData->ps_Revision);
  89.  
  90.             printf("PrinterClass: 0x%lx, ColorClass: 0x%lx\n",
  91.             PED->ped_PrinterClass, PED->ped_ColorClass);
  92.  
  93.             printf("MaxColumns: %ld, NumCharSets: %ld, NumRows: %ld\n",
  94.                 PED->ped_MaxColumns, PED->ped_NumCharSets,PED->ped_NumRows);
  95.  
  96.             printf("MaxXDots: %ld, MaxYDots: %ld, XDotsInch: %ld, YDotsInch: %ld\n",
  97.                 PED->ped_MaxXDots, PED->ped_MaxYDots, PED->ped_XDotsInch, PED->ped_YDotsInch);
  98.  
  99.             CloseDevice((struct IORequest *)PIO);
  100.             }
  101.          else
  102.              printf("Can't open printer.device\n");
  103.         DeleteExtIO((struct IORequest *)PIO);
  104.         }
  105.     else
  106.         printf("Can't CreateExtIO\n");
  107.     DeletePort((struct MsgPort *)PrinterMP);
  108.     }
  109. }
  110.