diff common/listutil.c @ 310:f758460ca437

Merged
author Sascha Wilde <wilde@intevation.de>
date Fri, 04 Apr 2014 09:54:19 +0200
parents 57867a523dcf
children f6ce186cebc2
line wrap: on
line diff
--- a/common/listutil.c	Fri Apr 04 09:53:55 2014 +0200
+++ b/common/listutil.c	Fri Apr 04 09:54:19 2014 +0200
@@ -9,6 +9,8 @@
 #include <sys/stat.h>
 #include <string.h>
 
+#include "strhelp.h"
+
 #ifdef RELEASE
 #include "pubkey-release.h"
 #else
@@ -232,22 +234,30 @@
     return retval;
 }
 
-char **get_certs_to_remove(const char *data, const size_t size) {
+char **
+get_certs_from_list (char *data, const size_t size)
+{
+  char *cur = data;
+  char **retval = NULL;
 
-    /* TODO */
-    if (!data || !size) {
-        printf ("Invalid call to get_certs_to_remove \n");
-        return NULL;
+  if (!data || !size)
+    {
+      printf ("Invalid call to get_certs_to_remove \n");
+      return NULL;
     }
-    return NULL;
+
+  while (cur)
+    {
+      char *next = strchr(cur, '\n');
+      if (strlen(cur) > 3 && (cur[0] == 'I' || cur[0] == 'R') &&
+          next - cur > 4)
+        {
+          size_t len = (size_t) (next - cur - 3);
+          /* Remove I: or R: at the beginning and \r\n at the end */
+          strv_append(&retval, cur + 2, len);
+        }
+      cur = next ? (next + 1) : NULL;
+    }
+  return retval;
 }
 
-char **get_certs_to_install(const char *data, const size_t size) {
-
-    /* TODO */
-    if (!data || !size) {
-        printf ("Invalid call to get_certs_to_install \n");
-        return NULL;
-    }
-    return NULL;
-}

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