1 /* (C) 2011 - 2012 rofl0r.
2 Permission for use by AGS is hereby granted. */
18 enum ByteArray_Endianess
{
28 enum ByteArray_Flags
{
36 enum ByteArray_Endianess endian
;
37 enum ByteArray_Endianess sys_endian
;
44 ssize_t (*readMultiByte
)(struct ByteArray
*, char*, size_t);
45 unsigned long long (*readUnsignedLongLong
)(struct ByteArray
*);
46 unsigned int (*readUnsignedInt
)(struct ByteArray
*);
47 signed int (*readInt
)(struct ByteArray
*);
48 unsigned short (*readUnsignedShort
)(struct ByteArray
*);
49 signed short (*readShort
)(struct ByteArray
*);
50 unsigned char (*readUnsignedByte
)(struct ByteArray
*);
51 signed char (*readByte
)(struct ByteArray
*);
52 off_t (*readBytes
) (struct ByteArray
* self
, struct ByteArray
*dest
, off_t start
, off_t len
);
53 off_t (*bytesAvailable
)(struct ByteArray
*);
54 off_t (*writeByte
) (struct ByteArray
* self
, signed char what
);
55 off_t (*writeUnsignedByte
) (struct ByteArray
* self
, unsigned char what
);
56 off_t (*writeShort
) (struct ByteArray
* self
, signed short what
);
57 off_t (*writeUnsignedShort
) (struct ByteArray
* self
, unsigned short what
);
58 off_t (*writeInt
) (struct ByteArray
* self
, signed int what
);
59 off_t (*writeUnsignedInt
) (struct ByteArray
* self
, unsigned int what
);
60 off_t (*writeMem
) (struct ByteArray
* self
, unsigned char* what
, size_t len
);
61 off_t (*writeUTFBytes
) (struct ByteArray
* self
, char* what
);
62 off_t (*writeBytes
) (struct ByteArray
* self
, struct ByteArray
* what
);
63 off_t (*writeFloat
) (struct ByteArray
* self
, float what
);
64 int (*set_position_rel
) (struct ByteArray
* self
, int rel
);
65 int (*set_position
) (struct ByteArray
* self
, off_t pos
);
66 off_t (*get_position
) (struct ByteArray
* self
);
69 void ByteArray_defaults(struct ByteArray
* self
);
70 void ByteArray_ctor(struct ByteArray
* self
);
71 struct ByteArray
* ByteArray_new(void);
73 void ByteArray_set_endian(struct ByteArray
* self
, enum ByteArray_Endianess endian
);
74 void ByteArray_set_flags(struct ByteArray
*self
, int flags
);
75 enum ByteArray_Endianess
ByteArray_get_endian(struct ByteArray
* self
);
77 int ByteArray_open_file(struct ByteArray
* self
, const char* filename
);
78 void ByteArray_close_file(struct ByteArray
*self
);
79 int ByteArray_open_mem(struct ByteArray
* self
, char* data
, size_t size
);
80 void ByteArray_clear(struct ByteArray
* self
);
81 void ByteArray_close(struct ByteArray
* self
);
83 void ByteArray_set_length(struct ByteArray
* self
, off_t len
);
84 off_t
ByteArray_get_length(struct ByteArray
* self
);
86 off_t
ByteArray_get_position(struct ByteArray
* self
);
87 int ByteArray_set_position(struct ByteArray
* self
, off_t pos
);
88 int ByteArray_set_position_rel(struct ByteArray
* self
, int rel
);
89 off_t
ByteArray_bytesAvailable(struct ByteArray
* self
);
91 ssize_t
ByteArray_readMultiByte(struct ByteArray
* self
, char* buffer
, size_t len
);
92 unsigned long long ByteArray_readUnsignedLongLong(struct ByteArray
* self
);
93 unsigned int ByteArray_readUnsignedInt(struct ByteArray
* self
);
94 int ByteArray_readInt(struct ByteArray
* self
);
95 unsigned short ByteArray_readUnsignedShort(struct ByteArray
* self
);
96 short ByteArray_readShort(struct ByteArray
* self
);
97 unsigned char ByteArray_readUnsignedByte(struct ByteArray
* self
);
98 signed char ByteArray_readByte(struct ByteArray
* self
);
99 off_t
ByteArray_readBytes(struct ByteArray
* self
, struct ByteArray
*dest
, off_t start
, off_t len
);
101 off_t
ByteArray_writeByte(struct ByteArray
* self
, signed char what
);
102 off_t
ByteArray_writeUnsignedByte(struct ByteArray
* self
, unsigned char what
);
103 off_t
ByteArray_writeShort(struct ByteArray
* self
, signed short what
);
104 off_t
ByteArray_writeUnsignedShort(struct ByteArray
* self
, unsigned short what
);
105 off_t
ByteArray_writeInt(struct ByteArray
* self
, signed int what
);
106 off_t
ByteArray_writeUnsignedInt(struct ByteArray
* self
, unsigned int what
);
107 off_t
ByteArray_writeFloat(struct ByteArray
* self
, float what
);
108 off_t
ByteArray_writeMem(struct ByteArray
* self
, unsigned char* what
, size_t len
);
109 off_t
ByteArray_writeUTFBytes(struct ByteArray
* self
, char* what
);
110 off_t
ByteArray_writeBytes(struct ByteArray
* self
, struct ByteArray
* what
);
112 unsigned char ByteArray_getUnsignedByte(struct ByteArray
* self
, off_t index
);
113 void ByteArray_setUnsignedByte(struct ByteArray
* self
, off_t index
, unsigned char what
);
115 void ByteArray_dump_to_stream(struct ByteArray
* self
, FILE *out
);
116 void ByteArray_dump_to_file(struct ByteArray
* self
, char* filename
);
122 #pragma RcB2 DEP "ByteArray.c"