misc/winutils/include/SDL_rwops.h
author nemo
Mon, 29 Oct 2012 18:20:08 -0400
changeset 7889 57b117d441b9
parent 7809 7d4fb2f35f4f
child 10017 de822cd3df3a
permissions -rw-r--r--
consistent line endings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     1
/*
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
7809
7d4fb2f35f4f update SDL headers for winutils
koda
parents: 6560
diff changeset
     3
    Copyright (C) 1997-2012 Sam Lantinga
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     4
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
     9
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    13
    Lesser General Public License for more details.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    14
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    18
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    19
    Sam Lantinga
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    20
    slouken@libsdl.org
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    21
*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    22
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    23
/** @file SDL_rwops.h
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    24
 *  This file provides a general interface for SDL to read and write
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    25
 *  data sources.  It can easily be extended to files, memory, etc.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    26
 */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    27
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    28
#ifndef _SDL_rwops_h
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    29
#define _SDL_rwops_h
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    30
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    31
#include "SDL_stdinc.h"
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    32
#include "SDL_error.h"
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    33
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    34
#include "begin_code.h"
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    35
/* Set up for C function definitions, even when using C++ */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    36
#ifdef __cplusplus
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    37
extern "C" {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    38
#endif
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    39
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    40
/** This is the read/write operation structure -- very basic */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    41
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    42
typedef struct SDL_RWops {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    43
	/** Seek to 'offset' relative to whence, one of stdio's whence values:
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    44
	 *	SEEK_SET, SEEK_CUR, SEEK_END
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    45
	 *  Returns the final offset in the data source.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    46
	 */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    47
	int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    48
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    49
	/** Read up to 'maxnum' objects each of size 'size' from the data
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    50
	 *  source to the area pointed at by 'ptr'.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    51
	 *  Returns the number of objects read, or -1 if the read failed.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    52
	 */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    53
	int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    54
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    55
	/** Write exactly 'num' objects each of size 'objsize' from the area
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    56
	 *  pointed at by 'ptr' to data source.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    57
	 *  Returns 'num', or -1 if the write failed.
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    58
	 */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    59
	int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    60
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    61
	/** Close and free an allocated SDL_FSops structure */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    62
	int (SDLCALL *close)(struct SDL_RWops *context);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    63
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    64
	Uint32 type;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    65
	union {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    66
#if defined(__WIN32__) && !defined(__SYMBIAN32__)
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    67
	    struct {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    68
		int   append;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    69
		void *h;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    70
		struct {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    71
		    void *data;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    72
		    int size;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    73
		    int left;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    74
		} buffer;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    75
	    } win32io;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    76
#endif
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    77
#ifdef HAVE_STDIO_H 
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    78
	    struct {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    79
		int autoclose;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    80
	 	FILE *fp;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    81
	    } stdio;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    82
#endif
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    83
	    struct {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    84
		Uint8 *base;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    85
	 	Uint8 *here;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    86
		Uint8 *stop;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    87
	    } mem;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    88
	    struct {
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    89
		void *data1;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    90
	    } unknown;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    91
	} hidden;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    92
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    93
} SDL_RWops;
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    94
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    95
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    96
/** @name Functions to create SDL_RWops structures from various data sources */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    97
/*@{*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    98
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    99
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   100
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   101
#ifdef HAVE_STDIO_H
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   102
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   103
#endif
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   104
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   105
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   106
extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   107
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   108
extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   109
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   110
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   111
/*@}*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   112
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   113
/** @name Seek Reference Points */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   114
/*@{*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   115
#define RW_SEEK_SET	0	/**< Seek from the beginning of data */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   116
#define RW_SEEK_CUR	1	/**< Seek relative to current read point */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   117
#define RW_SEEK_END	2	/**< Seek relative to the end of data */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   118
/*@}*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   119
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   120
/** @name Macros to easily read and write from an SDL_RWops structure */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   121
/*@{*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   122
#define SDL_RWseek(ctx, offset, whence)	(ctx)->seek(ctx, offset, whence)
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   123
#define SDL_RWtell(ctx)			(ctx)->seek(ctx, 0, RW_SEEK_CUR)
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   124
#define SDL_RWread(ctx, ptr, size, n)	(ctx)->read(ctx, ptr, size, n)
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   125
#define SDL_RWwrite(ctx, ptr, size, n)	(ctx)->write(ctx, ptr, size, n)
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   126
#define SDL_RWclose(ctx)		(ctx)->close(ctx)
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   127
/*@}*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   128
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   129
/** @name Read an item of the specified endianness and return in native format */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   130
/*@{*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   131
extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   132
extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   133
extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   134
extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   135
extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   136
extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   137
/*@}*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   138
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   139
/** @name Write an item of native format to the specified endianness */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   140
/*@{*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   141
extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   142
extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   143
extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   144
extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   145
extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   146
extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   147
/*@}*/
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   148
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   149
/* Ends C function definitions when using C++ */
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   150
#ifdef __cplusplus
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   151
}
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   152
#endif
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   153
#include "close_code.h"
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   154
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
   155
#endif /* _SDL_rwops_h */