接口转换问题,懂C/C++的高手请进
C#中如何调用C的接口(.h和.lib文件),直接添加.lib引用是不行的,是不是需要转换成DLL成类库或者其他什么的,还有其他方法吗?
如需转换,以下是C的头文件:(如需更详细,请留下e-mail,我发文件过去)
#ifndef ASR_CLIENT_H
#define ASR_CLIENT_H
#ifdef __cplusplus
extern "C" {
#endif
enum ASR_WAV_FORMAT {
WAV_FORMAT_ULAW, /* MU-law */
WAV_FORMAT_ALAW, /* A-LAW */
WAV_FORMAT_LPCM /* linear pcm */
};
enum ASR_STATUS {
ASR_SUCCESS = 0, /* function is called successfully */
ASR_EINTERNAL, /* internal error */
ASR_EFILE, /* file error */
ASR_EMEM, /* out of memory */
ASR_ENETWORK, /* network/socket errors */
ASR_EINVAL, /* invalid parameters */
ASR_EOVERFLOW, /* buffer too small */
};
typedef struct asr_result_t{
int n; /* number of n-best result */
char output[5][512]; /* top 5 result */
char score[5][12]; /* top 5 score */
char aux[2048]; /* aux */
} asr_result;
/**
* Initialize the ASR client module
* @param host the host name
* @param port the port on host
* @return ASR_STATUS
*/
int asr_init(const char* host, int port);
/**
* Finalize the ASR client module
*/
void asr_final();
/**
* Request the ASR server to generate resources
* @param class_name the name of the resources
* @param enc the encoding type of the buffer (e.g. gb2312, utf-8)
* @param buf the buffer of the words list.
* The words are seperated by the new line.
* @param size the size of the buffer
* @return ASR_STATUS
*/
int asr_gen(const char* class_name,
const char* enc, const char* buf, int size);
/**
* asr_t is a handle to a asr client
* It is obtained by asr_open()
* and used in asr_write(), asr_read() and asr_close()
*/
typedef struct asr_t asr_t;
/**
* Decode a file. A shortcut from invoking asr_open, asr_write,
* asr_read, and asr_close in sequence.
* @param class_name the name of the resources to be used for decoding
* @param fname the name of a file containing wave data to be decoded
* @param wavfmt the format of the wave data in file passed in
* @param result_buf return the result of the decoding
* @param result_bufsz size of the result_buf
* @param aux_buf is aux data of previous wave
* @return ASR_STATUS
*/
int asr_decode(const char* class_name,
const char* fname,
int wavfmt,
char* result_buf,
int result_bufsz,
char* aux_buf);
/**
* Open and start a new asr session
* @param asr return an asr handle
* @param class_name the name of the resources to be used for decoding
* @param wavfmt the format of the wave data in file passed in
* @return ASR_STATUS
*/
int asr_open(asr_t** asr, const char* class_name,
int wavfmt);
/**
* Sets the aux info of this asr session. The Aux info is embedded in the
* results of the previous asr decoding session. The ASR stores some auxiliary
* information in the Aux info that uses characteristics of the previous
* decoding session to help in improving the accuracy of this session. The use
* of the aux info is completely optional, but you are encouraged to supply
* this info if available.
*
* @param asr the asr handle
* @param aux the aux info
* @return ASR_STATUS
*/
int asr_set_aux(asr_t* asr, const char* aux);
/**
* Send a block of data to the ASR server. Each block should be less
* than 4 Kbytes in size.
*
* @param asr the asr handle
* @param buf the buffer of the wave data
* @param size the size of the buffer
* @param result_pending 0 if result is not ready, non-zero otherwise
* @return ASR_STATUS
*/
int asr_write(asr_t* asr, const char* buf, int size, int *result_pending);
/**
* Read the result from the ASR server
* @param asr the asr resource handle
* @param asr_result the result returned by the ASR server
* @return ASR_STATUS
*/
int asr_read(asr_t* asr, char** asr_result);
/**
* Close the asr client handle
* @param asr the asr handle
* @return ASR_STATUS
*/
void asr_close(asr_t* asr);
#ifdef __cplusplus
}
#endif
#endif