This repository has been archived by the owner on Jan 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmsp_cmn.h
563 lines (260 loc) · 11.5 KB
/
msp_cmn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/**
* @file msp_cmn.h
* @brief Mobile Speech Platform Common Interface Header File
*
* This file contains the quick common programming interface (API) declarations
* of MSP. Developer can include this file in your project to build applications.
* For more information, please read the developer guide.
* Use of this software is subject to certain restrictions and limitations set
* forth in a license agreement entered into between iFLYTEK, Co,LTD.
* and the licensee of this software. Please refer to the license
* agreement for license use rights and restrictions.
*
* Copyright (C) 1999 - 2012 by ANHUI USTC iFLYTEK, Co,LTD.
* All rights reserved.
*
* @author Speech Dept. iFLYTEK.
* @version 1.0
* @date 2012/09/01
*
* @see
*
* History:
* index version date author notes
* 0 1.0 2012/09/01 MSC40 Create this file
*/
#ifndef __MSP_CMN_H__
#define __MSP_CMN_H__
#include "msp_types.h"
#ifdef __cplusplus
extern "C" {
#endif /* C++ */
//#ifdef MSP_WCHAR_SUPPORT
/**
* @fn Wchar2Mbytes
* @brief wchar to mbytes
*
* User login.
*
* @return int MSPAPI - Return 0 in success, otherwise return error code.
* @param const wchar_t* wcstr - [in] Null-terminated source string(wchar_t *).
* @param char* mbstr - [in] Destination string(char *).
* @param int len - [in] The maximum number of bytes that can be stored in the multibyte output string.
* @see
*/
char *Wchar2Mbytes(const wchar_t* wcstr);
/**
* @fn Mbytes2Wchar
* @brief mbytes to wchar
*
* User login.
*
* @return int MSPAPI - Return 0 in success, otherwise return error code.
* @param const char* mbstr - [in] Null-terminated source string(char *).
* @param wchar_t* wcstr - [in] Destination string(wchar_t *).
* @param int wlen - [in] The maximum number of multibyte characters to convert.
* @see
*/
wchar_t *Mbytes2Wchar(const char *mbstr);
//#endif /*MSP_WCHAR_SUPPORT*/
/**
* @fn MSPLogin
* @brief user login interface
*
* User login.
*
* @return int MSPAPI - Return 0 in success, otherwise return error code.
* @param const char* usr - [in] user name.
* @param const char* pwd - [in] password.
* @param const char* params - [in] parameters when user login.
* @see
*/
int MSPAPI MSPLogin(const char* usr, const char* pwd, const char* params);
typedef int (MSPAPI *Proc_MSPLogin)(const char* usr, const char* pwd, const char* params);
//#ifdef MSP_WCHAR_SUPPORT
int MSPAPI MSPLoginW(const wchar_t* usr, const wchar_t* pwd, const wchar_t* params);
typedef int (MSPAPI *Proc_MSPLoginW)(const wchar_t* usr, const wchar_t* pwd, const wchar_t* params);
//#endif/*MSP_WCHAR_SUPPORT*/
/**
* @fn MSPLogout
* @brief user logout interface
*
* User logout
*
* @return int MSPAPI - Return 0 in success, otherwise return error code.
* @see
*/
int MSPAPI MSPLogout();
typedef int (MSPAPI *Proc_MSPLogout)();
//#ifdef MSP_WCHAR_SUPPORT
int MSPAPI MSPLogoutW();
typedef int (MSPAPI *Proc_MSPLogoutW)();
//#endif/*MSP_WCHAR_SUPPORT*/
/**
* @fn MSPUpload
* @brief Upload User Specific Data
*
* Upload data such as user config, custom grammar, etc.
*
* @return int MSPAPI - Return 0 in success, otherwise return error code.
* @param const char* dataName - [in] data name, should be unique to diff other data.
* @param const char* params - [in] parameters about uploading data.
* @param const char* dataID - [in] id of the data to be operated.
* @see
*/
int MSPAPI MSPUpload( const char* dataName, const char* params, const char* dataID);
typedef int (MSPAPI* Proc_MSPUpload)( const char* dataName, const char* params, const char* dataID);
/**
* @fn MSPDownload
* @brief Download User Specific Data
*
* Download data such as user config, etc.
*
* @return int MSPAPI - Return 0 in success, otherwise return error code.
* @param const char* params - [in] parameters about data to be downloaded.
* @see
*/
typedef int (*DownloadStatusCB)(int errorCode, long param1, const void *param2, void *userData);
typedef int (*DownloadResultCB)(const void *data, long dataLen, void *userData);
int MSPAPI MSPDownload(const char* dataName, const char* params, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
typedef int (MSPAPI* Proc_MSPDownload)(const char* dataName, const char* params, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
int MSPAPI MSPDownloadW(const wchar_t* wdataName, const wchar_t* wparams, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
typedef int (MSPAPI* Proc_MSPDownloadW) (const wchar_t* wdataName, const wchar_t* wparams, DownloadStatusCB statusCb, DownloadResultCB resultCb, void*userData);
/**
* @fn MSPAppendData
* @brief Append Data.
*
* Write data to msc, such as data to be uploaded, searching text, etc.
*
* @return int MSPAPI - Return 0 in success, otherwise return error code.
* @param void* data - [in] the data buffer pointer, data could be binary.
* @param unsigned int dataLen - [in] length of data.
* @param unsigned int dataStatus - [in] data status, 2: first or continuous, 4: last.
* @see
*/
int MSPAPI MSPAppendData(void* data, unsigned int dataLen, unsigned int dataStatus);
typedef int (MSPAPI* Proc_MSPAppendData)(void* data, unsigned int dataLen, unsigned int dataStatus);
/**
* @fn MSPGetResult
* @brief Get Result
*
* Get result of uploading, downloading or searching, etc.
*
* @return const char* MSPAPI - Return result of uploading, downloading or searching, etc.
* @param int* rsltLen - [out] Length of result returned.
* @param int* rsltStatus - [out] Status of result returned.
* @param int* errorCode - [out] Return 0 in success, otherwise return error code.
* @see
*/
const char* MSPAPI MSPGetResult(unsigned int* rsltLen, int* rsltStatus, int *errorCode);
typedef const char * (MSPAPI *Proc_MSPGetResult)(unsigned int* rsltLen, int* rsltStatus, int *errorCode);
/**
* @fn MSPSetParam
* @brief set params of msc
*
* set param of msc
*
* @return int - Return 0 if success, otherwise return errcode.
* @param const char* paramName - [in] param name.
* @param const char* paramValue - [in] param value
* @see
*/
int MSPAPI MSPSetParam( const char* paramName, const char* paramValue );
typedef int (MSPAPI *Proc_MSPSetParam)(const char* paramName, const char* paramValue);
/**
* @fn MSPGetParam
* @brief get params of msc
*
* get param of msc
*
* @return int - Return 0 if success, otherwise return errcode.
* @param const char* paramName - [in] param name.
* @param const char* paramValue - [out] param value
* @param const char* valueLen - [in/out] param value (buffer) length
* @see
*/
int MSPAPI MSPGetParam( const char *paramName, char *paramValue, unsigned int *valueLen );
typedef int (MSPAPI *Proc_MSPGetParam)( const char *paramName, char *paramValue, unsigned int *valueLen );
/**
* @fn MSPUploadData
* @brief Upload User Specific Data
*
* Upload data such as user config, custom grammar, etc.
*
* @return const char* MSPAPI - data id returned by Server, used for special command.
* @param const char* dataName - [in] data name, should be unique to diff other data.
* @param void* data - [in] the data buffer pointer, data could be binary.
* @param unsigned int dataLen - [in] length of data.
* @param const char* params - [in] parameters about uploading data.
* @param int* errorCode - [out] Return 0 in success, otherwise return error code.
* @see
*/
const char* MSPAPI MSPUploadData(const char* dataName, void* data, unsigned int dataLen, const char* params, int* errorCode);
typedef const char* (MSPAPI* Proc_MSPUploadData)(const char* dataName, void* data, unsigned int dataLen, const char* params, int* errorCode);
/**
* @fn MSPDownloadData
* @brief Download User Specific Data
*
* Download data such as user config, etc.
*
* @return const void* MSPAPI - received data buffer pointer, data could be binary, NULL if failed or data does not exsit.
* @param const char* params - [in] parameters about data to be downloaded.
* @param unsigned int* dataLen - [out] length of received data.
* @param int* errorCode - [out] Return 0 in success, otherwise return error code.
* @see
*/
const void* MSPAPI MSPDownloadData(const char* params, unsigned int* dataLen, int* errorCode);
typedef const void* (MSPAPI* Proc_MSPDownloadData)(const char* params, unsigned int* dataLen, int* errorCode);
//#ifdef MSP_WCHAR_SUPPORT
const void* MSPAPI MSPDownloadDataW(const wchar_t* params, unsigned int* dataLen, int* errorCode);
typedef const void* (MSPAPI* Proc_MSPDownloadDataW)(const wchar_t* params, unsigned int* dataLen, int* errorCode);
//#endif/*MSP_WCHAR_SUPPORT*/
/**
* @fn MSPSearch
* @brief Search text for result
*
* Search text content, and got text result
*
* @return const void* MSPAPI - received data buffer pointer, data could be binary, NULL if failed or data does not exsit.
* @param const char* params - [in] parameters about data to be downloaded.
* @param unsigned int* dataLen - [out] length of received data.
* @param int* errorCode - [out] Return 0 in success, otherwise return error code.
* @see
*/
const char* MSPAPI MSPSearch(const char* params, const char* text, unsigned int* dataLen, int* errorCode);
typedef const char* (MSPAPI* Proc_MSPSearch)(const char* params, const char* text, unsigned int* dataLen, int* errorCode);
typedef int (*NLPSearchCB)(const char *sessionID, int errorCode, int status, const void* result, long rsltLen, void *userData);
const char* MSPAPI MSPNlpSearch(const char* params, const char* text, unsigned int textLen, int *errorCode, NLPSearchCB callback, void *userData);
typedef const char* (MSPAPI* Proc_MSPNlpSearch)(const char* params, const char* text, unsigned int textLen, int *errorCode, NLPSearchCB callback, void *userData);
int MSPAPI MSPNlpSchCancel(const char *sessionID, const char *hints);
/**
* @fn MSPRegisterNotify
* @brief Register a Callback
*
* Register a Callback
*
* @return int -
* @param msp_status_ntf_handler statusCb - [in] notify handler
* @param void *userData - [in] userData
* @see
*/
typedef void ( *msp_status_ntf_handler)( int type, int status, int param1, const void *param2, void *userData );
int MSPAPI MSPRegisterNotify( msp_status_ntf_handler statusCb, void *userData );
typedef const char* (MSPAPI* Proc_MSPRegisterNotify)( msp_status_ntf_handler statusCb, void *userData );
/**
* @fn MSPGetVersion
* @brief Get version of MSC or Local Engine
*
* Get version of MSC or Local Engine
*
* @return const char * MSPAPI - Return version value if success, NULL if fail.
* @param const char *verName - [in] version name, could be "msc", "aitalk", "aisound", "ivw".
* @param int *errorCode - [out] Return 0 in success, otherwise return error code.
* @see
*/
const char* MSPAPI MSPGetVersion(const char *verName, int *errorCode);
typedef const char* (MSPAPI * Proc_MSPGetVersion)(const char *verName, int *errorCode);
#ifdef __cplusplus
} /* extern "C" */
#endif /* C++ */
#endif /* __MSP_CMN_H__ */