Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libvcodex/vcrecode.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2003-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "vchdr.h"
21
22
/* Recode a chunk of data using a secondary coder.
23
**
24
** Written by Kiem-Phong Vo
25
*/
26
27
#if __STD_
28
int vcrecode(Vcodex_t* vc, Vcchar_t** dtp, ssize_t* dtz, ssize_t head, int type)
29
#else
30
int vcrecode(vc, dtp, dtz, head, type)
31
Vcodex_t* vc; /* coding handle */
32
Vcchar_t** dtp; /* input/output data */
33
ssize_t* dtz; /* input/output size */
34
ssize_t head; /* extra header */
35
int type; /* = 0: undone is bad */
36
#endif
37
{
38
ssize_t sz;
39
Vcchar_t *dt;
40
41
if(!vc->coder) /* nothing to do */
42
return 0;
43
44
/* ask follow-on coders to leave head room */
45
vc->coder->head += vc->head + head;
46
sz = vcapply(vc->coder, *dtp, *dtz, &dt);
47
vc->coder->head -= vc->head + head;
48
49
if(sz < 0) /* secondary coder failed */
50
return -1;
51
52
if(type == 0) /* no undone data allowed */
53
{ if(vcundone(vc->coder) > 0)
54
return -1;
55
}
56
else /* undone data ok and reflected upward */
57
{ vc->undone = vc->coder->undone;
58
}
59
60
*dtp = dt; *dtz = sz;
61
return 0;
62
}
63
64