home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextLibrary / Documentation / NextDev / Examples / DriverKit / TestDriver / myTestDriver / tester.tproj / user.m < prev   
Encoding:
Text File  |  1995-02-01  |  1.8 KB  |  56 lines

  1. /*
  2.  * A program that communicates with myTestDriver.
  3.  */
  4.  
  5. #import <driverkit/IODeviceMaster.h>
  6. #import <driverkit/IODevice.h>
  7. #import <mach/mach.h>
  8. #import <libc.h>
  9. #import "myTestDriverUser.h"
  10.  
  11. void main(void)
  12. {
  13.     IOReturn        ret;
  14.     IOObjectNumber  tag;
  15.     IOString        kind;
  16.     IOCharParameter value;
  17.     unsigned int    count = IO_MAX_PARAMETER_ARRAY_LENGTH, unit = 0;
  18.     char         name[80];
  19.     IODeviceMaster *devMaster;
  20.     
  21.     /* Look up the test driver, using IODeviceMaster. */
  22.     devMaster = [IODeviceMaster new];
  23.     sprintf(name, "%s%d", my_DEVICE_NAME, unit);
  24.     ret = [devMaster lookUpByDeviceName:name objectNumber:&tag 
  25.     deviceKind:&kind];
  26.     if (ret != IO_R_SUCCESS) { /* handle the error */
  27.     fprintf(stderr, "Lookup failed: %s\n", 
  28.         [IODevice stringFromReturn:ret]);
  29.     exit(-1);
  30.     } else { /* Successfully got the object number */
  31.     
  32.     /* Get the value of the test driver's parameter. */
  33.     ret = [devMaster getCharValues:value 
  34.         forParameter:my_PARAMETER_NAME objectNumber:tag
  35.         count:&count];
  36.     if (ret != IO_R_SUCCESS) { /* handle the error */
  37.         fprintf(stderr, "Failed to get parameter value: %s\n", 
  38.             [IODevice stringFromReturn:ret]);
  39.         exit(-1);
  40.     } else /* Successfully got the parameter value */
  41.         printf("Parameter value: %s; count = %d\n", value, count);
  42.     
  43.     /* Just to show we can, get a standard IODevice parameter. */
  44.     count = IO_MAX_PARAMETER_ARRAY_LENGTH;
  45.     ret = [devMaster getCharValues:value 
  46.         forParameter:IO_CLASS_NAME objectNumber:tag
  47.         count:&count];
  48.     if (ret != IO_R_SUCCESS) { /* handle the error */
  49.         fprintf(stderr, "Failed to get class name: %s\n", 
  50.             [IODevice stringFromReturn:ret]);
  51.         exit(-1);
  52.     } else { /* Successfully got the parameter value */
  53.         printf("Class name: %s; count = %d\n", value, count);
  54.     }
  55.     }
  56. }