return task_exec(opts2);
}
-static struct json_object *task_exec_json(char *opts)
+static struct json_object *task_exec_json(const char *opts)
{
struct json_object *o;
char *str, *cmd;
char *opts;
opts = malloc(strlen("export status:") + strlen(status) + 1);
- sprintf(opts, "export status:%s", status);
+
+ strcpy(opts, "export status:");
+ strcat(opts, status);
jtasks = task_exec_json(opts);
free(opts);
while (*txt) {
switch (*txt) {
case '"':
- *c = '\\'; c++;
- *c = '"';
- break;
case '$':
- *c = '\\'; c++;
- *c = '$';
- break;
case '&':
+ case '<':
+ case '>':
*c = '\\'; c++;
- *c = '&';
+ *c = *txt;
break;
default:
*c = *txt;
void tw_modify_description(const char *uuid, const char *newdesc)
{
- char *str;
char *opts;
- str = escape(newdesc);
-
opts = malloc(1
+ strlen(uuid)
+ strlen(" modify :\"")
- + strlen(str)
+ + strlen(newdesc)
+ strlen("\"")
+ 1);
- sprintf(opts, " %s modify \"%s\"", uuid, str);
+ sprintf(opts, " %s modify \"%s\"", uuid, newdesc);
tw_exec(opts);
- free(str);
free(opts);
}
free(opts);
}
-void tw_add(const char *newdesc)
+void tw_add(const char *newdesc, const char *prj, const char *prio)
{
- char *str;
- char *opts;
-
- str = escape(newdesc);
-
- opts = malloc(1
- + strlen(" add \"")
- + strlen(str)
+ char *opts, *eprj;
+
+ eprj = escape(prj);
+
+ opts = malloc(strlen(" add")
+ + strlen(" priority:")
+ + 1
+ + strlen(" project:\\\"")
+ + strlen(eprj)
+ + strlen("\\\"")
+ + strlen(" \"")
+ + strlen(newdesc)
+ strlen("\"")
+ 1);
- sprintf(opts, " add \"%s\"", str);
+
+ strcpy(opts, " add");
+
+ if (prio && strlen(prio) == 1) {
+ strcat(opts, " priority:");
+ strcat(opts, prio);
+ }
+
+ if (eprj && strlen(prj)) {
+ strcat(opts, " project:\\\"");
+ strcat(opts, eprj);
+ strcat(opts, "\\\"");
+ }
+
+ strcat(opts, " \"");
+ strcat(opts, newdesc);
+ strcat(opts, " \"");
tw_exec(opts);
- free(str);
free(opts);
+ free(eprj);
}
void tw_done(const char *uuid)