55extern "C" {
66#endif
77
8+
89/* {{{ API declaration */
910struct tp_transcode ;
1011
@@ -67,6 +68,9 @@ typedef struct tp_transcode {
6768#define TP_TRANSCODE_ERROR 2
6869#define TP_TRANSCODE_AGAIN 3
6970
71+ ssize_t
72+ tp_read_payload (const char * const buf , const char * const end );
73+
7074/**
7175 * Initialize struct tp_transcode.
7276 * Returns TP_TRANSCODE_ERROR if codec not found or create codec failed
@@ -102,7 +106,7 @@ tp_dump(char *output, size_t output_size, char *input, size_t input_size);
102106static inline int
103107tp_transcode_complete (tp_transcode_t * t , size_t * complete_msg_size )
104108{
105- if (mp_likely ( t != NULL ) ) {
109+ if (t != NULL ) {
106110 const int rc = t -> codec .complete (t -> codec .ctx , complete_msg_size );
107111 t -> codec .free (t -> codec .ctx );
108112 return rc ;
@@ -113,7 +117,7 @@ tp_transcode_complete(tp_transcode_t *t, size_t *complete_msg_size)
113117static inline int
114118tp_transcode (tp_transcode_t * t , char * b , size_t size )
115119{
116- if (mp_likely ( t != NULL ) )
120+ if (t != NULL )
117121 return t -> codec .transcode (t -> codec .ctx , b , size );
118122 return TP_TRANSCODE_ERROR ;
119123}
@@ -123,11 +127,11 @@ tp_dump(char *output, size_t output_size, char *input, size_t input_size)
123127{
124128 tp_transcode_t t ;
125129 if (tp_transcode_init (& t , output , output_size , TP_TO_JSON )
126- == TP_TRANSCODE_ERROR )
130+ == TP_TRANSCODE_ERROR )
127131 return false;
128132
129133 if (tp_transcode (& t , input , input_size ) == TP_TRANSCODE_ERROR )
130- return false;
134+ return false;
131135
132136 size_t complete_msg_size = 0 ;
133137 tp_transcode_complete (& t , & complete_msg_size );
@@ -136,21 +140,6 @@ tp_dump(char *output, size_t output_size, char *input, size_t input_size)
136140 return complete_msg_size > 0 ;
137141}
138142
139- static inline ssize_t
140- tp_read_payload (const char * const buf , const char * const end )
141- {
142- const size_t size = end - buf ;
143- if (size == 0 || size < 6 )
144- return 0 ;
145- const char * p = buf , * test = buf ;
146- memset (r , 0 , sizeof (struct tpresponse ));
147- if (mp_check (& test , buf + size ))
148- return -1 ;
149- if (mp_typeof (* p ) != MP_UINT )
150- return -1 ;
151- return mp_decode_uint (& p ) + p - buf ;
152- }
153-
154143#ifdef __cplusplus
155144} /* extern "C" */
156145#endif
0 commit comments