diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/identity/identity_api_lookup.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/identity/identity_api_lookup.c')
-rw-r--r-- | src/identity/identity_api_lookup.c | 117 |
1 files changed, 59 insertions, 58 deletions
diff --git a/src/identity/identity_api_lookup.c b/src/identity/identity_api_lookup.c index faf647c07..108fc7fcf 100644 --- a/src/identity/identity_api_lookup.c +++ b/src/identity/identity_api_lookup.c | |||
@@ -28,13 +28,14 @@ | |||
28 | #include "gnunet_identity_service.h" | 28 | #include "gnunet_identity_service.h" |
29 | #include "identity.h" | 29 | #include "identity.h" |
30 | 30 | ||
31 | #define LOG(kind, ...) GNUNET_log_from(kind, "identity-api", __VA_ARGS__) | 31 | #define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__) |
32 | 32 | ||
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Handle for ego lookup. | 35 | * Handle for ego lookup. |
36 | */ | 36 | */ |
37 | struct GNUNET_IDENTITY_EgoLookup { | 37 | struct GNUNET_IDENTITY_EgoLookup |
38 | { | ||
38 | /** | 39 | /** |
39 | * Connection to service. | 40 | * Connection to service. |
40 | */ | 41 | */ |
@@ -66,10 +67,10 @@ struct GNUNET_IDENTITY_EgoLookup { | |||
66 | * @return #GNUNET_OK if the message is well-formed | 67 | * @return #GNUNET_OK if the message is well-formed |
67 | */ | 68 | */ |
68 | static int | 69 | static int |
69 | check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) | 70 | check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) |
70 | { | 71 | { |
71 | if (sizeof(*rcm) != htons(rcm->header.size)) | 72 | if (sizeof(*rcm) != htons (rcm->header.size)) |
72 | GNUNET_MQ_check_zero_termination(rcm); | 73 | GNUNET_MQ_check_zero_termination (rcm); |
73 | return GNUNET_OK; | 74 | return GNUNET_OK; |
74 | } | 75 | } |
75 | 76 | ||
@@ -81,12 +82,12 @@ check_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) | |||
81 | * @param rcm result message received | 82 | * @param rcm result message received |
82 | */ | 83 | */ |
83 | static void | 84 | static void |
84 | handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) | 85 | handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm) |
85 | { | 86 | { |
86 | struct GNUNET_IDENTITY_EgoLookup *el = cls; | 87 | struct GNUNET_IDENTITY_EgoLookup *el = cls; |
87 | 88 | ||
88 | el->cb(el->cb_cls, NULL); | 89 | el->cb (el->cb_cls, NULL); |
89 | GNUNET_IDENTITY_ego_lookup_cancel(el); | 90 | GNUNET_IDENTITY_ego_lookup_cancel (el); |
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
@@ -98,18 +99,18 @@ handle_identity_result_code(void *cls, const struct ResultCodeMessage *rcm) | |||
98 | * @return #GNUNET_OK if the message is well-formed | 99 | * @return #GNUNET_OK if the message is well-formed |
99 | */ | 100 | */ |
100 | static int | 101 | static int |
101 | check_identity_update(void *cls, const struct UpdateMessage *um) | 102 | check_identity_update (void *cls, const struct UpdateMessage *um) |
102 | { | 103 | { |
103 | uint16_t size = ntohs(um->header.size); | 104 | uint16_t size = ntohs (um->header.size); |
104 | uint16_t name_len = ntohs(um->name_len); | 105 | uint16_t name_len = ntohs (um->name_len); |
105 | const char *str = (const char *)&um[1]; | 106 | const char *str = (const char *) &um[1]; |
106 | 107 | ||
107 | if ((size != name_len + sizeof(struct UpdateMessage)) || | 108 | if ((size != name_len + sizeof(struct UpdateMessage)) || |
108 | ((0 != name_len) && ('\0' != str[name_len - 1]))) | 109 | ((0 != name_len) && ('\0' != str[name_len - 1]))) |
109 | { | 110 | { |
110 | GNUNET_break(0); | 111 | GNUNET_break (0); |
111 | return GNUNET_SYSERR; | 112 | return GNUNET_SYSERR; |
112 | } | 113 | } |
113 | return GNUNET_OK; | 114 | return GNUNET_OK; |
114 | } | 115 | } |
115 | 116 | ||
@@ -121,23 +122,23 @@ check_identity_update(void *cls, const struct UpdateMessage *um) | |||
121 | * @param um message received | 122 | * @param um message received |
122 | */ | 123 | */ |
123 | static void | 124 | static void |
124 | handle_identity_update(void *cls, const struct UpdateMessage *um) | 125 | handle_identity_update (void *cls, const struct UpdateMessage *um) |
125 | { | 126 | { |
126 | struct GNUNET_IDENTITY_EgoLookup *el = cls; | 127 | struct GNUNET_IDENTITY_EgoLookup *el = cls; |
127 | uint16_t name_len = ntohs(um->name_len); | 128 | uint16_t name_len = ntohs (um->name_len); |
128 | const char *str = (0 == name_len) ? NULL : (const char *)&um[1]; | 129 | const char *str = (0 == name_len) ? NULL : (const char *) &um[1]; |
129 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 130 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; |
130 | struct GNUNET_HashCode id; | 131 | struct GNUNET_HashCode id; |
131 | struct GNUNET_IDENTITY_Ego ego; | 132 | struct GNUNET_IDENTITY_Ego ego; |
132 | 133 | ||
133 | GNUNET_break(GNUNET_YES != ntohs(um->end_of_list)); | 134 | GNUNET_break (GNUNET_YES != ntohs (um->end_of_list)); |
134 | GNUNET_CRYPTO_ecdsa_key_get_public(&um->private_key, &pub); | 135 | GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key, &pub); |
135 | GNUNET_CRYPTO_hash(&pub, sizeof(pub), &id); | 136 | GNUNET_CRYPTO_hash (&pub, sizeof(pub), &id); |
136 | ego.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *)&um->private_key; | 137 | ego.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) &um->private_key; |
137 | ego.name = (char *)str; | 138 | ego.name = (char *) str; |
138 | ego.id = id; | 139 | ego.id = id; |
139 | el->cb(el->cb_cls, &ego); | 140 | el->cb (el->cb_cls, &ego); |
140 | GNUNET_IDENTITY_ego_lookup_cancel(el); | 141 | GNUNET_IDENTITY_ego_lookup_cancel (el); |
141 | } | 142 | } |
142 | 143 | ||
143 | 144 | ||
@@ -150,11 +151,11 @@ handle_identity_update(void *cls, const struct UpdateMessage *um) | |||
150 | * @param error error code | 151 | * @param error error code |
151 | */ | 152 | */ |
152 | static void | 153 | static void |
153 | mq_error_handler(void *cls, enum GNUNET_MQ_Error error) | 154 | mq_error_handler (void *cls, enum GNUNET_MQ_Error error) |
154 | { | 155 | { |
155 | struct GNUNET_IDENTITY_EgoLookup *el = cls; | 156 | struct GNUNET_IDENTITY_EgoLookup *el = cls; |
156 | 157 | ||
157 | el->cb(el->cb_cls, NULL); | 158 | el->cb (el->cb_cls, NULL); |
158 | } | 159 | } |
159 | 160 | ||
160 | 161 | ||
@@ -168,46 +169,46 @@ mq_error_handler(void *cls, enum GNUNET_MQ_Error error) | |||
168 | * @return NULL on error | 169 | * @return NULL on error |
169 | */ | 170 | */ |
170 | struct GNUNET_IDENTITY_EgoLookup * | 171 | struct GNUNET_IDENTITY_EgoLookup * |
171 | GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, | 172 | GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg, |
172 | const char *name, | 173 | const char *name, |
173 | GNUNET_IDENTITY_EgoCallback cb, | 174 | GNUNET_IDENTITY_EgoCallback cb, |
174 | void *cb_cls) | 175 | void *cb_cls) |
175 | { | 176 | { |
176 | struct GNUNET_IDENTITY_EgoLookup *el; | 177 | struct GNUNET_IDENTITY_EgoLookup *el; |
177 | struct GNUNET_MQ_Envelope *env; | 178 | struct GNUNET_MQ_Envelope *env; |
178 | struct GNUNET_MessageHeader *req; | 179 | struct GNUNET_MessageHeader *req; |
179 | size_t nlen; | 180 | size_t nlen; |
180 | 181 | ||
181 | GNUNET_assert(NULL != cb); | 182 | GNUNET_assert (NULL != cb); |
182 | el = GNUNET_new(struct GNUNET_IDENTITY_EgoLookup); | 183 | el = GNUNET_new (struct GNUNET_IDENTITY_EgoLookup); |
183 | el->cb = cb; | 184 | el->cb = cb; |
184 | el->cb_cls = cb_cls; | 185 | el->cb_cls = cb_cls; |
185 | { | 186 | { |
186 | struct GNUNET_MQ_MessageHandler handlers[] = | 187 | struct GNUNET_MQ_MessageHandler handlers[] = |
187 | { GNUNET_MQ_hd_var_size(identity_result_code, | 188 | { GNUNET_MQ_hd_var_size (identity_result_code, |
188 | GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, | 189 | GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, |
189 | struct ResultCodeMessage, | 190 | struct ResultCodeMessage, |
190 | el), | 191 | el), |
191 | GNUNET_MQ_hd_var_size(identity_update, | 192 | GNUNET_MQ_hd_var_size (identity_update, |
192 | GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, | 193 | GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, |
193 | struct UpdateMessage, | 194 | struct UpdateMessage, |
194 | el), | 195 | el), |
195 | GNUNET_MQ_handler_end() }; | 196 | GNUNET_MQ_handler_end () }; |
196 | 197 | ||
197 | el->mq = | 198 | el->mq = |
198 | GNUNET_CLIENT_connect(cfg, "identity", handlers, &mq_error_handler, el); | 199 | GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el); |
199 | } | 200 | } |
200 | if (NULL == el->mq) | 201 | if (NULL == el->mq) |
201 | { | 202 | { |
202 | GNUNET_break(0); | 203 | GNUNET_break (0); |
203 | GNUNET_free(el); | 204 | GNUNET_free (el); |
204 | return NULL; | 205 | return NULL; |
205 | } | 206 | } |
206 | el->name = GNUNET_strdup(name); | 207 | el->name = GNUNET_strdup (name); |
207 | nlen = strlen(name) + 1; | 208 | nlen = strlen (name) + 1; |
208 | env = GNUNET_MQ_msg_extra(req, nlen, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP); | 209 | env = GNUNET_MQ_msg_extra (req, nlen, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP); |
209 | memcpy(&req[1], name, nlen); | 210 | memcpy (&req[1], name, nlen); |
210 | GNUNET_MQ_send(el->mq, env); | 211 | GNUNET_MQ_send (el->mq, env); |
211 | return el; | 212 | return el; |
212 | } | 213 | } |
213 | 214 | ||
@@ -218,11 +219,11 @@ GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
218 | * @param el handle for lookup to abort | 219 | * @param el handle for lookup to abort |
219 | */ | 220 | */ |
220 | void | 221 | void |
221 | GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el) | 222 | GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el) |
222 | { | 223 | { |
223 | GNUNET_MQ_destroy(el->mq); | 224 | GNUNET_MQ_destroy (el->mq); |
224 | GNUNET_free(el->name); | 225 | GNUNET_free (el->name); |
225 | GNUNET_free(el); | 226 | GNUNET_free (el); |
226 | } | 227 | } |
227 | 228 | ||
228 | 229 | ||