|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ! 7: * Reserved. This file contains Original Code and/or Modifications of ! 8: * Original Code as defined in and that are subject to the Apple Public ! 9: * Source License Version 1.1 (the "License"). You may not use this file ! 10: * except in compliance with the License. Please obtain a copy of the ! 11: * License at http://www.apple.com/publicsource and read it before using ! 12: * this file. ! 13: * ! 14: * The Original Code and all software distributed under the License are ! 15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 18: * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the ! 19: * License for the specific language governing rights and limitations ! 20: * under the License. ! 21: * ! 22: * @APPLE_LICENSE_HEADER_END@ ! 23: */ ! 24: /* ! 25: * execute open:, wait for user action to close. ! 26: */ ! 27: ! 28: #import <bsd/sys/types.h> ! 29: #import <driverkit/IOClient.h> ! 30: #import <ansi/stdio.h> ! 31: #import <bsd/libc.h> ! 32: #import "defaults.h" ! 33: #import "buflib.h" ! 34: ! 35: void usage(char **argv); ! 36: void exit(int exitcode); ! 37: ! 38: int main(int argc, char **argv) { ! 39: ! 40: char *hostname=HOST_DEFAULT; ! 41: char *devname=DEVICE_DEFAULT; ! 42: int arg; ! 43: char c; ! 44: id idClient; ! 45: IOReturn rtn; ! 46: char outstr[100]; ! 47: ! 48: /* ! 49: * Get standard defaults from environment or defaults.h ! 50: */ ! 51: get_default_t("hostname", &hostname, HOST_DEFAULT); ! 52: get_default_t("devname", &devname, DEVICE_DEFAULT); ! 53: ! 54: for(arg=1; arg<argc; arg++) { ! 55: c = argv[arg][0]; ! 56: switch(c) { ! 57: case 'h': ! 58: hostname = &argv[arg][2]; ! 59: break; ! 60: case 'd': ! 61: devname = &argv[arg][2]; ! 62: break; ! 63: default: ! 64: usage(argv); ! 65: } ! 66: } ! 67: ! 68: rtn = [IOClient clientOpen:devname ! 69: hostName:hostname ! 70: intentions:IO_INT_READ ! 71: idp:&idClient]; ! 72: if(rtn) { ! 73: [IOClient ioError:rtn ! 74: logString:"clientOpen" ! 75: outString:outstr]; ! 76: printf(outstr); ! 77: exit(1); ! 78: } ! 79: printf("...%s open. Hit CR to close: ", devname); ! 80: gets(outstr); ! 81: rtn = [idClient ioClose]; ! 82: if(rtn) { ! 83: [IOClient ioError:rtn ! 84: logString:"ioClose" ! 85: outString:outstr]; ! 86: printf(outstr); ! 87: exit(1); ! 88: } ! 89: exit(0); ! 90: ! 91: } /* main() */ ! 92: ! 93: void usage(char **argv) { ! 94: printf("usage: %s [h=hostname] [d=devname]\n", argv[0]); ! 95: exit(1); ! 96: } ! 97: ! 98: ! 99: ! 100:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.