src/keyreset_command.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 4290 9ef77432a291
child 4792 7056435ab9e7
child 5246 67016f508d40
permissions -rw-r--r--
forgot test files
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #include "dynamic_api.h"
     7 #include "pEpEngine.h"
     8 
     9 #ifdef __cplusplus
    10 extern "C" {
    11 #endif
    12 
    13 typedef struct _keyreset_command {
    14     pEp_identity * ident;
    15     char * new_key;
    16 } keyreset_command;
    17 
    18 // new_keyreset_command() - allocate new keyreset_command
    19 //
    20 //  parameters:
    21 //      ident (in)      identity to reset, including fpr of existing key
    22 //      new_key (in)    fpr of new key
    23 //
    24 //  return value:
    25 //      pointer to keyreset_command or NULL on failure
    26 //
    27 //  caveat:
    28 //      ident, new_key are copied and remain in the ownership of the caller
    29 
    30 DYNAMIC_API keyreset_command * new_keyreset_command(const pEp_identity * ident, const char * new_key);
    31 
    32 
    33 // free_keyreset_command() - free memory allocated by keyreset_command
    34 //
    35 //  parameters:
    36 //      command (in)    pointer to keyreset_command to free
    37 
    38 DYNAMIC_API void free_keyreset_command(keyreset_command * command);
    39 
    40 
    41 // keyreset_command_dup() - duplicate keyreset_command (deep copy)
    42 //
    43 //  parameters:
    44 //      src (in)        pointer to keyreset_command to duplicate
    45 //
    46 //  return value:
    47 //      pointer to copy of src or NULL on failure
    48 
    49 DYNAMIC_API keyreset_command * keyreset_command_dup(const keyreset_command * src);
    50 
    51 
    52 typedef struct _keyreset_command_list {
    53     keyreset_command * command;
    54     struct _keyreset_command_list * next;
    55 } keyreset_command_list;
    56 
    57 
    58 // new_keyreset_command_list() - allocate a new keyreset_command_list
    59 //
    60 //  parameters:
    61 //      command (in)              initial command
    62 //
    63 //  return value:
    64 //      pointer to keyreset_command_list object or NULL if out of memory
    65 //
    66 //  caveat:
    67 //      the ownership of the command goes to the keyreset_command_list
    68 //      next pointer is NULL
    69 
    70 DYNAMIC_API keyreset_command_list * new_keyreset_command_list(keyreset_command * command);
    71 
    72 
    73 // keyreset_command_list_dup() - duplicate a keyreset_command_list (deep copy)
    74 //
    75 //  parameters:
    76 //      src (in)                keyreset_command_list to copy
    77 //
    78 //  return value:
    79 //      pointer to keyreset_command_list object or NULL if out of memory
    80 //      keyreset_command command copies created by this function belong to the returned list
    81 
    82 DYNAMIC_API keyreset_command_list * keyreset_command_list_dup(
    83         const keyreset_command_list * src
    84     );
    85 
    86 
    87 // keyreset_command_list_add() - add key to keyreset_command_list
    88 //
    89 //  parameters:
    90 //      command_list (in)       keyreset_command_list struct or NULL to create a new one
    91 //      command (in)            keyreset_command to add
    92 //
    93 //  return value:
    94 //      pointer to last element in keyreset_command_list or NULL if out of memory
    95 //
    96 //  caveat:
    97 //      the ownership of the command goes to the keyreset_command_list if add is successful
    98 
    99 DYNAMIC_API keyreset_command_list * keyreset_command_list_add(
   100         keyreset_command_list * command_list,
   101         keyreset_command * command
   102     );
   103 
   104 
   105 // keyreset_command_list_append() - append keyreset_command_list to keyreset_command_list
   106 //
   107 //  parameters:
   108 //      command_list (in)       keyreset_command_list struct to append to
   109 //      second (in)             keyreset_command_list struct to append
   110 //
   111 //  return value:
   112 //      pointer to last element in command_list or NULL if out of memory
   113 //      or command_list is NULL
   114 //
   115 //  caveat:
   116 //      all commands are being copied before being added to the list
   117 //      the original commands are still being owned by the caller
   118 
   119 DYNAMIC_API keyreset_command_list * keyreset_command_list_append(
   120         keyreset_command_list * command_list,
   121         keyreset_command_list * second
   122     );
   123 
   124 
   125 // keyreset_command_list_length() - get length of keyreset_command_list
   126 //
   127 //  parameters:
   128 //      command_list (in)       keyreset_command_list struct to determine length of
   129 //
   130 //  return value:
   131 //      length of command_list in number of elements
   132 
   133 DYNAMIC_API int keyreset_command_list_length(
   134         const keyreset_command_list * command_list
   135     );
   136 
   137 
   138 // free_keyreset_command_list() - free memory occupied by command_list
   139 //
   140 //  parameters:
   141 //      command_list (in)       keyreset_command_list to free
   142 
   143 DYNAMIC_API void free_keyreset_command_list(keyreset_command_list * command_list);
   144 
   145 
   146 #ifdef __cplusplus
   147 }
   148 #endif
   149