home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / goattracker_2.73.zip / src / asm / membuf.h < prev    next >
Encoding:
C/C++ Source or Header  |  2014-07-23  |  2.1 KB  |  60 lines

  1. #ifndef ALREADY_INCLUDED_MEMBUF
  2. #define ALREADY_INCLUDED_MEMBUF
  3.  
  4. /*
  5.  * Copyright (c) 2002 - 2005 Magnus Lind.
  6.  *
  7.  * This software is provided 'as-is', without any express or implied warranty.
  8.  * In no event will the authors be held liable for any damages arising from
  9.  * the use of this software.
  10.  *
  11.  * Permission is granted to anyone to use this software, alter it and re-
  12.  * distribute it freely for any non-commercial, non-profit purpose subject to
  13.  * the following restrictions:
  14.  *
  15.  *   1. The origin of this software must not be misrepresented; you must not
  16.  *   claim that you wrote the original software. If you use this software in a
  17.  *   product, an acknowledgment in the product documentation would be
  18.  *   appreciated but is not required.
  19.  *
  20.  *   2. Altered source versions must be plainly marked as such, and must not
  21.  *   be misrepresented as being the original software.
  22.  *
  23.  *   3. This notice may not be removed or altered from any distribution.
  24.  *
  25.  *   4. The names of this software and/or it's copyright holders may not be
  26.  *   used to endorse or promote products derived from this software without
  27.  *   specific prior written permission.
  28.  *
  29.  */
  30.  
  31. #define STATIC_MEMBUF_INIT {0, 0, 0}
  32.  
  33. struct membuf {
  34.     void *buf;
  35.     int len;
  36.     int size;
  37. };
  38.  
  39. void membuf_init(struct membuf *sb);
  40. void membuf_clear(struct membuf *sb);
  41. void membuf_free(struct membuf *sb);
  42. void membuf_new(struct membuf **sbp);
  43. void membuf_delete(struct membuf **sbp);
  44. int membuf_memlen(struct membuf *sb);
  45. void membuf_truncate(struct membuf *sb, int len);
  46.  
  47. /* returns the new len or < 0 if failure */
  48. int membuf_trim(struct membuf *sb, int pos);
  49.  
  50. void *membuf_memcpy(struct membuf *sb, const void *mem, int len);
  51. void *membuf_append(struct membuf *sb, const void *mem, int len);
  52. void *membuf_append_char(struct membuf *sb, char c);
  53. void *membuf_insert(struct membuf *sb, int offset, const void *mem, int len);
  54. void membuf_atleast(struct membuf *sb, int size);
  55. void membuf_atmost(struct membuf *sb, int size);
  56. int membuf_get_size(struct membuf *sb);
  57. void *membuf_get(struct membuf *sb);
  58.  
  59. #endif
  60.