From a0592c8cc08b802f86061c88dc6862352b6c3e94 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Fri, 19 Mar 2004 13:26:18 +0000 Subject: Imported ncmpc (mpc-ncures). git-svn-id: https://svn.musicpd.org/ncmpc/trunk@292 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- support.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 support.c (limited to 'support.c') diff --git a/support.c b/support.c new file mode 100644 index 000000000..ce67dc81e --- /dev/null +++ b/support.c @@ -0,0 +1,64 @@ +/* + * $Id: support.c,v 1.2 2004/03/17 23:17:09 kalle Exp $ + * + */ + +#include +#include +#include +#include + +#include "config.h" +#include "support.h" + +#ifndef HAVE_LIBGEN_H + +char * +remove_trailing_slash(char *path) +{ + int len; + + if( path==NULL ) + return NULL; + + len=strlen(path); + if( len>1 && path[len-1] == '/' ) + path[len-1] = '\0'; + + return path; +} + + +char * +basename(char *path) +{ + char *end; + + path = remove_trailing_slash(path); + end = path + strlen(path); + + while( end>path && *end!='/' ) + end--; + + if( *end=='/' && end!=path ) + return end+1; + + return path; +} + +#endif /* HAVE_LIBGEN_H */ + +char * +utf8(char *str) +{ + static const gchar *charset = NULL; + static gboolean locale_is_utf8 = FALSE; + + if( !charset ) + locale_is_utf8 = g_get_charset(&charset); + + if( locale_is_utf8 ) + return str; + + return g_locale_from_utf8(str, -1, NULL, NULL, NULL); +} -- cgit v1.2.3