-static gchar *
-secure_filename(const gchar *fn)
-{
- gchar *tmp, *p;
- GString *s;
-
- s = g_string_new("");
-#if 1 || DEBUG
- tmp = g_strdup(fn);
- for (p = tmp; p[0] ; p++ ) {
- p[0] &= 0x5f; /* 01011111 */
- p[0] |= 0x40; /* 01000000 */
- }
- g_string_printf(s, "0x%x:%s", g_str_hash(fn), tmp);
- g_free(tmp);
- return g_string_free(s, FALSE);
-#else
- g_string_printf(s, "0x%x", g_str_hash(fn));
- return g_string_free(s, FALSE);
-#endif
-}
-
-
-static gchar *
-construct_virtual_filename(const gchar *filename,
- const gint position,
- const gchar *id,
- const gboolean active)
-{
- GString *s;
- gchar *fn;
-
- if (position < 0)
- return g_strdup("AttachmentInvalid");
-
- s = g_string_new("");
- if (active)
- g_string_append(s, ATTACHMENT_ID_INLINE);
- else
- g_string_append(s, ATTACHMENT_ID_LINK);
- g_string_append_printf(s, ":%d:", position);
- if (id)
- g_string_append(s, id);
- g_string_append_c(s, ':');
-
- fn = secure_filename(filename);
- if (fn)
- g_string_append(s, fn);
- g_free(fn);
- g_string_append_c(s, ':');
- return g_string_free(s, FALSE);
-}