home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / editor / func.c < prev    next >
C/C++ Source or Header  |  1998-06-08  |  3KB  |  126 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/main/editor/rcs/func.c $
  15.  * $Revision: 1.1 $
  16.  * $Author: matt $
  17.  * $Date: 1994/11/21 14:13:17 $
  18.  * 
  19.  * .
  20.  * 
  21.  * $Log: func.c $
  22.  * Revision 1.1  1994/11/21  14:13:17  matt
  23.  * Initial revision
  24.  * 
  25.  * Revision 1.1  1993/11/15  12:28:17  john
  26.  * Initial revision
  27.  * 
  28.  * 
  29.  */
  30.  
  31.  
  32. #pragma off (unreferenced)
  33. static char rcsid[] = "$Id: func.c 1.1 1994/11/21 14:13:17 matt Exp $";
  34. #pragma on (unreferenced)
  35.  
  36. #include <stdlib.h>
  37. #include <string.h>
  38.  
  39. #include "func.h"
  40.  
  41. #define MAX_PARAMS 10
  42.  
  43. static FUNCTION * func_table = NULL;
  44. static int func_size = 0;
  45. static int initialized = 0;
  46. static int func_params[MAX_PARAMS];
  47.  
  48. int func_howmany()
  49. {
  50.     return func_size;
  51. }
  52.  
  53. void func_init( FUNCTION * funtable, int size )
  54. {
  55.     if (!initialized)
  56.     {
  57.         initialized = 1;
  58.         func_table = funtable;
  59.         func_size = size;
  60.         atexit( func_close );
  61.     }
  62. }
  63.  
  64.  
  65. void func_close()
  66. {
  67.     if (initialized)
  68.     {
  69.         initialized = 0;
  70.         func_table = NULL;
  71.         func_size = 0;
  72.     }
  73. }
  74.  
  75. int (*func_get( char * name, int * numparams ))(void)
  76. {
  77.     int i;
  78.  
  79.     for (i=0; i<func_size; i++ )
  80.         if (!strcmpi( name, func_table[i].name ))
  81.         {
  82.             *numparams = func_table[i].nparams;
  83.             return func_table[i].cfunction;
  84.         }
  85.  
  86.     return NULL;
  87. }
  88.  
  89. int func_get_index( char * name )
  90. {
  91.     int i;
  92.  
  93.     for (i=0; i<func_size; i++ )
  94.         if (!strcmpi( name, func_table[i].name ))
  95.         {
  96.             return i;
  97.         }
  98.  
  99.     return -1;
  100. }
  101.  
  102.  
  103. int (*func_nget( int func_number, int * numparams, char **name ))(void)
  104. {
  105.     if (func_number < func_size )
  106.     {
  107.         *name = func_table[func_number].name;
  108.         *numparams = func_table[func_number].nparams;
  109.         return func_table[func_number].cfunction;
  110.     }
  111.  
  112.     return NULL;
  113. }
  114.  
  115. void func_set_param( int n, int value )
  116. {
  117.     func_params[n] = value;
  118. }
  119.  
  120. int func_get_param( int n )
  121. {
  122.     return func_params[n];
  123. }
  124.  
  125.  
  126.