/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2012 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#ifndef _SFIO_T_H22#define _SFIO_T_H 12324/* This header file is for library writers who need to know certain25** internal info concerning the full Sfio_t structure. Including this26** file means that you agree to track closely with sfio development27** in case its internal architecture is changed.28**29** Written by Kiem-Phong Vo30*/3132/* the parts of Sfio_t private to sfio functions */33#define _SFIO_PRIVATE \34Sfoff_t extent; /* current file size */ \35Sfoff_t here; /* current physical location */ \36unsigned char unused_1;/* unused #1 */ \37unsigned char tiny[1];/* for unbuffered read stream */ \38unsigned short bits; /* private flags */ \39unsigned int mode; /* current io mode */ \40struct _sfdisc_s* disc; /* discipline */ \41struct _sfpool_s* pool; /* the pool containing this */ \42struct _sfrsrv_s* rsrv; /* reserved buffer */ \43struct _sfproc_s* proc; /* coprocess id, etc. */ \44Void_t* mutex; /* mutex for thread-safety */ \45Void_t* stdio; /* stdio FILE if any */ \46Sfoff_t lpos; /* last seek position */ \47size_t iosz; /* preferred size for I/O */ \48size_t blksz; /* preferred block size */ \49int getr; /* the last sfgetr separator */ \50_SFIO_PRIVATE_PAD5152#if _ast_sizeof_pointer == 853#define _SFIO_PRIVATE_PAD int pad;54#else55#define _SFIO_PRIVATE_PAD56#endif5758#include "sfio.h"5960/* mode bit to indicate that the structure hasn't been initialized */61#define SF_INIT 000000462#define SF_DCDOWN 000100006364/* short-hand for common stream types */65#define SF_RDWR (SF_READ|SF_WRITE)66#define SF_RDSTR (SF_READ|SF_STRING)67#define SF_WRSTR (SF_WRITE|SF_STRING)68#define SF_RDWRSTR (SF_RDWR|SF_STRING)6970/* for static initialization of an Sfio_t structure */71#define SFNEW(data,size,file,type,disc,mutex) \72{ (unsigned char*)(data), /* next */ \73(unsigned char*)(data), /* endw */ \74(unsigned char*)(data), /* endr */ \75(unsigned char*)(data), /* endb */ \76(Sfio_t*)0, /* push */ \77(unsigned short)((type)&SF_FLAGS), /* flags */ \78(short)(file), /* file */ \79(unsigned char*)(data), /* data */ \80(ssize_t)(size), /* size */ \81(ssize_t)(-1), /* val */ \82(Sfoff_t)0, /* extent */ \83(Sfoff_t)0, /* here */ \840, /* getr */ \85{0}, /* tiny */ \860, /* bits */ \87(unsigned int)(((type)&(SF_RDWR))|SF_INIT), /* mode */ \88(struct _sfdisc_s*)(disc), /* disc */ \89(struct _sfpool_s*)0, /* pool */ \90(struct _sfrsrv_s*)0, /* rsrv */ \91(struct _sfproc_s*)0, /* proc */ \92(mutex), /* mutex */ \93(Void_t*)0, /* stdio */ \94(Sfoff_t)0, /* lpos */ \95(size_t)0 /* iosz */ \96}9798/* function to clear an Sfio_t structure */99#define SFCLEAR(f,mtx) \100( (f)->next = (unsigned char*)0, /* next */ \101(f)->endw = (unsigned char*)0, /* endw */ \102(f)->endr = (unsigned char*)0, /* endr */ \103(f)->endb = (unsigned char*)0, /* endb */ \104(f)->push = (Sfio_t*)0, /* push */ \105(f)->flags = (unsigned short)0, /* flags */ \106(f)->file = -1, /* file */ \107(f)->data = (unsigned char*)0, /* data */ \108(f)->size = (ssize_t)(-1), /* size */ \109(f)->val = (ssize_t)(-1), /* val */ \110(f)->extent = (Sfoff_t)(-1), /* extent */ \111(f)->here = (Sfoff_t)0, /* here */ \112(f)->getr = 0, /* getr */ \113(f)->tiny[0] = 0, /* tiny */ \114(f)->bits = 0, /* bits */ \115(f)->mode = 0, /* mode */ \116(f)->disc = (struct _sfdisc_s*)0, /* disc */ \117(f)->pool = (struct _sfpool_s*)0, /* pool */ \118(f)->rsrv = (struct _sfrsrv_s*)0, /* rsrv */ \119(f)->proc = (struct _sfproc_s*)0, /* proc */ \120(f)->mutex = (mtx), /* mutex */ \121(f)->stdio = (Void_t*)0, /* stdio */ \122(f)->lpos = (Sfoff_t)0, /* lpos */ \123(f)->iosz = (size_t)0 /* iosz */ \124)125126/* expose next stream inside discipline function; state saved in int f */127#define SFDCNEXT(sp,f) (((f)=(sp)->bits&SF_DCDOWN),(sp)->bits|=SF_DCDOWN)128129/* restore SFDCNEXT() state from int f */130#define SFDCPREV(sp,f) ((f)?(0):((sp)->bits&=~SF_DCDOWN))131132#endif /* _SFIO_T_H */133134135