diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2017-11-29 07:53:24 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2017-11-29 07:53:24 +0000 |
commit | 28e49fdc3673445257be5213c1a264fe8767bffd (patch) | |
tree | f5800121f1702aae8375f5e3b24c071b641e32fd /libsylph/utils.c | |
parent | 278ff465694b8435fbb5dd4018c5cfe5cbf0dce9 (diff) |
addressbook: implemented CSV export feature.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3584 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r-- | libsylph/utils.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c index 1e40d52f..a76d0a55 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -1,6 +1,6 @@ /* * LibSylph -- E-Mail client library - * Copyright (C) 1999-2013 Hiroyuki Yamamoto + * Copyright (C) 1999-2017 Hiroyuki Yamamoto * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1730,6 +1730,44 @@ gchar **strsplit_csv(const gchar *str, gchar delim, gint max_tokens) return str_array; } +gchar *strconcat_csv(gchar delim, const gchar *field1, ...) +{ + va_list args; + gchar *s; + GString *csv; + gint count = 0; + const gchar *p; + + g_return_val_if_fail(field1 != NULL, NULL); + + csv = g_string_new(""); + + va_start(args, field1); + s = (gchar *)field1; + while (s) { + gboolean add_quote = FALSE; + + if (count > 0) + g_string_append_c(csv, delim); + if (delim != '\t' && strchr(s, delim) != NULL) + add_quote = TRUE; + if (add_quote) + g_string_append_c(csv, '"'); + for (p = s; *p != '\0'; p++) { + if (*p == '"') + g_string_append_c(csv, '"'); + g_string_append_c(csv, *p); + } + if (add_quote) + g_string_append_c(csv, '"'); + count++; + s = va_arg(args, gchar*); + } + va_end(args); + + return g_string_free(csv, FALSE); +} + gchar *get_abbrev_newsgroup_name(const gchar *group, gint len) { gchar *abbrev_group; |