added --debug
authorJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 17 Oct 2013 06:59:53 +0000 (06:59 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Thu, 17 Oct 2013 06:59:53 +0000 (06:59 +0000)
18 files changed:
Makefile.in
NEWS
NEWS.html
config.status
configure
po/Makefile
po/Makefile.in
src/Makefile.am
src/Makefile.in
src/glade/Makefile.in
src/log.c [new file with mode: 0644]
src/log.h [new file with mode: 0644]
src/main.c
src/note.c
src/ptime.c [new file with mode: 0644]
src/ptime.h [new file with mode: 0644]
src/tw.c
tests/Makefile.in

index e3c10f9..5371af5 100644 (file)
@@ -54,9 +54,9 @@ host_triplet = @host@
 subdir = .
 DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
        $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-       $(top_srcdir)/configure ABOUT-NLS AUTHORS COPYING ChangeLog \
-       INSTALL NEWS compile config.guess config.rpath config.sub \
-       depcomp install-sh missing
+       $(srcdir)/config.h.in $(top_srcdir)/configure ABOUT-NLS \
+       AUTHORS COPYING ChangeLog INSTALL NEWS compile config.guess \
+       config.rpath config.sub depcomp install-sh missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -64,6 +64,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
 mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
@@ -294,7 +295,8 @@ dist_doc_DATA = AUTHORS \
        README \
        README.html
 
-all: all-recursive
+all: config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
 am--refresh: Makefile
@@ -331,6 +333,21 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
        $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 $(am__aclocal_m4_deps):
+
+config.h: stamp-h1
+       @if test ! -f $@; then rm -f stamp-h1; else :; fi
+       @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+       ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
 install-dist_docDATA: $(dist_doc_DATA)
        @$(NORMAL_INSTALL)
        @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
@@ -433,7 +450,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
        mkid -fID $$unique
 tags: TAGS
 
-TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
                $(TAGS_FILES) $(LISP)
        set x; \
        here=`pwd`; \
@@ -450,7 +467,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
              set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
          fi; \
        done; \
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
        unique=`for i in $$list; do \
            if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
          done | \
@@ -468,9 +485,9 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
          fi; \
        fi
 ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
                $(TAGS_FILES) $(LISP)
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
        unique=`for i in $$list; do \
            if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
          done | \
@@ -677,7 +694,7 @@ distcleancheck: distclean
               exit 1; } >&2
 check-am: all-am
 check: check-recursive
-all-am: Makefile $(DATA)
+all-am: Makefile $(DATA) config.h
 installdirs: installdirs-recursive
 installdirs-am:
        for dir in "$(DESTDIR)$(docdir)"; do \
@@ -720,7 +737,7 @@ clean-am: clean-generic mostlyclean-am
 distclean: distclean-recursive
        -rm -f $(am__CONFIG_DISTCLEAN_FILES)
        -rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-tags
+distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
 
 dvi: dvi-recursive
 
@@ -782,17 +799,17 @@ ps-am:
 
 uninstall-am: uninstall-dist_docDATA
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
-       install-am install-strip tags-recursive
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+       ctags-recursive install-am install-strip tags-recursive
 
 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
        all all-am am--refresh check check-am clean clean-generic \
        ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
        dist-lzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
-       distcheck distclean distclean-generic distclean-tags \
-       distcleancheck distdir distuninstallcheck dvi dvi-am html \
-       html-am info info-am install install-am install-data \
-       install-data-am install-dist_docDATA install-dvi \
+       distcheck distclean distclean-generic distclean-hdr \
+       distclean-tags distcleancheck distdir distuninstallcheck dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-data install-data-am install-dist_docDATA install-dvi \
        install-dvi-am install-exec install-exec-am install-html \
        install-html-am install-info install-info-am install-man \
        install-pdf install-pdf-am install-ps install-ps-am \
diff --git a/NEWS b/NEWS
index 54322af..7a1b1eb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ v0.0.4
  * added --version and --help options.
  * added manpage.
  * popup error dialog when .taskrc does not exist.
+ * added --debug.
 
 v0.0.3
 ------
index ed78c85..9069856 100644 (file)
--- a/NEWS.html
+++ b/NEWS.html
@@ -763,6 +763,16 @@ added --version and --help options.
 added manpage.\r
 </p>\r
 </li>\r
+<li>\r
+<p>\r
+popup error dialog when .taskrc does not exist.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+added --debug.\r
+</p>\r
+</li>\r
 </ul></div>\r
 </div>\r
 </div>\r
