home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / LharcUUCP1_0.lha / LharcUUCP / source / SystemDep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-03  |  2.9 KB  |  118 lines

  1. /*
  2.  *      $Filename: SystemDep.c $
  3.  *      $Revision: 1.1 $
  4.  *      $Date: 1994/04/03 14:38:12 $
  5.  *
  6.  *      Copyright (C) 1993 by Peter Simons <simons@peti.GUN.de>
  7.  *
  8.  *      This program is free software; you can redistribute it and/or
  9.  *      modify it under the terms of the GNU General Public License as
  10.  *      published by the Free Software Foundation; either version 2 of
  11.  *      the License, or (at your option) any later version.
  12.  *
  13.  *      This program is distributed in the hope that it will be useful,
  14.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  *      General Public License for more details.
  17.  *
  18.  *      You should have received a copy of the GNU General Public License
  19.  *      along with this program; if not, write to the Free Software
  20.  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  *      $Id: SystemDep.c,v 1.1 1994/04/03 14:38:12 simons Exp simons $
  23.  *
  24.  */
  25.  
  26.  
  27. /************************************* includes ***********/
  28. #include <stdio.h>
  29. #include <exec/exec.h>
  30. #include <dos/dos.h>
  31. #include <libraries/netsupport.h>
  32. #include <proto/exec.h>
  33. #include <proto/dos.h>
  34. #include <proto/netsupport.h>
  35.  
  36. #include "protos.h"
  37.  
  38. /************************************* global variables ***/
  39. static const char __RCSId[] = "$Id: SystemDep.c,v 1.1 1994/04/03 14:38:12 simons Exp simons $";
  40.  
  41. #ifdef AMIGA
  42. struct NetSupportLibrary *NetSupportBase = NULL;
  43. #endif
  44.  
  45. /************************************* routines ***********/
  46.  
  47.  /*
  48.   * Initialize and open all required system resources we'll
  49.   * need for our program.
  50.   */
  51.  
  52. int InitSystem(void)
  53. {
  54. #ifdef AMIGA
  55.         if (!(NetSupportBase = (struct NetSupportLibrary *) OpenLibrary(NETSUPPORTNAME, 0L))) {
  56.                 fprintf(stderr, "FATAL ERROR: Failed opening %s!\n", NETSUPPORTNAME);
  57.                 return 0;
  58.         }
  59.  
  60.         if (!(DOSBase = (struct DosLibrary *) OpenLibrary(DOSNAME, 0L))) {
  61.                 fprintf(stderr, "FATAL ERROR: Failed opening %s!\n", DOSNAME);
  62.                 return 0;
  63.         }
  64.  
  65.         return 1;
  66. #endif
  67. }
  68.  
  69.  
  70.  
  71.  /* Free all previously allocated system resources. */
  72.  
  73. void FreeSystem(void)
  74. {
  75. #ifdef AMIGA
  76.         if (NetSupportBase) {
  77.                 UnLockFiles();
  78.                 CloseLibrary((struct Library *) NetSupportBase);
  79.         }
  80.  
  81.         if (DOSBase)
  82.                 CloseLibrary((struct Library *) DOSBase);
  83. #endif
  84. }
  85.  
  86.  
  87.  
  88. #ifdef AMIGA
  89.  
  90.  /*
  91.   * My Amiga C compiler allows to simply replace the routine that is
  92.   * called whenever a CTRL-C interrupt is detected. You UNIX folks
  93.   * have to install this trap handler using signal() in InitSystem().
  94.   * Sorry. :-))
  95.   */
  96.  
  97. void __regargs _CXBRK(void)
  98. {
  99.         break_detected = 1;
  100. }
  101.  
  102. #endif
  103.  
  104.  
  105. #ifdef AMIGA
  106.  
  107.  /*
  108.   * sleep() is available under UNIX, as far as I know, so we just need
  109.   * to define it for the Amiga.
  110.   */
  111.  
  112. void sleep(int secs)
  113. {
  114.         Delay(secs*50);
  115. }
  116.  
  117. #endif
  118.