comparison src/video/riscos/SDL_riscostask.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
187 187
188 /* Figure out a sensible task name */ 188 /* Figure out a sensible task name */
189 if (_kernel_swi(OS_GetEnv, &regs, &regs) == 0) 189 if (_kernel_swi(OS_GetEnv, &regs, &regs) == 0)
190 { 190 {
191 char *command_line = (char *)regs.r[0]; 191 char *command_line = (char *)regs.r[0];
192 char *buffer = malloc(strlen(command_line)+1); 192 char *buffer = SDL_malloc(SDL_strlen(command_line)+1);
193 char *env_var; 193 char *env_var;
194 char *p; 194 char *p;
195 195
196 strcpy(buffer, command_line); 196 SDL_strcpy(buffer, command_line);
197 p = strchr(buffer, ' '); 197 p = SDL_strchr(buffer, ' ');
198 if (p) *p = 0; 198 if (p) *p = 0;
199 p = strrchr(buffer, '.'); 199 p = SDL_strrchr(buffer, '.');
200 if (p == 0) p = buffer; 200 if (p == 0) p = buffer;
201 if (stricmp(p+1,"!RunImage") == 0) 201 if (stricmp(p+1,"!RunImage") == 0)
202 { 202 {
203 *p = 0; 203 *p = 0;
204 p = strrchr(buffer, '.'); 204 p = SDL_strrchr(buffer, '.');
205 if (p == 0) p = buffer; 205 if (p == 0) p = buffer;
206 } 206 }
207 if (*p == '.') p++; 207 if (*p == '.') p++;
208 if (*p == '!') p++; /* Skip "!" at beginning of application directories */ 208 if (*p == '!') p++; /* Skip "!" at beginning of application directories */
209 209
210 if (*p == '<') 210 if (*p == '<')
211 { 211 {
212 // Probably in the form <appname$Dir> 212 // Probably in the form <appname$Dir>
213 char *q = strchr(p, '$'); 213 char *q = SDL_strchr(p, '$');
214 if (q == 0) q = strchr(p,'>'); /* Use variable name if not */ 214 if (q == 0) q = SDL_strchr(p,'>'); /* Use variable name if not */
215 if (q) *q = 0; 215 if (q) *q = 0;
216 p++; /* Move over the < */ 216 p++; /* Move over the < */
217 } 217 }
218 218
219 if (*p) 219 if (*p)
220 { 220 {
221 /* Read variables that effect the RISC OS SDL engine for this task */ 221 /* Read variables that effect the RISC OS SDL engine for this task */
222 env_var = malloc(strlen(p) + 18); /* 18 is larger than the biggest variable name */ 222 env_var = SDL_malloc(SDL_strlen(p) + 18); /* 18 is larger than the biggest variable name */
223 if (env_var) 223 if (env_var)
224 { 224 {
225 char *env_val; 225 char *env_val;
226 226
227 /* See if a variable of form SDL$<dirname>$TaskName exists */ 227 /* See if a variable of form SDL$<dirname>$TaskName exists */
228 228
229 strcpy(env_var, "SDL$"); 229 SDL_strcpy(env_var, "SDL$");
230 strcat(env_var, p); 230 strcat(env_var, p);
231 strcat(env_var, "$TaskName"); 231 strcat(env_var, "$TaskName");
232 232
233 env_val = getenv(env_var); 233 env_val = SDL_getenv(env_var);
234 if (env_val) strncpy(task_name, env_val, 31); 234 if (env_val) SDL_strncpy(task_name, env_val, 31);
235 235
236 strcpy(env_var, "SDL$"); 236 SDL_strcpy(env_var, "SDL$");
237 strcat(env_var, p); 237 strcat(env_var, p);
238 strcat(env_var, "$BackBuffer"); 238 strcat(env_var, "$BackBuffer");
239 239
240 env_val = getenv(env_var); 240 env_val = SDL_getenv(env_var);
241 if (env_val) riscos_backbuffer = atoi(env_val); 241 if (env_val) riscos_backbuffer = atoi(env_val);
242 242
243 strcpy(env_var, "SDL$"); 243 SDL_strcpy(env_var, "SDL$");
244 strcat(env_var, p); 244 strcat(env_var, p);
245 strcat(env_var, "$CloseAction"); 245 strcat(env_var, "$CloseAction");
246 246
247 env_val = getenv(env_var); 247 env_val = SDL_getenv(env_var);
248 if (env_val && strcmp(env_val,"0") == 0) riscos_closeaction = 0; 248 if (env_val && SDL_strcmp(env_val,"0") == 0) riscos_closeaction = 0;
249 249
250 free(env_var); 250 SDL_free(env_var);
251 } 251 }
252 252
253 if (task_name[0] == 0) strncpy(task_name, p, 31); 253 if (task_name[0] == 0) SDL_strncpy(task_name, p, 31);
254 task_name[31] = 0; 254 task_name[31] = 0;
255 } 255 }
256 256
257 free(buffer); 257 SDL_free(buffer);
258 } 258 }
259 259
260 if (task_name[0] == 0) strcpy(task_name, "SDL Task"); 260 if (task_name[0] == 0) SDL_strcpy(task_name, "SDL Task");
261 261
262 return 1; 262 return 1;
263 } 263 }
264 264
265 /***************************************************************** 265 /*****************************************************************
285 int *storeBlock; 285 int *storeBlock;
286 int j; 286 int j;
287 287
288 while(blockSize < 5 || retBlock[blockSize] != -1) blockSize++; 288 while(blockSize < 5 || retBlock[blockSize] != -1) blockSize++;
289 blockSize++; 289 blockSize++;
290 storeBlock = (int *)malloc(blockSize * sizeof(int)); 290 storeBlock = (int *)SDL_malloc(blockSize * sizeof(int));
291 retBlock = (int *)regs.r[1]; 291 retBlock = (int *)regs.r[1];
292 for ( j = 0; j < blockSize; j++) 292 for ( j = 0; j < blockSize; j++)
293 storeBlock[j] = retBlock[j]; 293 storeBlock[j] = retBlock[j];
294 294
295 stored_mode = (int)storeBlock; 295 stored_mode = (int)storeBlock;
318 318
319 regs.r[0] = stored_mode; 319 regs.r[0] = stored_mode;
320 _kernel_swi(Wimp_SetMode, &regs, &regs); 320 _kernel_swi(Wimp_SetMode, &regs, &regs);
321 if (stored_mode < 0 || stored_mode > 256) 321 if (stored_mode < 0 || stored_mode > 256)
322 { 322 {
323 free((int *)stored_mode); 323 SDL_free((int *)stored_mode);
324 } 324 }
325 stored_mode = -1; 325 stored_mode = -1;
326 326
327 /* Flush keyboard buffer to dump the keystrokes we've already polled */ 327 /* Flush keyboard buffer to dump the keystrokes we've already polled */
328 regs.r[0] = 21; 328 regs.r[0] = 21;