comparison 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
comparison
equal deleted inserted replaced
9925:4e7590473515 9926:b23e70bd1215
3201 *a = '\0'; 3201 *a = '\0';
3202 3202
3203 return out; 3203 return out;
3204 } 3204 }
3205 3205
3206 const char* gaim_unescape_filename(const char *escaped) {
3207 return gaim_url_decode(escaped);
3208 }
3209
3210
3211 /* this is almost identical to gaim_url_encode (hence gaim_url_decode
3212 * being used above), but we want to keep certain characters unescaped
3213 * for compat reasons */
3214 const char *
3215 gaim_escape_filename(const char *str)
3216 {
3217 static char buf[BUF_LEN];
3218 guint i, j = 0;
3219
3220 g_return_val_if_fail(str != NULL, NULL);
3221
3222 for (i = 0; i < strlen(str); i++) {
3223 if (isalnum(str[i]) || str[i] == '@')
3224 buf[j++] = str[i];
3225 else {
3226 sprintf(buf + j, "%%%02x", (unsigned char)str[i]);
3227 j += 3;
3228 }
3229 }
3230
3231 buf[j] = '\0';
3232
3233 return buf;
3234 }
3235
3236