1.1 --- a/src/keyreset_command.c Fri Dec 20 11:14:52 2019 +0100
1.2 +++ b/src/keyreset_command.c Sun Dec 22 19:55:59 2019 +0100
1.3 @@ -9,9 +9,9 @@
1.4
1.5 #include "keyreset_command.h"
1.6
1.7 -DYNAMIC_API keyreset_command * new_keyreset_command(const pEp_identity *ident, const char *new_key)
1.8 +DYNAMIC_API keyreset_command * new_keyreset_command(const pEp_identity * ident, const char * new_key)
1.9 {
1.10 - keyreset_command *command = NULL;
1.11 + keyreset_command * command = NULL;
1.12
1.13 // key and command should not be NULL, that's bad style (while legal)
1.14
1.15 @@ -26,22 +26,22 @@
1.16 command->ident = ident ? identity_dup(ident) : new_identity(NULL, NULL, NULL, NULL);
1.17 if (command->ident == NULL)
1.18 goto enomem;
1.19 -
1.20 +
1.21 if (command->ident && command->ident->fpr) {
1.22 - // make hex code uppercase
1.23 + // make content uppercase
1.24 for (size_t i=0; i<strlen(command->ident->fpr); i++)
1.25 command->ident->fpr[i] = toupper(command->ident->fpr[i]);
1.26 }
1.27 -
1.28 +
1.29 command->new_key = new_key ? strdup(new_key) : strdup("");
1.30 assert(command->new_key);
1.31 if (command->new_key == NULL)
1.32 goto enomem;
1.33
1.34 - // make hex code uppercase
1.35 + // make content uppercase
1.36 for (size_t i=0; i<strlen(command->new_key); i++)
1.37 command->new_key[i] = toupper(command->new_key[i]);
1.38 -
1.39 +
1.40 return command;
1.41
1.42 enomem:
1.43 @@ -58,7 +58,7 @@
1.44 }
1.45 }
1.46
1.47 -DYNAMIC_API keyreset_command * keyreset_command_dup(const keyreset_command *src)
1.48 +DYNAMIC_API keyreset_command * keyreset_command_dup(const keyreset_command * src)
1.49 {
1.50 assert(src);
1.51 if (src == NULL)
1.52 @@ -67,9 +67,9 @@
1.53 return new_keyreset_command(src->ident, src->new_key);
1.54 }
1.55
1.56 -DYNAMIC_API keyreset_command_list *new_keyreset_command_list(keyreset_command *command)
1.57 +DYNAMIC_API keyreset_command_list * new_keyreset_command_list(keyreset_command * command)
1.58 {
1.59 - keyreset_command_list *result = calloc(1, sizeof(keyreset_command_list));
1.60 + keyreset_command_list * result = calloc(1, sizeof(keyreset_command_list));
1.61 assert(result);
1.62
1.63 if (result && command)
1.64 @@ -78,32 +78,32 @@
1.65 return result;
1.66 }
1.67
1.68 -DYNAMIC_API keyreset_command_list *keyreset_command_list_dup(
1.69 - const keyreset_command_list *src
1.70 +DYNAMIC_API keyreset_command_list * keyreset_command_list_dup(
1.71 + const keyreset_command_list * src
1.72 )
1.73 {
1.74 assert(src);
1.75 if (src == NULL)
1.76 return NULL;
1.77
1.78 - keyreset_command* copy_pair = keyreset_command_dup(src->command);
1.79 + keyreset_command * cpy = keyreset_command_dup(src->command);
1.80
1.81 - keyreset_command_list *dst = new_keyreset_command_list(copy_pair);
1.82 + keyreset_command_list * dst = new_keyreset_command_list(cpy);
1.83 if (dst == NULL)
1.84 return NULL;
1.85
1.86 - keyreset_command_list* src_curr = src->next;
1.87 - keyreset_command_list** dst_curr_ptr = &dst->next;
1.88 + keyreset_command_list * src_curr = src->next;
1.89 + keyreset_command_list ** dst_curr_ptr = &dst->next;
1.90
1.91 while (src_curr) {
1.92 - copy_pair = keyreset_command_dup(src_curr->command);
1.93 - if (copy_pair == NULL) {
1.94 + cpy = keyreset_command_dup(src_curr->command);
1.95 + if (cpy == NULL) {
1.96 free_keyreset_command_list(dst);
1.97 return NULL;
1.98 }
1.99 - *dst_curr_ptr = new_keyreset_command_list(copy_pair);
1.100 + *dst_curr_ptr = new_keyreset_command_list(cpy);
1.101 if (*dst_curr_ptr == NULL) {
1.102 - free_keyreset_command(copy_pair);
1.103 + free_keyreset_command(cpy);
1.104 free_keyreset_command_list(dst);
1.105 return NULL;
1.106 }
1.107 @@ -112,12 +112,11 @@
1.108 }
1.109
1.110 return dst;
1.111 -
1.112 }
1.113
1.114 -DYNAMIC_API keyreset_command_list *keyreset_command_list_add(
1.115 - keyreset_command_list *command_list,
1.116 - keyreset_command *command
1.117 +DYNAMIC_API keyreset_command_list * keyreset_command_list_add(
1.118 + keyreset_command_list * command_list,
1.119 + keyreset_command * command
1.120 )
1.121 {
1.122 assert(command);
1.123 @@ -140,7 +139,7 @@
1.124 return command_list;
1.125 }
1.126
1.127 - keyreset_command_list* list_curr = command_list;
1.128 + keyreset_command_list * list_curr = command_list;
1.129
1.130 while (list_curr->next)
1.131 list_curr = list_curr->next;
1.132 @@ -152,12 +151,11 @@
1.133 return NULL;
1.134
1.135 return list_curr->next;
1.136 -
1.137 }
1.138
1.139 -DYNAMIC_API keyreset_command_list *keyreset_command_list_append(
1.140 - keyreset_command_list *command_list,
1.141 - keyreset_command_list *second
1.142 +DYNAMIC_API keyreset_command_list * keyreset_command_list_append(
1.143 + keyreset_command_list * command_list,
1.144 + keyreset_command_list * second
1.145 )
1.146 {
1.147 assert(command_list);
1.148 @@ -168,9 +166,9 @@
1.149 if (second == NULL || second->command == NULL)
1.150 return command_list;
1.151
1.152 - keyreset_command_list *_s = command_list;
1.153 - for (keyreset_command_list *_s2 = second; _s2 != NULL; _s2 = _s2->next) {
1.154 - keyreset_command *_sp = keyreset_command_dup(_s2->command);
1.155 + keyreset_command_list * _s = command_list;
1.156 + for (keyreset_command_list * _s2 = second; _s2 != NULL; _s2 = _s2->next) {
1.157 + keyreset_command * _sp = keyreset_command_dup(_s2->command);
1.158 if (_sp == NULL)
1.159 return NULL;
1.160 _s = keyreset_command_list_add(_s, _sp);
1.161 @@ -183,18 +181,18 @@
1.162 }
1.163
1.164 DYNAMIC_API int keyreset_command_list_length(
1.165 - const keyreset_command_list *command_list
1.166 + const keyreset_command_list * command_list
1.167 )
1.168 {
1.169 int len = 0;
1.170
1.171 - for (const keyreset_command_list *_sl = command_list; _sl && _sl->command; _sl = _sl->next)
1.172 + for (const keyreset_command_list * _sl = command_list; _sl && _sl->command; _sl = _sl->next)
1.173 len++;
1.174
1.175 return len;
1.176 }
1.177
1.178 -DYNAMIC_API void free_keyreset_command_list(keyreset_command_list *command_list)
1.179 +DYNAMIC_API void free_keyreset_command_list(keyreset_command_list * command_list)
1.180 {
1.181 if (command_list) {
1.182 free_keyreset_command_list(command_list->next);
2.1 --- a/src/keyreset_command.h Fri Dec 20 11:14:52 2019 +0100
2.2 +++ b/src/keyreset_command.h Sun Dec 22 19:55:59 2019 +0100
2.3 @@ -11,8 +11,8 @@
2.4 #endif
2.5
2.6 typedef struct _keyreset_command {
2.7 - pEp_identity *ident;
2.8 - char *new_key;
2.9 + pEp_identity * ident;
2.10 + char * new_key;
2.11 } keyreset_command;
2.12
2.13 // new_keyreset_command() - allocate new keyreset_command
2.14 @@ -21,13 +21,13 @@
2.15 // ident (in) identity to reset, including fpr of existing key
2.16 // new_key (in) fpr of new key
2.17 //
2.18 -// return command:
2.19 +// return value:
2.20 // pointer to keyreset_command or NULL on failure
2.21 //
2.22 // caveat:
2.23 -// ident and new_key are copied and remain in the ownership of the caller
2.24 +// ident, new_key are copied and remain in the ownership of the caller
2.25
2.26 -DYNAMIC_API keyreset_command * new_keyreset_command(const pEp_identity *ident, const char *new_key);
2.27 +DYNAMIC_API keyreset_command * new_keyreset_command(const pEp_identity * ident, const char * new_key);
2.28
2.29
2.30 // free_keyreset_command() - free memory allocated by keyreset_command
2.31 @@ -35,7 +35,7 @@
2.32 // parameters:
2.33 // command (in) pointer to keyreset_command to free
2.34
2.35 -DYNAMIC_API void free_keyreset_command(keyreset_command *command);
2.36 +DYNAMIC_API void free_keyreset_command(keyreset_command * command);
2.37
2.38
2.39 // keyreset_command_dup() - duplicate keyreset_command (deep copy)
2.40 @@ -43,15 +43,15 @@
2.41 // parameters:
2.42 // src (in) pointer to keyreset_command to duplicate
2.43 //
2.44 -// return command:
2.45 +// return value:
2.46 // pointer to copy of src or NULL on failure
2.47
2.48 -DYNAMIC_API keyreset_command * keyreset_command_dup(const keyreset_command *src);
2.49 +DYNAMIC_API keyreset_command * keyreset_command_dup(const keyreset_command * src);
2.50
2.51
2.52 typedef struct _keyreset_command_list {
2.53 - keyreset_command *command;
2.54 - struct _keyreset_command_list *next;
2.55 + keyreset_command * command;
2.56 + struct _keyreset_command_list * next;
2.57 } keyreset_command_list;
2.58
2.59
2.60 @@ -60,14 +60,14 @@
2.61 // parameters:
2.62 // command (in) initial command
2.63 //
2.64 -// return command:
2.65 +// return value:
2.66 // pointer to keyreset_command_list object or NULL if out of memory
2.67 //
2.68 // caveat:
2.69 // the ownership of the command goes to the keyreset_command_list
2.70 // next pointer is NULL
2.71
2.72 -DYNAMIC_API keyreset_command_list *new_keyreset_command_list(keyreset_command *command);
2.73 +DYNAMIC_API keyreset_command_list * new_keyreset_command_list(keyreset_command * command);
2.74
2.75
2.76 // keyreset_command_list_dup() - duplicate a keyreset_command_list (deep copy)
2.77 @@ -75,12 +75,12 @@
2.78 // parameters:
2.79 // src (in) keyreset_command_list to copy
2.80 //
2.81 -// return command:
2.82 +// return value:
2.83 // pointer to keyreset_command_list object or NULL if out of memory
2.84 // keyreset_command command copies created by this function belong to the returned list
2.85
2.86 -DYNAMIC_API keyreset_command_list *keyreset_command_list_dup(
2.87 - const keyreset_command_list *src
2.88 +DYNAMIC_API keyreset_command_list * keyreset_command_list_dup(
2.89 + const keyreset_command_list * src
2.90 );
2.91
2.92
2.93 @@ -90,15 +90,15 @@
2.94 // command_list (in) keyreset_command_list struct or NULL to create a new one
2.95 // command (in) keyreset_command to add
2.96 //
2.97 -// return command:
2.98 +// return value:
2.99 // pointer to last element in keyreset_command_list or NULL if out of memory
2.100 //
2.101 // caveat:
2.102 // the ownership of the command goes to the keyreset_command_list if add is successful
2.103
2.104 -DYNAMIC_API keyreset_command_list *keyreset_command_list_add(
2.105 - keyreset_command_list *command_list,
2.106 - keyreset_command *command
2.107 +DYNAMIC_API keyreset_command_list * keyreset_command_list_add(
2.108 + keyreset_command_list * command_list,
2.109 + keyreset_command * command
2.110 );
2.111
2.112
2.113 @@ -108,7 +108,7 @@
2.114 // command_list (in) keyreset_command_list struct to append to
2.115 // second (in) keyreset_command_list struct to append
2.116 //
2.117 -// return command:
2.118 +// return value:
2.119 // pointer to last element in command_list or NULL if out of memory
2.120 // or command_list is NULL
2.121 //
2.122 @@ -116,9 +116,9 @@
2.123 // all commands are being copied before being added to the list
2.124 // the original commands are still being owned by the caller
2.125
2.126 -DYNAMIC_API keyreset_command_list *keyreset_command_list_append(
2.127 - keyreset_command_list *command_list,
2.128 - keyreset_command_list *second
2.129 +DYNAMIC_API keyreset_command_list * keyreset_command_list_append(
2.130 + keyreset_command_list * command_list,
2.131 + keyreset_command_list * second
2.132 );
2.133
2.134
2.135 @@ -127,11 +127,11 @@
2.136 // parameters:
2.137 // command_list (in) keyreset_command_list struct to determine length of
2.138 //
2.139 -// return command:
2.140 +// return value:
2.141 // length of command_list in number of elements
2.142
2.143 DYNAMIC_API int keyreset_command_list_length(
2.144 - const keyreset_command_list *command_list
2.145 + const keyreset_command_list * command_list
2.146 );
2.147
2.148
2.149 @@ -140,7 +140,7 @@
2.150 // parameters:
2.151 // command_list (in) keyreset_command_list to free
2.152
2.153 -DYNAMIC_API void free_keyreset_command_list(keyreset_command_list *command_list);
2.154 +DYNAMIC_API void free_keyreset_command_list(keyreset_command_list * command_list);
2.155
2.156
2.157 #ifdef __cplusplus