X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Ftw.c;h=43760d4202e43dd7f361d0375ccbab78a2ee2c0d;hb=9fdef88f8d8f65ed6b74c9213acac7344feedf67;hp=01695d51ac47a21f9e57f9e5fc5761e3567b1f56;hpb=8a8ea8604707b51f52e9791a7d601ac3f563f07b;p=ptask.git diff --git a/src/tw.c b/src/tw.c index 01695d5..43760d4 100644 --- a/src/tw.c +++ b/src/tw.c @@ -37,6 +37,8 @@ static char *task_exec(char *opts) size_t s; char *str, *tmp, *cmd, buf[1024]; + log_fct_enter(); + cmd = malloc(strlen("task ") + strlen(opts) + 1); strcpy(cmd, "task "); strcat(cmd, opts); @@ -67,6 +69,8 @@ static char *task_exec(char *opts) if (ret == -1) log_err("pclose fails"); + log_fct_exit(); + return str; } @@ -276,6 +280,8 @@ void tw_modify_priority(const char *uuid, const char *priority) char *str; char *opts; + log_fct_enter(); + str = escape(priority); opts = malloc(1 @@ -290,15 +296,19 @@ void tw_modify_priority(const char *uuid, const char *priority) free(str); free(opts); + + log_fct_exit(); } void tw_add(const char *newdesc, const char *prj, const char *prio) { char *opts, *eprj; + log_fct_enter(); + eprj = escape(prj); - opts = malloc(strlen(" add") + opts = malloc(strlen("add") + strlen(" priority:") + 1 + strlen(" project:\\\"") @@ -309,7 +319,7 @@ void tw_add(const char *newdesc, const char *prj, const char *prio) + strlen("\"") + 1); - strcpy(opts, " add"); + strcpy(opts, "add"); if (prio && strlen(prio) == 1) { strcat(opts, " priority:"); @@ -324,12 +334,14 @@ void tw_add(const char *newdesc, const char *prj, const char *prio) strcat(opts, " \""); strcat(opts, newdesc); - strcat(opts, " \""); + strcat(opts, "\""); tw_exec(opts); free(opts); free(eprj); + + log_fct_exit(); } void tw_done(const char *uuid) @@ -347,6 +359,21 @@ void tw_done(const char *uuid) free(opts); } +void tw_task_remove(const char *uuid) +{ + char *opts; + + opts = malloc(1 + + strlen(uuid) + + strlen(" delete") + + 1); + sprintf(opts, " %s delete", uuid); + + tw_exec(opts); + + free(opts); +} + static void task_free(struct task *task) { if (!task)