2008-01-29 18:15:54 +00:00
|
|
|
#include <config.h>
|
2007-12-05 21:40:15 +00:00
|
|
|
|
2006-08-29 22:27:07 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2007-11-12 22:16:25 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2006-08-29 22:27:07 +00:00
|
|
|
#include "conf.h"
|
2011-04-24 22:25:10 +00:00
|
|
|
#include "memory.h"
|
2006-08-29 22:27:07 +00:00
|
|
|
|
2011-04-24 22:25:10 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ret, exit_code = EXIT_FAILURE;
|
2006-08-29 22:27:07 +00:00
|
|
|
virConfPtr conf;
|
|
|
|
int len = 10000;
|
2011-04-24 22:25:10 +00:00
|
|
|
char *buffer = NULL;
|
2006-08-29 22:27:07 +00:00
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
fprintf(stderr, "Usage: %s conf_file\n", argv[0]);
|
2011-04-24 22:25:10 +00:00
|
|
|
goto cleanup;
|
2006-08-29 22:27:07 +00:00
|
|
|
}
|
|
|
|
|
2011-04-24 22:25:10 +00:00
|
|
|
if (VIR_ALLOC_N(buffer, len) < 0) {
|
|
|
|
fprintf(stderr, "out of memory\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-06-19 12:34:30 +00:00
|
|
|
conf = virConfReadFile(argv[1], 0);
|
2006-08-29 22:27:07 +00:00
|
|
|
if (conf == NULL) {
|
|
|
|
fprintf(stderr, "Failed to process %s\n", argv[1]);
|
2011-04-24 22:25:10 +00:00
|
|
|
goto cleanup;
|
2006-08-29 22:27:07 +00:00
|
|
|
}
|
2011-04-24 22:25:10 +00:00
|
|
|
ret = virConfWriteMem(buffer, &len, conf);
|
2006-08-29 22:27:07 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
fprintf(stderr, "Failed to serialize %s back\n", argv[1]);
|
2011-04-24 22:25:10 +00:00
|
|
|
goto cleanup;
|
2006-08-29 22:27:07 +00:00
|
|
|
}
|
|
|
|
virConfFree(conf);
|
2007-11-12 22:16:25 +00:00
|
|
|
if (fwrite(buffer, 1, len, stdout) != len) {
|
2008-04-10 16:54:54 +00:00
|
|
|
fprintf(stderr, "Write failed: %s\n", strerror (errno));
|
2011-04-24 22:25:10 +00:00
|
|
|
goto cleanup;
|
2007-10-19 08:29:13 +00:00
|
|
|
}
|
2011-04-24 22:25:10 +00:00
|
|
|
|
|
|
|
exit_code = EXIT_SUCCESS;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FREE(buffer);
|
|
|
|
return exit_code;
|
2006-08-29 22:27:07 +00:00
|
|
|
}
|