src/bloblist.h
author vb
Sun, 15 Mar 2015 10:14:43 +0100
changeset 113 4bee48270834
parent 98 9e3d28932e7b
child 230 5b36a2663539
permissions -rw-r--r--
...
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@98
    11
    char *data;                     // 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:
vb@98
    71
//      pointer to the last element of bloblist or NULL if out of memory
vb@98
    72
//
vb@98
    73
//  caveat:
vb@113
    74
//      the ownership of the blob goes to the bloblist; mime_type and filename
vb@98
    75
//      are being copied, the originals remain in the ownership of the caller
vb@98
    76
vb@98
    77
DYNAMIC_API bloblist_t *bloblist_add(bloblist_t *bloblist, char *blob, size_t size,
vb@113
    78
        const char *mime_type, const char *filename);
vb@98
    79
vb@98
    80
vb@98
    81
#ifdef __cplusplus
vb@98
    82
}
vb@98
    83
#endif
vb@98
    84