src/bloblist.h
author Roker <roker@pep-project.org>
Tue, 27 Sep 2016 21:36:31 +0200
branchkeysync
changeset 1201 571f488333be
parent 900 2b8f651433ee
child 1396 26ae3f0cea22
permissions -rw-r--r--
add "-luuid" to LDFLAGS due to linker errors on Ubuntu
vb@98
     1
#pragma once
vb@98
     2
vb@98
     3
#include "dynamic_api.h"
vb@98
     4
vb@98
     5
#ifdef __cplusplus
vb@98
     6
extern "C" {
vb@98
     7
#endif
vb@98
     8
vb@98
     9
vb@98
    10
typedef struct _bloblist_t {
vb@301
    11
    char *value;                    // blob
vb@98
    12
    size_t size;                    // size of blob
vb@98
    13
    char *mime_type;                // UTF-8 string of MIME type of blob or
vb@98
    14
                                    // NULL if unknown
vb@113
    15
    char *filename;                // UTF-8 string of file name of blob or
vb@98
    16
                                    // NULL if unknown
vb@98
    17
    struct _bloblist_t *next;
vb@98
    18
} bloblist_t;
vb@98
    19
vb@98
    20
vb@98
    21
// new_bloblist() - allocate a new bloblist
vb@98
    22
//
vb@98
    23
//  parameters:
vb@98
    24
//      blob (in)       blob to add to the list
vb@98
    25
//      size (in)       size of the blob
vb@98
    26
//      mime_type (in)  MIME type of the blob data or NULL if unknown
vb@113
    27
//      filename (in)  file name of origin of blob data or NULL if unknown
vb@98
    28
//
vb@98
    29
//  return value:
vb@98
    30
//      pointer to new bloblist_t or NULL if out of memory
vb@98
    31
//
vb@98
    32
//  caveat:
vb@113
    33
//      the ownership of the blob goes to the bloblist; mime_type and filename
vb@98
    34
//      are being copied, the originals remain in the ownership of the caller
vb@98
    35
vb@98
    36
DYNAMIC_API bloblist_t *new_bloblist(char *blob, size_t size, const char *mime_type,
vb@113
    37
        const char *filename);
vb@98
    38
vb@98
    39
vb@98
    40
// free_bloblist() - free bloblist
vb@98
    41
//
vb@98
    42
//  parameters:
vb@98
    43
//      bloblist (in)   bloblist to free
vb@98
    44
vb@98
    45
DYNAMIC_API void free_bloblist(bloblist_t *bloblist);
vb@98
    46
vb@98
    47
vb@98
    48
// bloblist_dup() - duplicate bloblist
vb@98
    49
//
vb@98
    50
//  parameters:
vb@98
    51
//      src (in)    bloblist to duplicate
vb@98
    52
//
vb@98
    53
//  return value:
vb@98
    54
//      pointer to a new bloblist_t or NULL if out of memory
vb@98
    55
//
vb@98
    56
//  caveat:
vb@98
    57
//      this is an expensive operation because all blobs are copied
vb@98
    58
vb@98
    59
DYNAMIC_API bloblist_t *bloblist_dup(const bloblist_t *src);
vb@98
    60
vb@98
    61
// bloblist_add() - add reference to a blob to bloblist
vb@98
    62
//
vb@98
    63
//  parameters:
vb@98
    64
//      bloblist (in)   bloblist to add to
vb@98
    65
//      blob (in)       blob
vb@98
    66
//      size (in)       size of the blob
vb@98
    67
//      mime_type (in)  MIME type of the blob or NULL if unknown
vb@113
    68
//      filename (in)  file name of the blob or NULL if unknown
vb@98
    69
//
vb@98
    70
//  return value:
krista@900
    71
//      pointer to the last element of bloblist or NULL if out of memory or
krista@900
    72
//      NULL passed in as blob value
vb@98
    73
//
vb@98
    74
//  caveat:
vb@113
    75
//      the ownership of the blob goes to the bloblist; mime_type and filename
krista@900
    76
//      are being copied, the originals remain in the ownership of the caller.
krista@900
    77
//      bloblist input parameter equal to NULL or with value == NULL is a valid
krista@900
    78
//      empty input list.
vb@98
    79
vb@98
    80
DYNAMIC_API bloblist_t *bloblist_add(bloblist_t *bloblist, char *blob, size_t size,
vb@113
    81
        const char *mime_type, const char *filename);
vb@98
    82
vb@98
    83
vb@230
    84
// bloblist_length() - get length of bloblist
vb@230
    85
//
vb@230
    86
//  parameters:
vb@230
    87
//      bloblist (in)   bloblist struct to determine length of
vb@230
    88
//
vb@230
    89
//  return value:
vb@230
    90
//      length of bloblist in number of elements
vb@230
    91
vb@230
    92
DYNAMIC_API int bloblist_length(const bloblist_t *bloblist);
vb@230
    93
vb@230
    94
vb@98
    95
#ifdef __cplusplus
vb@98
    96
}
vb@98
    97
#endif
vb@98
    98