From fa6a26c6fdb10831328d63efd35606ede3819b03 Mon Sep 17 00:00:00 2001 From: Will Song Date: Mon, 23 Nov 2015 20:09:51 -0600 Subject: add feature in issue #585 this should only be temporary due the silly amounts of syscalls involved ideally we would create a new escaped string and write that directly via fputs --- src/command/command.c | 14 +++++++++++++ src/command/commands.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/command/commands.h | 1 + 3 files changed, 69 insertions(+) (limited to 'src/command') diff --git a/src/command/command.c b/src/command/command.c index bc2ee121..6a66d730 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1766,6 +1766,20 @@ static struct cmd_t command_defs[] = "/script run myscript", "/script show somescript") }, + + { "/export", + cmd_export, parse_args, 1, 1, NULL, + CMD_NOTAGS + CMD_SYN( + "/export ") + CMD_DESC( + "Exports contacts to a csv file.") + CMD_ARGS( + { "", "Path to the output file." }) + CMD_EXAMPLES( + "/export /path/to/output.cxv", + "/export ~/contacts.csv") + }, }; static Autocomplete commands_ac; diff --git a/src/command/commands.c b/src/command/commands.c index c17dca43..c6d7986b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -39,6 +39,10 @@ #include #include #include +#include +#include +#include +#include #include "chat_session.h" #include "command/commands.h" @@ -793,6 +797,56 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) return TRUE; } +static void +writecsv(int fd, const char *const str){ + if(str){ + for(int i = 0; i < strlen(str); i++){ + if(str[i] != '"') write(fd, str + i, 1); + /* two quotes ("") escapes a single quote (") */ + else write(fd, "\"\"", 2); + } + } +} + +gboolean +cmd_export(ProfWin *window, const char *const command, gchar **args) +{ + if(args[0]){ + /* temporary, we SHOULD pass everything to an escape function (to escape out quotes) + * and then use fputs */ + int fd = open(args[0], O_WRONLY | O_CREAT, 00600); + GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); + + write(fd, "jid,name\n", strlen("jid,name\n")); + if(list){ + GSList *curr = list; + while(curr){ + PContact contact = curr->data; + const char *jid = p_contact_barejid(contact); + const char *name = p_contact_name(contact); + + /* write the data to the file */ + write(fd, "\"", 1); + writecsv(fd, jid); + write(fd, "\",\"", 3); + writecsv(fd, name); + write(fd, "\"\n", 2); + + /* loop */ + curr = g_slist_next(curr); + } + } else { + cons_show("No contacts in roster."); + } + + g_slist_free(list); + close(fd); + return TRUE; + } else { + return FALSE; + } +} + gboolean cmd_sub(ProfWin *window, const char *const command, gchar **args) { diff --git a/src/command/commands.h b/src/command/commands.h index 4256387e..501046d4 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -150,6 +150,7 @@ gboolean cmd_resource(ProfWin *window, const char *const command, gchar **args); gboolean cmd_inpblock(ProfWin *window, const char *const command, gchar **args); gboolean cmd_encwarn(ProfWin *window, const char *const command, gchar **args); gboolean cmd_script(ProfWin *window, const char *const command, gchar **args); +gboolean cmd_export(ProfWin *window, const char *const command, gchar **args); gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args); -- cgit 1.4.1-2-gfad0 From aac8bfe98f779c6f06b39f3e4524e6d1ca63449a Mon Sep 17 00:00:00 2001 From: Will Song Date: Mon, 23 Nov 2015 20:25:55 -0600 Subject: decrease the amount of sys_writes used and add a useful error message also pretty up console messages by adding an empty line --- src/command/commands.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index c6d7986b..e6082bd8 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -797,15 +797,19 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) return TRUE; } +/* escape a string into csv and write it to the file descriptor */ static void writecsv(int fd, const char *const str){ - if(str){ - for(int i = 0; i < strlen(str); i++){ - if(str[i] != '"') write(fd, str + i, 1); - /* two quotes ("") escapes a single quote (") */ - else write(fd, "\"\"", 2); - } - } + if(!str) return; + size_t len = strlen(str); + char *s = malloc((2 * len + 1) * sizeof(char)); + char *c = s; + for(int i = 0; i < strlen(str); i++){ + if(str[i] != '"') *c++ = str[i]; + else { *c++ = '"'; *c++ = '"'; len++; } + } + write(fd, s, len); + free(s); } gboolean @@ -815,9 +819,16 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) /* temporary, we SHOULD pass everything to an escape function (to escape out quotes) * and then use fputs */ int fd = open(args[0], O_WRONLY | O_CREAT, 00600); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); + GSList *list = NULL; + + if(fd == -1){ + cons_show("error: cannot open %s: %s", args[0], strerror(errno)); + cons_show(""); + return TRUE; + } write(fd, "jid,name\n", strlen("jid,name\n")); + list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); if(list){ GSList *curr = list; while(curr){ @@ -835,8 +846,11 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) /* loop */ curr = g_slist_next(curr); } + cons_show("Contacts exported successfully"); + cons_show(""); } else { cons_show("No contacts in roster."); + cons_show(""); } g_slist_free(list); -- cgit 1.4.1-2-gfad0 From f73f88c571a559d8d441a9090e938ceec6725131 Mon Sep 17 00:00:00 2001 From: Will Song Date: Mon, 23 Nov 2015 20:29:17 -0600 Subject: fix typo --- src/command/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/command') diff --git a/src/command/command.c b/src/command/command.c index 6a66d730..3e9adc9c 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1777,7 +1777,7 @@ static struct cmd_t command_defs[] = CMD_ARGS( { "", "Path to the output file." }) CMD_EXAMPLES( - "/export /path/to/output.cxv", + "/export /path/to/output.csv", "/export ~/contacts.csv") }, }; -- cgit 1.4.1-2-gfad0 From 4501231eb312f8a449101966470eee85e37c7b66 Mon Sep 17 00:00:00 2001 From: Will Song Date: Mon, 23 Nov 2015 20:30:48 -0600 Subject: since we keep track of length correctly, we don't need to add a null terminator for sys_write --- src/command/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index e6082bd8..ef2de3b1 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -802,7 +802,7 @@ static void writecsv(int fd, const char *const str){ if(!str) return; size_t len = strlen(str); - char *s = malloc((2 * len + 1) * sizeof(char)); + char *s = malloc(2 * len * sizeof(char)); char *c = s; for(int i = 0; i < strlen(str); i++){ if(str[i] != '"') *c++ = str[i]; -- cgit 1.4.1-2-gfad0 From ddd5ce857d58f1da36a53fc867a80dcbe094663a Mon Sep 17 00:00:00 2001 From: Will Song Date: Mon, 23 Nov 2015 20:39:04 -0600 Subject: mark return value of sys_write as unused to fix tests --- src/command/commands.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index ef2de3b1..2d76aeda 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -808,7 +808,8 @@ writecsv(int fd, const char *const str){ if(str[i] != '"') *c++ = str[i]; else { *c++ = '"'; *c++ = '"'; len++; } } - write(fd, s, len); + int unused = write(fd, s, len); + (void)(unused); free(s); } @@ -835,13 +836,15 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) PContact contact = curr->data; const char *jid = p_contact_barejid(contact); const char *name = p_contact_name(contact); + int unused; + (void)(unused); /* write the data to the file */ - write(fd, "\"", 1); + unused = write(fd, "\"", 1); writecsv(fd, jid); - write(fd, "\",\"", 3); + unused = write(fd, "\",\"", 3); writecsv(fd, name); - write(fd, "\"\n", 2); + unused = write(fd, "\"\n", 2); /* loop */ curr = g_slist_next(curr); -- cgit 1.4.1-2-gfad0 From 8b9b06c24fbdb4bc2b6ddba1c0639421dd20a316 Mon Sep 17 00:00:00 2001 From: Will Song Date: Mon, 23 Nov 2015 20:43:42 -0600 Subject: ignore another return value and move initial loop declaration outside of loop --- src/command/commands.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index 2d76aeda..4605e5f7 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -804,7 +804,8 @@ writecsv(int fd, const char *const str){ size_t len = strlen(str); char *s = malloc(2 * len * sizeof(char)); char *c = s; - for(int i = 0; i < strlen(str); i++){ + int i = 0; + for(; i < strlen(str); i++){ if(str[i] != '"') *c++ = str[i]; else { *c++ = '"'; *c++ = '"'; len++; } } @@ -827,8 +828,10 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) cons_show(""); return TRUE; } + int unused; + (void)(unused); - write(fd, "jid,name\n", strlen("jid,name\n")); + unused = write(fd, "jid,name\n", strlen("jid,name\n")); list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); if(list){ GSList *curr = list; @@ -836,8 +839,6 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) PContact contact = curr->data; const char *jid = p_contact_barejid(contact); const char *name = p_contact_name(contact); - int unused; - (void)(unused); /* write the data to the file */ unused = write(fd, "\"", 1); -- cgit 1.4.1-2-gfad0 From d4e0be71765d85eb4429805da4f64586631825e4 Mon Sep 17 00:00:00 2001 From: Will Song Date: Mon, 23 Nov 2015 21:02:23 -0600 Subject: actually check the return value of write for rare fail conditions --- src/command/commands.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index 4605e5f7..ec49969c 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -798,9 +798,9 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) } /* escape a string into csv and write it to the file descriptor */ -static void +static int writecsv(int fd, const char *const str){ - if(!str) return; + if(!str) return 0; size_t len = strlen(str); char *s = malloc(2 * len * sizeof(char)); char *c = s; @@ -809,9 +809,12 @@ writecsv(int fd, const char *const str){ if(str[i] != '"') *c++ = str[i]; else { *c++ = '"'; *c++ = '"'; len++; } } - int unused = write(fd, s, len); - (void)(unused); + if(-1 == write(fd, s, len)){ + cons_show("error: failed to write '%s' to the requested file: %s", s, strerror(errno)); + return -1; + } free(s); + return 0; } gboolean @@ -823,15 +826,14 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) int fd = open(args[0], O_WRONLY | O_CREAT, 00600); GSList *list = NULL; - if(fd == -1){ + if(-1 == fd){ cons_show("error: cannot open %s: %s", args[0], strerror(errno)); cons_show(""); return TRUE; } - int unused; - (void)(unused); - unused = write(fd, "jid,name\n", strlen("jid,name\n")); + if(-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) goto write_error; + list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); if(list){ GSList *curr = list; @@ -841,11 +843,11 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) const char *name = p_contact_name(contact); /* write the data to the file */ - unused = write(fd, "\"", 1); - writecsv(fd, jid); - unused = write(fd, "\",\"", 3); - writecsv(fd, name); - unused = write(fd, "\"\n", 2); + if(-1 == write(fd, "\"", 1)) goto write_error; + if(-1 == writecsv(fd, jid)) goto write_error; + if(-1 == write(fd, "\",\"", 3)) goto write_error; + if(-1 == writecsv(fd, name)) goto write_error; + if(-1 == write(fd, "\"\n", 2)) goto write_error; /* loop */ curr = g_slist_next(curr); @@ -857,6 +859,12 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) cons_show(""); } + g_slist_free(list); + close(fd); + return TRUE; +write_error: + cons_show("error: write failed: %s", strerror(errno)); + cons_show(""); g_slist_free(list); close(fd); return TRUE; -- cgit 1.4.1-2-gfad0 From b2bc69f9261f4cb10675fe772bfe758fbc75961b Mon Sep 17 00:00:00 2001 From: Will Song Date: Tue, 24 Nov 2015 17:58:55 -0600 Subject: styling changes and remove temporary comment --- src/command/commands.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index ec49969c..0d5ce5e0 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -799,17 +799,17 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) /* escape a string into csv and write it to the file descriptor */ static int -writecsv(int fd, const char *const str){ +_writecsv(int fd, const char *const str){ if(!str) return 0; size_t len = strlen(str); char *s = malloc(2 * len * sizeof(char)); char *c = s; int i = 0; - for(; i < strlen(str); i++){ + for(; i < strlen(str); i++) { if(str[i] != '"') *c++ = str[i]; else { *c++ = '"'; *c++ = '"'; len++; } } - if(-1 == write(fd, s, len)){ + if(-1 == write(fd, s, len)) { cons_show("error: failed to write '%s' to the requested file: %s", s, strerror(errno)); return -1; } @@ -821,12 +821,10 @@ gboolean cmd_export(ProfWin *window, const char *const command, gchar **args) { if(args[0]){ - /* temporary, we SHOULD pass everything to an escape function (to escape out quotes) - * and then use fputs */ int fd = open(args[0], O_WRONLY | O_CREAT, 00600); GSList *list = NULL; - if(-1 == fd){ + if(-1 == fd) { cons_show("error: cannot open %s: %s", args[0], strerror(errno)); cons_show(""); return TRUE; @@ -835,7 +833,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) if(-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) goto write_error; list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); - if(list){ + if(list) { GSList *curr = list; while(curr){ PContact contact = curr->data; -- cgit 1.4.1-2-gfad0 From 35b8d58270211b6249fc692e61b331ef25b7a089 Mon Sep 17 00:00:00 2001 From: Will Song Date: Tue, 24 Nov 2015 17:59:28 -0600 Subject: move brace to newline to follow conventions --- src/command/commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index 0d5ce5e0..2c3b6352 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -799,7 +799,8 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) /* escape a string into csv and write it to the file descriptor */ static int -_writecsv(int fd, const char *const str){ +_writecsv(int fd, const char *const str) +{ if(!str) return 0; size_t len = strlen(str); char *s = malloc(2 * len * sizeof(char)); -- cgit 1.4.1-2-gfad0 From c4a1e7da9b4c41395d1bec27fea3b47b387e86a6 Mon Sep 17 00:00:00 2001 From: Will Song Date: Tue, 24 Nov 2015 18:02:48 -0600 Subject: show different message when one is not connected --- src/command/commands.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index 2c3b6352..dc562e81 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -821,7 +821,13 @@ _writecsv(int fd, const char *const str) gboolean cmd_export(ProfWin *window, const char *const command, gchar **args) { - if(args[0]){ + jabber_conn_status_t conn_status = jabber_get_connection_status(); + + if (conn_status != JABBER_CONNECTED) { + cons_show("You are not currently connected."); + cons_show(""); + return TRUE; + } else if(args[0]) { int fd = open(args[0], O_WRONLY | O_CREAT, 00600); GSList *list = NULL; @@ -843,9 +849,9 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) /* write the data to the file */ if(-1 == write(fd, "\"", 1)) goto write_error; - if(-1 == writecsv(fd, jid)) goto write_error; + if(-1 == _writecsv(fd, jid)) goto write_error; if(-1 == write(fd, "\",\"", 3)) goto write_error; - if(-1 == writecsv(fd, name)) goto write_error; + if(-1 == _writecsv(fd, name)) goto write_error; if(-1 == write(fd, "\"\n", 2)) goto write_error; /* loop */ -- cgit 1.4.1-2-gfad0 From bd33a24bebde076ab760d7a34c9a415b0d9cd7b6 Mon Sep 17 00:00:00 2001 From: Will Song Date: Tue, 24 Nov 2015 18:12:41 -0600 Subject: add some code to deal with a common $HOME convention --- src/command/commands.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index dc562e81..5e7e0951 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -828,8 +828,19 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) cons_show(""); return TRUE; } else if(args[0]) { - int fd = open(args[0], O_WRONLY | O_CREAT, 00600); + GString *fname = g_string_new(""); GSList *list = NULL; + int fd; + + /* deal with the ~ convention for $HOME */ + if(args[0][0] == '~') { + fname = g_string_append(fname, getenv("HOME")); + fname = g_string_append(fname, args[0] + 1); + } else { + fname = g_string_append(fname, args[0]); + } + + fd = open(fname->str, O_WRONLY | O_CREAT, 00600); if(-1 == fd) { cons_show("error: cannot open %s: %s", args[0], strerror(errno)); @@ -866,6 +877,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) g_slist_free(list); close(fd); + g_string_free(fname, TRUE); return TRUE; write_error: cons_show("error: write failed: %s", strerror(errno)); -- cgit 1.4.1-2-gfad0 From d8022a9f208c238d9f2bdca5ebad1604683f4273 Mon Sep 17 00:00:00 2001 From: Will Song Date: Tue, 24 Nov 2015 18:15:35 -0600 Subject: remove NULL check because parse_args will fail before calling cmd_export --- src/command/commands.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index 5e7e0951..286b0afe 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -827,7 +827,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) cons_show("You are not currently connected."); cons_show(""); return TRUE; - } else if(args[0]) { + } else { GString *fname = g_string_new(""); GSList *list = NULL; int fd; @@ -885,8 +885,6 @@ write_error: g_slist_free(list); close(fd); return TRUE; - } else { - return FALSE; } } -- cgit 1.4.1-2-gfad0 From e945347f5242c496d9003a6af45adf716b707eaf Mon Sep 17 00:00:00 2001 From: Will Song Date: Tue, 24 Nov 2015 18:19:02 -0600 Subject: free fname as soon as we are done with it (also prevents a memory leak) --- src/command/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index 286b0afe..25ba0d1e 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -841,6 +841,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) } fd = open(fname->str, O_WRONLY | O_CREAT, 00600); + g_string_free(fname, TRUE); if(-1 == fd) { cons_show("error: cannot open %s: %s", args[0], strerror(errno)); @@ -877,7 +878,6 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) g_slist_free(list); close(fd); - g_string_free(fname, TRUE); return TRUE; write_error: cons_show("error: write failed: %s", strerror(errno)); -- cgit 1.4.1-2-gfad0 From df2726bdf550d1da2d2f4d57dca04ae847123604 Mon Sep 17 00:00:00 2001 From: Will Song Date: Tue, 24 Nov 2015 18:24:48 -0600 Subject: add spaces after constructs such as if/for/while --- src/command/commands.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/command') diff --git a/src/command/commands.c b/src/command/commands.c index 25ba0d1e..db947556 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -801,16 +801,16 @@ cmd_script(ProfWin *window, const char *const command, gchar **args) static int _writecsv(int fd, const char *const str) { - if(!str) return 0; + if (!str) return 0; size_t len = strlen(str); char *s = malloc(2 * len * sizeof(char)); char *c = s; int i = 0; - for(; i < strlen(str); i++) { + for (; i < strlen(str); i++) { if(str[i] != '"') *c++ = str[i]; else { *c++ = '"'; *c++ = '"'; len++; } } - if(-1 == write(fd, s, len)) { + if (-1 == write(fd, s, len)) { cons_show("error: failed to write '%s' to the requested file: %s", s, strerror(errno)); return -1; } @@ -833,7 +833,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) int fd; /* deal with the ~ convention for $HOME */ - if(args[0][0] == '~') { + if (args[0][0] == '~') { fname = g_string_append(fname, getenv("HOME")); fname = g_string_append(fname, args[0] + 1); } else { @@ -843,28 +843,28 @@ cmd_export(ProfWin *window, const char *const command, gchar **args) fd = open(fname->str, O_WRONLY | O_CREAT, 00600); g_string_free(fname, TRUE); - if(-1 == fd) { + if (-1 == fd) { cons_show("error: cannot open %s: %s", args[0], strerror(errno)); cons_show(""); return TRUE; } - if(-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) goto write_error; + if (-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) goto write_error; list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); - if(list) { + if (list) { GSList *curr = list; - while(curr){ + while (curr){ PContact contact = curr->data; const char *jid = p_contact_barejid(contact); const char *name = p_contact_name(contact); /* write the data to the file */ - if(-1 == write(fd, "\"", 1)) goto write_error; - if(-1 == _writecsv(fd, jid)) goto write_error; - if(-1 == write(fd, "\",\"", 3)) goto write_error; - if(-1 == _writecsv(fd, name)) goto write_error; - if(-1 == write(fd, "\"\n", 2)) goto write_error; + if (-1 == write(fd, "\"", 1)) goto write_error; + if (-1 == _writecsv(fd, jid)) goto write_error; + if (-1 == write(fd, "\",\"", 3)) goto write_error; + if (-1 == _writecsv(fd, name)) goto write_error; + if (-1 == write(fd, "\"\n", 2)) goto write_error; /* loop */ curr = g_slist_next(curr); -- cgit 1.4.1-2-gfad0