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