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