@@ -831,7 +841,7 @@ Initial release.
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Last updated 2013-03-24 13:47:24 CET\r
+Last updated 2013-10-17 08:59:25 CEST\r
 </div>\r
 </div>\r
 </body>\r
index 36440cf..25fb07d 100755 (executable)
@@ -394,6 +394,7 @@ on `(hostname || uname -n) 2>/dev/null | sed 1q`
 
 # Files that config.status was made for.
 config_files=" Makefile po/Makefile.in src/Makefile src/glade/Makefile tests/Makefile"
+config_headers=" config.h"
 config_commands=" depfiles po-directories"
 
 ac_cs_usage="\
@@ -412,17 +413,22 @@ Usage: $0 [OPTION]... [TAG]...
       --recheck    update $as_me by reconfiguring in the same conditions
       --file=FILE[:TEMPLATE]
                    instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
 
 Configuration files:
 $config_files
 
+Configuration headers:
+$config_headers
+
 Configuration commands:
 $config_commands
 
 Report bugs to <jeanfi@gmail.com>.
 ptask home page: <http://wpitchoune.net/ptask>."
 
-ac_cs_config=""
+ac_cs_config="'--prefix=/tmp'"
 ac_cs_version="\
 ptask config.status 0.0.x
 configured by ./configure, generated by GNU Autoconf 2.69,
@@ -478,7 +484,18 @@ do
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
     ac_need_defaults=false;;
-  --he | --h |  --help | --hel | -h )
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil | --si | --s)
@@ -503,7 +520,7 @@ if $ac_cs_silent; then
 fi
 
 if $ac_cs_recheck; then
-  set X /bin/bash './configure'  $ac_configure_extra_args --no-create --no-recursion
+  set X /bin/bash './configure'  '--prefix=/tmp' $ac_configure_extra_args --no-create --no-recursion
   shift
   $as_echo "running CONFIG_SHELL=/bin/bash $*" >&6
   CONFIG_SHELL='/bin/bash'
@@ -537,6 +554,7 @@ AMDEP_TRUE="" ac_aux_dir="."
 for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
@@ -556,6 +574,7 @@ done
 # bizarre bug on SunOS 4.1.3.
 if $ac_need_defaults; then
   test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
   test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
 fi
 
@@ -706,8 +725,7 @@ S["LIBS"]=""
 S["ECHO_T"]=""
 S["ECHO_N"]="-n"
 S["ECHO_C"]=""
-S["DEFS"]="-DPACKAGE_NAME=\\\"ptask\\\" -DPACKAGE_TARNAME=\\\"ptask\\\" -DPACKAGE_VERSION=\\\"0.0.x\\\" -DPACKAGE_STRING=\\\"ptask\\ 0.0.x\\\" -DPACKAGE_BUGREPORT=\\\"jeanfi@gmai"\
-"l.com\\\" -DPACKAGE_URL=\\\"http://wpitchoune.net/ptask\\\" -DPACKAGE=\\\"ptask\\\" -DVERSION=\\\"0.0.x\\\" -DENABLE_NLS=1 -DHAVE_GETTEXT=1 -DHAVE_DCGETTEXT=1"
+S["DEFS"]="-DHAVE_CONFIG_H"
 S["mandir"]="${datarootdir}/man"
 S["localedir"]="${datarootdir}/locale"
 S["libdir"]="${exec_prefix}/lib"
@@ -728,7 +746,7 @@ S["libexecdir"]="${exec_prefix}/libexec"
 S["sbindir"]="${exec_prefix}/sbin"
 S["bindir"]="${exec_prefix}/bin"
 S["program_transform_name"]="s,x,x,"
-S["prefix"]="/usr/local"
+S["prefix"]="/tmp"
 S["exec_prefix"]="${prefix}"
 S["PACKAGE_URL"]="http://wpitchoune.net/ptask"
 S["PACKAGE_BUGREPORT"]="jeanfi@gmail.com"
