server/Makefile.am: Add the codec test for Ogg Vorbis.
[disorder] / lib / charset.h
1 /*
2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2007-2009 Richard Kettlewell
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 /** @file lib/charset.h @brief Character set conversion */
19 #ifndef CHARSET_H
20 #define CHARSET_H
21
22 #include "log.h"
23
24 struct dynstr;
25
26 /* Character encoding conversion routines */
27
28 char *mb2utf8(const char *mb);
29 char *utf82mb(const char *utf8);
30 /* various conversions, between multibyte strings (mb) in
31 * whatever the current encoding is, and UTF-8 strings (utf8). On
32 * error, a null pointer is returned and @errno@ set. */
33
34 char *any2utf8(const char *from/*encoding*/,
35 const char *any/*string*/);
36 /* arbitrary conversions from any null-free byte-based encoding that
37 * iconv knows about to UTF-8 */
38
39 char *any2mb(const char *from/*encoding or 0*/,
40 const char *any/*string*/);
41 /* Arbitrary conversions from any null-free byte-based encoding that
42 * iconv knows about to a multibyte string. If FROM is 0 then ANY is
43 * returned unchanged. */
44
45 char *any2any(const char *from/*encoding or 0*/,
46 const char *to/*encoding to 0*/,
47 const char *any/*string*/);
48 /* Arbitrary conversions between any null-free byte-based encodings
49 * that iconv knows. If FROM and TO are both 0 then ANY is returned
50 * unchanged. */
51
52 char *mb2utf8_f(char *mb);
53 char *utf82mb_f(char *utf8);
54 char *any2utf8_f(const char *from/*encoding*/,
55 char *any/*string*/);
56 char *any2mb_f(const char *from/*encoding or 0*/,
57 char *any/*string*/);
58 char *any2any_f(const char *from/*encoding or 0*/,
59 const char *to/*encoding to 0*/,
60 char *any/*string*/);
61
62 /** @brief Insist that @p s is not null
63 * @param s Pointer to check
64 * @return @p s
65 *
66 * Terminates the process if @p s is a null pointer.
67 */
68 static inline char *nullcheck(char *s) {
69 if(!s) exitfn(1); /* assume an error already reported */
70 return s;
71 }
72
73 const char *truncate_for_display(const char *s, long max);
74
75 #endif /* CHARSET_H */
76
77 /*
78 Local Variables:
79 c-basic-offset:2
80 comment-column:40
81 End:
82 */