diff --git a/configure.ac b/configure.ac index bdb256f5..a52ccdb8 100644 --- a/configure.ac +++ b/configure.ac @@ -755,8 +755,7 @@ AC_TRY_COMPILE( ], AC_MSG_RESULT(no)) -dnl if we don\'t have this, use g_snprintf instead -AC_CHECK_FUNCS(snprintf vsnprintf memrchr strtoull) +AC_CHECK_FUNCS(memrchr) AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(resolv, gethostbyname, , diff --git a/plugins/fishlim/fish.c b/plugins/fishlim/fish.c index a230185d..00ecfbfa 100644 --- a/plugins/fishlim/fish.c +++ b/plugins/fishlim/fish.c @@ -39,17 +39,17 @@ static const char fish_base64[64] = "./0123456789abcdefghijklmnopqrstuvwxyzABCDE static const signed char fish_unbase64[256] = { IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB,IB,IB, -// ! " # $ % & ' ( ) * + , - . / +/* ! " # $ % & ' ( ) * + , - . / */ IB,IB,IB,IB,IB,IB,IB,IB, IB,IB,IB,IB,IB,IB, 0, 1, -// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? +/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ 2, 3, 4, 5, 6, 7, 8, 9, 10,11,IB,IB,IB,IB,IB,IB, -// @ A B C D E F G H I J K L M N O +/* @ A B C D E F G H I J K L M N O */ IB,38,39,40,41,42,43,44, 45,46,47,48,49,50,51,52, -// P Q R S T U V W X Y Z [ \ ] ^ _ +/* P Q R S T U V W X Y Z [ \ ] ^ _*/ 53,54,55,56,57,58,59,60, 61,62,63,IB,IB,IB,IB,IB, -// ` a b c d e f g h i j k l m n o +/* ` a b c d e f g h i j k l m n o */ IB,12,13,14,15,16,17,18, 19,20,21,22,23,24,25,26, -// p q r s t u v w x y z { | } ~ +/* p q r s t u v w x y z { | } ~ */ 27,28,29,30,31,32,33,34, 35,36,37,IB,IB,IB,IB,IB, }; @@ -75,11 +75,11 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) { messagelen = strlen(message); if (messagelen == 0) return NULL; - encrypted = g_malloc(((messagelen - 1) / 8) * 12 + 12 + 1); // each 8-byte block becomes 12 bytes + encrypted = g_malloc(((messagelen - 1) / 8) * 12 + 12 + 1); /* each 8-byte block becomes 12 bytes */ end = encrypted; while (*message) { - // Read 8 bytes (a Blowfish block) + /* Read 8 bytes (a Blowfish block) */ BF_LONG binary[2] = { 0, 0 }; unsigned char c; for (i = 0; i < 8; i++) { @@ -89,10 +89,10 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) { } message += 8; - // Encrypt block + /* Encrypt block */ BF_encrypt(binary, &bfkey); - // Emit FiSH-BASE64 + /* Emit FiSH-BASE64 */ bit = 0; word = 1; for (j = 0; j < 12; j++) { @@ -105,7 +105,7 @@ char *fish_encrypt(const char *key, size_t keylen, const char *message) { } } - // Stop if a null terminator was found + /* Stop if a null terminator was found */ if (c == '\0') break; } *end = '\0'; @@ -127,7 +127,7 @@ char *fish_decrypt(const char *key, size_t keylen, const char *data) { end = decrypted; while (*data) { - // Convert from FiSH-BASE64 + /* Convert from FiSH-BASE64 */ BF_LONG binary[2] = { 0, 0 }; bit = 0; word = 1; @@ -142,10 +142,10 @@ char *fish_decrypt(const char *key, size_t keylen, const char *data) { } } - // Decrypt block + /* Decrypt block */ BF_decrypt(binary, &bfkey); - // Copy to buffer + /* Copy to buffer */ GET_BYTES(end, binary[0]); GET_BYTES(end, binary[1]); } @@ -163,11 +163,11 @@ char *fish_encrypt_for_nick(const char *nick, const char *data) { char *key; char *encrypted; - // Look for key + /* Look for key */ key = keystore_get_key(nick); if (!key) return NULL; - // Encrypt + /* Encrypt */ encrypted = fish_encrypt(key, strlen(key), data); g_free(key); @@ -181,11 +181,11 @@ char *fish_encrypt_for_nick(const char *nick, const char *data) { char *fish_decrypt_from_nick(const char *nick, const char *data) { char *key; char *decrypted; - // Look for key + /* Look for key */ key = keystore_get_key(nick); if (!key) return NULL; - // Decrypt + /* Decrypt */ decrypted = fish_decrypt(key, strlen(key), data); g_free(key); diff --git a/plugins/fishlim/fish.h b/plugins/fishlim/fish.h index d7415a5a..238f52e7 100644 --- a/plugins/fishlim/fish.h +++ b/plugins/fishlim/fish.h @@ -25,7 +25,6 @@ #ifndef FISH_H #define FISH_H -#include #include #include diff --git a/plugins/fishlim/irc.c b/plugins/fishlim/irc.c index 9bd84769..deba545b 100644 --- a/plugins/fishlim/irc.c +++ b/plugins/fishlim/irc.c @@ -32,26 +32,26 @@ * at spaces. The prefix and command is extracted from the message, and * parameters_offset is set to the index of the first parameter. */ -bool irc_parse_message(const char *words[], +gboolean irc_parse_message(const char *words[], const char **prefix, const char **command, size_t *parameters_offset) { size_t w = 1; if (prefix) *prefix = NULL; if (command) *command = NULL; - // See if the message starts with a prefix (sender user) + /* See if the message starts with a prefix (sender user) */ if (words[w][0] == ':') { if (prefix) *prefix = &words[w][1]; w++; } - // Check command - if (words[w][0] == '\0') return false; + /* Check command */ + if (words[w][0] == '\0') return FALSE; if (command) *command = words[w]; w++; *parameters_offset = w; - return true; + return TRUE; } @@ -70,11 +70,11 @@ char *irc_prefix_get_nick(const char *prefix) { if (!prefix) return NULL; - // Find end of nick + /* Find end of nick */ end = prefix; while (*end != '\0' && *end != '!' && *end != '@') end++; - // Allocate string + /* Allocate string */ length = end - prefix; return g_strndup (prefix, length); } diff --git a/plugins/fishlim/irc.h b/plugins/fishlim/irc.h index 7ff72355..c5649233 100644 --- a/plugins/fishlim/irc.h +++ b/plugins/fishlim/irc.h @@ -25,12 +25,10 @@ #ifndef IRC_H #define IRC_H -#include #include - #include -bool irc_parse_message(const char *words[], +gboolean irc_parse_message(const char *words[], const char **prefix, const char **command, size_t *parameters_offset); char *irc_prefix_get_nick(const char *prefix); diff --git a/plugins/fishlim/keystore.c b/plugins/fishlim/keystore.c index 964b4cb4..84373996 100644 --- a/plugins/fishlim/keystore.c +++ b/plugins/fishlim/keystore.c @@ -58,7 +58,7 @@ static GKeyFile *getConfigFile() { static const char *get_keystore_password() { return (keystore_password != NULL ? keystore_password : - // Silly default value... + /* Silly default value... */ "blowinikey"); } @@ -88,17 +88,17 @@ static gchar *get_nick_value(GKeyFile *keyfile, const char *nick, const char *it * Extracts a key from the key store file. */ char *keystore_get_key(const char *nick) { - // Get the key + /* Get the key */ GKeyFile *keyfile = getConfigFile(); gchar *value = get_nick_value(keyfile, nick, "key"); g_key_file_free(keyfile); if (!value) return NULL; if (strncmp(value, "+OK ", 4) != 0) { - // Key is stored in plaintext + /* Key is stored in plaintext */ return value; } else { - // Key is encrypted + /* Key is encrypted */ const char *encrypted = value+4; const char *password = get_keystore_password(); char *decrypted = fish_decrypt(password, strlen(password), encrypted); @@ -110,10 +110,10 @@ char *keystore_get_key(const char *nick) { /** * Deletes a nick and the associated key in the key store file. */ -static bool delete_nick(GKeyFile *keyfile, const char *nick) { +static gboolean delete_nick(GKeyFile *keyfile, const char *nick) { gchar **group; gchar **groups = g_key_file_get_groups(keyfile, NULL); - bool ok = false; + gboolean ok = FALSE; for (group = groups; *group != NULL; group++) { if (!irc_nick_cmp(*group, nick)) { @@ -149,9 +149,9 @@ static gboolean keyfile_save_to_file (GKeyFile *keyfile, char *filename) { /** * Writes the key store file to disk. */ -static bool save_keystore(GKeyFile *keyfile) { +static gboolean save_keystore(GKeyFile *keyfile) { char *filename; - bool ok; + gboolean ok; filename = get_config_filename(); #if !GLIB_CHECK_VERSION(2,40,0) @@ -167,36 +167,36 @@ static bool save_keystore(GKeyFile *keyfile) { /** * Sets a key in the key store file. */ -bool keystore_store_key(const char *nick, const char *key) { +gboolean keystore_store_key(const char *nick, const char *key) { const char *password; char *encrypted; char *wrapped; - bool ok = false; + gboolean ok = FALSE; GKeyFile *keyfile = getConfigFile(); - // Remove old key + /* Remove old key */ delete_nick(keyfile, nick); - // Add new key + /* Add new key */ password = get_keystore_password(); if (password) { - // Encrypt the password + /* Encrypt the password */ encrypted = fish_encrypt(password, strlen(password), key); if (!encrypted) goto end; - // Prepend "+OK " + /* Prepend "+OK " */ wrapped = g_strconcat("+OK ", encrypted, NULL); g_free(encrypted); - // Store encrypted in file + /* Store encrypted in file */ g_key_file_set_string(keyfile, nick, "key", wrapped); g_free(wrapped); } else { - // Store unencrypted in file + /* Store unencrypted in file */ g_key_file_set_string(keyfile, nick, "key", key); } - // Save key store file + /* Save key store file */ ok = save_keystore(keyfile); end: @@ -207,13 +207,13 @@ bool keystore_store_key(const char *nick, const char *key) { /** * Deletes a nick from the key store. */ -bool keystore_delete_nick(const char *nick) { +gboolean keystore_delete_nick(const char *nick) { GKeyFile *keyfile = getConfigFile(); - // Delete entry - bool ok = delete_nick(keyfile, nick); + /* Delete entry */ + gboolean ok = delete_nick(keyfile, nick); - // Save + /* Save */ if (ok) save_keystore(keyfile); g_key_file_free(keyfile); diff --git a/plugins/fishlim/keystore.h b/plugins/fishlim/keystore.h index 3c609867..3d90606a 100644 --- a/plugins/fishlim/keystore.h +++ b/plugins/fishlim/keystore.h @@ -25,14 +25,13 @@ #ifndef KEYSTORE_H #define KEYSTORE_H -#include #include #include char *keystore_get_key(const char *nick); -bool keystore_store_key(const char *nick, const char *key); -bool keystore_delete_nick(const char *nick); +gboolean keystore_store_key(const char *nick, const char *key); +gboolean keystore_delete_nick(const char *nick); #endif diff --git a/plugins/fishlim/plugin_hexchat.c b/plugins/fishlim/plugin_hexchat.c index 82befceb..556a2f51 100644 --- a/plugins/fishlim/plugin_hexchat.c +++ b/plugins/fishlim/plugin_hexchat.c @@ -28,13 +28,8 @@ #include #include -// #pragma GCC visibility push(default) #include "hexchat-plugin.h" #define HEXCHAT_MAX_WORDS 32 -// #pragma GCC visibility pop - -//#define EXPORT __attribute((visibility("default"))) -//#define EXPORT #include "fish.h" #include "keystore.h" @@ -81,16 +76,16 @@ int irc_nick_cmp(const char *a, const char *b) { */ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) { const char *own_nick; - // Encrypt the message if possible + /* Encrypt the message if possible */ const char *channel = hexchat_get_info(ph, "channel"); char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]); if (!encrypted) return HEXCHAT_EAT_NONE; - // Display message + /* Display message */ own_nick = hexchat_get_info(ph, "nick"); hexchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL); - // Send message + /* Send message */ hexchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted); g_free(encrypted); @@ -117,10 +112,10 @@ static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs * if (!irc_parse_message((const char **)word, &prefix, &command, &w)) return HEXCHAT_EAT_NONE; - // Topic (command 332) has an extra parameter + /* Topic (command 332) has an extra parameter */ if (!strcmp(command, "332")) w++; - // Look for encrypted data + /* Look for encrypted data */ for (ew = w+1; ew < HEXCHAT_MAX_WORDS-1; ew++) { const char *s = (ew == w+1 ? word[ew]+1 : word[ew]); if (*s && (s[1] == '+' || s[1] == 'm')) { prefix_char = *(s++); } @@ -129,19 +124,19 @@ static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs * } return HEXCHAT_EAT_NONE; has_encrypted_data: ; - // Extract sender nick and recipient nick/channel + /* Extract sender nick and recipient nick/channel */ sender_nick = irc_prefix_get_nick(prefix); recipient = word[w]; - // Try to decrypt with these (the keys are searched for in the key store) + /* Try to decrypt with these (the keys are searched for in the key store) */ encrypted = word[ew+1]; decrypted = fish_decrypt_from_nick(recipient, encrypted); if (!decrypted) decrypted = fish_decrypt_from_nick(sender_nick, encrypted); - // Check for error + /* Check for error */ if (!decrypted) goto decrypt_error; - // Build unecrypted message + /* Build unecrypted message */ message = g_string_sized_new (100); /* TODO: more accurate estimation of size */ g_string_append (message, "RECV"); @@ -160,12 +155,12 @@ static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs * g_string_append_c (message, ' '); if (uw == ew) { - // Add the encrypted data + /* Add the encrypted data */ peice = decrypted; - uw++; // Skip "OK+" + uw++; /* Skip "OK+" */ if (ew == w+1) { - // Prefix with colon, which gets stripped out otherwise + /* Prefix with colon, which gets stripped out otherwise */ g_string_append_c (message, ':'); } @@ -174,7 +169,7 @@ static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs * } } else { - // Add unencrypted data (for example, a prefix from a bouncer or bot) + /* Add unencrypted data (for example, a prefix from a bouncer or bot) */ peice = word[uw]; } @@ -182,8 +177,8 @@ static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs * } g_free(decrypted); - // Simulate unencrypted message - //hexchat_printf(ph, "simulating: %s\n", message->str); + /* Simulate unencrypted message */ + /* hexchat_printf(ph, "simulating: %s\n", message->str); */ hexchat_command(ph, message->str); g_string_free (message, TRUE); @@ -203,23 +198,23 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) { const char *nick; const char *key; - // Check syntax + /* Check syntax */ if (*word[2] == '\0') { hexchat_printf(ph, "%s\n", usage_setkey); return HEXCHAT_EAT_HEXCHAT; } if (*word[3] == '\0') { - // /setkey password + /* /setkey password */ nick = hexchat_get_info(ph, "channel"); key = word_eol[2]; } else { - // /setkey #channel password + /* /setkey #channel password */ nick = word[2]; key = word_eol[3]; } - // Set password + /* Set password */ if (keystore_store_key(nick, key)) { hexchat_printf(ph, "Stored key for %s\n", nick); } else { @@ -235,7 +230,7 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) { static int handle_delkey(char *word[], char *word_eol[], void *userdata) { const char *nick; - // Check syntax + /* Check syntax */ if (*word[2] == '\0' || *word[3] != '\0') { hexchat_printf(ph, "%s\n", usage_delkey); return HEXCHAT_EAT_HEXCHAT; @@ -243,7 +238,7 @@ static int handle_delkey(char *word[], char *word_eol[], void *userdata) { nick = g_strstrip (word_eol[2]); - // Delete the given nick from the key store + /* Delete the given nick from the key store */ if (keystore_delete_nick(nick)) { hexchat_printf(ph, "Deleted key for %s\n", nick); } else { @@ -286,7 +281,7 @@ int hexchat_plugin_init(hexchat_plugin *plugin_handle, hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, handle_outgoing, NULL, NULL); hexchat_hook_server_attrs(ph, "NOTICE", HEXCHAT_PRI_NORM, handle_incoming, NULL); hexchat_hook_server_attrs(ph, "PRIVMSG", HEXCHAT_PRI_NORM, handle_incoming, NULL); - //hexchat_hook_server(ph, "RAW LINE", HEXCHAT_PRI_NORM, handle_debug, NULL); + /* hexchat_hook_server(ph, "RAW LINE", HEXCHAT_PRI_NORM, handle_debug, NULL); */ hexchat_hook_server_attrs(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL); hexchat_hook_server_attrs(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL); diff --git a/plugins/python/python.c b/plugins/python/python.c index 903b2bed..cb3484ec 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -1885,7 +1885,7 @@ Module_hexchat_pluginpref_get(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:get_pluginpref", &var)) return NULL; - // This will always return numbers as integers. + /* This will always return numbers as integers. */ BEGIN_XCHAT_CALLS(NONE); result = hexchat_pluginpref_get_str(prefph, var, retstr); END_XCHAT_CALLS(); diff --git a/plugins/sysinfo/match.c b/plugins/sysinfo/match.c index 5f49ae41..cfd66e37 100644 --- a/plugins/sysinfo/match.c +++ b/plugins/sysinfo/match.c @@ -41,7 +41,7 @@ char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned lo result = g_new(char, bsize); if (total_space == 0) { - snprintf(result, bsize, "%s: none", desc); + g_snprintf(result, bsize, "%s: none", desc); return result; } quantity = quantities; @@ -52,11 +52,11 @@ char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned lo total_space = total_space / 1024; } if (sysinfo_get_percent () != 0) - snprintf(result, bsize, "%s: %.1f%s, %.1f%% free", + g_snprintf(result, bsize, "%s: %.1f%s, %.1f%% free", desc, total_space, *quantity, percentage(free_k, total_k)); else - snprintf(result, bsize, "%s: %.1f%s/%.1f%s free", + g_snprintf(result, bsize, "%s: %.1f%s/%.1f%s free", desc, free_space, *quantity, total_space, *quantity); return result; } diff --git a/plugins/sysinfo/parse.c b/plugins/sysinfo/parse.c index caba8a7d..3b210022 100644 --- a/plugins/sysinfo/parse.c +++ b/plugins/sysinfo/parse.c @@ -123,7 +123,7 @@ int xs_parse_cpu(char *model, char *vendor, double *freq, char *cache, unsigned while ((entry = readdir(dir)) != NULL) if (strncmp(entry->d_name,"SUNW,UltraSPARC",15) == 0) { - snprintf(buffer,bsize,"/proc/openprom/%s/ecache-size",entry->d_name); + g_snprintf(buffer,bsize,"/proc/openprom/%s/ecache-size",entry->d_name); fp2 = fopen(buffer, "r"); if (fp2 == NULL) break; fscanf(fp2,"%16s",cache); @@ -172,7 +172,7 @@ int xs_parse_os(char *user, char *host, char *kernel) strncpy(user, usern, bsize); strcpy(host, hostn); - snprintf(kernel, bsize, "%s %s %s", osinfo.sysname, osinfo.release, osinfo.machine); + g_snprintf(kernel, bsize, "%s %s %s", osinfo.sysname, osinfo.release, osinfo.machine); return 0; } @@ -203,9 +203,9 @@ int xs_parse_sound(char *snd_card) pos = strstr(buffer, ":"); card_id = strtoll(buffer, NULL, 0); if (card_id == 0) - snprintf(card_buf, bsize, "%s", pos+2); + g_snprintf(card_buf, bsize, "%s", pos+2); else - snprintf(card_buf, bsize, "%ld: %s", card_id, pos+2); + g_snprintf(card_buf, bsize, "%ld: %s", card_id, pos+2); pos = strstr(card_buf, "\n"); *pos = '\0'; strcat(cards, card_buf); @@ -269,11 +269,11 @@ int xs_parse_netdev(const char *device, unsigned long long *bytes_recv, unsigned fclose(fp); pos = strstr(buffer, ":"); pos++; - *bytes_recv = strtoull(pos, &pos, 0); + *bytes_recv = g_ascii_strtoull (pos, &pos, 0); - for(i=0;i<7;i++) strtoull(pos, &pos, 0); + for(i=0;i<7;i++) g_ascii_strtoull (pos, &pos, 0); - *bytes_sent = strtoull(pos, NULL, 0); + *bytes_sent = g_ascii_strtoull (pos, NULL, 0); return 0; } @@ -299,15 +299,15 @@ int xs_parse_df(const char *mount_point, char *result) for(;isspace(*pos);pos++); if(mount_point == NULL) { - total_k += strtoull(pos, &pos, 0); - strtoull(pos, &pos, 0); - free_k += strtoull(pos, &pos, 0); + total_k += g_ascii_strtoull (pos, &pos, 0); + g_ascii_strtoull(pos, &pos, 0); + free_k += g_ascii_strtoull (pos, &pos, 0); continue; } - total_k = strtoull(pos, &pos, 0); - strtoull(pos, &pos, 0); - free_k = strtoull(pos, &pos, 0); - strtoull(pos, &pos, 0); + total_k = g_ascii_strtoull (pos, &pos, 0); + g_ascii_strtoull(pos, &pos, 0); + free_k = g_ascii_strtoull (pos, &pos, 0); + g_ascii_strtoull (pos, &pos, 0); for(;isspace(*pos);pos++); for(;*pos!='/';pos++); for(i=0;*(buffer+i)!='\n';i++); @@ -327,7 +327,7 @@ int xs_parse_df(const char *mount_point, char *result) g_free(tmp_buf); break; } - else snprintf(result, bsize, "Mount point %s not found!", mount_point); + else g_snprintf(result, bsize, "Mount point %s not found!", mount_point); } if(mount_point != NULL && strncasecmp(mount_point, "ALL", 3)==0) @@ -389,9 +389,9 @@ int xs_parse_distro(char *name) find_match_char(buffer, "ACCEPT_KEYWORDS", keywords); /* cppcheck-suppress uninitvar */ if (strstr(keywords, "\"") == NULL) - snprintf(buffer, bsize, "Gentoo Linux (stable)"); + g_snprintf(buffer, bsize, "Gentoo Linux (stable)"); else - snprintf(buffer, bsize, "Gentoo Linux %s", keywords); + g_snprintf(buffer, bsize, "Gentoo Linux %s", keywords); } else if((fp = fopen("/etc/redhat-release", "r")) != NULL) fgets(buffer, bsize, fp); @@ -406,7 +406,7 @@ int xs_parse_distro(char *name) else if((fp = fopen("/etc/turbolinux-release", "r")) != NULL) fgets(buffer, bsize, fp); else if((fp = fopen("/etc/arch-release", "r")) != NULL) - snprintf(buffer, bsize, "ArchLinux"); + g_snprintf(buffer, bsize, "ArchLinux"); else if((fp = fopen("/etc/lsb-release", "r")) != NULL) { char id[bsize], codename[bsize], release[bsize]; @@ -419,16 +419,16 @@ int xs_parse_distro(char *name) find_match_char(buffer, "DISTRIB_CODENAME", codename); find_match_char(buffer, "DISTRIB_RELEASE", release); } - snprintf(buffer, bsize, "%s \"%s\" %s", id, codename, release); + g_snprintf(buffer, bsize, "%s \"%s\" %s", id, codename, release); } else if((fp = fopen("/etc/debian_version", "r")) != NULL) { char release[bsize]; fgets(release, bsize, fp); - snprintf(buffer, bsize, "Debian %s", release); + g_snprintf(buffer, bsize, "Debian %s", release); } else - snprintf(buffer, bsize, "Unknown Distro"); + g_snprintf(buffer, bsize, "Unknown Distro"); if(fp != NULL) fclose(fp); pos=strchr(buffer, '\n'); diff --git a/plugins/sysinfo/pci.c b/plugins/sysinfo/pci.c index d0f8d811..bda4888b 100644 --- a/plugins/sysinfo/pci.c +++ b/plugins/sysinfo/pci.c @@ -99,8 +99,8 @@ int pci_find_by_class(u16 *class, char *vendor, char *device) /* Acquire vendor & device ID if the class matches */ if(get_conf_word(d, PCI_CLASS_DEVICE) == *class) { nomatch = 0; - snprintf(vendor,7,"%04x",p->vendor_id); - snprintf(device,7,"%04x",p->device_id); + g_snprintf(vendor,7,"%04x",p->vendor_id); + g_snprintf(device,7,"%04x",p->device_id); break; } } @@ -122,7 +122,7 @@ void pci_find_fullname(char *fullname, char *vendor, char *device) fp = fopen (buffer, "r"); if(fp == NULL) { - snprintf(fullname, bsize, "%s:%s", vendor, device); + g_snprintf(fullname, bsize, "%s:%s", vendor, device); sysinfo_print_error ("pci.ids file not found! You might want to adjust your pciids setting with /SYSINFO SET pciids (you can query its current value with /SYSINFO LIST).\n"); return; } @@ -151,8 +151,8 @@ void pci_find_fullname(char *fullname, char *vendor, char *device) } } if (cardfound == 1) - snprintf(fullname, bsize, "%s %s", vendorname, devicename); + g_snprintf(fullname, bsize, "%s %s", vendorname, devicename); else - snprintf(fullname, bsize, "%s:%s", vendor, device); + g_snprintf(fullname, bsize, "%s:%s", vendor, device); fclose(fp); } diff --git a/plugins/sysinfo/sysinfo.cpp b/plugins/sysinfo/sysinfo.cpp index 43ab48c0..322dac17 100644 --- a/plugins/sysinfo/sysinfo.cpp +++ b/plugins/sysinfo/sysinfo.cpp @@ -155,7 +155,7 @@ getOsName (void) static char * getCpuName (void) { - // Get extended ids. + /* Get extended ids. */ unsigned int nExIds; unsigned int i; int CPUInfo[4] = {-1}; diff --git a/plugins/sysinfo/xsys.c b/plugins/sysinfo/xsys.c index 0c32b751..be38b379 100644 --- a/plugins/sysinfo/xsys.c +++ b/plugins/sysinfo/xsys.c @@ -100,7 +100,7 @@ print_summary (int announce, char* format) int seconds; sysinfo[0] = '\0'; - snprintf (buffer, bsize, "%s", hexchat_get_info (ph, "version")); + g_snprintf (buffer, bsize, "%s", hexchat_get_info (ph, "version")); format_output ("HexChat", buffer, format); strcat (sysinfo, "\017 "); strncat (sysinfo, buffer, bsize - strlen (sysinfo)); @@ -112,7 +112,7 @@ print_summary (int announce, char* format) return HEXCHAT_EAT_ALL; } - snprintf (buffer, bsize, "%s", os_kernel); + g_snprintf (buffer, bsize, "%s", os_kernel); format_output ("OS", buffer, format); strcat (sysinfo, "\017 "); strncat (sysinfo, buffer, bsize - strlen (sysinfo)); @@ -142,11 +142,11 @@ print_summary (int announce, char* format) if (giga) { - snprintf (buffer, bsize, "%u x %s (%s) @ %.2fGHz", count, cpu_model, cpu_vendor, cpu_freq); + g_snprintf (buffer, bsize, "%u x %s (%s) @ %.2fGHz", count, cpu_model, cpu_vendor, cpu_freq); } else { - snprintf (buffer, bsize, "%u x %s (%s) @ %.0fMHz", count, cpu_model, cpu_vendor, cpu_freq); + g_snprintf (buffer, bsize, "%u x %s (%s) @ %.0fMHz", count, cpu_model, cpu_vendor, cpu_freq); } format_output ("CPU", buffer, format); @@ -161,7 +161,7 @@ print_summary (int announce, char* format) } free_space = pretty_freespace ("Physical", &mem_free, &mem_total); - snprintf (buffer, bsize, "%s", free_space); + g_snprintf (buffer, bsize, "%s", free_space); g_free (free_space); format_output ("RAM", buffer, format); strcat (sysinfo, "\017 "); @@ -224,21 +224,21 @@ print_summary (int announce, char* format) { if (weeks != 0) { - snprintf (buffer, bsize, "%dw %dd %dh %dm %ds", weeks, days, hours, minutes, seconds); + g_snprintf (buffer, bsize, "%dw %dd %dh %dm %ds", weeks, days, hours, minutes, seconds); } else { - snprintf (buffer, bsize, "%dd %dh %dm %ds", days, hours, minutes, seconds); + g_snprintf (buffer, bsize, "%dd %dh %dm %ds", days, hours, minutes, seconds); } } else { - snprintf (buffer, bsize, "%dh %dm %ds", hours, minutes, seconds); + g_snprintf (buffer, bsize, "%dh %dm %ds", hours, minutes, seconds); } } else { - snprintf (buffer, bsize, "%dm %ds", minutes, seconds); + g_snprintf (buffer, bsize, "%dm %ds", minutes, seconds); } } @@ -272,7 +272,7 @@ print_os (int announce, char* format) return HEXCHAT_EAT_ALL; } - snprintf (buffer, bsize, "%s@%s, %s", user, host, kernel); + g_snprintf (buffer, bsize, "%s@%s, %s", user, host, kernel); format_output ("OS", buffer, format); if (announce) @@ -336,11 +336,11 @@ print_cpu (int announce, char* format) if (giga) { - snprintf (buffer, bsize, "%u x %s (%s) @ %.2fGHz w/ %s L2 Cache", count, model, vendor, freq, cache); + g_snprintf (buffer, bsize, "%u x %s (%s) @ %.2fGHz w/ %s L2 Cache", count, model, vendor, freq, cache); } else { - snprintf (buffer, bsize, "%u x %s (%s) @ %.0fMHz w/ %s L2 Cache", count, model, vendor, freq, cache); + g_snprintf (buffer, bsize, "%u x %s (%s) @ %.0fMHz w/ %s L2 Cache", count, model, vendor, freq, cache); } format_output ("CPU", buffer, format); @@ -377,7 +377,7 @@ print_ram (int announce, char* format) return HEXCHAT_EAT_ALL; } - snprintf (string, bsize, "%s - %s", pretty_freespace ("Physical", &mem_free, &mem_total), pretty_freespace ("Swap", &swap_free, &swap_total)); + g_snprintf (string, bsize, "%s - %s", pretty_freespace ("Physical", &mem_free, &mem_total), pretty_freespace ("Swap", &swap_free, &swap_total)); format_output ("RAM", string, format); if (announce) @@ -452,11 +452,11 @@ print_vga (int announce, char* format) if (xs_parse_agpbridge (agp_bridge) != 0) { - snprintf (buffer, bsize, "%s", vid_card); + g_snprintf (buffer, bsize, "%s", vid_card); } else { - snprintf (buffer, bsize, "%s @ %s", vid_card, agp_bridge); + g_snprintf (buffer, bsize, "%s @ %s", vid_card, agp_bridge); } format_output ("VGA", buffer, format); @@ -547,21 +547,21 @@ print_uptime (int announce, char* format) { if (weeks != 0) { - snprintf (buffer, bsize, "%dw %dd %dh %dm %ds", weeks, days, hours, minutes, seconds); + g_snprintf (buffer, bsize, "%dw %dd %dh %dm %ds", weeks, days, hours, minutes, seconds); } else { - snprintf (buffer, bsize, "%dd %dh %dm %ds", days, hours, minutes, seconds); + g_snprintf (buffer, bsize, "%dd %dh %dm %ds", days, hours, minutes, seconds); } } else { - snprintf (buffer, bsize, "%dh %dm %ds", hours, minutes, seconds); + g_snprintf (buffer, bsize, "%dh %dm %ds", hours, minutes, seconds); } } else { - snprintf (buffer, bsize, "%dm %ds", minutes, seconds); + g_snprintf (buffer, bsize, "%dm %ds", minutes, seconds); } } @@ -602,7 +602,7 @@ netdata_cb (char *word[], char *word_eol[], void *userdata) bytes_recv /= 1024; bytes_sent /= 1024; - snprintf (netdata, bsize, "%s: %.1f MB Received, %.1f MB Sent", word[2], (double)bytes_recv/1024.0, (double)bytes_sent/1024.0); + g_snprintf (netdata, bsize, "%s: %.1f MB Received, %.1f MB Sent", word[2], (double)bytes_recv/1024.0, (double)bytes_sent/1024.0); hexchat_pluginpref_get_str (ph, "format", format); format_output ("Netdata", netdata, format); @@ -658,24 +658,24 @@ netstream_cb (char *word[], char *word_eol[], void *userdata) if (bytes_recv > 1024) { bytes_recv /= 1024; - snprintf (mag_r, 5, "KB/s"); + g_snprintf (mag_r, 5, "KB/s"); } else { - snprintf (mag_r, 5, "B/s"); + g_snprintf (mag_r, 5, "B/s"); } if (bytes_sent > 1024) { bytes_sent /= 1024; - snprintf (mag_s, 5, "KB/s"); + g_snprintf (mag_s, 5, "KB/s"); } else { - snprintf (mag_s, 5, "B/s"); + g_snprintf (mag_s, 5, "B/s"); } - snprintf (netstream, bsize, "%s: Receiving %llu %s, Sending %llu %s", word[2], bytes_recv, mag_r, bytes_sent, mag_s); + g_snprintf (netstream, bsize, "%s: Receiving %llu %s, Sending %llu %s", word[2], bytes_recv, mag_r, bytes_sent, mag_s); hexchat_pluginpref_get_str (ph, "format", format); format_output ("Netstream", netstream, format); diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 4dc03f35..54694452 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -220,7 +220,7 @@ cfg_put_str (int fh, char *var, char *value) char buf[512]; int len; - snprintf (buf, sizeof buf, "%s = %s\n", var, value); + g_snprintf (buf, sizeof buf, "%s = %s\n", var, value); len = strlen (buf); return (write (fh, buf, len) == len); } @@ -231,7 +231,7 @@ cfg_put_color (int fh, int r, int g, int b, char *var) char buf[400]; int len; - snprintf (buf, sizeof buf, "%s = %04x %04x %04x\n", var, r, g, b); + g_snprintf (buf, sizeof buf, "%s = %04x %04x %04x\n", var, r, g, b); len = strlen (buf); return (write (fh, buf, len) == len); } @@ -245,7 +245,7 @@ cfg_put_int (int fh, int value, char *var) if (value == -1) value = 1; - snprintf (buf, sizeof buf, "%s = %d\n", var, value); + g_snprintf (buf, sizeof buf, "%s = %d\n", var, value); len = strlen (buf); return (write (fh, buf, len) == len); } @@ -843,7 +843,7 @@ load_default_config(void) #ifdef WIN32 if (portable_mode () || SHGetKnownFolderPath (&FOLDERID_Downloads, 0, NULL, &roaming_path_wide) != S_OK) { - snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\downloads", get_xdir ()); + g_snprintf (prefs.hex_dcc_dir, sizeof (prefs.hex_dcc_dir), "%s\\downloads", get_xdir ()); } else { diff --git a/src/common/chanopt.c b/src/common/chanopt.c index 0a286da5..7bd66b4a 100644 --- a/src/common/chanopt.c +++ b/src/common/chanopt.c @@ -368,10 +368,10 @@ chanopt_save_one_channel (chanopt_in_memory *co, int fh) char buf[256]; guint8 val; - snprintf (buf, sizeof (buf), "%s = %s\n", "network", co->network); + g_snprintf (buf, sizeof (buf), "%s = %s\n", "network", co->network); write (fh, buf, strlen (buf)); - snprintf (buf, sizeof (buf), "%s = %s\n", "channel", co->channel); + g_snprintf (buf, sizeof (buf), "%s = %s\n", "channel", co->channel); write (fh, buf, strlen (buf)); i = 0; @@ -380,7 +380,7 @@ chanopt_save_one_channel (chanopt_in_memory *co, int fh) val = G_STRUCT_MEMBER (guint8, co, chanopt[i].offset); if (val != SET_DEFAULT) { - snprintf (buf, sizeof (buf), "%s = %d\n", chanopt[i].name, val); + g_snprintf (buf, sizeof (buf), "%s = %d\n", chanopt[i].name, val); write (fh, buf, strlen (buf)); } i++; diff --git a/src/common/ctcp.c b/src/common/ctcp.c index 44b96e18..bf0a8e7f 100644 --- a/src/common/ctcp.c +++ b/src/common/ctcp.c @@ -139,10 +139,10 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.hex_irc_hide_version) { #ifdef WIN32 - snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" [x%d] / %s", + g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" [x%d] / %s", get_cpu_arch (), get_sys_str (1)); #else - snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" / %s", + g_snprintf (outbuf, sizeof (outbuf), "VERSION HexChat "PACKAGE_VERSION" / %s", get_sys_str (1)); #endif serv->p_nctcp (serv, nick, outbuf); diff --git a/src/common/dbus/dbus-client.c b/src/common/dbus/dbus-client.c index dd2d5ebe..bbbe10e8 100644 --- a/src/common/dbus/dbus-client.c +++ b/src/common/dbus/dbus-client.c @@ -93,7 +93,7 @@ hexchat_remote (void) g_object_unref (dbus); if (!hexchat_running) { - //dbus_g_connection_unref (connection); + /* dbus_g_connection_unref (connection); */ return; } diff --git a/src/common/dcc.c b/src/common/dcc.c index 7ae6372b..8c6396b3 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -705,7 +705,7 @@ dcc_read (GIOChannel *source, GIOCondition condition, struct DCC *dcc) do { n++; - snprintf (buf, sizeof (buf), "%s.%d", dcc->destfile, n); + g_snprintf (buf, sizeof (buf), "%s.%d", dcc->destfile, n); } while (g_access (buf, F_OK) == 0); @@ -865,7 +865,7 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc return TRUE; dcc->dccstat = STAT_ACTIVE; - snprintf (host, sizeof host, "%s:%d", net_ip (dcc->addr), dcc->port); + g_snprintf (host, sizeof host, "%s:%d", net_ip (dcc->addr), dcc->port); switch (dcc->type) { @@ -984,7 +984,7 @@ dcc_wingate_proxy_traverse (GIOChannel *source, GIOCondition condition, struct D struct proxy_state *proxy = dcc->proxy; if (proxy->phase == 0) { - proxy->buffersize = snprintf ((char*) proxy->buffer, MAX_PROXY_BUFFER, + proxy->buffersize = g_snprintf ((char*) proxy->buffer, MAX_PROXY_BUFFER, "%s %d\r\n", net_ip(dcc->addr), dcc->port); proxy->bufferused = 0; @@ -1282,16 +1282,16 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC char auth_data2[68]; int n, n2; - n = snprintf (buf, sizeof (buf), "CONNECT %s:%d HTTP/1.0\r\n", + n = g_snprintf (buf, sizeof (buf), "CONNECT %s:%d HTTP/1.0\r\n", net_ip(dcc->addr), dcc->port); if (prefs.hex_net_proxy_auth) { - n2 = snprintf (auth_data2, sizeof (auth_data2), "%s:%s", + n2 = g_snprintf (auth_data2, sizeof (auth_data2), "%s:%s", prefs.hex_net_proxy_user, prefs.hex_net_proxy_pass); base64_encode (auth_data, auth_data2, n2); - n += snprintf (buf+n, sizeof (buf)-n, "Proxy-Authorization: Basic %s\r\n", auth_data); + n += g_snprintf (buf+n, sizeof (buf)-n, "Proxy-Authorization: Basic %s\r\n", auth_data); } - n += snprintf (buf+n, sizeof (buf)-n, "\r\n"); + n += g_snprintf (buf+n, sizeof (buf)-n, "\r\n"); proxy->buffersize = n; proxy->bufferused = 0; memcpy (proxy->buffer, buf, proxy->buffersize); @@ -1402,12 +1402,12 @@ dcc_connect (struct DCC *dcc) } /* possible problems with filenames containing spaces? */ if (dcc->type == TYPE_RECV) - snprintf (tbuf, sizeof (tbuf), strchr (dcc->file, ' ') ? + g_snprintf (tbuf, sizeof (tbuf), strchr (dcc->file, ' ') ? "DCC SEND \"%s\" %u %d %" G_GUINT64_FORMAT " %d" : "DCC SEND %s %u %d %" G_GUINT64_FORMAT " %d", dcc->file, dcc->addr, dcc->port, dcc->size, dcc->pasvid); else - snprintf (tbuf, sizeof (tbuf), "DCC CHAT chat %u %d %d", + g_snprintf (tbuf, sizeof (tbuf), "DCC CHAT chat %u %d %d", dcc->addr, dcc->port, dcc->pasvid); dcc->serv->p_ctcp (dcc->serv, dcc->nick, tbuf); } @@ -1605,7 +1605,7 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc) dcc->lasttime = dcc->starttime = time (0); dcc->fastsend = prefs.hex_dcc_fast_send; - snprintf (host, sizeof (host), "%s:%d", net_ip (dcc->addr), dcc->port); + g_snprintf (host, sizeof (host), "%s:%d", net_ip (dcc->addr), dcc->port); switch (dcc->type) { @@ -1898,7 +1898,7 @@ dcc_send (struct session *sess, char *to, char *filename, gint64 maxcps, int pas if (passive) { dcc->pasvid = new_id(); - snprintf (outbuf, sizeof (outbuf), (havespaces) ? + g_snprintf (outbuf, sizeof (outbuf), (havespaces) ? "DCC SEND \"%s\" 199 0 %" G_GUINT64_FORMAT " %d" : "DCC SEND %s 199 0 %" G_GUINT64_FORMAT " %d", file_part (dcc->file), @@ -1906,7 +1906,7 @@ dcc_send (struct session *sess, char *to, char *filename, gint64 maxcps, int pas } else { - snprintf (outbuf, sizeof (outbuf), (havespaces) ? + g_snprintf (outbuf, sizeof (outbuf), (havespaces) ? "DCC SEND \"%s\" %u %d %" G_GUINT64_FORMAT : "DCC SEND %s %u %d %" G_GUINT64_FORMAT, file_part (dcc->file), dcc->addr, @@ -2309,11 +2309,11 @@ dcc_chat (struct session *sess, char *nick, int passive) if (passive) { dcc->pasvid = new_id (); - snprintf (outbuf, sizeof (outbuf), "DCC CHAT chat 199 %d %d", + g_snprintf (outbuf, sizeof (outbuf), "DCC CHAT chat 199 %d %d", dcc->port, dcc->pasvid); } else { - snprintf (outbuf, sizeof (outbuf), "DCC CHAT chat %u %d", + g_snprintf (outbuf, sizeof (outbuf), "DCC CHAT chat %u %d", dcc->addr, dcc->port); } dcc->serv->p_ctcp (dcc->serv, nick, outbuf); @@ -2339,7 +2339,7 @@ dcc_resume (struct DCC *dcc) { dcc->resume_sent = 1; /* filename contains spaces? Quote them! */ - snprintf (tbuf, sizeof (tbuf) - 10, strchr (dcc->file, ' ') ? + g_snprintf (tbuf, sizeof (tbuf) - 10, strchr (dcc->file, ' ') ? "DCC RESUME \"%s\" %d %" G_GUINT64_FORMAT : "DCC RESUME %s %d %" G_GUINT64_FORMAT, dcc->file, dcc->port, dcc->resumable); @@ -2416,7 +2416,7 @@ dcc_add_chat (session *sess, char *nick, int port, guint32 addr, int pasvid) else { char buff[128]; - snprintf (buff, sizeof (buff), "%s is offering DCC Chat. Do you want to accept?", nick); + g_snprintf (buff, sizeof (buff), "%s is offering DCC Chat. Do you want to accept?", nick); fe_confirm (buff, dcc_confirm_chat, dcc_deny_chat, dcc); } } @@ -2475,7 +2475,7 @@ dcc_add_file (session *sess, char *file, guint64 size, int port, char *nick, gui if (prefs.hex_dcc_auto_recv == 1) { - snprintf (tbuf, sizeof (tbuf), _("%s is offering \"%s\". Do you want to accept?"), nick, file); + g_snprintf (tbuf, sizeof (tbuf), _("%s is offering \"%s\". Do you want to accept?"), nick, file); fe_confirm (tbuf, dcc_confirm_send, dcc_deny_send, dcc); } else if (prefs.hex_dcc_auto_recv == 2) @@ -2490,7 +2490,7 @@ dcc_add_file (session *sess, char *file, guint64 size, int port, char *nick, gui fe_dcc_add (dcc); } sprintf (tbuf, "%" G_GUINT64_FORMAT, size); - snprintf (tbuf + 24, 300, "%s:%d", net_ip (addr), port); + g_snprintf (tbuf + 24, 300, "%s:%d", net_ip (addr), port); EMIT_SIGNAL (XP_TE_DCCSENDOFFER, sess->server->front_session, nick, file, tbuf, tbuf + 24, 0); @@ -2582,12 +2582,12 @@ handle_dcc (struct session *sess, char *nick, char *word[], char *word_eol[], /* Checking if dcc is passive and if filename contains spaces */ if (dcc->pasvid) - snprintf (tbuf, sizeof (tbuf), strchr (file_part (dcc->file), ' ') ? + g_snprintf (tbuf, sizeof (tbuf), strchr (file_part (dcc->file), ' ') ? "DCC ACCEPT \"%s\" %d %" G_GUINT64_FORMAT " %d" : "DCC ACCEPT %s %d %" G_GUINT64_FORMAT " %d", file_part (dcc->file), port, dcc->resumable, dcc->pasvid); else - snprintf (tbuf, sizeof (tbuf), strchr (file_part (dcc->file), ' ') ? + g_snprintf (tbuf, sizeof (tbuf), strchr (file_part (dcc->file), ' ') ? "DCC ACCEPT \"%s\" %d %" G_GUINT64_FORMAT : "DCC ACCEPT %s %d %" G_GUINT64_FORMAT, file_part (dcc->file), port, dcc->resumable); diff --git a/src/common/hexchat.c b/src/common/hexchat.c index f8be5a84..767d60ed 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -280,7 +280,7 @@ lag_check (void) } else { - snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); + g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); serv->p_ping (serv, "", tbuf); if (!serv->lag_sent) @@ -821,7 +821,7 @@ xchat_init (void) notify_load (); ignore_load (); - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), "NAME %s~%s~\n" "CMD query %%s\n\n"\ "NAME %s~%s~\n" "CMD send %%s\n\n"\ "NAME %s~%s~\n" "CMD whois %%s %%s\n\n"\ @@ -877,7 +877,7 @@ xchat_init (void) list_loadconf ("popup.conf", &popup_list, buf); - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), "NAME %s\n" "CMD part\n\n" "NAME %s\n" "CMD getstr # join \"%s\"\n\n" "NAME %s\n" "CMD quote LINKS\n\n" @@ -891,7 +891,7 @@ xchat_init (void) _("Hide Version")); list_loadconf ("usermenu.conf", &usermenu_list, buf); - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), "NAME %s\n" "CMD op %%a\n\n" "NAME %s\n" "CMD deop %%a\n\n" "NAME %s\n" "CMD ban %%s\n\n" @@ -908,7 +908,7 @@ xchat_init (void) _("Dialog")); list_loadconf ("buttons.conf", &button_list, buf); - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), "NAME %s\n" "CMD whois %%s %%s\n\n" "NAME %s\n" "CMD send %%s\n\n" "NAME %s\n" "CMD dcc chat %%s\n\n" diff --git a/src/common/hexchat.h b/src/common/hexchat.h index ef05b4f4..efac3f22 100644 --- a/src/common/hexchat.h +++ b/src/common/hexchat.h @@ -38,14 +38,6 @@ #include "history.h" -#ifndef HAVE_SNPRINTF -#define snprintf g_snprintf -#endif - -#ifndef HAVE_VSNPRINTF -#define vsnprintf _vsnprintf -#endif - #ifdef SOCKS #ifdef __sgi #include diff --git a/src/common/identd.c b/src/common/identd.c index cbe6ff5e..ae95df8d 100644 --- a/src/common/identd.c +++ b/src/common/identd.c @@ -82,7 +82,7 @@ identd (char *username) EMIT_SIGNAL (XP_TE_IDENTD, current_sess, inet_ntoa (addr.sin_addr), username, NULL, NULL, 0); #endif inet_ntop (AF_INET, &addr.sin_addr, ipbuf, sizeof (ipbuf)); - snprintf (outbuf, sizeof (outbuf), "*\tServicing ident request from %s as %s\n", ipbuf, username); + g_snprintf (outbuf, sizeof (outbuf), "*\tServicing ident request from %s as %s\n", ipbuf, username); PrintText (current_sess, outbuf); recv (read_sok, buf, sizeof (buf) - 1, 0); @@ -91,7 +91,7 @@ identd (char *username) p = strchr (buf, ','); if (p) { - snprintf (outbuf, sizeof (outbuf) - 1, "%d, %d : USERID : UNIX : %s\r\n", + g_snprintf (outbuf, sizeof (outbuf) - 1, "%d, %d : USERID : UNIX : %s\r\n", atoi (buf), atoi (p + 1), username); outbuf[sizeof (outbuf) - 1] = 0; /* ensure null termination */ send (read_sok, outbuf, strlen (outbuf), 0); @@ -155,7 +155,7 @@ identd_ipv6 (char *username) identd_ipv6_is_running = FALSE; inet_ntop (AF_INET6, &addr.sin6_addr, ipbuf, sizeof (ipbuf)); - snprintf (outbuf, sizeof (outbuf), "*\tServicing ident request from %s as %s\n", ipbuf, username); + g_snprintf (outbuf, sizeof (outbuf), "*\tServicing ident request from %s as %s\n", ipbuf, username); PrintText (current_sess, outbuf); recv (read_sok, buf, sizeof (buf) - 1, 0); @@ -164,7 +164,7 @@ identd_ipv6 (char *username) p = strchr (buf, ','); if (p) { - snprintf (outbuf, sizeof (outbuf) - 1, "%d, %d : USERID : UNIX : %s\r\n", atoi (buf), atoi (p + 1), username); + g_snprintf (outbuf, sizeof (outbuf) - 1, "%d, %d : USERID : UNIX : %s\r\n", atoi (buf), atoi (p + 1), username); outbuf[sizeof (outbuf) - 1] = 0; /* ensure null termination */ send (read_sok, outbuf, strlen (outbuf), 0); } diff --git a/src/common/ignore.c b/src/common/ignore.c index bfc6cf93..6085b657 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -122,7 +122,7 @@ ignore_showlist (session *sess) ig = list->data; i++; - snprintf (tbuf, sizeof (tbuf), " %-25s ", ig->mask); + g_snprintf (tbuf, sizeof (tbuf), " %-25s ", ig->mask); if (ig->type & IG_PRIV) strcat (tbuf, _("YES ")); else @@ -319,7 +319,7 @@ ignore_save () ig = (struct ignore *) temp->data; if (!(ig->type & IG_NOSAVE)) { - snprintf (buf, sizeof (buf), "mask = %s\ntype = %u\n\n", + g_snprintf (buf, sizeof (buf), "mask = %s\ntype = %u\n\n", ig->mask, ig->type); write (fh, buf, strlen (buf)); } @@ -372,9 +372,9 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct for (i = 0; i < 128; i++) if (ip[i] == '@') break; - snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]); + g_snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]); - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), _("You are being CTCP flooded from %s, ignoring %s\n"), nick, real_ip); PrintText (sess, buf); @@ -399,7 +399,7 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct serv->msg_counter++; if (serv->msg_counter == prefs.hex_flood_msg_num) /*if we reached the maximun numbers of ctcp in the seconds limits */ { - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), _("You are being MSG flooded from %s, setting gui_autoopen_dialog OFF.\n"), ip); PrintText (sess, buf); diff --git a/src/common/inbound.c b/src/common/inbound.c index a3b1b7da..720c7e9b 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -184,7 +184,7 @@ inbound_privmsg (server *serv, char *from, char *ip, char *text, int id, (!sess->topic || strcmp(sess->topic, ip))) { char tbuf[1024]; - snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", from, ip); + g_snprintf (tbuf, sizeof (tbuf), "[%s has address %s]\n", from, ip); write (sess->logfd, tbuf, strlen (tbuf)); } set_topic (sess, ip, ip); @@ -914,7 +914,7 @@ inbound_ping_reply (session *sess, char *timestring, char *from, tags_data->timestamp); } else { - snprintf (outbuf, sizeof (outbuf), "%ld.%03ld", dif / 1000, dif % 1000); + g_snprintf (outbuf, sizeof (outbuf), "%ld.%03ld", dif / 1000, dif % 1000); EMIT_SIGNAL_TIMESTAMP (XP_TE_PINGREP, sess, from, outbuf, NULL, NULL, 0, tags_data->timestamp); } diff --git a/src/common/notify.c b/src/common/notify.c index 9b604d4b..b7c56573 100644 --- a/src/common/notify.c +++ b/src/common/notify.c @@ -341,9 +341,9 @@ notify_watch (server * serv, char *nick, int add) addchar = '-'; if (serv->supports_monitor) - snprintf (tbuf, sizeof (tbuf), "MONITOR %c %s", addchar, nick); + g_snprintf (tbuf, sizeof (tbuf), "MONITOR %c %s", addchar, nick); else if (serv->supports_watch) - snprintf (tbuf, sizeof (tbuf), "WATCH %c%s", addchar, nick); + g_snprintf (tbuf, sizeof (tbuf), "WATCH %c%s", addchar, nick); else return; @@ -556,9 +556,9 @@ notify_showlist (struct session *sess, const message_tags_data *tags_data) notify = (struct notify *) list->data; servnot = notify_find_server_entry (notify, sess->server); if (servnot && servnot->ison) - snprintf (outbuf, sizeof (outbuf), _(" %-20s online\n"), notify->name); + g_snprintf (outbuf, sizeof (outbuf), _(" %-20s online\n"), notify->name); else - snprintf (outbuf, sizeof (outbuf), _(" %-20s offline\n"), notify->name); + g_snprintf (outbuf, sizeof (outbuf), _(" %-20s offline\n"), notify->name); PrintTextTimeStamp (sess, outbuf, tags_data->timestamp); list = list->next; } diff --git a/src/common/outbound.c b/src/common/outbound.c index 7cbf84ad..fe62bc2a 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -481,19 +481,19 @@ create_mask (session * sess, char *mask, char *mode, char *typestr, int deop) switch (type) { case 0: - snprintf (buf, sizeof (buf), "%s %s *!*@%s.*", mode, p2, domain); + g_snprintf (buf, sizeof (buf), "%s %s *!*@%s.*", mode, p2, domain); break; case 1: - snprintf (buf, sizeof (buf), "%s %s *!*@%s", mode, p2, fullhost); + g_snprintf (buf, sizeof (buf), "%s %s *!*@%s", mode, p2, fullhost); break; case 2: - snprintf (buf, sizeof (buf), "%s %s *!%s@%s.*", mode, p2, username, domain); + g_snprintf (buf, sizeof (buf), "%s %s *!%s@%s.*", mode, p2, username, domain); break; case 3: - snprintf (buf, sizeof (buf), "%s %s *!%s@%s", mode, p2, username, fullhost); + g_snprintf (buf, sizeof (buf), "%s %s *!%s@%s", mode, p2, username, fullhost); break; } } else @@ -501,26 +501,26 @@ create_mask (session * sess, char *mask, char *mode, char *typestr, int deop) switch (type) { case 0: - snprintf (buf, sizeof (buf), "%s %s *!*@*%s", mode, p2, domain); + g_snprintf (buf, sizeof (buf), "%s %s *!*@*%s", mode, p2, domain); break; case 1: - snprintf (buf, sizeof (buf), "%s %s *!*@%s", mode, p2, fullhost); + g_snprintf (buf, sizeof (buf), "%s %s *!*@%s", mode, p2, fullhost); break; case 2: - snprintf (buf, sizeof (buf), "%s %s *!%s@*%s", mode, p2, username, domain); + g_snprintf (buf, sizeof (buf), "%s %s *!%s@*%s", mode, p2, username, domain); break; case 3: - snprintf (buf, sizeof (buf), "%s %s *!%s@%s", mode, p2, username, fullhost); + g_snprintf (buf, sizeof (buf), "%s %s *!%s@%s", mode, p2, username, fullhost); break; } } } else { - snprintf (buf, sizeof (buf), "%s %s", mode, mask); + g_snprintf (buf, sizeof (buf), "%s %s", mode, mask); } return g_strdup (buf); @@ -1108,9 +1108,9 @@ menu_del_children (char *path, char *label) if (!label) label = ""; if (path[0]) - snprintf (buf, sizeof (buf), "%s/%s", path, label); + g_snprintf (buf, sizeof (buf), "%s/%s", path, label); else - snprintf (buf, sizeof (buf), "%s", label); + g_snprintf (buf, sizeof (buf), "%s", label); list = menu_list; while (list) @@ -1929,7 +1929,7 @@ get_bool_cb (int val, getvalinfo *info) { char buf[512]; - snprintf (buf, sizeof (buf), "%s %d", info->cmd, val); + g_snprintf (buf, sizeof (buf), "%s %d", info->cmd, val); if (is_session (info->sess)) handle_command (info->sess, buf, FALSE); @@ -1961,7 +1961,7 @@ get_int_cb (int cancel, int val, getvalinfo *info) if (!cancel) { - snprintf (buf, sizeof (buf), "%s %d", info->cmd, val); + g_snprintf (buf, sizeof (buf), "%s %d", info->cmd, val); if (is_session (info->sess)) handle_command (info->sess, buf, FALSE); } @@ -1996,7 +1996,7 @@ get_file_cb (char *cmd, char *file) no args */ if (file) { - snprintf (buf, sizeof (buf), "%s %s", cmd, file); + g_snprintf (buf, sizeof (buf), "%s %s", cmd, file); handle_command (current_sess, buf, FALSE); } else @@ -2045,7 +2045,7 @@ get_str_cb (int cancel, char *val, getvalinfo *info) if (!cancel) { - snprintf (buf, sizeof (buf), "%s %s", info->cmd, val); + g_snprintf (buf, sizeof (buf), "%s %s", info->cmd, val); if (is_session (info->sess)) handle_command (info->sess, buf, FALSE); } @@ -2282,7 +2282,7 @@ cmd_ignore (struct session *sess, char *tbuf, char *word[], char *word_eol[]) strchr (mask, '*') == NULL) { mask = tbuf; - snprintf (tbuf, TBUFSIZE, "%s!*@*", word[2]); + g_snprintf (tbuf, TBUFSIZE, "%s!*@*", word[2]); } i = ignore_add (mask, type, TRUE); @@ -2640,7 +2640,7 @@ cmd_me (struct session *sess, char *tbuf, char *word[], char *word_eol[]) return TRUE; } - snprintf (tbuf, TBUFSIZE, "\001ACTION %s\001\r", act); + g_snprintf (tbuf, TBUFSIZE, "\001ACTION %s\001\r", act); /* first try through DCC CHAT */ if (dcc_write_chat (sess->channel, tbuf)) { @@ -2980,7 +2980,7 @@ cmd_ping (struct session *sess, char *tbuf, char *word[], char *word_eol[]) tim = make_ping_time (); - snprintf (timestring, sizeof (timestring), "%lu", tim); + g_snprintf (timestring, sizeof (timestring), "%lu", tim); sess->server->p_ping (sess->server, to, timestring); return TRUE; @@ -3220,9 +3220,9 @@ cmd_send (struct session *sess, char *tbuf, char *word[], char *word_eol[]) if ((addr & 0xffff0000) == 0xc0a80000 || /* 192.168.x.x */ (addr & 0xff000000) == 0x0a000000) /* 10.x.x.x */ /* we got a private net address, let's PSEND or it'll fail */ - snprintf (tbuf, 512, "DCC PSEND %s", word_eol[2]); + g_snprintf (tbuf, 512, "DCC PSEND %s", word_eol[2]); else - snprintf (tbuf, 512, "DCC SEND %s", word_eol[2]); + g_snprintf (tbuf, 512, "DCC SEND %s", word_eol[2]); handle_command (sess, tbuf, FALSE); @@ -3522,7 +3522,7 @@ cmd_unignore (struct session *sess, char *tbuf, char *word[], if (strchr (mask, '?') == NULL && strchr (mask, '*') == NULL) { mask = tbuf; - snprintf (tbuf, TBUFSIZE, "%s!*@*", word[2]); + g_snprintf (tbuf, TBUFSIZE, "%s!*@*", word[2]); } if (ignore_del (mask, NULL)) @@ -4085,7 +4085,7 @@ usercommand_show_help (session *sess, char *name) pop = (struct popup *) list->data; if (!g_ascii_strcasecmp (pop->name, name)) { - snprintf (buf, sizeof(buf), _("User Command for: %s\n"), pop->cmd); + g_snprintf (buf, sizeof(buf), _("User Command for: %s\n"), pop->cmd); PrintText (sess, buf); found = TRUE; @@ -4112,7 +4112,7 @@ help (session *sess, char *tbuf, char *helpcmd, int quiet) { if (cmd->help) { - snprintf (tbuf, TBUFSIZE, _("Usage: %s\n"), _(cmd->help)); + g_snprintf (tbuf, TBUFSIZE, _("Usage: %s\n"), _(cmd->help)); PrintText (sess, tbuf); } else { @@ -4241,7 +4241,7 @@ auto_insert (char *dest, gsize destlen, unsigned char *src, char *word[], case 'y': now = time (0); tm_ptr = localtime (&now); - snprintf (buf, sizeof (buf), "%4d%02d%02d", 1900 + + g_snprintf (buf, sizeof (buf), "%4d%02d%02d", 1900 + tm_ptr->tm_year, 1 + tm_ptr->tm_mon, tm_ptr->tm_mday); utf = buf; break; @@ -4394,7 +4394,7 @@ nick_comp_cb (struct User *user, nickdata *data) lenu = strlen (user->nick); if (lenu == data->len) { - snprintf (data->tbuf, TBUFSIZE, "%s%s", user->nick, data->space); + g_snprintf (data->tbuf, TBUFSIZE, "%s%s", user->nick, data->space); data->len = -1; return FALSE; } else if (lenu < data->bestlen) @@ -4438,7 +4438,7 @@ perform_nick_completion (struct session *sess, char *cmd, char *tbuf) if (data.best) { - snprintf (tbuf, TBUFSIZE, "%s%s", data.best->nick, space - 1); + g_snprintf (tbuf, TBUFSIZE, "%s%s", data.best->nick, space - 1); return; } } diff --git a/src/common/plugin.c b/src/common/plugin.c index 1b4a38fd..bdb11bb8 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -1926,7 +1926,7 @@ hexchat_pluginpref_set_int (hexchat_plugin *pl, const char *var, int value) { char buffer[12]; - snprintf (buffer, sizeof (buffer), "%d", value); + g_snprintf (buffer, sizeof (buffer), "%d", value); return hexchat_pluginpref_set_str_real (pl, var, buffer, 1); } diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index d3adef86..f6b7cd9f 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -429,7 +429,7 @@ irc_raw (server *serv, char *raw) len = strlen (raw); if (len < sizeof (tbuf) - 3) { - len = snprintf (tbuf, sizeof (tbuf), "%s\r\n", raw); + len = g_snprintf (tbuf, sizeof (tbuf), "%s\r\n", raw); tcp_send_len (serv, tbuf, len); } else { @@ -590,7 +590,7 @@ process_numeric (session * sess, int n, char *tim; char outbuf[64]; - snprintf (outbuf, sizeof (outbuf), + g_snprintf (outbuf, sizeof (outbuf), "%02ld:%02ld:%02ld", idle / 3600, (idle / 60) % 60, idle % 60); if (timestamp == 0) diff --git a/src/common/server.c b/src/common/server.c index 87ead792..c10b0a3c 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -281,7 +281,7 @@ tcp_sendf (server *serv, const char *fmt, ...) int len; va_start (args, fmt); - len = vsnprintf (send_buf, sizeof (send_buf) - 1, fmt, args); + len = g_vsnprintf (send_buf, sizeof (send_buf) - 1, fmt, args); va_end (args); send_buf[sizeof (send_buf) - 1] = '\0'; @@ -591,7 +591,7 @@ ssl_cb_info (SSL * s, int where, int ret) return; /* FIXME: make debug level adjustable in serverlist or settings */ -/* snprintf (buf, sizeof (buf), "%s (%d)", SSL_state_string_long (s), where); +/* g_snprintf (buf, sizeof (buf), "%s (%d)", SSL_state_string_long (s), where); if (g_sess) EMIT_SIGNAL (XP_TE_SSLMESSAGE, g_sess, buf, NULL, NULL, NULL, 0); else @@ -611,9 +611,9 @@ ssl_cb_verify (int ok, X509_STORE_CTX * ctx) X509_NAME_oneline (X509_get_issuer_name (ctx->current_cert), issuer, sizeof (issuer)); - snprintf (buf, sizeof (buf), "* Subject: %s", subject); + g_snprintf (buf, sizeof (buf), "* Subject: %s", subject); EMIT_SIGNAL (XP_TE_SSLMESSAGE, g_sess, buf, NULL, NULL, NULL, 0); - snprintf (buf, sizeof (buf), "* Issuer: %s", issuer); + g_snprintf (buf, sizeof (buf), "* Issuer: %s", issuer); EMIT_SIGNAL (XP_TE_SSLMESSAGE, g_sess, buf, NULL, NULL, NULL, 0); return (TRUE); /* always ok */ @@ -634,7 +634,7 @@ ssl_do_connect (server * serv) if ((err = ERR_get_error ()) > 0) { ERR_error_string (err, err_buf); - snprintf (buf, sizeof (buf), "(%d) %s", err, err_buf); + g_snprintf (buf, sizeof (buf), "(%d) %s", err, err_buf); EMIT_SIGNAL (XP_TE_CONNFAIL, serv->server_session, buf, NULL, NULL, NULL, 0); @@ -660,59 +660,59 @@ ssl_do_connect (server * serv) if (!_SSL_get_cert_info (&cert_info, serv->ssl)) { - snprintf (buf, sizeof (buf), "* Certification info:"); + g_snprintf (buf, sizeof (buf), "* Certification info:"); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); - snprintf (buf, sizeof (buf), " Subject:"); + g_snprintf (buf, sizeof (buf), " Subject:"); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); for (i = 0; cert_info.subject_word[i]; i++) { - snprintf (buf, sizeof (buf), " %s", cert_info.subject_word[i]); + g_snprintf (buf, sizeof (buf), " %s", cert_info.subject_word[i]); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); } - snprintf (buf, sizeof (buf), " Issuer:"); + g_snprintf (buf, sizeof (buf), " Issuer:"); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); for (i = 0; cert_info.issuer_word[i]; i++) { - snprintf (buf, sizeof (buf), " %s", cert_info.issuer_word[i]); + g_snprintf (buf, sizeof (buf), " %s", cert_info.issuer_word[i]); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); } - snprintf (buf, sizeof (buf), " Public key algorithm: %s (%d bits)", + g_snprintf (buf, sizeof (buf), " Public key algorithm: %s (%d bits)", cert_info.algorithm, cert_info.algorithm_bits); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); /*if (cert_info.rsa_tmp_bits) { - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), " Public key algorithm uses ephemeral key with %d bits", cert_info.rsa_tmp_bits); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); }*/ - snprintf (buf, sizeof (buf), " Sign algorithm %s", + g_snprintf (buf, sizeof (buf), " Sign algorithm %s", cert_info.sign_algorithm/*, cert_info.sign_algorithm_bits*/); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); - snprintf (buf, sizeof (buf), " Valid since %s to %s", + g_snprintf (buf, sizeof (buf), " Valid since %s to %s", cert_info.notbefore, cert_info.notafter); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); } else { - snprintf (buf, sizeof (buf), " * No Certificate"); + g_snprintf (buf, sizeof (buf), " * No Certificate"); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); } chiper_info = _SSL_get_cipher_info (serv->ssl); /* static buffer */ - snprintf (buf, sizeof (buf), "* Cipher info:"); + g_snprintf (buf, sizeof (buf), "* Cipher info:"); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); - snprintf (buf, sizeof (buf), " Version: %s, cipher %s (%u bits)", + g_snprintf (buf, sizeof (buf), " Version: %s, cipher %s (%u bits)", chiper_info->version, chiper_info->chiper, chiper_info->chiper_bits); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, @@ -727,7 +727,7 @@ ssl_do_connect (server * serv) int hostname_err; if ((hostname_err = _SSL_check_hostname(cert, serv->hostname)) != 0) { - snprintf (buf, sizeof (buf), "* Verify E: Failed to validate hostname? (%d)%s", + g_snprintf (buf, sizeof (buf), "* Verify E: Failed to validate hostname? (%d)%s", hostname_err, serv->accept_invalid_cert ? " -- Ignored" : ""); if (serv->accept_invalid_cert) EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); @@ -736,7 +736,7 @@ ssl_do_connect (server * serv) } break; } - /* snprintf (buf, sizeof (buf), "* Verify OK (?)"); */ + /* g_snprintf (buf, sizeof (buf), "* Verify OK (?)"); */ /* EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); */ case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: @@ -745,7 +745,7 @@ ssl_do_connect (server * serv) case X509_V_ERR_CERT_HAS_EXPIRED: if (serv->accept_invalid_cert) { - snprintf (buf, sizeof (buf), "* Verify E: %s.? (%d) -- Ignored", + g_snprintf (buf, sizeof (buf), "* Verify E: %s.? (%d) -- Ignored", X509_verify_cert_error_string (verify_error), verify_error); EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, @@ -753,7 +753,7 @@ ssl_do_connect (server * serv) break; } default: - snprintf (buf, sizeof (buf), "%s.? (%d)", + g_snprintf (buf, sizeof (buf), "%s.? (%d)", X509_verify_cert_error_string (verify_error), verify_error); conn_fail: @@ -775,7 +775,7 @@ conn_fail: { if (serv->ssl->session && serv->ssl->session->time + SSLTMOUT < time (NULL)) { - snprintf (buf, sizeof (buf), "SSL handshake timed out"); + g_snprintf (buf, sizeof (buf), "SSL handshake timed out"); EMIT_SIGNAL (XP_TE_CONNFAIL, serv->server_session, buf, NULL, NULL, NULL, 0); server_cleanup (serv); /* ->connecting = FALSE */ @@ -970,11 +970,11 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv) } } #else - snprintf (outbuf, sizeof (outbuf), "%s/auth/xchat_auth", + g_snprintf (outbuf, sizeof (outbuf), "%s/auth/xchat_auth", g_get_home_dir ()); if (access (outbuf, X_OK) == 0) { - snprintf (outbuf, sizeof (outbuf), "exec -d %s/auth/xchat_auth %s", + g_snprintf (outbuf, sizeof (outbuf), "exec -d %s/auth/xchat_auth %s", g_get_home_dir (), prefs.hex_irc_user_name); handle_command (serv->server_session, outbuf, FALSE); } @@ -1198,7 +1198,7 @@ traverse_socks (int print_fd, int sok, char *serverAddr, int port) if (buf[1] == 90) return 0; - snprintf (buf, sizeof (buf), "SOCKS\tServer reported error %d,%d.\n", buf[0], buf[1]); + g_snprintf (buf, sizeof (buf), "SOCKS\tServer reported error %d,%d.\n", buf[0], buf[1]); proxy_error (print_fd, buf); return 1; } @@ -1299,9 +1299,9 @@ traverse_socks5 (int print_fd, int sok, char *serverAddr, int port) if (buf[0] != 5 || buf[1] != 0) { if (buf[1] == 2) - snprintf (buf, sizeof (buf), "SOCKS\tProxy refused to connect to host (not allowed).\n"); + g_snprintf (buf, sizeof (buf), "SOCKS\tProxy refused to connect to host (not allowed).\n"); else - snprintf (buf, sizeof (buf), "SOCKS\tProxy failed to connect to host (error %d).\n", buf[1]); + g_snprintf (buf, sizeof (buf), "SOCKS\tProxy failed to connect to host (error %d).\n", buf[1]); proxy_error (print_fd, buf); return 1; } @@ -1334,7 +1334,7 @@ traverse_wingate (int print_fd, int sok, char *serverAddr, int port) { char buf[128]; - snprintf (buf, sizeof (buf), "%s %d\r\n", serverAddr, port); + g_snprintf (buf, sizeof (buf), "%s %d\r\n", serverAddr, port); send (sok, buf, strlen (buf), 0); return 0; @@ -1422,16 +1422,16 @@ traverse_http (int print_fd, int sok, char *serverAddr, int port) char auth_data2[252]; int n, n2; - n = snprintf (buf, sizeof (buf), "CONNECT %s:%d HTTP/1.0\r\n", + n = g_snprintf (buf, sizeof (buf), "CONNECT %s:%d HTTP/1.0\r\n", serverAddr, port); if (prefs.hex_net_proxy_auth) { - n2 = snprintf (auth_data2, sizeof (auth_data2), "%s:%s", + n2 = g_snprintf (auth_data2, sizeof (auth_data2), "%s:%s", prefs.hex_net_proxy_user, prefs.hex_net_proxy_pass); base64_encode (auth_data, auth_data2, n2); - n += snprintf (buf+n, sizeof (buf)-n, "Proxy-Authorization: Basic %s\r\n", auth_data); + n += g_snprintf (buf+n, sizeof (buf)-n, "Proxy-Authorization: Basic %s\r\n", auth_data); } - n += snprintf (buf+n, sizeof (buf)-n, "\r\n"); + n += g_snprintf (buf+n, sizeof (buf)-n, "\r\n"); send (sok, buf, n, 0); n = http_read_line (print_fd, sok, buf, sizeof (buf)); @@ -1504,7 +1504,7 @@ server_child (server * serv) local_ip = net_resolve (ns_local, prefs.hex_net_bind_host, 0, &real_hostname); if (local_ip != NULL) { - snprintf (buf, sizeof (buf), "5\n%s\n", local_ip); + g_snprintf (buf, sizeof (buf), "5\n%s\n", local_ip); write (serv->childwrite, buf, strlen (buf)); net_bind (ns_local, serv->sok4, serv->sok6); bound = 1; @@ -1567,7 +1567,7 @@ server_child (server * serv) /* first resolve where we want to connect to */ if (proxy_type > 0) { - snprintf (buf, sizeof (buf), "9\n%s\n", proxy_host); + g_snprintf (buf, sizeof (buf), "9\n%s\n", proxy_host); write (serv->childwrite, buf, strlen (buf)); ip = net_resolve (ns_server, proxy_host, proxy_port, &real_hostname); g_free (proxy_host); @@ -1601,7 +1601,7 @@ server_child (server * serv) connect_port = port; } - snprintf (buf, sizeof (buf), "3\n%s\n%s\n%d\n", + g_snprintf (buf, sizeof (buf), "3\n%s\n%s\n%d\n", real_hostname, ip, connect_port); write (serv->childwrite, buf, strlen (buf)); @@ -1615,7 +1615,7 @@ server_child (server * serv) if (error != 0) { - snprintf (buf, sizeof (buf), "2\n%d\n", sock_error ()); + g_snprintf (buf, sizeof (buf), "2\n%d\n", sock_error ()); write (serv->childwrite, buf, strlen (buf)); } else { @@ -1627,11 +1627,11 @@ server_child (server * serv) case 0: /* success */ #ifdef USE_MSPROXY if (!serv->dont_use_proxy && (proxy_type == 5)) - snprintf (buf, sizeof (buf), "4\n%d %d %d %d %d\n", sok, psok, serv->msp_state.clientid, serv->msp_state.serverid, + g_snprintf (buf, sizeof (buf), "4\n%d %d %d %d %d\n", sok, psok, serv->msp_state.clientid, serv->msp_state.serverid, serv->msp_state.seq_sent); else #endif - snprintf (buf, sizeof (buf), "4\n%d\n", sok); /* success */ + g_snprintf (buf, sizeof (buf), "4\n%d\n", sok); /* success */ write (serv->childwrite, buf, strlen (buf)); break; case 1: /* socks traversal failed */ @@ -1640,7 +1640,7 @@ server_child (server * serv) } } else { - snprintf (buf, sizeof (buf), "4\n%d\n", sok); /* success */ + g_snprintf (buf, sizeof (buf), "4\n%d\n", sok); /* success */ write (serv->childwrite, buf, strlen (buf)); } } diff --git a/src/common/text.c b/src/common/text.c index 8d270fcb..0bee65be 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -319,9 +319,9 @@ scrollback_load (session *sess) if (buf[0] == 'T') { if (sizeof (time_t) == 4) - stamp = strtoul (buf + 2, NULL, 10); + stamp = g_ascii_strtoull (buf + 2, NULL, 10); else - stamp = strtoull (buf + 2, NULL, 10); /* in case time_t is 64 bits */ + stamp = g_ascii_strtoull (buf + 2, NULL, 10); /* in case time_t is 64 bits */ text = strchr (buf + 3, ' '); if (text && text[1]) { @@ -383,7 +383,7 @@ log_close (session *sess) { currenttime = time (NULL); write (sess->logfd, obuf, - snprintf (obuf, sizeof (obuf) - 1, _("**** ENDING LOGGING AT %s\n"), + g_snprintf (obuf, sizeof (obuf) - 1, _("**** ENDING LOGGING AT %s\n"), ctime (¤ttime))); close (sess->logfd); sess->logfd = -1; @@ -570,11 +570,11 @@ log_create_pathname (char *servname, char *channame, char *netname) /* create final path/filename */ if (logmask_is_fullpath ()) { - snprintf (fname, sizeof (fname), "%s", fnametime); + g_snprintf (fname, sizeof (fname), "%s", fnametime); } else /* relative path */ { - snprintf (fname, sizeof (fname), "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", get_xdir (), fnametime); + g_snprintf (fname, sizeof (fname), "%s" G_DIR_SEPARATOR_S "logs" G_DIR_SEPARATOR_S "%s", get_xdir (), fnametime); } /* create all the subdirectories */ @@ -606,7 +606,7 @@ log_open_file (char *servname, char *channame, char *netname) return -1; currenttime = time (NULL); write (fd, buf, - snprintf (buf, sizeof (buf), _("**** BEGIN LOGGING AT %s\n"), + g_snprintf (buf, sizeof (buf), _("**** BEGIN LOGGING AT %s\n"), ctime (¤ttime))); return fd; @@ -998,7 +998,7 @@ PrintTextTimeStampf (session *sess, time_t timestamp, const char *format, ...) Each XP_TE_* signal is hard coded to call text_emit which calls display_event which decodes the data - This means that this system *should be faster* than snprintf because + This means that this system *should be faster* than g_snprintf because it always 'knows' that format of the string (basically is preparses much of the work) @@ -1584,7 +1584,7 @@ pevent_make_pntevts () g_free (pntevts[i]); if (pevt_build_string (pntevts_text[i], &(pntevts[i]), &m) != 0) { - snprintf (out, sizeof (out), + g_snprintf (out, sizeof (out), _("Error parsing event %s.\nLoading default."), te[i].name); fe_message (out, FE_MSG_WARN); g_free (pntevts_text[i]); @@ -1725,7 +1725,7 @@ pevent_check_all_loaded () if (pntevts_text[i] == NULL) { /*printf ("%s\n", te[i].name); - snprintf(out, sizeof(out), "The data for event %s failed to load. Reverting to defaults.\nThis may be because a new version of HexChat is loading an old config file.\n\nCheck all print event texts are correct", evtnames[i]); + g_snprintf(out, sizeof(out), "The data for event %s failed to load. Reverting to defaults.\nThis may be because a new version of HexChat is loading an old config file.\n\nCheck all print event texts are correct", evtnames[i]); gtkutil_simpledialog(out); */ /* make-te.c sets this 128 flag (DON'T call gettext() flag) */ if (te[i].num_args & 128) @@ -1944,7 +1944,7 @@ pevt_build_string (const char *input, char **output, int *max_arg) } if (d < '1' || d > '9') { - snprintf (o, sizeof (o), "Error, invalid argument $%c\n", d); + g_snprintf (o, sizeof (o), "Error, invalid argument $%c\n", d); fe_message (o, FE_MSG_WARN); goto err; } @@ -2064,7 +2064,7 @@ text_emit (int index, session *sess, char *a, char *b, char *c, char *d, if (prefs.hex_text_color_nicks && (index == XP_TE_CHANACTION || index == XP_TE_CHANMSG)) { - snprintf (tbuf, sizeof (tbuf), "\003%d%s", text_color_of (a), a); + g_snprintf (tbuf, sizeof (tbuf), "\003%d%s", text_color_of (a), a); a = tbuf; stripcolor_args &= ~ARG_FLAG(1); /* don't strip color from this argument */ } @@ -2196,9 +2196,9 @@ pevent_save (char *fn) for (i = 0; i < NUM_XP; i++) { - write (fd, buf, snprintf (buf, sizeof (buf), + write (fd, buf, g_snprintf (buf, sizeof (buf), "event_name=%s\n", te[i].name)); - write (fd, buf, snprintf (buf, sizeof (buf), + write (fd, buf, g_snprintf (buf, sizeof (buf), "event_text=%s\n\n", pntevts_text[i])); } @@ -2373,9 +2373,9 @@ sound_save () { if (sound_files[i] && sound_files[i][0]) { - write (fd, buf, snprintf (buf, sizeof (buf), + write (fd, buf, g_snprintf (buf, sizeof (buf), "event=%s\n", te[i].name)); - write (fd, buf, snprintf (buf, sizeof (buf), + write (fd, buf, g_snprintf (buf, sizeof (buf), "sound=%s\n\n", sound_files[i])); } } diff --git a/src/common/util.c b/src/common/util.c index f1c5bf82..9deec8c2 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -66,10 +66,6 @@ #endif #endif -#ifndef HAVE_SNPRINTF -#define snprintf g_snprintf -#endif - char * file_part (char *file) { diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c index 1c10c161..f6ef46f3 100644 --- a/src/fe-gtk/chanlist.c +++ b/src/fe-gtk/chanlist.c @@ -94,7 +94,7 @@ chanlist_update_caption (server *serv) { gchar tbuf[256]; - snprintf (tbuf, sizeof tbuf, + g_snprintf (tbuf, sizeof tbuf, _("Displaying %d/%d users on %d/%d channels."), serv->gui->chanlist_users_shown_count, serv->gui->chanlist_users_found_count, @@ -456,7 +456,7 @@ chanlist_join (GtkWidget * wid, server *serv) { if (serv->connected && (strcmp (chan, "*") != 0)) { - snprintf (tbuf, sizeof (tbuf), "join %s", chan); + g_snprintf (tbuf, sizeof (tbuf), "join %s", chan); handle_command (serv->server_session, tbuf, FALSE); } else gdk_beep (); @@ -482,7 +482,7 @@ chanlist_filereq_done (server *serv, char *file) if (fh == -1) return; - snprintf (buf, sizeof buf, "HexChat Channel List: %s - %s\n", + g_snprintf (buf, sizeof buf, "HexChat Channel List: %s - %s\n", serv->servername, ctime (&t)); write (fh, buf, strlen (buf)); @@ -494,7 +494,7 @@ chanlist_filereq_done (server *serv, char *file) COL_CHANNEL, &chan, COL_USERS, &users, COL_TOPIC, &topic, -1); - snprintf (buf, sizeof buf, "%-16s %-5d%s\n", chan, users, topic); + g_snprintf (buf, sizeof buf, "%-16s %-5d%s\n", chan, users, topic); g_free (chan); g_free (topic); write (fh, buf, strlen (buf)); @@ -717,7 +717,7 @@ chanlist_opengui (server *serv, int do_refresh) return; } - snprintf (tbuf, sizeof tbuf, _(DISPLAY_NAME": Channel List (%s)"), + g_snprintf (tbuf, sizeof tbuf, _(DISPLAY_NAME": Channel List (%s)"), server_get_network (serv, TRUE)); serv->gui->chanlist_pending_rows = NULL; diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c index 27365af4..8c9dc8b4 100644 --- a/src/fe-gtk/dccgui.c +++ b/src/fe-gtk/dccgui.c @@ -194,12 +194,12 @@ dcc_prepare_row_send (struct DCC *dcc, GtkListStore *store, GtkTreeIter *iter, per = (float) ((dcc->ack * 100.00) / dcc->size); proper_unit (dcc->size, size, sizeof (size)); proper_unit (dcc->pos, pos, sizeof (pos)); - snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); - snprintf (perc, sizeof (perc), "%.0f%%", per); + g_snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); + g_snprintf (perc, sizeof (perc), "%.0f%%", per); if (dcc->cps != 0) { to_go = (dcc->size - dcc->ack) / dcc->cps; - snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", + g_snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", to_go / 3600, (to_go / 60) % 60, to_go % 60); } else strcpy (eta, "--:--:--"); @@ -252,14 +252,14 @@ dcc_prepare_row_recv (struct DCC *dcc, GtkListStore *store, GtkTreeIter *iter, proper_unit (dcc->resumable, pos, sizeof (pos)); else proper_unit (dcc->pos, pos, sizeof (pos)); - snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); + g_snprintf (kbs, sizeof (kbs), "%.1f", ((float)dcc->cps) / 1024); /* percentage recv'ed */ per = (float) ((dcc->pos * 100.00) / dcc->size); - snprintf (perc, sizeof (perc), "%.0f%%", per); + g_snprintf (perc, sizeof (perc), "%.0f%%", per); if (dcc->cps != 0) { to_go = (dcc->size - dcc->pos) / dcc->cps; - snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", + g_snprintf (eta, sizeof (eta), "%.2d:%.2d:%.2d", to_go / 3600, (to_go / 60) % 60, to_go % 60); } else strcpy (eta, "--:--:--"); @@ -525,7 +525,7 @@ resume_clicked (GtkWidget * wid, gpointer none) fe_message (_("That file is not resumable."), FE_MSG_ERROR); break; case 1: - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), _( "Cannot access file: %s\n" "%s.\n" "Resuming not possible."), dcc->destfile, @@ -606,7 +606,7 @@ browse_folder (char *dir) #else char buf[512]; - snprintf (buf, sizeof (buf), "file://%s", dir); + g_snprintf (buf, sizeof (buf), "file://%s", dir); fe_open_url (buf); #endif } @@ -639,7 +639,7 @@ dcc_details_populate (struct DCC *dcc) gtk_label_set_text (GTK_LABEL (dccfwin.file_label), dcc->file); /* address and port */ - snprintf (buf, sizeof (buf), "%s : %d", net_ip (dcc->addr), dcc->port); + g_snprintf (buf, sizeof (buf), "%s : %d", net_ip (dcc->addr), dcc->port); gtk_label_set_text (GTK_LABEL (dccfwin.address_label), buf); } @@ -737,7 +737,7 @@ dcc_detail_label (char *text, GtkWidget *box, int num) char buf[64]; label = gtk_label_new (NULL); - snprintf (buf, sizeof (buf), "%s", text); + g_snprintf (buf, sizeof (buf), "%s", text); gtk_label_set_markup (GTK_LABEL (label), buf); gtk_misc_set_alignment (GTK_MISC (label), 0, 0); gtk_table_attach (GTK_TABLE (box), label, 0, 1, 0 + num, 1 + num, GTK_FILL, GTK_FILL, 0, 0); diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 64382d68..21aa9b9b 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -265,7 +265,7 @@ create_input_style (GtkStyle *style) /* fall back */ if (pango_font_description_get_size (style->font_desc) == 0) { - snprintf (buf, sizeof (buf), _("Failed to open font:\n\n%s"), prefs.hex_text_font); + g_snprintf (buf, sizeof (buf), _("Failed to open font:\n\n%s"), prefs.hex_text_font); fe_message (buf, FE_MSG_ERROR); pango_font_description_free (style->font_desc); style->font_desc = pango_font_description_from_string ("sans 11"); @@ -746,9 +746,9 @@ fe_set_lag (server *serv, long lag) if (per > 1.0) per = 1.0; - snprintf (lagtext, sizeof (lagtext) - 1, "%s%ld.%lds", + g_snprintf (lagtext, sizeof (lagtext) - 1, "%s%ld.%lds", serv->lag_sent ? "+" : "", lag / 1000, (lag/100) % 10); - snprintf (lagtip, sizeof (lagtip) - 1, "Lag: %s%ld.%ld seconds", + g_snprintf (lagtip, sizeof (lagtip) - 1, "Lag: %s%ld.%ld seconds", serv->lag_sent ? "+" : "", lag / 1000, (lag/100) % 10); while (list) @@ -797,8 +797,8 @@ fe_set_throttle (server *serv) sess = list->data; if (sess->server == serv) { - snprintf (tbuf, sizeof (tbuf) - 1, _("%d bytes"), serv->sendq_len); - snprintf (tip, sizeof (tip) - 1, _("Network send queue: %d bytes"), serv->sendq_len); + g_snprintf (tbuf, sizeof (tbuf) - 1, _("%d bytes"), serv->sendq_len); + g_snprintf (tip, sizeof (tip) - 1, _("Network send queue: %d bytes"), serv->sendq_len); g_free (sess->res->queue_tip); sess->res->queue_tip = g_strdup (tip); diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index 66c98018..ea197290 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -849,7 +849,7 @@ key_save_kbs (void) 0x180, XOF_DOMODE); if (fd < 0) return 1; - write (fd, buf, snprintf (buf, 510, "# HexChat key bindings config file\n\n")); + write (fd, buf, g_snprintf (buf, 510, "# HexChat key bindings config file\n\n")); while (list) { @@ -857,17 +857,17 @@ key_save_kbs (void) accel_text = gtk_accelerator_name (kb->keyval, kb->mod); - snprintf (buf, 510, "ACCEL=%s\n%s\n", accel_text, key_actions[kb->action].name); + g_snprintf (buf, 510, "ACCEL=%s\n%s\n", accel_text, key_actions[kb->action].name); write (fd, buf, strlen (buf)); g_free (accel_text); if (kb->data1 && kb->data1[0]) - write (fd, buf, snprintf (buf, 510, "D1:%s\n", kb->data1)); + write (fd, buf, g_snprintf (buf, 510, "D1:%s\n", kb->data1)); else write (fd, "D1!\n", 4); if (kb->data2 && kb->data2[0]) - write (fd, buf, snprintf (buf, 510, "D2:%s\n", kb->data2)); + write (fd, buf, g_snprintf (buf, 510, "D2:%s\n", kb->data2)); else write (fd, "D2!\n", 4); @@ -1813,9 +1813,9 @@ replace_handle (GtkWidget *t) memcpy (outbuf, text, xlen); outbuf[xlen] = 0; if (postfix_pnt == NULL) - snprintf (word, sizeof (word), "%s", pop->cmd); + g_snprintf (word, sizeof (word), "%s", pop->cmd); else - snprintf (word, sizeof (word), "%s%s", pop->cmd, postfix); + g_snprintf (word, sizeof (word), "%s%s", pop->cmd, postfix); g_strlcat (outbuf, word, sizeof(outbuf)); SPELL_ENTRY_SET_TEXT (t, outbuf); SPELL_ENTRY_SET_POS (t, -1); diff --git a/src/fe-gtk/joind.c b/src/fe-gtk/joind.c index 6dacd385..6ffc1ee8 100644 --- a/src/fe-gtk/joind.c +++ b/src/fe-gtk/joind.c @@ -158,9 +158,9 @@ joind_show_dialog (server *serv) gtk_widget_show (vbox2); gtk_box_pack_start (GTK_BOX (hbox1), vbox2, TRUE, TRUE, 0); - snprintf (buf2, sizeof (buf2), _("Connection to %s complete."), + g_snprintf (buf2, sizeof (buf2), _("Connection to %s complete."), server_get_network (serv, TRUE)); - snprintf (buf, sizeof (buf), "\n%s", buf2); + g_snprintf (buf, sizeof (buf), "\n%s", buf2); label = gtk_label_new (buf); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0); @@ -198,7 +198,7 @@ joind_show_dialog (server *serv) gtk_widget_show (entry1); gtk_box_pack_start (GTK_BOX (hbox2), entry1, TRUE, TRUE, 8); - snprintf (buf, sizeof (buf), " %s", + g_snprintf (buf, sizeof (buf), " %s", _("If you know the name of the channel you want to join, enter it here.")); label = gtk_label_new (buf); gtk_widget_show (label); @@ -212,7 +212,7 @@ joind_show_dialog (server *serv) gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton3), radiobutton1_group); radiobutton1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton3)); - snprintf (buf, sizeof (buf), " %s", + g_snprintf (buf, sizeof (buf), " %s", _("Retrieving the Channel-List may take a minute or two.")); label = gtk_label_new (buf); gtk_widget_show (label); diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 54132681..b1764a0a 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -393,42 +393,42 @@ fe_set_title (session *sess) switch (type) { case SESS_DIALOG: - snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s %s @ %s", + g_snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s %s @ %s", _("Dialog with"), sess->channel, server_get_network (sess->server, TRUE)); break; case SESS_SERVER: - snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s @ %s", + g_snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s @ %s", sess->server->nick, server_get_network (sess->server, TRUE)); break; case SESS_CHANNEL: /* don't display keys in the titlebar */ if (prefs.hex_gui_win_modes) { - snprintf (tbuf, sizeof (tbuf), + g_snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s @ %s / %s (%s)", sess->server->nick, server_get_network (sess->server, TRUE), sess->channel, sess->current_modes ? sess->current_modes : ""); } else { - snprintf (tbuf, sizeof (tbuf), + g_snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s @ %s / %s", sess->server->nick, server_get_network (sess->server, TRUE), sess->channel); } if (prefs.hex_gui_win_ucount) { - snprintf (tbuf + strlen (tbuf), 9, " (%d)", sess->total); + g_snprintf (tbuf + strlen (tbuf), 9, " (%d)", sess->total); } break; case SESS_NOTICES: case SESS_SNOTICES: - snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s @ %s (notices)", + g_snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME": %s @ %s (notices)", sess->server->nick, server_get_network (sess->server, TRUE)); break; default: def: - snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME); + g_snprintf (tbuf, sizeof (tbuf), DISPLAY_NAME); gtk_window_set_title (GTK_WINDOW (sess->gui->window), tbuf); return; } @@ -1567,7 +1567,7 @@ mg_create_tabmenu (session *sess, GdkEventButton *event, chan *ch) if (sess) { char *name = g_markup_escape_text (sess->channel[0] ? sess->channel : _(""), -1); - snprintf (buf, sizeof (buf), "%s", name); + g_snprintf (buf, sizeof (buf), "%s", name); g_free (name); item = gtk_menu_item_new_with_label (""); @@ -1940,7 +1940,7 @@ flagl_hit (GtkWidget * wid, struct session *sess) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (wid), FALSE); return; } - snprintf (modes, sizeof (modes), "+l %d", atoi (limit_str)); + g_snprintf (modes, sizeof (modes), "+l %d", atoi (limit_str)); serv->p_mode (serv, sess->channel, modes); serv->p_join_info (serv, sess->channel); } @@ -1956,7 +1956,7 @@ flagk_hit (GtkWidget * wid, struct session *sess) if (serv->connected && sess->channel[0]) { - snprintf (modes, sizeof (modes), "-k %s", + g_snprintf (modes, sizeof (modes), "-k %s", gtk_entry_get_text (GTK_ENTRY (sess->gui->key_entry))); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wid))) @@ -2022,7 +2022,7 @@ mg_key_entry_cb (GtkWidget * igad, gpointer userdata) if (serv->connected && sess->channel[0]) { - snprintf (modes, sizeof (modes), "+k %s", + g_snprintf (modes, sizeof (modes), "+k %s", gtk_entry_get_text (GTK_ENTRY (igad))); serv->p_mode (serv, sess->channel, modes); serv->p_join_info (serv, sess->channel); @@ -2045,7 +2045,7 @@ mg_limit_entry_cb (GtkWidget * igad, gpointer userdata) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sess->gui->flag_l), FALSE); return; } - snprintf (modes, sizeof(modes), "+l %d", + g_snprintf (modes, sizeof(modes), "+l %d", atoi (gtk_entry_get_text (GTK_ENTRY (igad)))); serv->p_mode (serv, sess->channel, modes); serv->p_join_info (serv, sess->channel); @@ -2596,7 +2596,7 @@ mg_change_nick (int cancel, char *text, gpointer userdata) if (!cancel) { - snprintf (buf, sizeof (buf), "nick %s", text); + g_snprintf (buf, sizeof (buf), "nick %s", text); handle_command (current_sess, buf, FALSE); } } diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 0aa52636..977b2d9f 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -393,9 +393,9 @@ toggle_cb (GtkWidget *item, char *pref_name) char buf[256]; if (GTK_CHECK_MENU_ITEM (item)->active) - snprintf (buf, sizeof (buf), "set %s 1", pref_name); + g_snprintf (buf, sizeof (buf), "set %s 1", pref_name); else - snprintf (buf, sizeof (buf), "set %s 0", pref_name); + g_snprintf (buf, sizeof (buf), "set %s 0", pref_name); handle_command (current_sess, buf, FALSE); } @@ -586,7 +586,7 @@ menu_nickinfo_cb (GtkWidget *menu, session *sess) return; /* issue a /WHOIS */ - snprintf (buf, sizeof (buf), "WHOIS %s %s", str_copy, str_copy); + g_snprintf (buf, sizeof (buf), "WHOIS %s %s", str_copy, str_copy); handle_command (sess, buf, FALSE); /* and hide the output */ sess->server->skip_next_whois = 1; @@ -612,30 +612,30 @@ menu_create_nickinfo_menu (struct User *user, GtkWidget *submenu) /* let the translators tweak this if need be */ fmt = _("%-11s %s"); - snprintf (unknown, sizeof (unknown), "%s", _("Unknown")); + g_snprintf (unknown, sizeof (unknown), "%s", _("Unknown")); if (user->realname) { real = strip_color (user->realname, -1, STRIP_ALL|STRIP_ESCMARKUP); - snprintf (buf, sizeof (buf), fmt, _("Real Name:"), real); + g_snprintf (buf, sizeof (buf), fmt, _("Real Name:"), real); g_free (real); } else { - snprintf (buf, sizeof (buf), fmt, _("Real Name:"), unknown); + g_snprintf (buf, sizeof (buf), fmt, _("Real Name:"), unknown); } item = menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (copy_to_clipboard_cb), user->realname ? user->realname : unknown); - snprintf (buf, sizeof (buf), fmt, _("User:"), + g_snprintf (buf, sizeof (buf), fmt, _("User:"), user->hostname ? user->hostname : unknown); item = menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (copy_to_clipboard_cb), user->hostname ? user->hostname : unknown); - snprintf (buf, sizeof (buf), fmt, _("Account:"), + g_snprintf (buf, sizeof (buf), fmt, _("Account:"), user->account ? user->account : unknown); item = menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); g_signal_connect (G_OBJECT (item), "activate", @@ -645,13 +645,13 @@ menu_create_nickinfo_menu (struct User *user, GtkWidget *submenu) users_country = country (user->hostname); if (users_country) { - snprintf (buf, sizeof (buf), fmt, _ ("Country:"), users_country); + g_snprintf (buf, sizeof (buf), fmt, _ ("Country:"), users_country); item = menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (copy_to_clipboard_cb), users_country); } - snprintf (buf, sizeof (buf), fmt, _("Server:"), + g_snprintf (buf, sizeof (buf), fmt, _("Server:"), user->servername ? user->servername : unknown); item = menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); g_signal_connect (G_OBJECT (item), "activate", @@ -662,12 +662,12 @@ menu_create_nickinfo_menu (struct User *user, GtkWidget *submenu) { char min[96]; - snprintf (min, sizeof (min), _("%u minutes ago"), + g_snprintf (min, sizeof (min), _("%u minutes ago"), (unsigned int) ((time (0) - user->lasttalk) / 60)); - snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), min); + g_snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), min); } else { - snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), unknown); + g_snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), unknown); } menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); @@ -677,7 +677,7 @@ menu_create_nickinfo_menu (struct User *user, GtkWidget *submenu) if (away) { char *msg = strip_color (away->message ? away->message : unknown, -1, STRIP_ALL|STRIP_ESCMARKUP); - snprintf (buf, sizeof (buf), fmt, _("Away Msg:"), msg); + g_snprintf (buf, sizeof (buf), fmt, _("Away Msg:"), msg); g_free (msg); item = menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0); g_signal_connect (G_OBJECT (item), "activate", @@ -734,7 +734,7 @@ menu_nickmenu (session *sess, GdkEventButton *event, char *nick, int num_sel) /* more than 1 nick selected? */ if (num_sel > 1) { - snprintf (buf, sizeof (buf), _("%d nicks selected."), num_sel); + g_snprintf (buf, sizeof (buf), _("%d nicks selected."), num_sel); menu_quick_item (0, buf, menu, 0, 0, 0); menu_quick_item (0, 0, menu, XCMENU_SHADED, 0, 0); } else @@ -935,7 +935,7 @@ open_url_cb (GtkWidget *item, char *url) char buf[512]; /* pass this to /URL so it can handle irc:// */ - snprintf (buf, sizeof (buf), "URL %s", url); + g_snprintf (buf, sizeof (buf), "URL %s", url); handle_command (current_sess, buf, FALSE); } @@ -984,7 +984,7 @@ menu_chan_cycle (GtkWidget * menu, char *chan) if (current_sess) { - snprintf (tbuf, sizeof tbuf, "CYCLE %s", chan); + g_snprintf (tbuf, sizeof tbuf, "CYCLE %s", chan); handle_command (current_sess, tbuf, FALSE); } } @@ -996,7 +996,7 @@ menu_chan_part (GtkWidget * menu, char *chan) if (current_sess) { - snprintf (tbuf, sizeof tbuf, "part %s", chan); + g_snprintf (tbuf, sizeof tbuf, "part %s", chan); handle_command (current_sess, tbuf, FALSE); } } @@ -1008,7 +1008,7 @@ menu_chan_join (GtkWidget * menu, char *chan) if (current_sess) { - snprintf (tbuf, sizeof tbuf, "join %s", chan); + g_snprintf (tbuf, sizeof tbuf, "join %s", chan); handle_command (current_sess, tbuf, FALSE); } } diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c index 5aa60d0a..ed16f44f 100644 --- a/src/fe-gtk/notifygui.c +++ b/src/fe-gtk/notifygui.c @@ -190,11 +190,11 @@ notify_gui_update (void) { lastseenminutes = (int)(time (0) - lastseen) / 60; if (lastseenminutes < 60) - snprintf (agobuf, sizeof (agobuf), _("%d minutes ago"), lastseenminutes); + g_snprintf (agobuf, sizeof (agobuf), _("%d minutes ago"), lastseenminutes); else if (lastseenminutes < 120) - snprintf (agobuf, sizeof (agobuf), _("An hour ago")); + g_snprintf (agobuf, sizeof (agobuf), _("An hour ago")); else - snprintf (agobuf, sizeof (agobuf), _("%d hours ago"), lastseenminutes / 60); + g_snprintf (agobuf, sizeof (agobuf), _("%d hours ago"), lastseenminutes / 60); seen = agobuf; } if (!valid) /* create new tree row if required */ @@ -219,7 +219,7 @@ notify_gui_update (void) name = ""; server = server_get_network (servnot->server, TRUE); - snprintf (agobuf, sizeof (agobuf), _("%d minutes ago"), (int)(time (0) - lastseen) / 60); + g_snprintf (agobuf, sizeof (agobuf), _("%d minutes ago"), (int)(time (0) - lastseen) / 60); seen = agobuf; if (!valid) /* create new tree row if required */ @@ -380,7 +380,7 @@ fe_notify_ask (char *nick, char *networks) gtk_table_attach_defaults (GTK_TABLE (table), wid, 1, 2, 2, 3); label = gtk_label_new (NULL); - snprintf (buf, sizeof (buf), "%s", _("Comma separated list of networks is accepted.")); + g_snprintf (buf, sizeof (buf), "%s", _("Comma separated list of networks is accepted.")); gtk_label_set_markup (GTK_LABEL (label), buf); gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4); diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c index 0e933051..a0f8b9eb 100644 --- a/src/fe-gtk/palette.c +++ b/src/fe-gtk/palette.c @@ -122,7 +122,7 @@ palette_load (void) /* mIRC colors 0-31 are here */ for (i = 0; i < 32; i++) { - snprintf (prefname, sizeof prefname, "color_%d", i); + g_snprintf (prefname, sizeof prefname, "color_%d", i); cfg_get_color (cfg, prefname, &red, &green, &blue); colors[i].red = red; colors[i].green = green; @@ -132,7 +132,7 @@ palette_load (void) /* our special colors are mapped at 256+ */ for (i = 256, j = 32; j < MAX_COL+1; i++, j++) { - snprintf (prefname, sizeof prefname, "color_%d", i); + g_snprintf (prefname, sizeof prefname, "color_%d", i); cfg_get_color (cfg, prefname, &red, &green, &blue); colors[j].red = red; colors[j].green = green; @@ -155,14 +155,14 @@ palette_save (void) /* mIRC colors 0-31 are here */ for (i = 0; i < 32; i++) { - snprintf (prefname, sizeof prefname, "color_%d", i); + g_snprintf (prefname, sizeof prefname, "color_%d", i); cfg_put_color (fh, colors[i].red, colors[i].green, colors[i].blue, prefname); } /* our special colors are mapped at 256+ */ for (i = 256, j = 32; j < MAX_COL+1; i++, j++) { - snprintf (prefname, sizeof prefname, "color_%d", i); + g_snprintf (prefname, sizeof prefname, "color_%d", i); cfg_put_color (fh, colors[j].red, colors[j].green, colors[j].blue, prefname); } diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c index 4d036c19..1d4bf9fd 100644 --- a/src/fe-gtk/rawlog.c +++ b/src/fe-gtk/rawlog.c @@ -109,7 +109,7 @@ open_rawlog (struct server *serv) return; } - snprintf (tbuf, sizeof tbuf, _(DISPLAY_NAME": Raw Log (%s)"), serv->servername); + g_snprintf (tbuf, sizeof tbuf, _(DISPLAY_NAME": Raw Log (%s)"), serv->servername); serv->gui->rawlog_window = mg_create_generic_tab ("RawLog", tbuf, FALSE, TRUE, close_rawlog, serv, 640, 320, &vbox, serv); diff --git a/src/fe-gtk/servlistgui.c b/src/fe-gtk/servlistgui.c index 2202a6a6..a9aa3343 100644 --- a/src/fe-gtk/servlistgui.c +++ b/src/fe-gtk/servlistgui.c @@ -1658,7 +1658,7 @@ bold_label (char *text) char buf[128]; GtkWidget *label; - snprintf (buf, sizeof (buf), "%s", text); + g_snprintf (buf, sizeof (buf), "%s", text); label = gtk_label_new (buf); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); @@ -1700,7 +1700,7 @@ servlist_open_edit (GtkWidget *parent, ircnet *net) editwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (editwindow), 4); - snprintf (buf, sizeof (buf), _(DISPLAY_NAME": Edit %s"), net->name); + g_snprintf (buf, sizeof (buf), _(DISPLAY_NAME": Edit %s"), net->name); gtk_window_set_title (GTK_WINDOW (editwindow), buf); gtk_window_set_default_size (GTK_WINDOW (editwindow), netedit_win_width, netedit_win_height); gtk_window_set_transient_for (GTK_WINDOW (editwindow), GTK_WINDOW (parent)); diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 4e24ca68..3719c65b 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -631,7 +631,7 @@ setup_headlabel (GtkWidget *tab, int row, int col, char *text) char buf[128]; char *sp; - snprintf (buf, sizeof (buf), "%s", text); + g_snprintf (buf, sizeof (buf), "%s", text); sp = strchr (buf + 17, ' '); if (sp) *sp = '\n'; @@ -753,7 +753,7 @@ setup_create_italic_label (char *text) char buf[256]; label = gtk_label_new (NULL); - snprintf (buf, sizeof (buf), "%s", text); + g_snprintf (buf, sizeof (buf), "%s", text); gtk_label_set_markup (GTK_LABEL (label), buf); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); @@ -1221,9 +1221,9 @@ setup_create_header (GtkWidget *table, int row, char *labeltext) char buf[128]; if (row == 0) - snprintf (buf, sizeof (buf), "%s", _(labeltext)); + g_snprintf (buf, sizeof (buf), "%s", _(labeltext)); else - snprintf (buf, sizeof (buf), "\n%s", _(labeltext)); + g_snprintf (buf, sizeof (buf), "\n%s", _(labeltext)); label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (label), buf); @@ -1790,7 +1790,7 @@ setup_add_page (const char *title, GtkWidget *book, GtkWidget *tab) /* label */ label = gtk_label_new (NULL); - snprintf (buf, sizeof (buf), "%s", _(title)); + g_snprintf (buf, sizeof (buf), "%s", _(title)); gtk_label_set_markup (GTK_LABEL (label), buf); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_misc_set_padding (GTK_MISC (label), 2, 1); diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c index e587026f..b95eb522 100644 --- a/src/fe-gtk/userlistgui.c +++ b/src/fe-gtk/userlistgui.c @@ -42,11 +42,11 @@ enum { - COL_PIX=0, // GdkPixbuf * - COL_NICK=1, // char * - COL_HOST=2, // char * - COL_USER=3, // struct User * - COL_GDKCOLOR=4 // GdkColor * + COL_PIX=0, /* GdkPixbuf * */ + COL_NICK=1, /* char * */ + COL_HOST=2, /* char * */ + COL_USER=3, /* struct User * */ + COL_GDKCOLOR=4 /* GdkColor * */ }; @@ -105,7 +105,7 @@ fe_userlist_numbers (session *sess) { if (sess->total) { - snprintf (tbuf, sizeof (tbuf), _("%d ops, %d total"), sess->ops, sess->total); + g_snprintf (tbuf, sizeof (tbuf), _("%d ops, %d total"), sess->ops, sess->total); tbuf[sizeof (tbuf) - 1] = 0; gtk_label_set_text (GTK_LABEL (sess->gui->namelistinfo), tbuf); } else diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index bf96f649..56811359 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -91,7 +91,7 @@ fe_new_window (struct session *sess, int focus) return; done_intro = 1; - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), "\n" " \017HexChat-Text \00310"PACKAGE_VERSION"\n" " \017Running on \00310%s \017glib \00310%d.%d.%d\n"