int pakfire_config_dump(struct pakfire_config* config, FILE* f) {
return pakfire_config_walk_sections(config, pakfire_config_dump_section, f);
}
+
+FILE* pakfire_config_fdump(struct pakfire_config* config) {
+ FILE* f = NULL;
+ int r;
+
+ char* buffer = NULL;
+ size_t length = 0;
+
+ // Open a new memory stream
+ f = open_memstream(&buffer, &length);
+ if (!f)
+ goto ERROR;
+
+ // Dump the configuration
+ r = pakfire_config_dump(config, f);
+ if (r < 0)
+ goto ERROR;
+
+ // Close the memory stream
+ fclose(f);
+
+ // Re-open as a new file handle
+ f = fmemopen(buffer, length, "r");
+ if (!f)
+ goto ERROR;
+
+ return f;
+
+ERROR:
+ if (buffer)
+ free(buffer);
+
+ return NULL;
+}
int pakfire_config_read(struct pakfire_config* config, FILE* f);
int pakfire_config_dump(struct pakfire_config* config, FILE* f);
+FILE* pakfire_config_fdump(struct pakfire_config* config);
#endif