src/baseprotocol.h
author Dirk Zimmermann <dz@pep.security>
Thu, 11 Apr 2019 10:46:46 +0200
branchIOS-1482
changeset 3505 3fe4b41696d3
parent 3393 ecdb1635904a
child 3544 70eae1a189c3
permissions -rw-r--r--
IOS-1482 close branch
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include "message.h"
     7 
     8 #ifdef __cplusplus
     9 extern "C" {
    10 #endif
    11 
    12 
    13 // base_decorate_message() - decorate a message with payload
    14 //
    15 //  parameters:
    16 //      session (in)    session handle
    17 //      msg (inout)     message to decorate
    18 //      payload (in)    payload to send
    19 //      size (in)       size of payload
    20 //      fpr (in)        optional key to sign or NULL
    21 //
    22 //  returns:
    23 //      PEP_STATUS_OK and result on success or an error on failure
    24 //
    25 //  caveat:
    26 //      on success (and only then) payload goes to the ownership of the msg
    27 //      the ownership of the msg remains with the caller
    28 
    29 PEP_STATUS base_decorate_message(
    30         PEP_SESSION session,
    31         message *msg,
    32         char *payload,
    33         size_t size,
    34         const char *fpr,
    35         stringlist_t **keys
    36     );
    37 
    38 
    39 // base_prepare_message() - prepare a sync message with payload
    40 //
    41 //  parameters:
    42 //      session (in)    session handle
    43 //      me (in)         identity to use for the sender
    44 //      partner (in)    identity to use for the receiver
    45 //      payload (in)    payload to send
    46 //      size (in)       size of payload
    47 //      fpr (in)        optional key to sign or NULL
    48 //      result (out)    message with payload
    49 //
    50 //  returns:
    51 //      PEP_STATUS_OK and result on success or an error on failure
    52 //
    53 //  caveat:
    54 //      on success (and only then) payload goes to the ownership of the result
    55 //      the ownership of the result goes to the caller
    56 
    57 PEP_STATUS base_prepare_message(
    58         PEP_SESSION session,
    59         const pEp_identity *me,
    60         const pEp_identity *partner,
    61         char *payload,
    62         size_t size,
    63         const char *fpr,
    64         stringlist_t **keys,
    65         message **result
    66     );
    67 
    68 
    69 // base_extract_message() - extract a sync message from a pEp message
    70 //
    71 //  parameters:
    72 //      session (in)    session handle
    73 //      msg (in)        message to analyze
    74 //      size (out)      size of extracted payload or 0 if not found
    75 //      payload (out)   extraced payload
    76 //      fpr (out)       if message was correctly signed then fpr of signature's
    77 //                      key, otherwise NULL
    78 //
    79 //  returns:
    80 //      PEP_STATUS_OK and payload == NULL if no sync message
    81 //      PEP_STATUS_OK and payload, size if sync message found
    82 //      any other value on error
    83 //
    84 //  caveat:
    85 //      payload may point to msg attachment, the ownership does not change
    86 //      if fpr != NULL the ownership goes to the caller
    87 
    88 PEP_STATUS base_extract_message(
    89         PEP_SESSION session,
    90         message *msg,
    91         size_t *size,
    92         const char **payload,
    93         char **fpr
    94     );
    95 
    96 
    97 #ifdef __cplusplus
    98 }
    99 #endif
   100