path.h 2.23 KB
Newer Older
Warren Dukes's avatar
Warren Dukes committed
1
/* the Music Player Daemon (MPD)
2
 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
Warren Dukes's avatar
Warren Dukes committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * This project's homepage is: http://www.musicpd.org
 *
 * 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; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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
 */

#ifndef PATH_H
#define PATH_H

22 23
#include "../config.h"

Warren Dukes's avatar
Warren Dukes committed
24 25
#include <sys/param.h>

Eric Wong's avatar
Eric Wong committed
26
extern const char *musicDir;
Warren Dukes's avatar
Warren Dukes committed
27

28
void initPaths(void);
Warren Dukes's avatar
Warren Dukes committed
29

30
void finishPaths(void);
Warren Dukes's avatar
Warren Dukes committed
31

32 33 34 35 36
/* utf8ToFsCharset() and fsCharsetToUtf8()
 * Each returns a static pointer to a dynamically allocated buffer
 * which means:
 * - Do not manually free the return value of these functions, it'll be
 *   automatically freed the next time it is called.
37
 * - They are not reentrant, xstrdup the return value immediately if
38 39 40 41
 *   you expect to call one of these functions again, but still need the
 *   previous result.
 * - The static pointer is unique to each function.
 */
Avuton Olrich's avatar
Avuton Olrich committed
42 43
char *utf8ToFsCharset(char *str);
char *fsCharsetToUtf8(char *str);
Warren Dukes's avatar
Warren Dukes committed
44

Avuton Olrich's avatar
Avuton Olrich committed
45
void setFsCharset(char *charset);
Warren Dukes's avatar
Warren Dukes committed
46

47
char *getFsCharset(void);
Warren Dukes's avatar
Warren Dukes committed
48 49 50 51

/* relative music path to absolute music path
 * char * passed is a static variable, so don't free it
 */
Avuton Olrich's avatar
Avuton Olrich committed
52
char *rmp2amp(char *file);
Warren Dukes's avatar
Warren Dukes committed
53 54

/* static char * returned */
Avuton Olrich's avatar
Avuton Olrich committed
55
char *rpp2app(char *file);
Warren Dukes's avatar
Warren Dukes committed
56 57

/* static char * returned */
Avuton Olrich's avatar
Avuton Olrich committed
58
char *parentPath(char *path);
Warren Dukes's avatar
Warren Dukes committed
59

60
/* strips extra "///" and leading "/" and trailing "/" */
Avuton Olrich's avatar
Avuton Olrich committed
61
char *sanitizePathDup(char *path);
62

Eric Wong's avatar
Eric Wong committed
63 64 65 66 67 68
/* this is actually like strlcpy (OpenBSD), but we don't actually want to
 * blindly use it everywhere, only for paths that are OK to truncate (for
 * error reporting and such.
 * dest must be MAXPATHLEN+1 bytes large (which is standard in mpd) */
void pathcpy_trunc(char *dest, const char *src);

Warren Dukes's avatar
Warren Dukes committed
69
#endif