]> icculus.org git repositories - btb/d2x.git/blob - main/editor/func.c
remove rcs tags
[btb/d2x.git] / main / editor / func.c
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 /*
15  *
16  * .
17  *
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #include "conf.h"
22 #endif
23
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "func.h"
28 #include "strutil.h"
29
30 #define MAX_PARAMS 10
31
32 static FUNCTION * func_table = NULL;
33 static int func_size = 0;
34 static int initialized = 0;
35 static int func_params[MAX_PARAMS];
36
37 int func_howmany()
38 {
39         return func_size;
40 }
41
42 void func_init( FUNCTION * funtable, int size )
43 {
44         if (!initialized)
45         {
46                 initialized = 1;
47                 func_table = funtable;
48                 func_size = size;
49                 atexit( func_close );
50         }
51 }
52
53
54 void func_close()
55 {
56         if (initialized)
57         {
58                 initialized = 0;
59                 func_table = NULL;
60                 func_size = 0;
61         }
62 }
63
64 int (*func_get( char * name, int * numparams ))(void)
65 {
66         int i;
67
68         for (i=0; i<func_size; i++ )
69                 if (!stricmp( name, func_table[i].name ))
70                 {
71                         *numparams = func_table[i].nparams;
72                         return func_table[i].cfunction;
73                 }
74
75         return NULL;
76 }
77
78 int func_get_index( char * name )
79 {
80         int i;
81
82         for (i=0; i<func_size; i++ )
83                 if (!stricmp( name, func_table[i].name ))
84                 {
85                         return i;
86                 }
87
88         return -1;
89 }
90
91
92 int (*func_nget( int func_number, int * numparams, char **name ))(void)
93 {
94         if (func_number < func_size )
95         {
96                 *name = func_table[func_number].name;
97                 *numparams = func_table[func_number].nparams;
98                 return func_table[func_number].cfunction;
99         }
100
101         return NULL;
102 }
103
104 void func_set_param( int n, int value )
105 {
106         func_params[n] = value;
107 }
108
109 int func_get_param( int n )
110 {
111         return func_params[n];
112 }
113
114