@@ -773,8 +791,60 @@ fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
   || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
 fi # test -n "$CONFIG_FILES"
 
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+D["PACKAGE_NAME"]=" \"ptask\""
+D["PACKAGE_TARNAME"]=" \"ptask\""
+D["PACKAGE_VERSION"]=" \"0.0.x\""
+D["PACKAGE_STRING"]=" \"ptask 0.0.x\""
+D["PACKAGE_BUGREPORT"]=" \"jeanfi@gmail.com\""
+D["PACKAGE_URL"]=" \"http://wpitchoune.net/ptask\""
+D["PACKAGE"]=" \"ptask\""
+D["VERSION"]=" \"0.0.x\""
+D["ENABLE_NLS"]=" 1"
+D["HAVE_GETTEXT"]=" 1"
+D["HAVE_DCGETTEXT"]=" 1"
+  for (key in D) D_is_set[key] = 1
+  FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ {
+  line = $ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
 
-eval set X "  :F $CONFIG_FILES      :C $CONFIG_COMMANDS"
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
 shift
 for ac_tag
 do
@@ -995,7 +1065,64 @@ which seems to be undefined.  Please make sure it is defined" >&2;}
   esac \
   || as_fn_error $? "could not create $ac_file" "$LINENO" 5
  ;;
-
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+       || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$_am_arg" : 'X\(//\)[^/]' \| \
+        X"$_am_arg" : 'X\(//\)$' \| \
+        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
 
   :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
 $as_echo "$as_me: executing $ac_file commands" >&6;}
index 0d36bac..a76efb3 100755 (executable)
--- a/configure
+++ b/configure
@@ -2512,6 +2512,8 @@ am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
 
 
 
+ac_config_headers="$ac_config_headers config.h"
+
 
 # Checks for programs.
 ac_ext=c
@@ -6867,43 +6869,7 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix
 # Let make expand exec_prefix.
 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-#
