home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / exec / io / io_example.c next >
Encoding:
C/C++ Source or Header  |  1980-02-04  |  2.9 KB  |  89 lines

  1. ;/* io_example.c - Execute me to compile me with Lattice 5.04
  2. LC -b1 -cfistq -v -y -j73 io_example.c
  3. Blink FROM LIB:c.o,io_example.o TO io_example LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6.  
  7. /* IO_Example.c - an example of exec device IO using the trackdisk device 
  8.  * Requires use of ANSI function prototypes.
  9.  *
  10.  * Copyright (c) 1990 Commodore-Amiga, Inc.
  11.  *
  12.  * This example is provided in electronic form by Commodore-Amiga, Inc. for
  13.  * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  14.  * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  15.  * information on the correct usage of the techniques and operating system
  16.  * functions presented in this example.  The source and executable code of
  17.  * this example may only be distributed in free electronic form, via bulletin
  18.  * board or as part of a fully non-commercial and freely redistributable
  19.  * diskette.  Both the source and executable code (including comments) must
  20.  * be included, without modification, in any copy.  This example may not be
  21.  * published in printed form or distributed with any commercial product.
  22.  * However, the programming techniques and support routines set forth in
  23.  * this example may be used in the development of original executable
  24.  * software products for Commodore Amiga computers.
  25.  * All other rights reserved.
  26.  * This example is provided "as-is" and is subject to change; no warranties
  27.  * are made.  All use is at your own risk.  No liability or responsibility
  28.  * is assumed.
  29.  */
  30.  
  31. #include <exec/types.h>
  32. #include <devices/trackdisk.h>
  33. #include <libraries/dos.h>
  34.  
  35. #ifdef LATTICE
  36. #include <proto/all.h>
  37. #include <stdlib.h>
  38. #include <stdio.h>
  39. int CXBRK(void) { return(0); }        /* Disable Lattice CTRL-C handling */
  40. int chkabort(void) { return(0); }    /* really */
  41. void cleanExit(int);
  42. void main(void);
  43. #endif
  44.  
  45. struct IOExtTD *trackIO;    /* global pointer to trackdisk IORequest */
  46. short       openerror;  /* global flag */
  47.  
  48. void cleanExit(returncode)
  49. int returncode;
  50. {
  51. if(!openerror)CloseDevice(trackIO);
  52.  
  53. if(trackIO)
  54.     {
  55.     /* extract Port address from I/O Request */
  56.     DeletePort(trackIO->iotd_Req.io_Message.mn_ReplyPort);
  57.     DeleteExtIO(trackIO);
  58.     }
  59. exit(returncode);
  60. }
  61.  
  62. void main()
  63. {
  64. /* CreatePort() and pass the result to CreatreExtIO in one step */
  65. trackIO=(struct IOExtTD *)
  66.     CreateExtIO( CreatePort(0,0),sizeof(struct IOExtTD) );
  67. if(!trackIO)cleanExit(RETURN_FAIL+1);
  68.  
  69. if(openerror=OpenDevice("trackdisk.device",0L,trackIO,0L))
  70.     cleanExit(RETURN_FAIL+2);
  71.  
  72. trackIO->iotd_Req.io_Command=TD_SEEK;       /* command */
  73.  
  74. trackIO->iotd_Req.io_Offset =0L;            /* out */
  75. DoIO(trackIO); printf("1\n");
  76.  
  77. trackIO->iotd_Req.io_Offset =79*11*2*512L;  /* in  */
  78. DoIO(trackIO); printf("2\n");
  79.  
  80. trackIO->iotd_Req.io_Offset =0L;            /* out */
  81. DoIO(trackIO); printf("3\n");
  82.  
  83. trackIO->iotd_Req.io_Offset =79*11*2*512L;  /* in  */
  84. DoIO(trackIO); printf("4\n");
  85.  
  86. cleanExit(RETURN_OK);
  87.  
  88. }
  89.