Added a certexpire empty_string option
authorMartin Willi <martin@revosec.ch>
Fri, 19 Aug 2011 07:12:54 +0000 (09:12 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 22 Aug 2011 16:42:33 +0000 (18:42 +0200)
src/libcharon/plugins/certexpire/certexpire_export.c

index 7976724..c73b0be 100644 (file)
@@ -82,6 +82,11 @@ struct private_certexpire_export_t {
         * TRUE to use fixed field count, CA at end
         */
        bool fixed_fields;
         * TRUE to use fixed field count, CA at end
         */
        bool fixed_fields;
+
+       /**
+        * String to use in empty fields, if using fixed_fields
+        */
+       char *empty_string;
 };
 
 /**
 };
 
 /**
@@ -156,10 +161,14 @@ static void export_csv(private_certexpire_export_t *this, char *path,
                                {
                                        fprintf(file, "\n");
                                }
                                {
                                        fprintf(file, "\n");
                                }
-                               else if (this->fixed_fields || entry->expire[i])
+                               else if (entry->expire[i])
                                {
                                        fprintf(file, "%s", this->separator);
                                }
                                {
                                        fprintf(file, "%s", this->separator);
                                }
+                               else if (this->fixed_fields)
+                               {
+                                       fprintf(file, "%s%s", this->empty_string, this->separator);
+                               }
                        }
                        chains->remove_at(chains, enumerator);
                        free(entry);
                        }
                        chains->remove_at(chains, enumerator);
                        free(entry);
@@ -364,6 +373,8 @@ certexpire_export_t *certexpire_export_create()
                                                        "charon.plugins.certexpire.csv.format", "%d:%m:%Y"),
                .fixed_fields = lib->settings->get_bool(lib->settings,
                                                        "charon.plugins.certexpire.csv.fixed_fields", TRUE),
                                                        "charon.plugins.certexpire.csv.format", "%d:%m:%Y"),
                .fixed_fields = lib->settings->get_bool(lib->settings,
                                                        "charon.plugins.certexpire.csv.fixed_fields", TRUE),
+               .empty_string = lib->settings->get_str(lib->settings,
+                                                       "charon.plugins.certexpire.csv.empty_string", ""),
        );
 
        cron = lib->settings->get_str(lib->settings,
        );
 
        cron = lib->settings->get_str(lib->settings,