forked from metin2/server
58 lines
2.1 KiB
C
58 lines
2.1 KiB
C
|
/*
|
|||
|
* Filename: buffer.h
|
|||
|
* Description: Buffer ó<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* Author: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (aka. <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, Cronan), <EFBFBD>ۿ<EFBFBD><EFBFBD><EFBFBD> (aka. myevan, <EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD>)
|
|||
|
*/
|
|||
|
#ifndef __INC_LIBTHECORE_BUFFER_H__
|
|||
|
#define __INC_LIBTHECORE_BUFFER_H__
|
|||
|
|
|||
|
#define SAFE_BUFFER_DELETE(buf) { if(buf != NULL) { buffer_delete(buf); buf = NULL; } }
|
|||
|
|
|||
|
typedef struct buffer BUFFER;
|
|||
|
typedef struct buffer * LPBUFFER;
|
|||
|
|
|||
|
struct buffer
|
|||
|
{
|
|||
|
struct buffer * next;
|
|||
|
|
|||
|
char * write_point;
|
|||
|
int write_point_pos;
|
|||
|
|
|||
|
const char * read_point;
|
|||
|
int length;
|
|||
|
|
|||
|
char * mem_data;
|
|||
|
int mem_size;
|
|||
|
|
|||
|
long flag;
|
|||
|
};
|
|||
|
|
|||
|
extern LPBUFFER buffer_new(int size); // <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
extern void buffer_delete(LPBUFFER buffer); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
extern void buffer_reset(LPBUFFER buffer); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD> <20>ʱ<EFBFBD>ȭ
|
|||
|
|
|||
|
extern DWORD buffer_size(LPBUFFER buffer); // <20><><EFBFBD>ۿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
extern int buffer_has_space(LPBUFFER buffer); // <20><> <20><> <20>ִ<EFBFBD> <20><><EFBFBD≯<EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
extern void buffer_write (LPBUFFER& buffer, const void* src, int length); // <20><><EFBFBD>ۿ<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
extern void buffer_read(LPBUFFER buffer, void * buf, int bytes); // <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>д´<D0B4>.
|
|||
|
extern BYTE buffer_get_byte(LPBUFFER buffer);
|
|||
|
extern WORD buffer_get_word(LPBUFFER buffer);
|
|||
|
extern DWORD buffer_get_dword(LPBUFFER buffer);
|
|||
|
|
|||
|
// buffer_proceed <20>Լ<EFBFBD><D4BC><EFBFBD> buffer_peek<65><6B><EFBFBD><EFBFBD> <20>б<EFBFBD><D0B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ƽ<DEBE> <20><> <20>ʿ䰡
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><> ó<><C3B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD> ó<><C3B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ٰ<EFBFBD> <20>뺸<EFBFBD>ؾ<EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD>.
|
|||
|
// (buffer_read, buffer_get_* <20>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>쿡<EFBFBD><ECBFA1> <20>˾Ƽ<CBBE> ó<><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> peek<65><6B><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><EFBFBD><D7B7><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>)
|
|||
|
extern const void * buffer_read_peek(LPBUFFER buffer); // <20>д<EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD>
|
|||
|
extern void buffer_read_proceed(LPBUFFER buffer, int length); // length<74><68>ŭ<EFBFBD><C5AD> ó<><C3B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> write_peek<65><6B><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD> <20>質 <20>뺸<EFBFBD><EBBAB8> <20><>
|
|||
|
// buffer_write_proceed<65><64> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|||
|
extern void * buffer_write_peek(LPBUFFER buffer); // <20><><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD>
|
|||
|
extern void buffer_write_proceed(LPBUFFER buffer, int length); // length<74><68> <20><><EFBFBD><EFBFBD> <20><>Ų<EFBFBD><C5B2>.
|
|||
|
|
|||
|
extern void buffer_adjust_size(LPBUFFER & buffer, int add_size); // add_size<7A><65>ŭ <20>߰<EFBFBD><DFB0><EFBFBD> ũ<>⸦ Ȯ<><C8AE>
|
|||
|
#endif
|