/* * Filename: buffer.h * Description: Buffer ó¸® ¸ðµâ * * Author: ±èÇÑÁÖ (aka. ºñ¿±, Cronan), ¼Û¿µÁø (aka. myevan, ºøÀÚ·ç) */ #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; int flag; }; extern LPBUFFER buffer_new(int size); // »õ ¹öÆÛ »ý¼º extern void buffer_delete(LPBUFFER buffer); // ¹öÆÛ »èÁ¦ extern void buffer_reset(LPBUFFER buffer); // ¹öÆÛ ±æÀ̵éÀ» ÃʱâÈ­ extern DWORD buffer_size(LPBUFFER buffer); // ¹öÆÛ¿¡ ³²Àº ±æÀÌ extern int buffer_has_space(LPBUFFER buffer); // ¾µ ¼ö ÀÖ´Â ±æÀ̸¦ ¸®ÅÏ extern void buffer_write (LPBUFFER& buffer, const void* src, int length); // ¹öÆÛ¿¡ ¾´´Ù. extern void buffer_read(LPBUFFER buffer, void * buf, int bytes); // ¹öÆÛ¿¡¼­ Àд´Ù. extern BYTE buffer_get_byte(LPBUFFER buffer); extern WORD buffer_get_word(LPBUFFER buffer); extern DWORD buffer_get_dword(LPBUFFER buffer); // buffer_proceed ÇÔ¼ö´Â buffer_peekÀ¸·Î Àбâ¿ë Æ÷ÀÎÅ͸¦ ¸®ÅÏ ¹Þ¾Æ¼­ ¾µ ÇÊ¿ä°¡ // ÀÖÀ» ¶§ 󸮰¡ ³¡³ª¸é ¾ó¸¶³ª 󸮰¡ ³¡³µ´Ù°í Å뺸ÇØ¾ß ÇÒ ¶§ ¾´´Ù. // (buffer_read, buffer_get_* ½Ã¸®ÁîÀÇ °æ¿ì¿¡´Â ¾Ë¾Æ¼­ 󸮵ÇÁö¸¸ peekÀ¸·Î ó¸®ÇßÀ» // ¶§´Â ±×·¸°Ô µÉ ¼ö°¡ ¾øÀ¸¹Ç·Î) extern const void * buffer_read_peek(LPBUFFER buffer); // Àд À§Ä¡¸¦ ¸®ÅÏ extern void buffer_read_proceed(LPBUFFER buffer, int length); // length¸¸Å­ÀÇ Ã³¸®°¡ ³¡³² // ¸¶Âù°¡Áö·Î write_peekÀ¸·Î ¾²±â À§Ä¡¸¦ ¾ò¾î¿Â ´ÙÀ½ ¾ó¸¶³ª ½è³ª Å뺸ÇÒ ¶§ // buffer_write_proceed¸¦ »ç¿ëÇÑ´Ù. extern void * buffer_write_peek(LPBUFFER buffer); // ¾²´Â À§Ä¡¸¦ ¸®ÅÏ extern void buffer_write_proceed(LPBUFFER buffer, int length); // length¸¸ Áõ°¡ ½ÃŲ´Ù. extern void buffer_adjust_size(LPBUFFER & buffer, int add_size); // add_size¸¸Å­ Ãß°¡ÇÒ Å©±â¸¦ È®º¸ #endif