]> icculus.org git repositories - btb/d2x.git/blob - main/editor/func.c
imported missing editor files from d1x
[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  * $Source: /cvs/cvsroot/d2x/main/editor/func.c,v $
15  * $Revision: 1.1 $
16  * $Author: btb $
17  * $Date: 2004-12-19 13:54:27 $
18  * 
19  * .
20  * 
21  * $Log: not supported by cvs2svn $
22  * Revision 1.1.1.1  1999/06/14 22:03:05  donut
23  * Import of d1x 1.37 source.
24  *
25  * Revision 1.1  1994/11/21  14:13:17  matt
26  * Initial revision
27  * 
28  * Revision 1.1  1993/11/15  12:28:17  john
29  * Initial revision
30  * 
31  * 
32  */
33
34
35 #ifdef RCS
36 static char rcsid[] = "$Id: func.c,v 1.1 2004-12-19 13:54:27 btb Exp $";
37 #endif
38
39 #include <stdlib.h>
40 #include <string.h>
41
42 #include "func.h"
43
44 #define MAX_PARAMS 10
45
46 static FUNCTION * func_table = NULL;
47 static int func_size = 0;
48 static int initialized = 0;
49 static int func_params[MAX_PARAMS];
50
51 int func_howmany()
52 {
53         return func_size;
54 }
55
56 void func_init( FUNCTION * funtable, int size )
57 {
58         if (!initialized)
59         {
60                 initialized = 1;
61                 func_table = funtable;
62                 func_size = size;
63                 atexit( func_close );
64         }
65 }
66
67
68 void func_close()
69 {
70         if (initialized)
71         {
72                 initialized = 0;
73                 func_table = NULL;
74                 func_size = 0;
75         }
76 }
77
78 int (*func_get( char * name, int * numparams ))(void)
79 {
80         int i;
81
82         for (i=0; i<func_size; i++ )
83                 if (!stricmp( name, func_table[i].name ))
84                 {
85                         *numparams = func_table[i].nparams;
86                         return func_table[i].cfunction;
87                 }
88
89         return NULL;
90 }
91
92 int func_get_index( char * name )
93 {
94         int i;
95
96         for (i=0; i<func_size; i++ )
97                 if (!stricmp( name, func_table[i].name ))
98                 {
99                         return i;
100                 }
101
102         return -1;
103 }
104
105
106 int (*func_nget( int func_number, int * numparams, char **name ))(void)
107 {
108         if (func_number < func_size )
109         {
110                 *name = func_table[func_number].name;
111                 *numparams = func_table[func_number].nparams;
112                 return func_table[func_number].cfunction;
113         }
114
115         return NULL;
116 }
117
118 void func_set_param( int n, int value )
119 {
120         func_params[n] = value;
121 }
122
123 int func_get_param( int n )
124 {
125         return func_params[n];
126 }
127
128