예제 #1
0
gchar *
gsearchtool_get_next_duplicate_name (const gchar * basename)
{
	gchar * utf8_name;
	gchar * utf8_result;
	gchar * result;

	utf8_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
	
	if (utf8_name == NULL) {
		/* Couldn't convert to utf8 - probably
		 * G_BROKEN_FILENAMES not set when it should be.
		 * Try converting from the locale */
		utf8_name = g_locale_to_utf8 (basename, -1, NULL, NULL, NULL);	

		if (utf8_name == NULL) {
			utf8_name = make_valid_utf8 (basename);
		}
	}

	utf8_result = get_duplicate_name (utf8_name);
	g_free (utf8_name);

	result = g_filename_from_utf8 (utf8_result, -1, NULL, NULL, NULL);
	g_free (utf8_result);
	return result;
}
/* we try to be as forgiving as we possibly can here - this isn't a
 * validator.  Almost nothing is considered a fatal error.  We always
 * try to return *something*.
 */
static void
parse (EVCard *evc, const char *str)
{
	char *buf ;
	char *p;
	EVCardAttribute *attr;

	buf = make_valid_utf8 (str);

	//buf = fold_lines (buf);

	d(printf ("BEFORE FOLDING:\n"));
	d(printf (str));
	d(printf ("\n\nAFTER FOLDING:\n"));
	d(printf (buf));

	p = buf;

	attr = read_attribute (&p);
	if (!attr || attr->group || g_ascii_strcasecmp (attr->name, "begin")) {
		g_warning ("vcard began without a BEGIN:VCARD\n");
	}
	if (attr && !g_ascii_strcasecmp (attr->name, "begin")) {
		e_vcard_attribute_free (attr);
		attr = NULL;
	} else if (attr)
		e_vcard_add_attribute (evc, attr);

	while (*p) {
		EVCardAttribute *next_attr = read_attribute (&p);

		if (next_attr) {
			attr = next_attr;

			if (g_ascii_strcasecmp (next_attr->name, "end"))
				e_vcard_add_attribute (evc, next_attr);
			else
				break;
		}
	}

	if (!attr || attr->group || g_ascii_strcasecmp (attr->name, "end")) {
		g_warning ("vcard ended without END:VCARD\n");
	}

	if (attr && !g_ascii_strcasecmp (attr->name, "end"))
		e_vcard_attribute_free (attr);

	g_free (buf);

	evc->priv->attributes = g_list_reverse (evc->priv->attributes);
}