src/growing_buf.h
author Neal H. Walfield <neal@pep.foundation>
Wed, 08 May 2019 12:20:37 +0200
branchemail_comparison
changeset 3649 1dd837adc30b
parent 2840 b881c48c9e9d
permissions -rw-r--r--
Fix public key.
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 
     7 #include "pEpEngine.h"
     8 
     9 
    10 #ifdef __cplusplus
    11 extern "C" {
    12 #endif
    13 
    14 
    15 // this is a growing buffer, which is needed by the ASN.1 implementation
    16 // i.e. for encoding to XER
    17 
    18 typedef struct growing_buf {
    19     char *data;
    20     size_t size;
    21 } growing_buf_t;
    22 
    23 
    24 // new_growing_buf() - allocate a new growing buffer
    25 //
    26 //  return value:
    27 //      new buffer or NULL if out of memory
    28 
    29 growing_buf_t *new_growing_buf(void);
    30 
    31 
    32 // free_growing_buf() - free growing buffer
    33 //
    34 //  parameters:
    35 //      buf (in)            buffer to free
    36 
    37 void free_growing_buf(growing_buf_t *buf);
    38 
    39 
    40 // growing_buf_consume() - append new data to growing buffer
    41 //
    42 //  parameters:
    43 //      src (in)            new data
    44 //      size (in)           size of new data
    45 //      dst (in)            growing buffer where new data will be appended
    46 //
    47 //  return value:
    48 //      1 on succes, -1 on failure
    49 
    50 int growing_buf_consume(const void *src, size_t size, growing_buf_t *dst);
    51 
    52 
    53 #ifdef __cplusplus
    54 }
    55 #endif
    56