]> jfr.im git - irc/hexchat/hexchat.git/commitdiff
Move writeline func to cfgfiles
authorTingPing <redacted>
Tue, 26 Aug 2014 20:03:24 +0000 (16:03 -0400)
committerPatrick Griffis <redacted>
Sun, 31 Jan 2016 20:40:16 +0000 (15:40 -0500)
src/common/cfgfiles.c
src/common/cfgfiles.h
src/common/servlist.c

index 9f423ac62bada3e66eac430262643a3ea324f9c9..49a48e3335521fe357bb84751466fcec6b007d8c 100644 (file)
@@ -1379,3 +1379,22 @@ hexchat_open_gfile (const char *filename)
 
        return file;
 }
+
+G_GNUC_PRINTF (2, 3)
+gsize
+stream_writef (GOutputStream *ostream, const char *fmt, ...)
+{
+       char *tmp;
+       va_list args;
+       gint len;
+       gsize ret;
+
+       va_start (args, fmt);
+       len = g_vasprintf (&tmp, fmt, args);
+       va_end (args);
+
+       ret = g_output_stream_write (ostream, tmp, len, NULL, NULL);
+       g_free (tmp);
+       
+       return ret;
+}
index 13eb20ce02f258c8a509c12b988322b1c75059b6..fb6f7d1b4f5af74f4594031600c3fb3b90eb0b00 100644 (file)
@@ -51,6 +51,7 @@ int cmd_set (session *sess, char *tbuf, char *word[], char *word_eol[]);
 int hexchat_open_file (const char *file, int flags, int mode, int xof_flags);
 FILE *hexchat_fopen_file (const char *file, const char *mode, int xof_flags);
 GFile *hexchat_open_gfile (const char *filename);
+gsize stream_writef (GOutputStream *ostream, const char *fmt, ...) G_GNUC_PRINTF (2, 3);
 
 #define XOF_DOMODE 1
 #define XOF_FULLPATH 2
index 9520ac8b561f40281d4c1ff48093a2d62a94fa8f..6e8d66941d559646e3e35fc8bc507c724b9e4d4f 100644 (file)
@@ -1144,21 +1144,6 @@ servlist_check_encoding (char *charset)
        return FALSE;
 }
 
-G_GNUC_PRINTF (2, 3)
-static gsize
-servlist_writeline (GOutputStream *ostream, const char *fmt, ...)
-{
-       char buf[512];
-       va_list args;
-       gsize len;
-
-       va_start (args, fmt);
-       len = g_vsnprintf (buf, sizeof (buf), fmt, args);
-       va_end (args);
-
-       return g_output_stream_write (ostream, buf, len, NULL, NULL);
-}
-
 int
 servlist_save (void)
 {
@@ -1181,29 +1166,29 @@ servlist_save (void)
        if (!ostream)
                return FALSE;
 
-       servlist_writeline (ostream, "v=%s\n\n", PACKAGE_VERSION);
+       stream_writef (ostream, "v=%s\n\n", PACKAGE_VERSION);
 
        list = network_list;
        while (list)
        {
                net = list->data;
 
-               servlist_writeline (ostream, "N=%s\n", net->name);
+               stream_writef (ostream, "N=%s\n", net->name);
                if (net->nick)
-                       servlist_writeline (ostream, "I=%s\n", net->nick);
+                       stream_writef (ostream, "I=%s\n", net->nick);
                if (net->nick2)
-                       servlist_writeline (ostream, "i=%s\n", net->nick2);
+                       stream_writef (ostream, "i=%s\n", net->nick2);
                if (net->user)
-                       servlist_writeline (ostream, "U=%s\n", net->user);
+                       stream_writef (ostream, "U=%s\n", net->user);
                if (net->real)
-                       servlist_writeline (ostream, "R=%s\n", net->real);
+                       stream_writef (ostream, "R=%s\n", net->real);
                if (net->pass)
-                       servlist_writeline (ostream, "P=%s\n", net->pass);
+                       stream_writef (ostream, "P=%s\n", net->pass);
                if (net->logintype)
-                       servlist_writeline (ostream, "L=%d\n", net->logintype);
+                       stream_writef (ostream, "L=%d\n", net->logintype);
                if (net->encoding)
                {
-                       servlist_writeline (ostream, "E=%s\n", net->encoding);
+                       stream_writef (ostream, "E=%s\n", net->encoding);
                        if (!servlist_check_encoding (net->encoding))
                        {
                                buf = g_strdup_printf (_("Warning: \"%s\" character set is unknown. No conversion will be applied for network %s."),
@@ -1213,13 +1198,13 @@ servlist_save (void)
                        }
                }
 
-               servlist_writeline (ostream, "F=%d\nD=%d\n", net->flags, net->selected);
+               stream_writef (ostream, "F=%d\nD=%d\n", net->flags, net->selected);
 
                netlist = net->servlist;
                while (netlist)
                {
                        serv = netlist->data;
-                       servlist_writeline (ostream, "S=%s\n", serv->hostname);
+                       stream_writef (ostream, "S=%s\n", serv->hostname);
                        netlist = netlist->next;
                }
 
@@ -1227,7 +1212,7 @@ servlist_save (void)
                while (cmdlist)
                {
                        cmd = cmdlist->data;
-                       servlist_writeline (ostream, "C=%s\n", cmd->command);
+                       stream_writef (ostream, "C=%s\n", cmd->command);
                        cmdlist = cmdlist->next;
                }
 
@@ -1238,17 +1223,17 @@ servlist_save (void)
 
                        if (favchan->key)
                        {
-                               servlist_writeline (ostream, "J=%s,%s\n", favchan->name, favchan->key);
+                               stream_writef (ostream, "J=%s,%s\n", favchan->name, favchan->key);
                        }
                        else
                        {
-                               servlist_writeline (ostream, "J=%s\n", favchan->name);
+                               stream_writef (ostream, "J=%s\n", favchan->name);
                        }
 
                        favlist = favlist->next;
                }
 
-               if (!servlist_writeline (ostream, "\n"))
+               if (!stream_writef (ostream, "\n"))
                        return FALSE;
 
                list = list->next;