On Sun, Apr 11, 2010 at 1:37 PM, Julian Phillips <julian@xxxxxxxxxxxxxxxxx> wrote: > Add a library that allows commands to produce structured output in any > of a range of formats using a single API. > > The API includes an OPT_OUTPUT and handle_output_arg so that the > option handling for different commands will be as similar as possible. > > At the moment JSON and XML output options are available - though the > XML output is _very_ rudimentary. > > Signed-off-by: Julian Phillips <julian@xxxxxxxxxxxxxxxxx> > --- > Makefile | 3 + > output-json.c | 128 ++++++++++++++++++++++++++++++++++ > output-xml.c | 68 ++++++++++++++++++ > output.c | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > output.h | 71 +++++++++++++++++++ > 5 files changed, 482 insertions(+), 0 deletions(-) > create mode 100644 output-json.c > create mode 100644 output-xml.c > create mode 100644 output.c > create mode 100644 output.h > > diff --git a/Makefile b/Makefile > index 910f471..4ba2a4f 100644 > --- a/Makefile > +++ b/Makefile > @@ -576,6 +576,9 @@ LIB_OBJS += merge-recursive.o > LIB_OBJS += name-hash.o > LIB_OBJS += notes.o > LIB_OBJS += object.o > +LIB_OBJS += output.o > +LIB_OBJS += output-json.o > +LIB_OBJS += output-xml.o > LIB_OBJS += pack-check.o > LIB_OBJS += pack-refs.o > LIB_OBJS += pack-revindex.o > diff --git a/output-json.c b/output-json.c > new file mode 100644 > index 0000000..0eb66b2 > --- /dev/null > +++ b/output-json.c > @@ -0,0 +1,128 @@ > <snip> > + > +static void json_str(FILE *file, char *value) > +{ > + char *quoted = json_quote(value); > + fprintf(file, "\"%s\"", quoted); > + free(quoted); > +} > + > <snip> > diff --git a/output-xml.c b/output-xml.c > new file mode 100644 > index 0000000..50dd7d6 > --- /dev/null > +++ b/output-xml.c > @@ -0,0 +1,68 @@ > <snip> > + > +static void xml_str(FILE *file, char *value) > +{ > + fprintf(file, "\"%s\"", value); > +} > + Don't you need to quote this one, like you did in json_str()? -- Erik "kusma" Faye-Lund -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html