/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 2003-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Phong Vo <[email protected]> *17* *18***********************************************************************/19#include "vchdr.h"2021/* Recode a chunk of data using a secondary coder.22**23** Written by Kiem-Phong Vo24*/2526#if __STD_27int vcrecode(Vcodex_t* vc, Vcchar_t** dtp, ssize_t* dtz, ssize_t head, int type)28#else29int vcrecode(vc, dtp, dtz, head, type)30Vcodex_t* vc; /* coding handle */31Vcchar_t** dtp; /* input/output data */32ssize_t* dtz; /* input/output size */33ssize_t head; /* extra header */34int type; /* = 0: undone is bad */35#endif36{37ssize_t sz;38Vcchar_t *dt;3940if(!vc->coder) /* nothing to do */41return 0;4243/* ask follow-on coders to leave head room */44vc->coder->head += vc->head + head;45sz = vcapply(vc->coder, *dtp, *dtz, &dt);46vc->coder->head -= vc->head + head;4748if(sz < 0) /* secondary coder failed */49return -1;5051if(type == 0) /* no undone data allowed */52{ if(vcundone(vc->coder) > 0)53return -1;54}55else /* undone data ok and reflected upward */56{ vc->undone = vc->coder->undone;57}5859*dtp = dt; *dtz = sz;60return 0;61}626364