X-Git-Url: https://git.jankratochvil.net/?p=captive.git;a=blobdiff_plain;f=src%2Fclient%2Ffuse%2Futf8.c;fp=src%2Fclient%2Ffuse%2Futf8.c;h=8c0ee73bfdcf904c05157095a4dd451cce892724;hp=0000000000000000000000000000000000000000;hb=a369aa0578f4a98f7b18a18ecc11d266b0f7fe71;hpb=15736d2bd542588c873a156a3d7eefe5efa729e6 diff --git a/src/client/fuse/utf8.c b/src/client/fuse/utf8.c new file mode 100644 index 0000000..8c0ee73 --- /dev/null +++ b/src/client/fuse/utf8.c @@ -0,0 +1,78 @@ +/* $Id$ + * FUSE interface module utf8 conversions for libcaptive + * Copyright (C) 2003-2005 Jan Kratochvil + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; exactly version 2 of June 1991 is required + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "config.h" + +#include "utf8.h" /* self */ +#include +#include +#include +#include + + +char *capfuse_filename_to_utf8_malloc_errorchecking(const char *name) +{ +GError *error; +char *r; + + g_return_val_if_fail(name!=NULL,NULL); + + error=NULL; + r=g_filename_to_utf8( + name, /* opsysstring */ + -1, /* len; '\0'-terminated */ + NULL, /* bytes_read */ + NULL, /* bytes_written */ + &error); /* error */ + if (error) { + g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, + _("captive-FUSE %s(): name=\"%s\": %s (see locale(7) and mount(8) environment variables)"), + "g_filename_to_utf8",name,error->message); + g_clear_error(&error); + } + return r; +} + + +char *capfuse_filename_from_utf8_malloc_errorchecking(const char *name) +{ +GError *error; +char *r; + + g_return_val_if_fail(name!=NULL,NULL); + + error=NULL; + r=g_filename_from_utf8( + name, /* utf8string */ + -1, /* len; '\0'-terminated */ + NULL, /* bytes_read */ + NULL, /* bytes_written */ + &error); /* error */ + if (error) { +const gchar *charset; + + g_get_charset(&charset); + g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING,"captive-FUSE %s(): name=\"%s\"; g_get_charset()=\"%s\", %s: %s", + "g_filename_from_utf8",name,charset, + _("see environment variables - locale(7), mount(8) and locale(1) commands \"locale\" and \"locale -a\""), + error->message); + g_clear_error(&error); + } + return r; +}