tmisu

Notification to stdout daemon
git clone https://git.inz.fi/tmisu/
Log | Files | Refs | README | LICENSE

commit 754bd63c637b462c8db4bf472c3591a681695066
parent ca9b3af8d94e1f5f91c83ac4830f9c9587ec424d
Author: bit9tream <bit6tream@cock.li>
Date:   Tue, 23 Jun 2020 21:49:59 +0300

make code look better

Diffstat:
Mformat.c | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/format.c b/format.c @@ -3,7 +3,7 @@ #include "config.h" #include "format.h" -void escape_quotes(char *str, char *out) { +char* escape_quotes(char *str, char *out) { memset(out, 0, strlen(out)); while (*str) { if (*str == '"') @@ -12,6 +12,8 @@ void escape_quotes(char *str, char *out) { out[strlen(out)] = *str; str++; } + + return out; } void output_notification(gchar *app_name, guint32 replaces_id, gchar *app_icon, @@ -40,23 +42,23 @@ void output_notification(gchar *app_name, guint32 replaces_id, gchar *app_icon, timeout, OUTPUT_DELIMITER, summary, OUTPUT_DELIMITER, body); #else char *escaped_str = (char *)calloc(512, sizeof(char)); - escape_quotes(app_name, escaped_str); - sprintf(string, "{ \"app_name\": \"%s\"", escaped_str); + + sprintf(string, "{ \"app_name\": \"%s\"", escape_quotes(app_name, escaped_str)); #ifdef RECEIVE_APP_ICON - escape_quotes(app_icon, escaped_str); - sprintf(string, "%s, \"app_icon\": \"%s\"", string, escaped_str); + sprintf(string, "%s, \"app_icon\": \"%s\"", string, escape_quotes(app_icon, escaped_str)); #endif + /* TODO: actions */ + /* TODO: hints */ + #ifdef RECEIVE_REPLACES_ID sprintf(string, "%s, \"replaces_id\": %lu", string, replaces_id); #endif - escape_quotes(summary, escaped_str); - sprintf(string, "%s, \"timeout\": %d, \"summary\": \"%s\"", string, timeout, escaped_str); + sprintf(string, "%s, \"timeout\": %d, \"summary\": \"%s\"", string, timeout, escape_quotes(summary, escaped_str)); - escape_quotes(body, escaped_str); - sprintf(string, "%s, \"body\": \"%s\" }", string, escaped_str); + sprintf(string, "%s, \"body\": \"%s\" }", string, escape_quotes(body, escaped_str)); #endif