zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_rwops.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 /* Need this so Linux systems define fseek64o, ftell64o and off64_t */
22 #define _LARGEFILE64_SOURCE
23 #include "SDL_config.h"
24 
25 /* This file provides a general interface for SDL to read and write
26  data sources. It can easily be extended to files, memory, etc.
27 */
28 
29 #include "SDL_endian.h"
30 #include "SDL_rwops.h"
31 
32 #ifdef __APPLE__
34 #endif /* __APPLE__ */
35 
36 #ifdef ANDROID
37 #include "../core/android/SDL_android.h"
38 #include "SDL_system.h"
39 #endif
40 
41 #ifdef __WIN32__
42 
43 /* Functions to read/write Win32 API file pointers */
44 
45 #include "../core/windows/SDL_windows.h"
46 
47 #ifndef INVALID_SET_FILE_POINTER
48 #define INVALID_SET_FILE_POINTER 0xFFFFFFFF
49 #endif
50 
51 #define READAHEAD_BUFFER_SIZE 1024
52 
53 static int SDLCALL
54 windows_file_open(SDL_RWops * context, const char *filename, const char *mode)
55 {
56  UINT old_error_mode;
57  HANDLE h;
58  DWORD r_right, w_right;
59  DWORD must_exist, truncate;
60  int a_mode;
61 
62  if (!context)
63  return -1; /* failed (invalid call) */
64 
65  context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
66  context->hidden.windowsio.buffer.data = NULL;
67  context->hidden.windowsio.buffer.size = 0;
68  context->hidden.windowsio.buffer.left = 0;
69 
70  /* "r" = reading, file must exist */
71  /* "w" = writing, truncate existing, file may not exist */
72  /* "r+"= reading or writing, file must exist */
73  /* "a" = writing, append file may not exist */
74  /* "a+"= append + read, file may not exist */
75  /* "w+" = read, write, truncate. file may not exist */
76 
77  must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0;
78  truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0;
79  r_right = (SDL_strchr(mode, '+') != NULL
80  || must_exist) ? GENERIC_READ : 0;
81  a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0;
82  w_right = (a_mode || SDL_strchr(mode, '+')
83  || truncate) ? GENERIC_WRITE : 0;
84 
85  if (!r_right && !w_right) /* inconsistent mode */
86  return -1; /* failed (invalid call) */
87 
88  context->hidden.windowsio.buffer.data =
89  (char *) SDL_malloc(READAHEAD_BUFFER_SIZE);
90  if (!context->hidden.windowsio.buffer.data) {
91  return SDL_OutOfMemory();
92  }
93  /* Do not open a dialog box if failure */
94  old_error_mode =
95  SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
96 
97  {
98  LPTSTR tstr = WIN_UTF8ToString(filename);
99  h = CreateFile(tstr, (w_right | r_right),
100  (w_right) ? 0 : FILE_SHARE_READ, NULL,
101  (must_exist | truncate | a_mode),
102  FILE_ATTRIBUTE_NORMAL, NULL);
103  SDL_free(tstr);
104  }
105 
106  /* restore old behavior */
107  SetErrorMode(old_error_mode);
108 
109  if (h == INVALID_HANDLE_VALUE) {
110  SDL_free(context->hidden.windowsio.buffer.data);
111  context->hidden.windowsio.buffer.data = NULL;
112  SDL_SetError("Couldn't open %s", filename);
113  return -2; /* failed (CreateFile) */
114  }
115  context->hidden.windowsio.h = h;
116  context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE;
117 
118  return 0; /* ok */
119 }
120 
121 static Sint64 SDLCALL
122 windows_file_size(SDL_RWops * context)
123 {
124  LARGE_INTEGER size;
125 
126  if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
127  return SDL_SetError("windows_file_size: invalid context/file not opened");
128  }
129 
130  if (!GetFileSizeEx(context->hidden.windowsio.h, &size)) {
131  return WIN_SetError("windows_file_size");
132  }
133 
134  return size.QuadPart;
135 }
136 
137 static Sint64 SDLCALL
138 windows_file_seek(SDL_RWops * context, Sint64 offset, int whence)
139 {
140  DWORD windowswhence;
141  LARGE_INTEGER windowsoffset;
142 
143  if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
144  return SDL_SetError("windows_file_seek: invalid context/file not opened");
145  }
146 
147  /* FIXME: We may be able to satisfy the seek within buffered data */
148  if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) {
149  offset -= (long)context->hidden.windowsio.buffer.left;
150  }
151  context->hidden.windowsio.buffer.left = 0;
152 
153  switch (whence) {
154  case RW_SEEK_SET:
155  windowswhence = FILE_BEGIN;
156  break;
157  case RW_SEEK_CUR:
158  windowswhence = FILE_CURRENT;
159  break;
160  case RW_SEEK_END:
161  windowswhence = FILE_END;
162  break;
163  default:
164  return SDL_SetError("windows_file_seek: Unknown value for 'whence'");
165  }
166 
167  windowsoffset.QuadPart = offset;
168  if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, windowswhence)) {
169  return WIN_SetError("windows_file_seek");
170  }
171  return windowsoffset.QuadPart;
172 }
173 
174 static size_t SDLCALL
175 windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
176 {
177  size_t total_need;
178  size_t total_read = 0;
179  size_t read_ahead;
180  DWORD byte_read;
181 
182  total_need = size * maxnum;
183 
184  if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
185  || !total_need)
186  return 0;
187 
188  if (context->hidden.windowsio.buffer.left > 0) {
189  void *data = (char *) context->hidden.windowsio.buffer.data +
190  context->hidden.windowsio.buffer.size -
191  context->hidden.windowsio.buffer.left;
192  read_ahead =
193  SDL_min(total_need, context->hidden.windowsio.buffer.left);
194  SDL_memcpy(ptr, data, read_ahead);
195  context->hidden.windowsio.buffer.left -= read_ahead;
196 
197  if (read_ahead == total_need) {
198  return maxnum;
199  }
200  ptr = (char *) ptr + read_ahead;
201  total_need -= read_ahead;
202  total_read += read_ahead;
203  }
204 
205  if (total_need < READAHEAD_BUFFER_SIZE) {
206  if (!ReadFile
207  (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data,
208  READAHEAD_BUFFER_SIZE, &byte_read, NULL)) {
210  return 0;
211  }
212  read_ahead = SDL_min(total_need, (int) byte_read);
213  SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead);
214  context->hidden.windowsio.buffer.size = byte_read;
215  context->hidden.windowsio.buffer.left = byte_read - read_ahead;
216  total_read += read_ahead;
217  } else {
218  if (!ReadFile
219  (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) {
221  return 0;
222  }
223  total_read += byte_read;
224  }
225  return (total_read / size);
226 }
227 
228 static size_t SDLCALL
229 windows_file_write(SDL_RWops * context, const void *ptr, size_t size,
230  size_t num)
231 {
232 
233  size_t total_bytes;
234  DWORD byte_written;
235  size_t nwritten;
236 
237  total_bytes = size * num;
238 
239  if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE
240  || total_bytes <= 0 || !size)
241  return 0;
242 
243  if (context->hidden.windowsio.buffer.left) {
244  SetFilePointer(context->hidden.windowsio.h,
245  -(LONG)context->hidden.windowsio.buffer.left, NULL,
246  FILE_CURRENT);
247  context->hidden.windowsio.buffer.left = 0;
248  }
249 
250  /* if in append mode, we must go to the EOF before write */
251  if (context->hidden.windowsio.append) {
252  if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) ==
253  INVALID_SET_FILE_POINTER) {
255  return 0;
256  }
257  }
258 
259  if (!WriteFile
260  (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) {
262  return 0;
263  }
264 
265  nwritten = byte_written / size;
266  return nwritten;
267 }
268 
269 static int SDLCALL
270 windows_file_close(SDL_RWops * context)
271 {
272 
273  if (context) {
274  if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) {
275  CloseHandle(context->hidden.windowsio.h);
276  context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */
277  }
278  SDL_free(context->hidden.windowsio.buffer.data);
279  context->hidden.windowsio.buffer.data = NULL;
280  SDL_FreeRW(context);
281  }
282  return (0);
283 }
284 #endif /* __WIN32__ */
285 
286 #ifdef HAVE_STDIO_H
287 
288 /* Functions to read/write stdio file pointers */
289 
290 static Sint64 SDLCALL
291 stdio_size(SDL_RWops * context)
292 {
293  Sint64 pos, size;
294 
295  pos = SDL_RWseek(context, 0, RW_SEEK_CUR);
296  if (pos < 0) {
297  return -1;
298  }
299  size = SDL_RWseek(context, 0, RW_SEEK_END);
300 
301  SDL_RWseek(context, pos, RW_SEEK_SET);
302  return size;
303 }
304 
305 static Sint64 SDLCALL
306 stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
307 {
308 #ifdef HAVE_FSEEKO64
309  if (fseeko64(context->hidden.stdio.fp, (off64_t)offset, whence) == 0) {
310  return ftello64(context->hidden.stdio.fp);
311  }
312 #elif defined(HAVE_FSEEKO)
313  if (fseeko(context->hidden.stdio.fp, (off_t)offset, whence) == 0) {
314  return ftello(context->hidden.stdio.fp);
315  }
316 #else
317  if (fseek(context->hidden.stdio.fp, offset, whence) == 0) {
318  return (ftell(context->hidden.stdio.fp));
319  }
320 #endif
321  return SDL_Error(SDL_EFSEEK);
322 }
323 
324 static size_t SDLCALL
325 stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
326 {
327  size_t nread;
328 
329  nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
330  if (nread == 0 && ferror(context->hidden.stdio.fp)) {
332  }
333  return (nread);
334 }
335 
336 static size_t SDLCALL
337 stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
338 {
339  size_t nwrote;
340 
341  nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
342  if (nwrote == 0 && ferror(context->hidden.stdio.fp)) {
344  }
345  return (nwrote);
346 }
347 
348 static int SDLCALL
349 stdio_close(SDL_RWops * context)
350 {
351  int status = 0;
352  if (context) {
353  if (context->hidden.stdio.autoclose) {
354  /* WARNING: Check the return value here! */
355  if (fclose(context->hidden.stdio.fp) != 0) {
356  status = SDL_Error(SDL_EFWRITE);
357  }
358  }
359  SDL_FreeRW(context);
360  }
361  return status;
362 }
363 #endif /* !HAVE_STDIO_H */
364 
365 /* Functions to read/write memory pointers */
366 
367 static Sint64 SDLCALL
368 mem_size(SDL_RWops * context)
369 {
370  return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base);
371 }
372 
373 static Sint64 SDLCALL
374 mem_seek(SDL_RWops * context, Sint64 offset, int whence)
375 {
376  Uint8 *newpos;
377 
378  switch (whence) {
379  case RW_SEEK_SET:
380  newpos = context->hidden.mem.base + offset;
381  break;
382  case RW_SEEK_CUR:
383  newpos = context->hidden.mem.here + offset;
384  break;
385  case RW_SEEK_END:
386  newpos = context->hidden.mem.stop + offset;
387  break;
388  default:
389  return SDL_SetError("Unknown value for 'whence'");
390  }
391  if (newpos < context->hidden.mem.base) {
392  newpos = context->hidden.mem.base;
393  }
394  if (newpos > context->hidden.mem.stop) {
395  newpos = context->hidden.mem.stop;
396  }
397  context->hidden.mem.here = newpos;
398  return (Sint64)(context->hidden.mem.here - context->hidden.mem.base);
399 }
400 
401 static size_t SDLCALL
402 mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum)
403 {
404  size_t total_bytes;
405  size_t mem_available;
406 
407  total_bytes = (maxnum * size);
408  if ((maxnum <= 0) || (size <= 0)
409  || ((total_bytes / maxnum) != (size_t) size)) {
410  return 0;
411  }
412 
413  mem_available = (context->hidden.mem.stop - context->hidden.mem.here);
414  if (total_bytes > mem_available) {
415  total_bytes = mem_available;
416  }
417 
418  SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
419  context->hidden.mem.here += total_bytes;
420 
421  return (total_bytes / size);
422 }
423 
424 static size_t SDLCALL
425 mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num)
426 {
427  if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) {
428  num = (context->hidden.mem.stop - context->hidden.mem.here) / size;
429  }
430  SDL_memcpy(context->hidden.mem.here, ptr, num * size);
431  context->hidden.mem.here += num * size;
432  return (num);
433 }
434 
435 static size_t SDLCALL
436 mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num)
437 {
438  SDL_SetError("Can't write to read-only memory");
439  return (0);
440 }
441 
442 static int SDLCALL
444 {
445  if (context) {
446  SDL_FreeRW(context);
447  }
448  return (0);
449 }
450 
451 
452 /* Functions to create SDL_RWops structures from various data sources */
453 
454 SDL_RWops *
455 SDL_RWFromFile(const char *file, const char *mode)
456 {
457  SDL_RWops *rwops = NULL;
458  if (!file || !*file || !mode || !*mode) {
459  SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
460  return NULL;
461  }
462 #if defined(ANDROID)
463 #ifdef HAVE_STDIO_H
464  /* Try to open the file on the filesystem first */
465  if (*file == '/') {
466  FILE *fp = fopen(file, mode);
467  if (fp) {
468  return SDL_RWFromFP(fp, 1);
469  }
470  } else {
471  /* Try opening it from internal storage if it's a relative path */
472  char *path;
473  FILE *fp;
474 
475  path = SDL_stack_alloc(char, PATH_MAX);
476  if (path) {
477  SDL_snprintf(path, PATH_MAX, "%s/%s",
478  SDL_AndroidGetInternalStoragePath(), file);
479  fp = fopen(path, mode);
480  SDL_stack_free(path);
481  if (fp) {
482  return SDL_RWFromFP(fp, 1);
483  }
484  }
485  }
486 #endif /* HAVE_STDIO_H */
487 
488  /* Try to open the file from the asset system */
489  rwops = SDL_AllocRW();
490  if (!rwops)
491  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
492  if (Android_JNI_FileOpen(rwops, file, mode) < 0) {
493  SDL_FreeRW(rwops);
494  return NULL;
495  }
496  rwops->size = Android_JNI_FileSize;
497  rwops->seek = Android_JNI_FileSeek;
498  rwops->read = Android_JNI_FileRead;
499  rwops->write = Android_JNI_FileWrite;
500  rwops->close = Android_JNI_FileClose;
501  rwops->type = SDL_RWOPS_JNIFILE;
502 
503 #elif defined(__WIN32__)
504  rwops = SDL_AllocRW();
505  if (!rwops)
506  return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
507  if (windows_file_open(rwops, file, mode) < 0) {
508  SDL_FreeRW(rwops);
509  return NULL;
510  }
511  rwops->size = windows_file_size;
512  rwops->seek = windows_file_seek;
513  rwops->read = windows_file_read;
514  rwops->write = windows_file_write;
515  rwops->close = windows_file_close;
516  rwops->type = SDL_RWOPS_WINFILE;
517 
518 #elif HAVE_STDIO_H
519  {
520  #ifdef __APPLE__
521  FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode);
522  #else
523  FILE *fp = fopen(file, mode);
524  #endif
525  if (fp == NULL) {
526  SDL_SetError("Couldn't open %s", file);
527  } else {
528  rwops = SDL_RWFromFP(fp, 1);
529  }
530  }
531 #else
532  SDL_SetError("SDL not compiled with stdio support");
533 #endif /* !HAVE_STDIO_H */
534 
535  return (rwops);
536 }
537 
538 #ifdef HAVE_STDIO_H
539 SDL_RWops *
540 SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
541 {
542  SDL_RWops *rwops = NULL;
543 
544  rwops = SDL_AllocRW();
545  if (rwops != NULL) {
546  rwops->size = stdio_size;
547  rwops->seek = stdio_seek;
548  rwops->read = stdio_read;
549  rwops->write = stdio_write;
550  rwops->close = stdio_close;
551  rwops->hidden.stdio.fp = fp;
552  rwops->hidden.stdio.autoclose = autoclose;
553  rwops->type = SDL_RWOPS_STDFILE;
554  }
555  return (rwops);
556 }
557 #else
558 SDL_RWops *
559 SDL_RWFromFP(void * fp, SDL_bool autoclose)
560 {
561  SDL_SetError("SDL not compiled with stdio support");
562  return NULL;
563 }
564 #endif /* HAVE_STDIO_H */
565 
566 SDL_RWops *
567 SDL_RWFromMem(void *mem, int size)
568 {
569  SDL_RWops *rwops = NULL;
570  if (!mem) {
571  SDL_InvalidParamError("mem");
572  return (rwops);
573  }
574  if (!size) {
575  SDL_InvalidParamError("size");
576  return (rwops);
577  }
578 
579  rwops = SDL_AllocRW();
580  if (rwops != NULL) {
581  rwops->size = mem_size;
582  rwops->seek = mem_seek;
583  rwops->read = mem_read;
584  rwops->write = mem_write;
585  rwops->close = mem_close;
586  rwops->hidden.mem.base = (Uint8 *) mem;
587  rwops->hidden.mem.here = rwops->hidden.mem.base;
588  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
589  rwops->type = SDL_RWOPS_MEMORY;
590  }
591  return (rwops);
592 }
593 
594 SDL_RWops *
595 SDL_RWFromConstMem(const void *mem, int size)
596 {
597  SDL_RWops *rwops = NULL;
598  if (!mem) {
599  SDL_InvalidParamError("mem");
600  return (rwops);
601  }
602  if (!size) {
603  SDL_InvalidParamError("size");
604  return (rwops);
605  }
606 
607  rwops = SDL_AllocRW();
608  if (rwops != NULL) {
609  rwops->size = mem_size;
610  rwops->seek = mem_seek;
611  rwops->read = mem_read;
612  rwops->write = mem_writeconst;
613  rwops->close = mem_close;
614  rwops->hidden.mem.base = (Uint8 *) mem;
615  rwops->hidden.mem.here = rwops->hidden.mem.base;
616  rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
617  rwops->type = SDL_RWOPS_MEMORY_RO;
618  }
619  return (rwops);
620 }
621 
622 SDL_RWops *
624 {
625  SDL_RWops *area;
626 
627  area = (SDL_RWops *) SDL_malloc(sizeof *area);
628  if (area == NULL) {
629  SDL_OutOfMemory();
630  } else {
631  area->type = SDL_RWOPS_UNKNOWN;
632  }
633  return (area);
634 }
635 
636 void
638 {
639  SDL_free(area);
640 }
641 
642 /* Functions for dynamically reading and writing endian-specific values */
643 
644 Uint8
646 {
647  Uint8 value = 0;
648 
649  SDL_RWread(src, &value, (sizeof value), 1);
650  return value;
651 }
652 
653 Uint16
655 {
656  Uint16 value = 0;
657 
658  SDL_RWread(src, &value, (sizeof value), 1);
659  return (SDL_SwapLE16(value));
660 }
661 
662 Uint16
664 {
665  Uint16 value = 0;
666 
667  SDL_RWread(src, &value, (sizeof value), 1);
668  return (SDL_SwapBE16(value));
669 }
670 
671 Uint32
673 {
674  Uint32 value = 0;
675 
676  SDL_RWread(src, &value, (sizeof value), 1);
677  return (SDL_SwapLE32(value));
678 }
679 
680 Uint32
682 {
683  Uint32 value = 0;
684 
685  SDL_RWread(src, &value, (sizeof value), 1);
686  return (SDL_SwapBE32(value));
687 }
688 
689 Uint64
691 {
692  Uint64 value = 0;
693 
694  SDL_RWread(src, &value, (sizeof value), 1);
695  return (SDL_SwapLE64(value));
696 }
697 
698 Uint64
700 {
701  Uint64 value = 0;
702 
703  SDL_RWread(src, &value, (sizeof value), 1);
704  return (SDL_SwapBE64(value));
705 }
706 
707 size_t
709 {
710  return (SDL_RWwrite(dst, &value, (sizeof value), 1));
711 }
712 
713 size_t
715 {
716  value = SDL_SwapLE16(value);
717  return (SDL_RWwrite(dst, &value, (sizeof value), 1));
718 }
719 
720 size_t
722 {
723  value = SDL_SwapBE16(value);
724  return (SDL_RWwrite(dst, &value, (sizeof value), 1));
725 }
726 
727 size_t
729 {
730  value = SDL_SwapLE32(value);
731  return (SDL_RWwrite(dst, &value, (sizeof value), 1));
732 }
733 
734 size_t
736 {
737  value = SDL_SwapBE32(value);
738  return (SDL_RWwrite(dst, &value, (sizeof value), 1));
739 }
740 
741 size_t
743 {
744  value = SDL_SwapLE64(value);
745  return (SDL_RWwrite(dst, &value, (sizeof value), 1));
746 }
747 
748 size_t
750 {
751  value = SDL_SwapBE64(value);
752  return (SDL_RWwrite(dst, &value, (sizeof value), 1));
753 }
754 
755 /* vi: set ts=4 sw=4 expandtab: */
DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src)
Definition: SDL_rwops.c:690
DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops *src)
Definition: SDL_rwops.c:645
#define SDL_SwapBE64(X)
Definition: SDL_endian.h:217
int Android_JNI_FileClose(SDL_RWops *ctx)
#define WIN_UTF8ToString(S)
Definition: SDL_windows.h:42
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:7294
#define NULL
Definition: ftobjs.h:61
DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt,...)
Definition: SDL_string.c:1277
#define SDL_stack_free(data)
Definition: SDL_stdinc.h:227
#define SDL_RWwrite(ctx, ptr, size, n)
Definition: SDL_rwops.h:188
DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src)
Definition: SDL_rwops.c:654
SDL_bool
Definition: SDL_stdinc.h:116
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void *fp, SDL_bool autoclose)
Definition: SDL_rwops.c:559
void size_t size
Definition: SDL_rwops.h:74
#define SDL_RWOPS_WINFILE
Definition: SDL_rwops.h:43
DECLSPEC void SDLCALL SDL_free(void *mem)
FILE * file
Definition: visualinfo.c:88
#define SDL_RWread(ctx, ptr, size, n)
Definition: SDL_rwops.h:187
#define SDL_RWOPS_UNKNOWN
Definition: SDL_rwops.h:42
#define RW_SEEK_END
Definition: SDL_rwops.h:176
DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value)
Definition: SDL_rwops.c:735
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
#define SDLCALL
Definition: begin_code.h:72
typedef UINT(WINAPI *PFNWGLGETCONTEXTGPUIDAMDPROC)(HGLRC hglrc)
DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c)
Definition: SDL_string.c:575
DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value)
Definition: SDL_rwops.c:728
GLsizei const GLchar *const * path
Definition: glew.h:5828
int Android_JNI_FileOpen(SDL_RWops *ctx, const char *fileName, const char *mode)
Uint32 type
Definition: SDL_rwops.h:93
#define SDL_SwapBE32(X)
Definition: SDL_endian.h:216
#define SDL_SwapLE64(X)
Definition: SDL_endian.h:213
#define SDL_SwapBE16(X)
Definition: SDL_endian.h:215
DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void)
Definition: SDL_rwops.c:623
static int SDLCALL mem_close(SDL_RWops *context)
Definition: SDL_rwops.c:443
DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src)
Definition: SDL_rwops.c:672
#define SDL_RWseek(ctx, offset, whence)
Definition: SDL_rwops.h:185
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:145
static size_t SDLCALL mem_write(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:425
static size_t SDLCALL mem_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
Definition: SDL_rwops.c:402
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size)
Definition: SDL_rwops.c:567
typedef HANDLE(WINAPI *PFNWGLCREATEBUFFERREGIONARBPROC)(HDC hDC
GLenum GLenum dst
Definition: glew.h:2396
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl2ext.h:848
DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code)
Definition: SDL_error.c:222
uint64_t Uint64
An unsigned 64-bit integer type.
Definition: SDL_stdinc.h:154
#define SDL_SwapLE32(X)
Definition: SDL_endian.h:212
DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area)
Definition: SDL_rwops.c:637
size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer, size_t size, size_t num)
static Sint64 SDLCALL mem_size(SDL_RWops *context)
Definition: SDL_rwops.c:368
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
Definition: SDL_error.c:53
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src)
Definition: SDL_rwops.c:663
GLuint num
Definition: glew.h:2631
DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value)
Definition: SDL_rwops.c:721
#define PATH_MAX
Definition: hrtf.c:34
static Sint64 SDLCALL mem_seek(SDL_RWops *context, Sint64 offset, int whence)
Definition: SDL_rwops.c:374
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
static size_t SDLCALL mem_writeconst(SDL_RWops *context, const void *ptr, size_t size, size_t num)
Definition: SDL_rwops.c:436
DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src)
Definition: SDL_rwops.c:699
int WIN_SetError(const char *prefix)
#define SDL_RWOPS_MEMORY
Definition: SDL_rwops.h:46
EGLSurface EGLint void ** value
Definition: eglext.h:301
DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src)
Definition: SDL_rwops.c:681
#define SDL_RWOPS_STDFILE
Definition: SDL_rwops.h:44
GLintptr offset
Definition: glew.h:1668
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
Definition: SDL_string.c:293
size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer, size_t size, size_t maxnum)
#define SDL_RWOPS_MEMORY_RO
Definition: SDL_rwops.h:47
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:129
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex
DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value)
Definition: SDL_rwops.c:714
union SDL_RWops::@74 hidden
DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops *dst, Uint8 value)
Definition: SDL_rwops.c:708
struct SDL_RWops::@74::@75 mem
#define RW_SEEK_SET
Definition: SDL_rwops.h:174
#define SDL_stack_alloc(type, count)
Definition: SDL_stdinc.h:226
uint16_t Uint16
An unsigned 16-bit integer type.
Definition: SDL_stdinc.h:137
DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value)
Definition: SDL_rwops.c:749
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, int size)
Definition: SDL_rwops.c:595
#define RW_SEEK_CUR
Definition: SDL_rwops.h:175
#define SDL_min(x, y)
Definition: SDL_stdinc.h:244
GLenum src
Definition: glew.h:2396
TParseContext * context
DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value)
Definition: SDL_rwops.c:742
#define SDL_SwapLE16(X)
Definition: SDL_endian.h:211
int64_t Sint64
A signed 64-bit integer type.
Definition: SDL_stdinc.h:150
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode)
Definition: SDL_rwops.c:455
GLenum mode
Definition: glew.h:2394
Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence)
unsigned int size_t
Sint64 Android_JNI_FileSize(SDL_RWops *ctx)
GLsizei size
Definition: gl2ext.h:1467
#define SDL_RWOPS_JNIFILE
Definition: SDL_rwops.h:45