-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoder.h
52 lines (40 loc) · 905 Bytes
/
decoder.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
/**
* File: decoder.h
* Author: Joe Shang ([email protected])
* Brief: The decoder interface.
*/
#ifndef _DECODER_H_
#define _DECODER_H_
#include <stdlib.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
struct _Decoder;
typedef struct _Decoder Decoder;
struct _Decoder
{
int (*decode)(Decoder *thiz,
unsigned char **out_buf,
unsigned char *in_buf,
int buf_size);
void (*destroy)(Decoder *thiz);
char priv[];
};
static inline int decoder_decode(Decoder *thiz,
unsigned char **out_buf,
unsigned char *in_buf,
int buf_size)
{
assert(thiz != NULL && thiz->decode != NULL);
return thiz->decode(thiz, out_buf, in_buf, buf_size);
}
static inline void decoder_destroy(Decoder *thiz)
{
assert(thiz != NULL && thiz->destroy != NULL);
thiz->destroy(thiz);
}
#ifdef __cplusplus
}
#endif
#endif