buffer.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2009-2011 Nokia Corporation and/or its subsidiary(-ies).
  3. * All rights reserved.
  4. * This component and the accompanying materials are made available
  5. * under the terms of the License "Eclipse Public License v1.0"
  6. * which accompanies this distribution, and is available
  7. * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. *
  9. * Initial Contributors:
  10. * Nokia Corporation - initial contribution.
  11. *
  12. * Contributors:
  13. *
  14. * Description:
  15. * buffer.c
  16. * Resizable buffer for output from subprocesses.
  17. *
  18. */
  19. #ifndef _TALON_BUFFER_H_
  20. #define _TALON_BUFFER_H_
  21. typedef struct {
  22. unsigned int size, fill;
  23. /* This struct will be followed by the number of bytes in "size" */
  24. char byte0;
  25. } byteblock;
  26. typedef struct {
  27. byteblock **blocks;
  28. int maxblocks;
  29. int lastblock;
  30. unsigned int size;
  31. } buffer;
  32. buffer *buffer_new(void);
  33. char *buffer_append(buffer *b, char *bytes, unsigned int size);
  34. char *buffer_prepend(buffer *b, char *bytes, unsigned int size);
  35. char *buffer_makespace(buffer *b, unsigned int size);
  36. void buffer_usespace(buffer *b, unsigned int nbytes);
  37. byteblock *buffer_getbytes(buffer *b, unsigned int *iterator);
  38. void buffer_free(buffer **b);
  39. #endif