Debian Codegraph @

src/uchardet.h

raw
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is Mozilla Universal charset detector code.
15 *
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2001
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 * BYVoid <[email protected]>
23 * Jehan <jehan at girinstud.io>
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38 #ifndef UCHARDET_H___
39 #define UCHARDET_H___
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 #include <stddef.h>
46
47 #if defined(UCHARDET_SHARED) && (defined(_WIN32) || defined(__CYGWIN__))
48 #ifdef BUILDING_UCHARDET
49 #define UCHARDET_INTERFACE __declspec(dllexport)
50 #else
51 #define UCHARDET_INTERFACE __declspec(dllimport)
52 #endif
53 #else
54 #define UCHARDET_INTERFACE
55 #endif
56
57
58 /**
59 * A handle for a uchardet encoding detector.
60 */
61 typedef struct uchardet * uchardet_t;
62
63 /**
64 * Create an encoding detector.
65 * @return an instance of uchardet_t.
66 */
67 UCHARDET_INTERFACE uchardet_t uchardet_new(void);
68
69 /**
70 * Delete an encoding detector.
71 * @param ud [in] the uchardet_t handle to delete.
72 */
73 UCHARDET_INTERFACE void uchardet_delete(uchardet_t ud);
74
75 /**
76 * Feed data to an encoding detector.
77 * The detector is able to shortcut processing when it reaches certainty
78 * for an encoding, so you should not worry about limiting input data.
79 * As far as you should be concerned: the more the better.
80 *
81 * @param ud [in] handle of an instance of uchardet
82 * @param data [in] data
83 * @param len [in] number of byte of data
84 * @return non-zero number on failure.
85 */
86 UCHARDET_INTERFACE int uchardet_handle_data(uchardet_t ud, const char * data, size_t len);
87
88 /**
89 * Notify an end of data to an encoding detector.
90 * @param ud [in] handle of an instance of uchardet
91 */
92 UCHARDET_INTERFACE void uchardet_data_end(uchardet_t ud);
93
94 /**
95 * Reset an encoding detector.
96 * @param ud [in] handle of an instance of uchardet
97 */
98 UCHARDET_INTERFACE void uchardet_reset(uchardet_t ud);
99
100 /**
101 * Get an iconv-compatible name of the encoding that was detected.
102 * @param ud [in] handle of an instance of uchardet
103 * @return name of charset on success and "" on failure.
104 */
105 UCHARDET_INTERFACE const char * uchardet_get_charset(uchardet_t ud);
106
107 #ifdef __cplusplus
108 }
109 #endif
110
111 #endif