1 /* rsym_common.c */ 2 3 #include <stdio.h> 4 #include <string.h> 5 #include <stdlib.h> 6 7 #include "rsym.h" 8 9 char* 10 convert_path ( const char* origpath ) 11 { 12 char* newpath; 13 int i; 14 15 newpath = strdup(origpath); 16 17 i = 0; 18 while (newpath[i] != 0) 19 { 20 #ifdef UNIX_PATHS 21 if (newpath[i] == '\\') 22 { 23 newpath[i] = '/'; 24 } 25 #else 26 #ifdef DOS_PATHS 27 if (newpath[i] == '/') 28 { 29 newpath[i] = '\\'; 30 } 31 #endif 32 #endif 33 i++; 34 } 35 return(newpath); 36 } 37 38 void* 39 load_file ( const char* file_name, size_t* file_size ) 40 { 41 FILE* f; 42 void* FileData = NULL; 43 44 f = fopen ( file_name, "rb" ); 45 if (f != NULL) 46 { 47 fseek(f, 0L, SEEK_END); 48 *file_size = ftell(f); 49 fseek(f, 0L, SEEK_SET); 50 FileData = malloc(*file_size); 51 if (FileData != NULL) 52 { 53 if ( *file_size != fread(FileData, 1, *file_size, f) ) 54 { 55 free(FileData); 56 FileData = NULL; 57 } 58 } 59 fclose(f); 60 } 61 return FileData; 62 } 63