rnd-20091208-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   if (offset != -1)
95     fseek(file, offset - 1, SEEK_SET);
96
97   while (num_bytes--)
98     *(byte *)buffer++ = fgetc(file);
99 }
100
101 int FILE_PUT(FILE *a, int b, void *c, int d)
102 {
103   return 0;
104 }
105
106
107 /* this is just a workaround -- handle array definitions later */
108 void *Array(int a, ...)
109 {
110   return 0;
111 }
112
113
114 /* VB functions that do not return "int" (and would cause compiler errors) */
115 double Val(char *a)
116 {
117   return 0;
118 }
119
120 char *Left(char *a, int b)
121 {
122   return 0;
123 }
124
125 char *left(char *a, int b)
126 {
127   return 0;
128 }
129
130 char *Right(char *a, int b)
131 {
132   return 0;
133 }
134
135 char *right(char *a, int b)
136 {
137   return 0;
138 }
139
140 char *StrReverse(char *a)
141 {
142   return 0;
143 }
144
145 int InStr(int a, char *b, char *c)
146 {
147   return 0;
148 }
149
150 char *Dir(char *a)
151 {
152   return 0;
153 }
154
155 char *Dir_Without_Args()
156 {
157   return 0;
158 }
159
160 void Kill(char *a)
161 {
162   return;
163 }
164
165 char *Chr(int a)
166 {
167   return 0;
168 }
169
170 char *String(int a, char *b)
171 {
172   return 0;
173 }
174
175 void MkDir(char *a)
176 {
177   return;
178 }
179
180 char *Hex(int a)
181 {
182   return 0;
183 }
184
185
186 int FileLen(char *a)
187 {
188   struct stat buffer;
189
190   if (stat(a, &buffer) == 0)
191   {
192     return buffer.st_size;
193   }
194   else
195   {
196     return 0;
197   }
198 }
199
200 long MyGetTickCount()
201 {
202   return random_linux_libc(RANDOM_SIMPLE);
203 }
204
205 int GetAttr(char *a)
206 {
207   return 0;
208 }
209
210 void DoEvents()
211 {
212   return;
213 }
214
215 void SaveSetting(const char * a, const char *b, char *c, int d)
216 {
217   return;
218 }
219
220 #if 0
221
222 long GetTempPath(long a, char *b)
223 {
224   return 0;
225 }
226
227 #endif