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