diff src/util.c @ 9926:b23e70bd1215

[gaim-migrate @ 10818] remove some code duplication, add some code duplication, make these functions accessable to other stuff, and apparently a random whitespace cleanup committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Wed, 01 Sep 2004 00:48:38 +0000
parents 4d17a945aab3
children 31fddde685dd
line wrap: on
line diff
--- a/src/util.c	Wed Sep 01 00:46:42 2004 +0000
+++ b/src/util.c	Wed Sep 01 00:48:38 2004 +0000
@@ -3203,3 +3203,34 @@
 	return out;
 }
 
+const char* gaim_unescape_filename(const char *escaped) {
+	return gaim_url_decode(escaped);
+}
+
+
+/* this is almost identical to gaim_url_encode (hence gaim_url_decode
+ * being used above), but we want to keep certain characters unescaped
+ * for compat reasons */
+const char *
+gaim_escape_filename(const char *str)
+{
+	static char buf[BUF_LEN];
+	guint i, j = 0;
+
+	g_return_val_if_fail(str != NULL, NULL);
+
+	for (i = 0; i < strlen(str); i++) {
+		if (isalnum(str[i]) || str[i] == '@')
+			buf[j++] = str[i];
+		else {
+			sprintf(buf + j, "%%%02x", (unsigned char)str[i]);
+			j += 3;
+		}
+	}
+
+	buf[j] = '\0';
+
+	return buf;
+}
+
+