src/bloblist.h
changeset 98 9e3d28932e7b
child 113 4bee48270834
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/bloblist.h	Wed Mar 11 11:52:14 2015 +0100
     1.3 @@ -0,0 +1,84 @@
     1.4 +#pragma once
     1.5 +
     1.6 +#include "dynamic_api.h"
     1.7 +
     1.8 +#ifdef __cplusplus
     1.9 +extern "C" {
    1.10 +#endif
    1.11 +
    1.12 +
    1.13 +typedef struct _bloblist_t {
    1.14 +    char *data;                     // blob
    1.15 +    size_t size;                    // size of blob
    1.16 +    char *mime_type;                // UTF-8 string of MIME type of blob or
    1.17 +                                    // NULL if unknown
    1.18 +    char *file_name;                // UTF-8 string of file name of blob or
    1.19 +                                    // NULL if unknown
    1.20 +    struct _bloblist_t *next;
    1.21 +} bloblist_t;
    1.22 +
    1.23 +
    1.24 +// new_bloblist() - allocate a new bloblist
    1.25 +//
    1.26 +//  parameters:
    1.27 +//      blob (in)       blob to add to the list
    1.28 +//      size (in)       size of the blob
    1.29 +//      mime_type (in)  MIME type of the blob data or NULL if unknown
    1.30 +//      file_name (in)  file name of origin of blob data or NULL if unknown
    1.31 +//
    1.32 +//  return value:
    1.33 +//      pointer to new bloblist_t or NULL if out of memory
    1.34 +//
    1.35 +//  caveat:
    1.36 +//      the ownership of the blob goes to the bloblist; mime_type and file_name
    1.37 +//      are being copied, the originals remain in the ownership of the caller
    1.38 +
    1.39 +DYNAMIC_API bloblist_t *new_bloblist(char *blob, size_t size, const char *mime_type,
    1.40 +        const char *file_name);
    1.41 +
    1.42 +
    1.43 +// free_bloblist() - free bloblist
    1.44 +//
    1.45 +//  parameters:
    1.46 +//      bloblist (in)   bloblist to free
    1.47 +
    1.48 +DYNAMIC_API void free_bloblist(bloblist_t *bloblist);
    1.49 +
    1.50 +
    1.51 +// bloblist_dup() - duplicate bloblist
    1.52 +//
    1.53 +//  parameters:
    1.54 +//      src (in)    bloblist to duplicate
    1.55 +//
    1.56 +//  return value:
    1.57 +//      pointer to a new bloblist_t or NULL if out of memory
    1.58 +//
    1.59 +//  caveat:
    1.60 +//      this is an expensive operation because all blobs are copied
    1.61 +
    1.62 +DYNAMIC_API bloblist_t *bloblist_dup(const bloblist_t *src);
    1.63 +
    1.64 +// bloblist_add() - add reference to a blob to bloblist
    1.65 +//
    1.66 +//  parameters:
    1.67 +//      bloblist (in)   bloblist to add to
    1.68 +//      blob (in)       blob
    1.69 +//      size (in)       size of the blob
    1.70 +//      mime_type (in)  MIME type of the blob or NULL if unknown
    1.71 +//      file_name (in)  file name of the blob or NULL if unknown
    1.72 +//
    1.73 +//  return value:
    1.74 +//      pointer to the last element of bloblist or NULL if out of memory
    1.75 +//
    1.76 +//  caveat:
    1.77 +//      the ownership of the blob goes to the bloblist; mime_type and file_name
    1.78 +//      are being copied, the originals remain in the ownership of the caller
    1.79 +
    1.80 +DYNAMIC_API bloblist_t *bloblist_add(bloblist_t *bloblist, char *blob, size_t size,
    1.81 +        const char *mime_type, const char *file_name);
    1.82 +
    1.83 +
    1.84 +#ifdef __cplusplus
    1.85 +}
    1.86 +#endif
    1.87 +