home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377b.lha / resources / misc / flushdevice.c
Encoding:
C/C++ Source or Header  |  1980-02-03  |  2.0 KB  |  51 lines

  1. /* Copyright (c) 1990 Commodore-Amiga, Inc.
  2.  *
  3.  * This example is provided in electronic form by Commodore-Amiga, Inc. for
  4.  * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  5.  * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  6.  * information on the correct usage of the techniques and operating system
  7.  * functions presented in this example.  The source and executable code of
  8.  * this example may only be distributed in free electronic form, via bulletin
  9.  * board or as part of a fully non-commercial and freely redistributable
  10.  * diskette.  Both the source and executable code (including comments) must
  11.  * be included, without modification, in any copy.  This example may not be
  12.  * published in printed form or distributed with any commercial product.
  13.  * However, the programming techniques and support routines set forth in
  14.  * this example may be used in the development of original executable
  15.  * software products for Commodore Amiga computers.
  16.  * All other rights reserved.
  17.  * This example is provided "as-is" and is subject to change; no warranties
  18.  * are made.  All use is at your own risk.  No liability or responsibility
  19.  * is assumed.
  20.  */
  21.  
  22.   /*
  23.    * A safe way to expunge ONLY a certain device.  The serial.device holds
  24.    * on to the misc serial resource until a general expunge occurs.
  25.    * This code attempts to flush ONLY the named device out of memory and
  26.    * nothing else.  If it fails, no status is returned since it would have
  27.    * no valid use after the Permit().
  28.    */
  29.    #include <exec/types.h>
  30.    #include <exec/execbase.h>
  31.    #include <proto/all.h>
  32.  
  33.    #ifdef LATTICE
  34.    int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  35.    int chkabort(void) { return(0); }  /* really */
  36.    #endif
  37.  
  38.    void FlushDevice(char *);
  39.  
  40.    extern struct ExecBase *SysBase;
  41.  
  42.    void FlushDevice(char *name)
  43.    {
  44.    struct Device *devpoint;
  45.  
  46.        Forbid();
  47.        if( devpoint=(struct Device *)FindName(&SysBase->DeviceList,name) )
  48.        RemDevice(devpoint);
  49.        Permit();
  50.    }
  51.