home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / rng-810.zip / startup.cpp < prev    next >
C/C++ Source or Header  |  1994-01-28  |  2KB  |  90 lines

  1. /*
  2. *
  3. * Copyright (c) Sirius Software 1992.
  4. * All rights reserved.
  5. * But the README.DOC file from Sirius Software says:
  6. * This software is hereby placed in the public domain.
  7. */
  8. /*
  9.  RANDDRV.SYS random number driver for RNG-810 random # or similar.
  10.  Copyright (C) 1994 Paul Elliot
  11.  
  12.  This program is free software; you can redistribute it and/or
  13.  modify it under the terms of the GNU General Public License
  14.  as published by the Free Software Foundation; either version 2
  15.  of the License, or (at your option) any later version.
  16.  
  17.  This program is distributed in the hope that it will be useful,
  18.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.  GNU General Public License for more details.
  21.  
  22.  You should have received a copy of the GNU General Public License
  23.  along with this program; if not, write to the Free Software
  24.  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26. Paul.Elliott@Hrnowl.LoneStar.Org
  27.  
  28. Paul Elliott
  29.  
  30. 3986 South Gessner #224 Houston TX 77063
  31.  
  32. */
  33. /* this is initialization code that may be used by
  34. any IO driver. Initializes bcc c++ global and static
  35. objects.
  36. */
  37. /*
  38. *
  39. *  file_name = startup.cpp
  40. *
  41. *   Notes :
  42. *        - created May 9 1993 Greg Smith
  43. *        - startup code for Borland C++ version 3.0
  44. */
  45.  
  46. //
  47. // This routine is used to call the startup code for the libraries and
  48. // also call the C++ constructors
  49. //
  50.  
  51. #include <stdio.h>
  52.  
  53. typedef unsigned char byte;
  54.  
  55. typedef struct {
  56.     byte functionCallType;    // 0x00 = near call, 0x01 = far call, anything else ignore
  57.     byte priority;            // 0x00 = highest priority, 0xff = lowest priority
  58.     union {
  59.         void (far * farFunction)(void);
  60.          void (near * nearFunction)(void);
  61.     };
  62. } StartupEntry;
  63.  
  64. extern "C" {
  65.  
  66. void near CallStartup( StartupEntry far *startOfStartup, StartupEntry far *endOfStartup );
  67.  
  68. }
  69.  
  70. void near CallStartup( StartupEntry far *startOfStartup, StartupEntry far *endOfStartup ){
  71.     StartupEntry far *s;
  72.     int priority, count;
  73.     for    ( priority=255; priority >= 0; priority-- ){
  74.         s = startOfStartup;
  75.         count = endOfStartup - s;
  76.         while    (count--){
  77.             if    ( s->priority == priority ){
  78.                 if    ( s->functionCallType == 0 ){
  79.                     s->nearFunction();
  80.                 } else if    ( s->functionCallType == 1 ){
  81.                     s->farFunction();
  82.                 }
  83.             }
  84.             s++;
  85.         }
  86.     }
  87. }
  88.  
  89. // end of file
  90.