/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-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* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* AT&T Research25*26* sfio tmp string buffer support27*/2829#include <sfio_t.h>30#include <ast.h>3132#if __OBSOLETE__ >= 20070101 /* sfstr* macros now use sfsetbuf() */3334NoN(sfstrtmp)3536#else3738#if defined(__EXPORT__)39#define extern __EXPORT__40#endif4142/*43* replace buffer in string stream f for either SF_READ or SF_WRITE44*/4546extern int47sfstrtmp(register Sfio_t* f, int mode, void* buf, size_t siz)48{49if (!(f->_flags & SF_STRING))50return -1;51if (f->_flags & SF_MALLOC)52free(f->_data);53f->_flags &= ~(SF_ERROR|SF_MALLOC);54f->mode = mode;55f->_next = f->_data = (unsigned char*)buf;56f->_endw = f->_endr = f->_endb = f->_data + siz;57f->_size = siz;58return 0;59}6061#endif626364