comparison common/listutil.c @ 286:881ce5126f07

Add helper function to get all certificates in a list
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 02 Apr 2014 13:47:24 +0000
parents b0579d4fa186
children 57867a523dcf
comparison
equal deleted inserted replaced
285:f23e0ccd5d14 286:881ce5126f07
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <string.h> 10 #include <string.h>
11
12 #include "strhelp.h"
11 13
12 #ifdef RELEASE 14 #ifdef RELEASE
13 #include "pubkey-release.h" 15 #include "pubkey-release.h"
14 #else 16 #else
15 #include "pubkey-test.h" 17 #include "pubkey-test.h"
230 *size = 0; 232 *size = 0;
231 } 233 }
232 return retval; 234 return retval;
233 } 235 }
234 236
235 char **get_certs_to_remove(const char *data, const size_t size) { 237 char **
236 238 get_certs_from_list (char *data, const size_t size)
237 /* TODO */ 239 {
238 if (!data || !size) { 240 char *cur = data;
239 printf ("Invalid call to get_certs_to_remove \n"); 241 char **retval = NULL;
240 return NULL; 242
241 } 243 if (!data || !size)
242 return NULL; 244 {
243 } 245 printf ("Invalid call to get_certs_to_remove \n");
244 246 return NULL;
245 char **get_certs_to_install(const char *data, const size_t size) { 247 }
246 248
247 /* TODO */ 249 while (cur)
248 if (!data || !size) { 250 {
249 printf ("Invalid call to get_certs_to_install \n"); 251 char *next = strchr(cur, '\n');
250 return NULL; 252 if (strlen(cur) > 3 && (cur[0] == 'I' || cur[0] == 'R') &&
251 } 253 next - cur > 4)
252 return NULL; 254 {
253 } 255 size_t len = (size_t) (next - cur - 4);
256 /* Remove I: or R: at the beginning and \r\n at the end */
257 strv_append(&retval, cur + 2, len);
258 }
259 cur = next ? (next + 1) : NULL;
260 }
261 return retval;
262 }
263

http://wald.intevation.org/projects/trustbridge/