/***********************************************************************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 "vcwhdr.h"2021/* Method to get a matching window while decoding.22** In this case, data must be VCD_SOURCEFILE or VCD_TARGETFILE.23**24** Written by Kiem-Phong Vo ([email protected])25*/2627#if __STD_C28static Vcwmatch_t* decode(Vcwindow_t* vcw, Void_t* data, size_t size, Sfoff_t here)29#else30static Vcwmatch_t* decode(vcw, data, size, here)31Vcwindow_t* vcw; /* signature structure */32Void_t* data; /* target data to be matched */33size_t size; /* data size */34Sfoff_t here; /* current target position */35#endif36{37Sfio_t *sf;3839if(!vcw || !vcw->disc || size <= 0 )40return NIL(Vcwmatch_t*);4142if((vcw->match.type = TYPECAST(int,data)) == VCD_SOURCEFILE )43sf = vcw->disc->srcf;44else if(vcw->match.type == VCD_TARGETFILE)45sf = vcw->disc->tarf;46else sf = NIL(Sfio_t*);4748if(!sf)49return NIL(Vcwmatch_t*);5051if(sfseek(sf, here, SEEK_SET) != here)52return NIL(Vcwmatch_t*);5354if(!(vcw->match.wdata = sfreserve(sf, size, 0)) || sfvalue(sf) < size )55return NIL(Vcwmatch_t*);56vcw->match.wsize = size;57vcw->match.wpos = here;58vcw->match.msize = size;59vcw->match.more = 0;6061return &vcw->match;62}6364static Vcwmethod_t _Vcwdecode =65{ decode,660,67"decode"68};6970Vcwmethod_t* Vcwdecode = &_Vcwdecode;717273