misc/winutils/include/SDL_rwops.h
author Wuzzy <Wuzzy2@mail.ru>
Sun, 11 Feb 2018 01:15:23 +0100
changeset 12969 2fee2ee717eb
parent 10017 de822cd3df3a
permissions -rw-r--r--
Construction Mode: Spawn particles over generators, tweak other particles
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 {
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    43
    /** Seek to 'offset' relative to whence, one of stdio's whence values:
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    44
     *  SEEK_SET, SEEK_CUR, SEEK_END
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    45
     *  Returns the final offset in the data source.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    46
     */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    47
    int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    48
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    49
    /** Read up to 'maxnum' objects each of size 'size' from the data
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    50
     *  source to the area pointed at by 'ptr'.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    51
     *  Returns the number of objects read, or -1 if the read failed.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    52
     */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    53
    int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    54
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    55
    /** Write exactly 'num' objects each of size 'objsize' from the area
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    56
     *  pointed at by 'ptr' to data source.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    57
     *  Returns 'num', or -1 if the write failed.
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    58
     */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    59
    int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    60
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    61
    /** Close and free an allocated SDL_FSops structure */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    62
    int (SDLCALL *close)(struct SDL_RWops *context);
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    63
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    64
    Uint32 type;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    65
    union {
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    66
#if defined(__WIN32__) && !defined(__SYMBIAN32__)
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    67
        struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    68
        int   append;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    69
        void *h;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    70
        struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    71
            void *data;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    72
            int size;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    73
            int left;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    74
        } buffer;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    75
        } win32io;
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    76
#endif
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    77
#ifdef HAVE_STDIO_H
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    78
        struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    79
        int autoclose;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    80
        FILE *fp;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    81
        } stdio;
6560
ca07e6be08d0 GCI task: cmd.exe
bovi
parents:
diff changeset
    82
#endif
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    83
        struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    84
        Uint8 *base;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    85
        Uint8 *here;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    86
        Uint8 *stop;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    87
        } mem;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    88
        struct {
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    89
        void *data1;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    90
        } unknown;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
    91
    } hidden;
6560
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
/*@{*/
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   115
#define RW_SEEK_SET 0   /**< Seek from the beginning of data */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   116
#define RW_SEEK_CUR 1   /**< Seek relative to current read point */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   117
#define RW_SEEK_END 2   /**< Seek relative to the end of data */
6560
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
/*@{*/
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   122
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   123
#define SDL_RWtell(ctx)         (ctx)->seek(ctx, 0, RW_SEEK_CUR)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   124
#define SDL_RWread(ctx, ptr, size, n)   (ctx)->read(ctx, ptr, size, n)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   125
#define SDL_RWwrite(ctx, ptr, size, n)  (ctx)->write(ctx, ptr, size, n)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 7809
diff changeset
   126
#define SDL_RWclose(ctx)        (ctx)->close(ctx)
6560
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 */