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