diff options
author | Kalle Wallin <kaw@linux.se> | 2004-03-19 13:26:18 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2004-03-19 13:26:18 +0000 |
commit | a0592c8cc08b802f86061c88dc6862352b6c3e94 (patch) | |
tree | feda87ba55a404023e62b8d744e2667dccebdc95 /support.c | |
download | mpd-a0592c8cc08b802f86061c88dc6862352b6c3e94.tar.gz mpd-a0592c8cc08b802f86061c88dc6862352b6c3e94.tar.xz mpd-a0592c8cc08b802f86061c88dc6862352b6c3e94.zip |
Imported ncmpc (mpc-ncures).
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@292 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'support.c')
-rw-r--r-- | support.c | 64 |
1 files changed, 64 insertions, 0 deletions
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 <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <glib.h> + +#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); +} |