include/SDL_rwops.h
changeset 1895 c121d94672cb
parent 1453 2eb75f8a32ca
child 2159 dd4753e47ed4
     1.1 --- a/include/SDL_rwops.h	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/include/SDL_rwops.h	Mon Jul 10 21:04:37 2006 +0000
     1.3 @@ -20,9 +20,12 @@
     1.4      slouken@libsdl.org
     1.5  */
     1.6  
     1.7 -/* This file provides a general interface for SDL to read and write
     1.8 -   data sources.  It can easily be extended to files, memory, etc.
     1.9 -*/
    1.10 +/**
    1.11 + * \file SDL_rwops.h
    1.12 + *
    1.13 + * This file provides a general interface for SDL to read and write
    1.14 + * data sources.  It can easily be extended to files, memory, etc.
    1.15 + */
    1.16  
    1.17  #ifndef _SDL_rwops_h
    1.18  #define _SDL_rwops_h
    1.19 @@ -33,77 +36,89 @@
    1.20  #include "begin_code.h"
    1.21  /* Set up for C function definitions, even when using C++ */
    1.22  #ifdef __cplusplus
    1.23 +/* *INDENT-OFF* */
    1.24  extern "C" {
    1.25 +/* *INDENT-ON* */
    1.26  #endif
    1.27  
    1.28  /* This is the read/write operation structure -- very basic */
    1.29  
    1.30 -typedef struct SDL_RWops {
    1.31 -	/* Seek to 'offset' relative to whence, one of stdio's whence values:
    1.32 -		SEEK_SET, SEEK_CUR, SEEK_END
    1.33 -	   Returns the final offset in the data source.
    1.34 -	 */
    1.35 -	int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
    1.36 +typedef struct SDL_RWops
    1.37 +{
    1.38 +    /* Seek to 'offset' relative to whence, one of stdio's whence values:
    1.39 +       SEEK_SET, SEEK_CUR, SEEK_END
    1.40 +       Returns the final offset in the data source.
    1.41 +     */
    1.42 +    int (SDLCALL * seek) (struct SDL_RWops * context, int offset, int whence);
    1.43  
    1.44 -	/* Read up to 'num' objects each of size 'objsize' from the data
    1.45 -	   source to the area pointed at by 'ptr'.
    1.46 -	   Returns the number of objects read, or -1 if the read failed.
    1.47 -	 */
    1.48 -	int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
    1.49 +    /* Read up to 'num' objects each of size 'objsize' from the data
    1.50 +       source to the area pointed at by 'ptr'.
    1.51 +       Returns the number of objects read, or -1 if the read failed.
    1.52 +     */
    1.53 +    int (SDLCALL * read) (struct SDL_RWops * context, void *ptr, int size,
    1.54 +                          int maxnum);
    1.55  
    1.56 -	/* Write exactly 'num' objects each of size 'objsize' from the area
    1.57 -	   pointed at by 'ptr' to data source.
    1.58 -	   Returns 'num', or -1 if the write failed.
    1.59 -	 */
    1.60 -	int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
    1.61 +    /* Write exactly 'num' objects each of size 'objsize' from the area
    1.62 +       pointed at by 'ptr' to data source.
    1.63 +       Returns 'num', or -1 if the write failed.
    1.64 +     */
    1.65 +    int (SDLCALL * write) (struct SDL_RWops * context, const void *ptr,
    1.66 +                           int size, int num);
    1.67  
    1.68 -	/* Close and free an allocated SDL_FSops structure */
    1.69 -	int (SDLCALL *close)(struct SDL_RWops *context);
    1.70 +    /* Close and free an allocated SDL_FSops structure */
    1.71 +    int (SDLCALL * close) (struct SDL_RWops * context);
    1.72  
    1.73 -	Uint32 type;
    1.74 -	union {
    1.75 +    Uint32 type;
    1.76 +    union
    1.77 +    {
    1.78  #ifdef __WIN32__
    1.79 -	    struct {
    1.80 -		int    append;
    1.81 -		void*  h;
    1.82 -	    } win32io;
    1.83 +        struct
    1.84 +        {
    1.85 +            int append;
    1.86 +            void *h;
    1.87 +        } win32io;
    1.88  #endif
    1.89 -#ifdef HAVE_STDIO_H 
    1.90 -	    struct {
    1.91 -		int autoclose;
    1.92 -	 	FILE *fp;
    1.93 -	    } stdio;
    1.94 +#ifdef HAVE_STDIO_H
    1.95 +        struct
    1.96 +        {
    1.97 +            int autoclose;
    1.98 +            FILE *fp;
    1.99 +        } stdio;
   1.100  #endif
   1.101 -	    struct {
   1.102 -		Uint8 *base;
   1.103 -	 	Uint8 *here;
   1.104 -		Uint8 *stop;
   1.105 -	    } mem;
   1.106 -	    struct {
   1.107 -		void *data1;
   1.108 -	    } unknown;
   1.109 -	} hidden;
   1.110 +        struct
   1.111 +        {
   1.112 +            Uint8 *base;
   1.113 +            Uint8 *here;
   1.114 +            Uint8 *stop;
   1.115 +        } mem;
   1.116 +        struct
   1.117 +        {
   1.118 +            void *data1;
   1.119 +        } unknown;
   1.120 +    } hidden;
   1.121  
   1.122  } SDL_RWops;
   1.123  
   1.124  
   1.125  /* Functions to create SDL_RWops structures from various data sources */
   1.126  
   1.127 -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode);
   1.128 +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file,
   1.129 +                                                  const char *mode);
   1.130  
   1.131  #ifdef HAVE_STDIO_H
   1.132 -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose);
   1.133 +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, int autoclose);
   1.134  #endif
   1.135  
   1.136 -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size);
   1.137 -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size);
   1.138 +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size);
   1.139 +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem,
   1.140 +                                                      int size);
   1.141  
   1.142 -extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void);
   1.143 -extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
   1.144 +extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
   1.145 +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
   1.146  
   1.147 -#define RW_SEEK_SET	0	/* Seek from the beginning of data */
   1.148 -#define RW_SEEK_CUR	1	/* Seek relative to current read point */
   1.149 -#define RW_SEEK_END	2	/* Seek relative to the end of data */
   1.150 +#define RW_SEEK_SET	0       /* Seek from the beginning of data */
   1.151 +#define RW_SEEK_CUR	1       /* Seek relative to current read point */
   1.152 +#define RW_SEEK_END	2       /* Seek relative to the end of data */
   1.153  
   1.154  /* Macros to easily read and write from an SDL_RWops structure */
   1.155  #define SDL_RWseek(ctx, offset, whence)	(ctx)->seek(ctx, offset, whence)
   1.156 @@ -114,26 +129,30 @@
   1.157  
   1.158  
   1.159  /* Read an item of the specified endianness and return in native format */
   1.160 -extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
   1.161 -extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
   1.162 -extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
   1.163 -extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
   1.164 -extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
   1.165 -extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
   1.166 +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
   1.167 +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
   1.168 +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
   1.169 +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src);
   1.170 +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src);
   1.171 +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
   1.172  
   1.173  /* Write an item of native format to the specified endianness */
   1.174 -extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
   1.175 -extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
   1.176 -extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
   1.177 -extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
   1.178 -extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
   1.179 -extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
   1.180 +extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
   1.181 +extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
   1.182 +extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
   1.183 +extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value);
   1.184 +extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value);
   1.185 +extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value);
   1.186  
   1.187  
   1.188  /* Ends C function definitions when using C++ */
   1.189  #ifdef __cplusplus
   1.190 +/* *INDENT-OFF* */
   1.191  }
   1.192 +/* *INDENT-ON* */
   1.193  #endif
   1.194  #include "close_code.h"
   1.195  
   1.196  #endif /* _SDL_rwops_h */
   1.197 +
   1.198 +/* vi: set ts=4 sw=4 expandtab: */