From: Jean-Philippe Orsini Date: Mon, 15 Oct 2012 08:42:50 +0000 (+0000) Subject: (no commit message) X-Git-Tag: v0.0.6~169 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=ptask.git;a=commitdiff_plain;h=114b2d361bc78ca6827c17c4f7307f7b62f377ec --- diff --git a/src/Makefile.am b/src/Makefile.am index de7e334..3e95660 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,18 +1,18 @@ AM_LDFLAGS = -Wl,--as-needed -AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) +AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) $(JSON_CFLAGS) DEFS = -DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" -DLOCALEDIR=\"$(localedir)\" @DEFS@ -LIBS = $(GTK_LIBS) +LIBS = $(JSON_LIBS) $(GTK_LIBS) bin_PROGRAMS = gtask gtask_SOURCES = main.c -dist_man_MANS = gtask.1 +#dist_man_MANS = gtask.1 -gtask.1: main.c $(top_srcdir)/configure.ac - $(MAKE) $(AM_MAKEFLAGS) gtask$(EXEEXT) - help2man -N --name="GTk+ Task application" --output=gtask.1 ./gtask$(EXEEXT) +#gtask.1: main.c $(top_srcdir)/configure.ac +# $(MAKE) $(AM_MAKEFLAGS) gtask$(EXEEXT) +# help2man -N --name="GTk+ Task application" --output=gtask.1 ./gtask$(EXEEXT) diff --git a/src/Makefile.in b/src/Makefile.in index 1a0d6c2..6e75508 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -53,8 +53,7 @@ build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = gtask$(EXEEXT) subdir = src -DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -62,7 +61,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" +am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_gtask_OBJECTS = main.$(OBJEXT) gtask_OBJECTS = $(am_gtask_OBJECTS) @@ -82,36 +81,6 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -man1dir = $(mandir)/man1 -NROFF = nroff -MANS = $(dist_man_MANS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -155,7 +124,7 @@ LDFLAGS = @LDFLAGS@ LIBICONV = @LIBICONV@ LIBINTL = @LIBINTL@ LIBOBJS = @LIBOBJS@ -LIBS = $(GTK_LIBS) +LIBS = $(JSON_LIBS) $(GTK_LIBS) LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ @@ -241,9 +210,8 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_LDFLAGS = -Wl,--as-needed -AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) +AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) $(JSON_CFLAGS) gtask_SOURCES = main.c -dist_man_MANS = gtask.1 all: all-am .SUFFIXES: @@ -343,49 +311,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` -install-man1: $(dist_man_MANS) - @$(NORMAL_INSTALL) - @list1=''; \ - list2='$(dist_man_MANS)'; \ - test -n "$(man1dir)" \ - && test -n "`echo $$list1$$list2`" \ - || exit 0; \ - echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ - { for i in $$list1; do echo "$$i"; done; \ - if test -n "$$list2"; then \ - for i in $$list2; do echo "$$i"; done \ - | sed -n '/\.1[a-z]*$$/p'; \ - fi; \ - } | while read p; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; echo "$$p"; \ - done | \ - sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ - sed 'N;N;s,\n, ,g' | { \ - list=; while read file base inst; do \ - if test "$$base" = "$$inst"; then list="$$list $$file"; else \ - echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ - $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ - fi; \ - done; \ - for i in $$list; do echo "$$i"; done | $(am__base_list) | \ - while read files; do \ - test -z "$$files" || { \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ - done; } - -uninstall-man1: - @$(NORMAL_UNINSTALL) - @list=''; test -n "$(man1dir)" || exit 0; \ - files=`{ for i in $$list; do echo "$$i"; done; \ - l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.1[a-z]*$$/p'; \ - } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ @@ -440,19 +365,6 @@ distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) - @list='$(MANS)'; if test -n "$$list"; then \ - list=`for p in $$list; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ - if test -n "$$list" && \ - grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ - echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ - grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ - echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ - echo " typically \`make maintainer-clean' will remove them" >&2; \ - exit 1; \ - else :; fi; \ - else :; fi @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -484,9 +396,9 @@ distdir: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(PROGRAMS) $(MANS) +all-am: Makefile $(PROGRAMS) installdirs: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ + for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -541,7 +453,7 @@ info: info-am info-am: -install-data-am: install-man +install-data-am: install-dvi: install-dvi-am @@ -557,7 +469,7 @@ install-info: install-info-am install-info-am: -install-man: install-man1 +install-man: install-pdf: install-pdf-am @@ -586,9 +498,7 @@ ps: ps-am ps-am: -uninstall-am: uninstall-binPROGRAMS uninstall-man - -uninstall-man: uninstall-man1 +uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip @@ -598,18 +508,19 @@ uninstall-man: uninstall-man1 html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-man1 \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-binPROGRAMS \ - uninstall-man uninstall-man1 - - -gtask.1: main.c $(top_srcdir)/configure.ac - $(MAKE) $(AM_MAKEFLAGS) gtask$(EXEEXT) - help2man -N --name="GTk+ Task application" --output=gtask.1 ./gtask$(EXEEXT) + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS + + +#dist_man_MANS = gtask.1 + +#gtask.1: main.c $(top_srcdir)/configure.ac +# $(MAKE) $(AM_MAKEFLAGS) gtask$(EXEEXT) +# help2man -N --name="GTk+ Task application" --output=gtask.1 ./gtask$(EXEEXT) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..ac310b7 --- /dev/null +++ b/src/main.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2010-2012 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#include +#include +#include + +#include + +static char *task_exec(char *opts) +{ + FILE *f; + int ret, s; + char *str, *tmp, *cmd, buf[1024]; + + str = NULL; + + cmd = malloc(strlen("task rc.json.array=on ") + strlen(opts) + 1); + strcpy(cmd, "task rc.json.array=on "); + strcat(cmd, opts); + + f = popen(cmd, "r"); + + if (!f) { + perror("popen"); + goto exit_free; + } + + str = malloc(1); + str[0] = '\0'; + while ((s = fread(buf, 1, 1024, f))) { + tmp = malloc(strlen(str) + s + 1); + memcpy(tmp, str, strlen(str)); + memcpy(tmp + strlen(str), buf, s); + tmp[strlen(str) + s] = '\0'; + free(str); + str = tmp; + } + + ret = pclose(f); + + if (ret == -1) { + printf("pclose fails\n"); + perror("pclose"); + } + + exit_free: + free(cmd); + + return str; +} + +static struct json_object *task_exec_json(char *opts) +{ + struct json_object *o; + char *str; + + str = task_exec(opts); + + if (str) { + o = json_tokener_parse(str); + free(str); + return o; + } + + return NULL; +} + +int main(int argc, char **argv) +{ + struct json_object *o; + + o = task_exec_json("export"); + + printf("%s\n", json_object_to_json_string(o)); + + exit(EXIT_SUCCESS); +}