rnd-20091028-1-src
[rocksndiamonds.git] / src / game_sp / vb_lib.c
1 // ----------------------------------------------------------------------------
2 // vb_lib.c
3 // ----------------------------------------------------------------------------
4
5 #include "vb_types.h"
6 #include "vb_defs.h"
7 #include "vb_vars.h"
8 #include "vb_lib.h"
9
10 #include "main_sp.h"
11
12 #include <sys/stat.h>
13
14
15 /* helper functions for constructs not supported by C */
16
17 #if 1
18
19 void *REDIM_1D(int data_size, int first_data_pos, int last_data_pos)
20 {
21   /* for a buffer of n elements, first_data_pos is 0 and last_data_pos is n-1 */
22   /* a negative value for "first_data_pos" indicates a preceding buffer zone */
23
24   int data_count = last_data_pos - first_data_pos + 1;
25   int buffer_size = data_size * data_count;
26   int buffer_start = data_size * first_data_pos;
27
28   return (checked_calloc(buffer_size) - buffer_start);
29 }
30
31 #else
32
33 void *REDIM_1D(int a, int b, int c)
34 {
35   return checked_calloc(a * (c - b + 1));
36 }
37
38 #endif
39
40 void *REDIM_2D(int a, int b, int c, int d, int e)
41 {
42   return 0;
43 }
44
45 boolean IS_NOTHING(void *a, int b)
46 {
47   return 0;
48 }
49
50 void SET_TO_NOTHING(void *a, int b)
51 {
52   return;
53 }
54
55 void MESSAGE_BOX(char *a)
56 {
57   return;
58 }
59
60
61 char *CAT(const char *a, ...)
62 {
63   return 0;
64 }
65
66 char *GET_PATH(char *a, ...)
67 {
68   return 0;
69 }
70
71 char *INT_TO_STR(int a)
72 {
73   return 0;
74 }
75
76
77 boolean STRING_IS_LIKE(char *a, char *b)
78 {
79   if (*b == '*')                // something like "*.sp"
80   {
81     return (strSuffix(a, &b[1]));
82   }
83   else
84   {
85     // more sophisticated patterns currently not supported
86
87     return 0;
88   }
89 }
90
91
92 void FILE_GET(FILE *file, int offset, void *buffer, int num_bytes)
93 {
94   fseek(file, offset - 1, SEEK_SET);
95
96   while (num_bytes--)
97     *(byte *)buffer++ = fgetc(file);
98 }
99
100 int FILE_PUT(FILE *a, int b, void *c, int d)
101 {
102   return 0;
103 }
104
105
106 /* this is just a workaround -- handle array definitions later */
107 void *Array(int a, ...)
108 {
109   return 0;
110 }
111
112
113 /* VB functions that do not return "int" (and would cause compiler errors) */
114 double Val(char *a)
115 {
116   return 0;
117 }
118
119 char *Left(char *a, int b)
120 {
121   return 0;
122 }
123
124 char *left(char *a, int b)
125 {
126   return 0;
127 }
128
129 char *Right(char *a, int b)
130 {
131   return 0;
132 }
133
134 char *right(char *a, int b)
135 {
136   return 0;
137 }
138
139 char *StrReverse(char *a)
140 {
141   return 0;
142 }
143
144 int InStr(int a, char *b, char *c)
145 {
146   return 0;
147 }
148
149 char *Dir(char *a)
150 {
151   return 0;
152 }
153
154 char *Dir_Without_Args()
155 {
156   return 0;
157 }
158
159 void Kill(char *a)
160 {
161   return;
162 }
163
164 char *Chr(int a)
165 {
166   return 0;
167 }
168
169 char *String(int a, char *b)
170 {
171   return 0;
172 }
173
174 void MkDir(char *a)
175 {
176   return;
177 }
178
179 char *Hex(int a)
180 {
181   return 0;
182 }
183
184
185 int FileLen(char *a)
186 {
187   struct stat buffer;
188
189   if (stat(a, &buffer) == 0)
190   {
191     return buffer.st_size;
192   }
193   else
194   {
195     return 0;
196   }
197 }
198
199 long GetTickCount()
200 {
201   return random_linux_libc(RANDOM_SIMPLE);
202 }
203
204 int GetAttr(char *a)
205 {
206   return 0;
207 }
208
209 void DoEvents()
210 {
211   return;
212 }
213
214 void SaveSetting(const char * a, const char *b, char *c, int d)
215 {
216   return;
217 }
218
219 long GetTempPath(long a, char *b)
220 {
221   return 0;
222 }