-# If the first sed substitution is executed (which looks for macros that
-# take arguments), then branch to the quote section.  Otherwise,
-# look for a macro that doesn't take arguments.
-ac_script='
-:mline
-/\\$/{
- N
- s,\\\n,,
- b mline
-}
-t clear
-:clear
-s/^[    ]*#[    ]*define[       ][      ]*\([^  (][^    (]*([^)]*)\)[   ]*\(.*\)/-D\1=\2/g
-t quote
-s/^[    ]*#[    ]*define[       ][      ]*\([^  ][^     ]*\)[   ]*\(.*\)/-D\1=\2/g
-t quote
-b any
-:quote
-s/[     `~#$^&*(){}\\|;'\''"<>?]/\\&/g
-s/\[/\\&/g
-s/\]/\\&/g
-s/\$/$$/g
-H
-:any
-${
-       g
-       s/^\n//
-       s/\n/ /g
-       p
-}
-'
-DEFS=`sed -n "$ac_script" confdefs.h`
-
+DEFS=-DHAVE_CONFIG_H
 
 ac_libobjs=
 ac_ltlibobjs=
@@ -7357,11 +7323,15 @@ case $ac_config_files in *"
 "*) set x $ac_config_files; shift; ac_config_files=$*;;
 esac
 
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
 
 
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
 config_files="$ac_config_files"
+config_headers="$ac_config_headers"
 config_commands="$ac_config_commands"
 
 _ACEOF
@@ -7383,10 +7353,15 @@ Usage: $0 [OPTION]... [TAG]...
       --recheck    update $as_me by reconfiguring in the same conditions
       --file=FILE[:TEMPLATE]
                    instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
 
 Configuration files:
 $config_files
 
+Configuration headers:
+$config_headers
+
 Configuration commands:
 $config_commands
 
@@ -7454,7 +7429,18 @@ do
     esac
     as_fn_append CONFIG_FILES " '$ac_optarg'"
     ac_need_defaults=false;;
-  --he | --h |  --help | --hel | -h )
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
     $as_echo "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil | --si | --s)
@@ -7522,6 +7508,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
     "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
     "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
@@ -7541,6 +7528,7 @@ done
 # bizarre bug on SunOS 4.1.3.
 if $ac_need_defaults; then
   test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
   test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
 fi
 
@@ -7729,8 +7717,116 @@ fi
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 fi # test -n "$CONFIG_FILES"
 
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
 
-eval set X "  :F $CONFIG_FILES      :C $CONFIG_COMMANDS"
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[    ]*#[    ]*define[       ][      ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
 shift
 for ac_tag
 do
@@ -7949,7 +8045,64 @@ which seems to be undefined.  Please make sure it is defined" >&2;}
   esac \
   || as_fn_error $? "could not create $ac_file" "$LINENO" 5
  ;;
-
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+       || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$_am_arg" : 'X\(//\)[^/]' \| \
+        X"$_am_arg" : 'X\(//\)$' \| \
+        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
 
   :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
 $as_echo "$as_me: executing $ac_file commands" >&6;}
index 430bf0b..ea8150b 100644 (file)
@@ -21,7 +21,7 @@ srcdir = .
 top_srcdir = ..
 
 
-prefix = /usr/local
+prefix = /tmp
 exec_prefix = ${prefix}
 datarootdir = ${prefix}/share
 datadir = ${datarootdir}
index 9db3564..ca508b4 100644 (file)
@@ -21,7 +21,7 @@ srcdir = .
 top_srcdir = ..
 
 
-prefix = /usr/local
+prefix = /tmp
 exec_prefix = ${prefix}
 datarootdir = ${prefix}/share
 datadir = ${datarootdir}
index 9be47a7..db90364 100644 (file)
@@ -12,7 +12,9 @@ LIBS = $(JSON_LIBS) $(GTK_LIBS)
 bin_PROGRAMS = ptask
 
 ptask_SOURCES = main.c \
+       log.c log.h \
        note.c note.h \
+       ptime.c ptime.h \
        tw.c tw.h
 
 dist_man_MANS = ptask.1
index 374e313..bb54ec0 100644 (file)
@@ -60,14 +60,16 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 PROGRAMS = $(bin_PROGRAMS)
-am_ptask_OBJECTS = main.$(OBJEXT) note.$(OBJEXT) tw.$(OBJEXT)
+am_ptask_OBJECTS = main.$(OBJEXT) log.$(OBJEXT) note.$(OBJEXT) \
+       ptime.$(OBJEXT) tw.$(OBJEXT)
 ptask_OBJECTS = $(am_ptask_OBJECTS)
 ptask_LDADD = $(LDADD)
-DEFAULT_INCLUDES = -I.@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 am__mv = mv -f
@@ -284,7 +286,9 @@ SUBDIRS = glade
 AM_LDFLAGS = -Wl,--as-needed  -export-dynamic
 AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) $(JSON_CFLAGS)
 ptask_SOURCES = main.c \
+       log.c log.h \
        note.c note.h \
+       ptime.c ptime.h \
        tw.c tw.h
 
 dist_man_MANS = ptask.1
@@ -372,8 +376,10 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/note.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptime.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tw.Po@am__quote@
 
 .c.o:
index b27af57..f9eadec 100644 (file)
@@ -58,6 +58,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 SOURCES =
diff --git a/src/log.c b/src/log.c
new file mode 100644 (file)
index 0000000..7b4331f
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2010-2013 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
+ */
+#define _LARGEFILE_SOURCE 1
+#include "config.h"
+
+#include <locale.h>
+#include <libintl.h>
+#define _(str) gettext(str)
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include "log.h"
+#include "ptime.h"
+
+static FILE *file;
+int log_level =  LOG_WARN;
+
+void log_open(const char *path)
+{
+       file = fopen(path, "a");
+
+       if (!file)
+               log_printf(LOG_ERR, _("Cannot open log file: %s"), path);
+}
+
+void log_close()
+{
+       if (!file)
+               return ;
+
+       fclose(file);
+
+       file = NULL;
+}
+
+
+#define LOG_BUFFER 4096
+static void vlogf(int lvl, const char *fmt, va_list ap)
+{
+       char buffer[1 + LOG_BUFFER];
+       char *lvl_str, *t;
+       FILE *stdf;
+
+       if (lvl > LOG_INFO && (!file || lvl > log_level))
+               return ;
+
+       vsnprintf(buffer, LOG_BUFFER, fmt, ap);
+       buffer[LOG_BUFFER] = '\0';
+
+       switch (lvl) {
+       case LOG_WARN:
+               lvl_str = "[WARN]";
+               break;
+       case LOG_ERR:
+               lvl_str = "[ERR]";
+               break;
+       case LOG_DEBUG:
+               lvl_str = "[DEBUG]";
+               break;
+       case LOG_INFO:
+               lvl_str = "[INFO]";
+               break;
+       default:
+               lvl_str = "[??]";
+       }
+
+       t = get_time_str();
+       if (!t)
+               return ;
+
+       if (file && lvl <= log_level) {
+               fprintf(file, "[%s] %s %s\n", t, lvl_str, buffer);
+               fflush(file);
+       } else {
+               t = NULL;
+       }
+
+       if (lvl <= LOG_INFO) {
+               if (lvl == LOG_WARN || lvl == LOG_ERR)
+                       stdf = stderr;
+               else
+                       stdf = stdout;
+
+
+               fprintf(stdf, "[%s] %s %s\n", t, lvl_str, buffer);
+       }
+
+       free(t);
+}
+
+void log_printf(int lvl, const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       vlogf(lvl, fmt, ap);
+       va_end(ap);
+}
+
+void log_debug(const char *fmt, ...)
+{
+       va_list ap;
+
+       if (log_level < LOG_DEBUG)
+               return ;
+
+       va_start(ap, fmt);
+       vlogf(LOG_DEBUG, fmt, ap);
+       va_end(ap);
+}
+
+void log_err(const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       vlogf(LOG_ERR, fmt, ap);
+       va_end(ap);
+}
+
+void log_warn(const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       vlogf(LOG_WARN, fmt, ap);
+       va_end(ap);
+}
+
+void log_info(const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       vlogf(LOG_INFO, fmt, ap);
+       va_end(ap);
+}
diff --git a/src/log.h b/src/log.h
new file mode 100644 (file)
index 0000000..16d3282
--- /dev/null
+++ b/src/log.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010-2013 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
+ */
+#ifndef _PTASK_LOG_H_
+#define _PTASK_LOG_H_
+
+enum log_level {
+       LOG_ERR ,
+       LOG_WARN,
+       LOG_INFO,
+       LOG_DEBUG
+};
+
+void log_open(const char *path);
+
+void log_printf(int lvl, const char *fmt, ...);
+void log_debug(const char *fmt, ...);
+void log_err(const char *fmt, ...);
+void log_info(const char *fmt, ...);
+void log_warn(const char *fmt, ...);
+
+void log_close();
+
+/* level of the log file. */
+extern int log_level;
+
+#endif
index ad3f2af..e6552cd 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
+#include <sys/stat.h>
 
 #include <json/json.h>
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#include <config.h>
+
+#include "log.h"
 #include "note.h"
 #include "tw.h"
 
@@ -51,6 +55,7 @@ enum {
 static struct option long_options[] = {
        {"version", no_argument, 0, 'v'},
        {"help", no_argument, 0, 'h'},
+       {"debug", required_argument, 0, 'd'},
        {0, 0, 0, 0}
 };
 
@@ -79,6 +84,11 @@ static void print_help()
 
        puts("");
 
+       puts(_("  -d, --debug=LEVEL   "
+              "set the debug level, integer between 0 and 3"));
+
+       puts("");
+
        printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT);
        puts("");
        printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
@@ -94,7 +104,7 @@ static struct task *get_selected_task(GtkTreeView *treeview)
        GValue value = {0,};
        const char *uuid;
 
-       printf("get_selected_task\n");
+       log_debug("get_selected_task");
 
        gtk_tree_view_get_cursor(treeview, &path, &cols);
 
@@ -147,11 +157,11 @@ static void refresh()
        int status;
        const char *project;
 
-       printf("refresh\n");
+       log_debug("refresh");
        clear_task_panel();
 
        status = gtk_combo_box_get_active(w_status);
-       printf("status: %d\n", status);
+       log_debug("status: %d", status);
 
        if (tasks)
                tw_task_list_free(tasks);
@@ -184,15 +194,14 @@ static void refresh()
                        gtk_list_store_set(GTK_LIST_STORE(model),
                                           &iter,
                                           COL_ID, (*tasks_cur)->id,
-                                          COL_DESCRIPTION, 
+                                          COL_DESCRIPTION,
                                           (*tasks_cur)->description,
                                           COL_PROJECT, project,
                                           COL_UUID, (*tasks_cur)->uuid,
                                           COL_PRIORITY, (*tasks_cur)->priority,
                                           -1);
                }
-       }
-       else {
+       } else {
                dialog = gtk_message_dialog_new(NULL,
                                                GTK_DIALOG_DESTROY_WITH_PARENT,
                                                GTK_MESSAGE_ERROR,
@@ -202,10 +211,10 @@ static void refresh()
                                                  "correctly installed, and its"
                                                  " configuration file exist."
                                                  ));
-               gtk_dialog_run(GTK_DIALOG (dialog));
+               gtk_dialog_run(GTK_DIALOG(dialog));
                gtk_widget_destroy(dialog);
        }
-       printf("refresh done\n");
+       log_debug("refresh done");
 }
 
 int taskdone_clicked_cbk(GtkButton *btn, gpointer data)
@@ -230,7 +239,7 @@ static int tasksave_clicked_cbk(GtkButton *btn, gpointer data)
 
        task = get_selected_task(GTK_TREE_VIEW(w_treeview));
 
-       printf("tasksave_clicked_cbk %d\n", task->id);
+       log_debug("tasksave_clicked_cbk %d", task->id);
 
        buf = gtk_text_view_get_buffer(w_note);
 
@@ -238,7 +247,7 @@ static int tasksave_clicked_cbk(GtkButton *btn, gpointer data)
        gtk_text_buffer_get_iter_at_offset(buf, &eIter, -1);
        txt = gtk_text_buffer_get_text(buf, &sIter, &eIter, TRUE);
 
-       printf("note=%s\n", txt);
+       log_debug("note=%s", txt);
 
        if (!task->note || strcmp(txt, task->note))
                note_put(task->uuid, txt);
@@ -252,7 +261,7 @@ static int tasksave_clicked_cbk(GtkButton *btn, gpointer data)
                tw_modify_project(task->uuid, ctxt);
 
        priority = gtk_combo_box_get_active(w_priority);
-       printf("priority: %d\n", priority);
+       log_debug("priority: %d", priority);
 
        switch (priority) {
        case 3:
@@ -278,7 +287,7 @@ static int tasksave_clicked_cbk(GtkButton *btn, gpointer data)
 
 int refresh_clicked_cbk(GtkButton *btn, gpointer data)
 {
-       printf("refresh_clicked_cbk\n");
+       log_debug("refresh_clicked_cbk");
        refresh();
 
        return FALSE;
@@ -301,7 +310,7 @@ int newtask_clicked_cbk(GtkButton *btn, gpointer data)
        GtkEntry *entry;
        const char *ctxt;
 
-       printf("newtask_clicked_cbk\n");
+       log_debug("newtask_clicked_cbk");
 
        builder = gtk_builder_new();
        gtk_builder_add_from_file
@@ -314,17 +323,17 @@ int newtask_clicked_cbk(GtkButton *btn, gpointer data)
        result = gtk_dialog_run(diag);
 
        if (result == GTK_RESPONSE_ACCEPT) {
-               printf("ok\n");
+               log_debug("ok");
                entry = GTK_ENTRY(gtk_builder_get_object
                                  (builder, "diag_tasknew_description"));
                ctxt = gtk_entry_get_text(entry);
 
-               printf("%s\n", ctxt);
+               log_debug("%s", ctxt);
 
                tw_add(ctxt);
                refresh();
        } else {
-               printf("cancel\n");
+               log_debug("cancel");
        }
 
        g_object_unref(G_OBJECT(builder));
@@ -336,7 +345,7 @@ int newtask_clicked_cbk(GtkButton *btn, gpointer data)
 
 static int status_changed_cbk(GtkComboBox *w, gpointer data)
 {
-       printf("status_changed_cbk\n");
+       log_debug("status_changed_cbk");
        refresh();
 
        return FALSE;
@@ -362,7 +371,7 @@ static int cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
        GtkTextBuffer *buf;
        int priority;
 
-       printf("cursor_changed_cbk\n");
+       log_debug("cursor_changed_cbk");
 
        task = get_selected_task(treeview);
 
@@ -393,9 +402,9 @@ static int cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
                priority = priority_to_int(task->priority);
                gtk_combo_box_set_active(w_priority, priority);
        } else {
-               printf("clear task widgets\n");
+               log_debug("clear task widgets");
                clear_task_panel();
-               printf("clear task widgets done\n");
+               log_debug("clear task widgets done");
        }
 
        return FALSE;
@@ -426,6 +435,28 @@ static gint priority_cmp(GtkTreeModel *model,
                return 0;
 }
 
+static void log_init()
+{
+       char *home, *path, *dir;
+
+       home = getenv("HOME");
+
+       if (!home)
+               return ;
+
+       dir = malloc(strlen(home)+1+strlen(".ptask")+1);
+       sprintf(dir, "%s/%s", home, ".ptask");
+       mkdir(dir, 0777);
+
+       path = malloc(strlen(dir)+1+strlen("log")+1);
+       sprintf(path, "%s/%s", dir, "log");
+
+       log_open(path);
+
+       free(dir);
+       free(path);
+}
+
 int main(int argc, char **argv)
 {
        GtkWidget *window, *btn;
@@ -443,7 +474,7 @@ int main(int argc, char **argv)
 #endif
 
        cmdok = 1;
-       while ((optc = getopt_long(argc, argv, "vh", long_options,
+       while ((optc = getopt_long(argc, argv, "vhd:", long_options,
                                   &opti)) != -1) {
                switch (optc) {
                case 'h':
@@ -452,6 +483,10 @@ int main(int argc, char **argv)
                case 'v':
                        print_version();
                        exit(EXIT_SUCCESS);
+               case 'd':
+                       log_level = atoi(optarg);
+                       log_info(_("Enables debug mode."));
+                       break;
                default:
                        cmdok = 0;
                        break;
@@ -464,6 +499,8 @@ int main(int argc, char **argv)
                exit(EXIT_FAILURE);
        }
 
+       log_init();
+
        gtk_init(NULL, NULL);
        builder = gtk_builder_new();
        gtk_builder_add_from_file
index d9ce755..2fcb51f 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include <log.h>
 #include <note.h>
 
 static char *get_path(const char *uuid)
@@ -32,7 +33,7 @@ static char *get_path(const char *uuid)
        home = getenv("HOME");
 
        if (!home) {
-               fprintf(stderr, "HOME environment variable not defined\n");
+               log_err("HOME environment variable not defined");
                return NULL;
        }
 
@@ -58,7 +59,7 @@ void note_put(const char *uuid, const char *note)
        if (!path)
                return ;
 
-       printf("note_put %s %s %s\n", path, uuid, note);
+       log_debug("note_put %s %s %s", path, uuid, note);
 
        f = fopen(path, "w");
 
@@ -66,7 +67,7 @@ void note_put(const char *uuid, const char *note)
                fwrite(note, 1, strlen(note), f);
                fclose(f);
        } else {
-               fprintf(stderr, "Failed to open %s\n", path);
+               log_err("Failed to open %s", path);
        }
 
        free(path);
@@ -99,7 +100,7 @@ char *note_get(const char *uuid)
                }
                fclose(f);
        } else {
-               fprintf(stderr, "Failed to open %s\n", path);
+               log_err("Failed to open %s", path);
        }
 
        return str;
diff --git a/src/ptime.c b/src/ptime.c
new file mode 100644 (file)
index 0000000..34ae92e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010-2013 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 <stdlib.h>
+
+#include "ptime.h"
+
+char *time_to_str(time_t *t)
+{
+       struct tm lt;
+       char *str;
+
+       if (!localtime_r(t, &lt))
+               return NULL;
+
+       str = malloc(64);
+
+       if (strftime(str, 64, "%s", &lt)) {
+               return str;
+       } else {
+               free(str);
+               return NULL;
+       }
+}
+
+char *get_time_str()
+{
+       time_t t;
+
+       t = time(NULL);
+       return time_to_str(&t);
+}
diff --git a/src/ptime.h b/src/ptime.h
new file mode 100644 (file)
index 0000000..aac8c52
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010-2013 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
+ */
+#ifndef _P_TIME_H
+#define _P_TIME_H
+
+#include <time.h>
+
+char *get_time_str();
+char *time_to_str(time_t *t);
+
+#endif
index 5a6e4c9..2d95614 100644 (file)
--- a/src/tw.c
+++ b/src/tw.c
@@ -24,6 +24,7 @@
 
 #include <json/json.h>
 
+#include <log.h>
 #include "note.h"
 #include "tw.h"
 
@@ -36,7 +37,7 @@ static int has_taskrc()
        home = getenv("HOME");
 
        if (!home) {
-               fprintf(stderr, "HOME environment variable not defined\n");
+               log_err("HOME environment variable not defined");
                return 0;
        }
 
@@ -65,7 +66,7 @@ static char *task_exec(char *opts)
        strcpy(cmd, "task rc.json.array=on ");
        strcat(cmd, opts);
 
-       printf("execute: %s\n", cmd);
+       log_debug("execute: %s", cmd);
 
        f = popen(cmd, "r");
 
@@ -87,10 +88,8 @@ static char *task_exec(char *opts)
 
        ret = pclose(f);
 
-       if (ret == -1) {
-               printf("pclose fails\n");
-               perror("pclose");
-       }
+       if (ret == -1)
+               log_err("pclose fails");
 
  exit_free:
        free(cmd);
index 820bfc3..15b3bc2 100644 (file)
@@ -58,6 +58,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 SOURCES =