sbsv2/raptor/util/talon/buffer.h
changeset 0 044383f39525
child 3 e1eecf4d390d
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2009 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 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef _TALON_BUFFER_H_
       
    24 #define _TALON_BUFFER_H_
       
    25 
       
    26 
       
    27 typedef struct {
       
    28 	unsigned int size, fill;
       
    29 	/* This struct will be followed by the number of bytes in "size" */
       
    30 	char byte0;
       
    31 } byteblock;
       
    32 
       
    33 typedef struct {
       
    34 	byteblock **blocks;
       
    35 	int maxblocks;
       
    36 	int lastblock;
       
    37 	unsigned int size;
       
    38 } buffer;
       
    39 
       
    40 buffer *buffer_new(void);
       
    41 char *buffer_append(buffer *b, char *bytes, unsigned int size);
       
    42 char *buffer_prepend(buffer *b, char *bytes, unsigned int size);
       
    43 char *buffer_makespace(buffer *b, unsigned int size);
       
    44 void buffer_usespace(buffer *b, unsigned int nbytes);
       
    45 byteblock *buffer_getbytes(buffer *b, int *iterator);
       
    46 void buffer_free(buffer **b);
       
    47 
       
    48 #endif