The functions definitions in sfio are all surrounded by an `#if __STD_C`, if __STD_C is not defined than the old style function definition is used. These days STD C is the standard and the old style function defintions are obsolete.
They have been removed from lib/sfio and its subprojects, comments have been preserved by converting time to a Doxygen style.
#define P2I(p) (Sfulong_t)((char*)(p) - (char*)0)
#ifdef HAVE_STRUCT_DIOATTR
-#if __STD_C
static ssize_t diordwr(Sfio_t * f, Void_t * buf, size_t n, Direct_t * di,
int type)
-#else
-static ssize_t diordwr(f, buf, n, di, type)
-Sfio_t *f;
-Void_t *buf;
-size_t n;
-Direct_t *di;
-int type;
-#endif
{
size_t rw, done;
ssize_t rv = 0;
return done ? done : rv;
}
-#if __STD_C
static ssize_t dioread(Sfio_t * f, Void_t * buf, size_t n, Sfdisc_t * disc)
-#else
-static ssize_t dioread(f, buf, n, disc)
-Sfio_t *f;
-Void_t *buf;
-size_t n;
-Sfdisc_t *disc;
-#endif
{
return diordwr(f, buf, n, (Direct_t *) disc, SF_READ);
}
-#if __STD_C
static ssize_t diowrite(Sfio_t * f, const Void_t * buf, size_t n,
Sfdisc_t * disc)
-#else
-static ssize_t diowrite(f, buf, n, disc)
-Sfio_t *f;
-Void_t *buf;
-size_t n;
-Sfdisc_t *disc;
-#endif
{
return diordwr(f, (Void_t *) buf, n, (Direct_t *) disc, SF_WRITE);
}
-#if __STD_C
static int dioexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
-#else
-static int dioexcept(f, type, data, disc)
-Sfio_t *f;
-int type;
-Void_t *data;
-Sfdisc_t *disc;
-#endif
{
Direct_t *di = (Direct_t *) disc;
}
#endif /*HAVE_STRUCT_DIOATTR */
-#if __STD_C
int sfdcdio(Sfio_t * f, size_t bufsize)
-#else
-int sfdcdio(f, bufsize)
-Sfio_t *f;
-size_t bufsize;
-#endif
{
#ifndef HAVE_STRUCT_DIOATTR
return -1;
int bsize;
} Dosdisc_t;
-#if __STD_C
static void addmapping(register Dosdisc_t * dp)
-#else
-static void addmapping(dp)
-register Dosdisc_t *dp;
-#endif
{
register int n;
if ((n = dp->maptop++) >= dp->mapsize) {
dp->maptable[dp->maptop].logical = 0;
}
-#if __STD_C
static struct map *getmapping(Dosdisc_t * dp, off_t offset,
register int whence)
-#else
-static struct map *getmapping(dp, offset, whence)
-Dosdisc_t *dp;
-off_t offset;
-register int whence;
-#endif
{
register struct map *mp;
static struct map dummy;
return (mp - 1);
}
-#if __STD_C
static ssize_t dos_read(Sfio_t * iop, void *buff, size_t size,
Sfdisc_t * disc)
-#else
-static ssize_t dos_read(iop, buff, size, disc)
-Sfio_t *iop;
-void *buff;
-size_t size;
-Sfdisc_t *disc;
-#endif
{
register Dosdisc_t *dp = (Dosdisc_t *) disc;
register char *cp = (char *) buff, *first, *cpmax;
* if <whence> is SEEK_CUR, physical offset converted to logical offset
* otherwise, logical offset is converted to physical offset
*/
-#if __STD_C
static off_t cur_offset(Dosdisc_t * dp, off_t offset, Sfio_t * iop,
register int whence)
-#else
-static off_t cur_offset(dp, offset, iop, whence)
-Dosdisc_t *dp;
-off_t offset;
-Sfio_t *iop;
-register int whence;
-#endif
{
register off_t n, m = 0;
register char *cp;
return (offset + m);
}
-#if __STD_C
static Sfoff_t dos_seek(Sfio_t * iop, Sfoff_t offset, register int whence,
Sfdisc_t * disc)
-#else
-static Sfoff_t dos_seek(iop, offset, whence, disc)
-Sfio_t *iop;
-Sfoff_t offset;
-register int whence;
-Sfdisc_t *disc;
-#endif
{
register Dosdisc_t *dp = (Dosdisc_t *) disc;
struct map dummy, *mp = 0;
return (offset);
}
-#if __STD_C
static int dos_except(Sfio_t * iop, int type, void *arg, Sfdisc_t * disc)
-#else
-static int dos_except(iop, type, arg, disc)
-Sfio_t *iop;
-int type;
-void *arg;
-Sfdisc_t *disc;
-#endif
{
register Dosdisc_t *dp = (Dosdisc_t *) disc;
if (type == SF_DPOP || type == SF_FINAL) {
return (0);
}
-#if __STD_C
int sfdcdos(Sfio_t * f)
-#else
-int sfdcdos(f)
-Sfio_t *f;
-#endif
{
Dosdisc_t *dos;
} Filter_t;
/* read data from the filter */
-#if __STD_C
+/**
+ * @param f stream reading from
+ * @param buf buffer to read into
+ * @param n number of bytes requested
+ * @param disc discipline
+ */
static ssize_t filterread(Sfio_t * f, Void_t * buf, size_t n,
Sfdisc_t * disc)
-#else
-static ssize_t filterread(f, buf, n, disc)
-Sfio_t *f; /* stream reading from */
-Void_t *buf; /* buffer to read into */
-size_t n; /* number of bytes requested */
-Sfdisc_t *disc; /* discipline */
-#endif
{
Filter_t *fi;
ssize_t r, w;
}
}
-#if __STD_C
+/**
+ * @param f stream reading from
+ * @param buf buffer to read into
+ * @param n number of bytes requested
+ * @param disc discipline
+ */
static ssize_t filterwrite(Sfio_t * f, const Void_t * buf, size_t n,
Sfdisc_t * disc)
-#else
-static ssize_t filterwrite(f, buf, n, disc)
-Sfio_t *f; /* stream reading from */
-Void_t *buf; /* buffer to read into */
-size_t n; /* number of bytes requested */
-Sfdisc_t *disc; /* discipline */
-#endif
{
return -1;
}
/* for the duration of this discipline, the stream is unseekable */
-#if __STD_C
static Sfoff_t filterseek(Sfio_t * f, Sfoff_t addr, int offset,
Sfdisc_t * disc)
-#else
-static Sfoff_t filterseek(f, addr, offset, disc)
-Sfio_t *f;
-Sfoff_t addr;
-int offset;
-Sfdisc_t *disc;
-#endif
{
f = NIL(Sfio_t *);
addr = 0;
}
/* on close, remove the discipline */
-#if __STD_C
static int filterexcept(Sfio_t * f, int type, Void_t * data,
Sfdisc_t * disc)
-#else
-static int filterexcept(f, type, data, disc)
-Sfio_t *f;
-int type;
-Void_t *data;
-Sfdisc_t *disc;
-#endif
{
if (type == SF_FINAL || type == SF_DPOP) {
sfclose(((Filter_t *) disc)->filter);
return 0;
}
-#if __STD_C
+/**
+ * @param f stream to filter data
+ * @param cmd program to run as a filter
+ */
int sfdcfilter(Sfio_t * f, const char *cmd)
-#else
-int sfdcfilter(f, cmd)
-Sfio_t *f; /* stream to filter data */
-char *cmd; /* program to run as a filter */
-#endif
{
reg Filter_t *fi;
reg Sfio_t *filter;
static char_type rmask[9] =
{ 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
-#if __STD_C
static int peek(Sfio_t * f, char_type ** bufp, int count,
reg LZW_Disc * disc)
-#else
-static int peek(f, bufp, count, disc)
-Sfio_t *f;
-char_type **bufp;
-int count;
-reg LZW_Disc *disc;
-#endif
{
reg int io_sz, j;
* code or -1 is returned.
*/
-#if __STD_C
static code_int getcode(Sfio_t * f, LZW_Disc * disc)
-#else
-static code_int getcode(f, disc)
-Sfio_t *f;
-LZW_Disc *disc;
-#endif
{
reg code_int code;
reg int r_off, bits;
}
-#if __STD_C
static int lzwExcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
-#else
-static int lzwExcept(f, type, data, disc)
-Sfio_t *f;
-int type;
-Void_t *data;
-Sfdisc_t *disc;
-#endif
{
if (type == SF_FINAL || type == SF_DPOP)
free(disc);
* with those of the compress() routine. See the definitions above.
*/
-#if __STD_C
ssize_t lzwRead(Sfio_t * f, Void_t * iobuf, size_t iocnt,
Sfdisc_t * sfdisc)
-#else
-ssize_t lzwRead(f, iobuf, iocnt, sfdisc)
-Sfio_t *f;
-Void_t *iobuf;
-size_t iocnt;
-Sfdisc_t *sfdisc;
-#endif
{
LZW_Disc *disc = (LZW_Disc *) sfdisc;
reg char_type *stackp;
END_REGS return ioptr - (char *) iobuf;
}
-#if __STD_C
static Sfoff_t lzwSeek(Sfio_t * f, Sfoff_t offset, int whence,
Sfdisc_t * disc)
-#else
-static Sfoff_t lzwSeek(f, offset, whence, disc)
-Sfio_t *f;
-Sfoff_t offset;
-int whence;
-Sfdisc_t *disc;
-#endif
{
return (Sfoff_t) (-1);
}
-#if __STD_C
static ssize_t lzwWrite(Sfio_t * f, const Void_t * buf, size_t count,
Sfdisc_t * disc)
-#else
-static ssize_t lzwWrite(f, buf, count, disc)
-Sfio_t *f;
-Void_t *buf;
-size_t count;
-Sfdisc_t *disc;
-#endif
{
return (ssize_t) (-1);
}
-#if __STD_C
int sfdclzw(Sfio_t * f)
-#else
-int sfdclzw(f)
-Sfio_t *f;
-#endif
{
LZW_Disc *lz;
int eof; /* if eof has been reached */
} Seek_t;
-#if __STD_C
+/**
+ * @param f stream involved
+ * @param buf buffer to read into
+ * @param n number of bytes to read
+ * @param disc discipline
+ */
static ssize_t skwrite(Sfio_t * f, const Void_t * buf, size_t n,
Sfdisc_t * disc)
-#else
-static ssize_t skwrite(f, buf, n, disc)
-Sfio_t *f; /* stream involved */
-Void_t *buf; /* buffer to read into */
-size_t n; /* number of bytes to read */
-Sfdisc_t *disc; /* discipline */
-#endif
{
return (ssize_t) (-1);
}
-#if __STD_C
+/**
+ * @param f stream involved
+ * @param buf buffer to read into
+ * @param n number of bytes to read
+ * @param disc discipline
+ */
static ssize_t skread(Sfio_t * f, Void_t * buf, size_t n, Sfdisc_t * disc)
-#else
-static ssize_t skread(f, buf, n, disc)
-Sfio_t *f; /* stream involved */
-Void_t *buf; /* buffer to read into */
-size_t n; /* number of bytes to read */
-Sfdisc_t *disc; /* discipline */
-#endif
{
Seek_t *sk;
Sfio_t *sf;
return r + w;
}
-#if __STD_C
static Sfoff_t skseek(Sfio_t * f, Sfoff_t addr, int type, Sfdisc_t * disc)
-#else
-static Sfoff_t skseek(f, addr, type, disc)
-Sfio_t *f;
-Sfoff_t addr;
-int type;
-Sfdisc_t *disc;
-#endif
{
Sfoff_t extent;
Seek_t *sk;
}
/* on close, remove the discipline */
-#if __STD_C
static int skexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
-#else
-static int skexcept(f, type, data, disc)
-Sfio_t *f;
-int type;
-Void_t *data;
-Sfdisc_t *disc;
-#endif
{
if (type == SF_FINAL || type == SF_DPOP) {
sfclose(((Seek_t *) disc)->shadow);
return 0;
}
-#if __STD_C
int sfdcseekable(Sfio_t * f)
-#else
-int sfdcseekable(f)
-Sfio_t *f;
-#endif
{
reg Seek_t *sk;
** Written by Glenn Fowler (03/18/1998).
*/
-#if __STD_C
static int slowexcept(Sfio_t * f, int type, Void_t * v, Sfdisc_t * disc)
-#else
-static int slowexcept(f, type, v, disc)
-Sfio_t *f;
-int type;
-Void_t *v;
-Sfdisc_t *disc;
-#endif
{
NOTUSED(f);
NOTUSED(v);
return (0);
}
-#if __STD_C
int sfdcslow(Sfio_t * f)
-#else
-int sfdcslow(f)
-Sfio_t *f;
-#endif
{
Sfdisc_t *disc;
Sfoff_t here; /* current seek location */
} Subfile_t;
-#if __STD_C
static ssize_t streamio(Sfio_t * f, Void_t * buf, size_t n,
Sfdisc_t * disc, int type)
-#else
-static ssize_t streamio(f, buf, n, disc, type)
-Sfio_t *f;
-Void_t *buf;
-size_t n;
-Sfdisc_t *disc;
-int type;
-#endif
{
reg Subfile_t *su;
reg Sfoff_t here, parent;
return io;
}
-#if __STD_C
static ssize_t streamwrite(Sfio_t * f, const Void_t * buf, size_t n,
Sfdisc_t * disc)
-#else
-static ssize_t streamwrite(f, buf, n, disc)
-Sfio_t *f;
-Void_t *buf;
-size_t n;
-Sfdisc_t *disc;
-#endif
{
return streamio(f, (Void_t *) buf, n, disc, SF_WRITE);
}
-#if __STD_C
static ssize_t streamread(Sfio_t * f, Void_t * buf, size_t n,
Sfdisc_t * disc)
-#else
-static ssize_t streamread(f, buf, n, disc)
-Sfio_t *f;
-Void_t *buf;
-size_t n;
-Sfdisc_t *disc;
-#endif
{
return streamio(f, buf, n, disc, SF_READ);
}
-#if __STD_C
static Sfoff_t streamseek(Sfio_t * f, Sfoff_t pos, int type,
Sfdisc_t * disc)
-#else
-static Sfoff_t streamseek(f, pos, type, disc)
-Sfio_t *f;
-Sfoff_t pos;
-int type;
-Sfdisc_t *disc;
-#endif
{
reg Subfile_t *su;
reg Sfoff_t here, parent;
return (su->here = pos);
}
-#if __STD_C
static int streamexcept(Sfio_t * f, int type, Void_t * data,
Sfdisc_t * disc)
-#else
-static int streamexcept(f, type, data, disc)
-Sfio_t *f;
-int type;
-Void_t *data;
-Sfdisc_t *disc;
-#endif
{
if (type == SF_FINAL || type == SF_DPOP)
free(disc);
return 0;
}
-#if __STD_C
+/**
+ * @param f stream
+ * @param parent parent stream
+ * @param offset offset in parent stream
+ * @param extent desired size
+ */
int sfdcsubstream(Sfio_t * f, Sfio_t * parent, Sfoff_t offset,
Sfoff_t extent)
-#else
-int sfdcsubstream(f, parent, offset, extent)
-Sfio_t *f; /* stream */
-Sfio_t *parent; /* parent stream */
-Sfoff_t offset; /* offset in parent stream */
-Sfoff_t extent; /* desired size */
-#endif
{
reg Subfile_t *su;
reg Sfoff_t here;
} Tee_t;
/* write to the teed stream. */
-#if __STD_C
+/**
+ * @param f the stream being written to
+ * @param buf the buffer of data being output
+ * @param size the data size
+ * @param disc the tee discipline
+ */
static ssize_t teewrite(Sfio_t * f, const Void_t * buf, size_t size,
Sfdisc_t * disc)
-#else
-static ssize_t teewrite(f, buf, size, disc)
-Sfio_t *f; /* the stream being written to */
-Void_t *buf; /* the buffer of data being output */
-size_t size; /* the data size */
-Sfdisc_t *disc; /* the tee discipline */
-#endif
{
reg Tee_t *te = (Tee_t *) disc;
}
/* on close, remove the discipline */
-#if __STD_C
static int teeexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
-#else
-static int teeexcept(f, type, data, disc)
-Sfio_t *f;
-int type;
-Void_t *data;
-Sfdisc_t *disc;
-#endif
{
if (type == SF_FINAL || type == SF_DPOP)
free(disc);
return 0;
}
-#if __STD_C
+/**
+ * @param f stream to tee from
+ * @param tee stream to tee to
+ */
int sfdctee(Sfio_t * f, Sfio_t * tee)
-#else
-int sfdctee(f, tee)
-Sfio_t *f; /* stream to tee from */
-Sfio_t *tee; /* stream to tee to */
-#endif
{
reg Tee_t *te;
File_t f[1]; /* array of streams */
} Union_t;
-#if __STD_C
+/**
+ * @param f stream involved
+ * @param buf buffer to read into
+ * @param n number of bytes to read
+ * @param disc discipline
+ */
static ssize_t unwrite(Sfio_t * f, const Void_t * buf, size_t n,
Sfdisc_t * disc)
-#else
-static ssize_t unwrite(f, buf, n, disc)
-Sfio_t *f; /* stream involved */
-Void_t *buf; /* buffer to read into */
-size_t n; /* number of bytes to read */
-Sfdisc_t *disc; /* discipline */
-#endif
{
return -1;
}
-#if __STD_C
+/**
+ * @param f stream involved
+ * @param buf buffer to read into
+ * @param n number of bytes to read
+ * @param disc discipline
+ */
static ssize_t unread(Sfio_t * f, Void_t * buf, size_t n, Sfdisc_t * disc)
-#else
-static ssize_t unread(f, buf, n, disc)
-Sfio_t *f; /* stream involved */
-Void_t *buf; /* buffer to read into */
-size_t n; /* number of bytes to read */
-Sfdisc_t *disc; /* discipline */
-#endif
{
reg Union_t *un;
reg ssize_t r, m;
return n - m;
}
-#if __STD_C
static Sfoff_t unseek(Sfio_t * f, Sfoff_t addr, int type, Sfdisc_t * disc)
-#else
-static Sfoff_t unseek(f, addr, type, disc)
-Sfio_t *f;
-Sfoff_t addr;
-int type;
-Sfdisc_t *disc;
-#endif
{
reg Union_t *un;
reg int i;
}
/* on close, remove the discipline */
-#if __STD_C
static int unexcept(Sfio_t * f, int type, Void_t * data, Sfdisc_t * disc)
-#else
-static int unexcept(f, type, data, disc)
-Sfio_t *f;
-int type;
-Void_t *data;
-Sfdisc_t *disc;
-#endif
{
if (type == SF_FINAL || type == SF_DPOP)
free(disc);
return 0;
}
-#if __STD_C
int sfdcunion(Sfio_t * f, Sfio_t ** array, int n)
-#else
-int sfdcunion(f, array, n)
-Sfio_t *f;
-Sfio_t **array;
-int n;
-#endif
{
reg Union_t *un;
reg int i;
#undef sfclrerr
-#if __STD_C
int sfclrerr(reg Sfio_t * f)
-#else
-int sfclrerr(f)
-reg Sfio_t *f;
-#endif
{
return __sf_clrerr(f);
}
#undef sfdlen
-#if __STD_C
int sfdlen(reg Sfdouble_t v)
-#else
-int sfdlen(v)
-reg Sfdouble_t v;
-#endif
{
return __sf_dlen(v);
}
#undef sfeof
-#if __STD_C
int sfeof(reg Sfio_t * f)
-#else
-int sfeof(f)
-reg Sfio_t *f;
-#endif
{
return __sf_eof(f);
}
#undef sferror
-#if __STD_C
int sferror(reg Sfio_t * f)
-#else
-int sferror(f)
-reg Sfio_t *f;
-#endif
{
return __sf_error(f);
}
#undef sffileno
-#if __STD_C
int sffileno(reg Sfio_t * f)
-#else
-int sffileno(f)
-reg Sfio_t *f;
-#endif
{
return __sf_fileno(f);
}
#undef sfgetc
-#if __STD_C
int sfgetc(reg Sfio_t * f)
-#else
-int sfgetc(f)
-reg Sfio_t *f;
-#endif
{
return __sf_getc(f);
}
#undef sfllen
-#if __STD_C
int sfllen(reg Sflong_t v)
-#else
-int sfllen(v)
-reg Sflong_t v;
-#endif
{
return __sf_llen(v);
}
#undef sfputc
-#if __STD_C
int sfputc(reg Sfio_t * f, reg int c)
-#else
-int sfputc(f, c)
-reg Sfio_t *f;
-reg int c;
-#endif
{
return __sf_putc(f, c);
}
#undef sfputd
-#if __STD_C
int sfputd(reg Sfio_t * f, Sfdouble_t d)
-#else
-int sfputd(f, d)
-reg Sfio_t *f;
-reg Sfdouble_t d;
-#endif
{
return __sf_putd(f, d);
}
#undef sfputl
-#if __STD_C
int sfputl(reg Sfio_t * f, Sflong_t l)
-#else
-int sfputl(f, l)
-reg Sfio_t *f;
-reg Sflong_t l;
-#endif
{
return __sf_putl(f, l);
}
#undef sfputm
-#if __STD_C
int sfputm(reg Sfio_t * f, Sfulong_t u, Sfulong_t m)
-#else
-int sfputm(f, u, m)
-reg Sfio_t *f;
-reg Sfulong_t u;
-reg Sfulong_t m;
-#endif
{
return __sf_putm(f, u, m);
}
#undef sfputu
-#if __STD_C
int sfputu(reg Sfio_t * f, Sfulong_t u)
-#else
-int sfputu(f, u)
-reg Sfio_t *f;
-reg Sfulong_t u;
-#endif
{
return __sf_putu(f, u);
}
#undef sfslen
-#if __STD_C
ssize_t sfslen(void)
-#else
-ssize_t sfslen()
-#endif
{
return __sf_slen();
}
#undef sfstacked
-#if __STD_C
int sfstacked(reg Sfio_t * f)
-#else
-int sfstacked(f)
-reg Sfio_t *f;
-#endif
{
return __sf_stacked(f);
}
#undef sfulen
-#if __STD_C
int sfulen(reg Sfulong_t v)
-#else
-int sfulen(v)
-reg Sfulong_t v;
-#endif
{
return __sf_ulen(v);
}
#undef sfvalue
-#if __STD_C
ssize_t sfvalue(reg Sfio_t * f)
-#else
-ssize_t sfvalue(f)
-reg Sfio_t *f;
-#endif
{
return __sf_value(f);
}
** Written by Kiem-Phong Vo
*/
-#if __STD_C
int sfclose(reg Sfio_t * f)
-#else
-int sfclose(f)
-reg Sfio_t *f;
-#endif
{
reg int local, ex, rv;
Void_t *data = NIL(Void_t *);
**
** Written by Kiem-Phong Vo
*/
-#if __STD_C
int sfclrlock(reg Sfio_t * f)
-#else
-int sfclrlock(f)
-reg Sfio_t *f;
-#endif
{
int rv;
#define SF_INFINITE ((_Sfi = 3), Inf)
#define SF_ZERO ((_Sfi = 1), Zero)
-#if __STD_C
+/**
+ * @param dv value to convert
+ * @param n_digit number of digits wanted
+ * @param decpt return decimal point
+ * @param sign return sign
+ * @param format conversion format
+ */
char *_sfcvt(Void_t * dv, int n_digit, int *decpt, int *sign, int format)
-#else
-char *_sfcvt(dv, n_digit, decpt, sign, format)
-Void_t *dv; /* value to convert */
-int n_digit; /* number of digits wanted */
-int *decpt; /* to return decimal point */
-int *sign; /* to return sign */
-int format; /* conversion format */
-#endif
{
reg char *sp;
reg long n, v;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
Sfdisc_t *sfdisc(reg Sfio_t * f, reg Sfdisc_t * disc)
-#else
-Sfdisc_t *sfdisc(f, disc)
-reg Sfio_t *f;
-reg Sfdisc_t *disc;
-#endif
{
reg Sfdisc_t *d, *rdisc;
reg Sfread_f oreadf;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
int _sfdlen(Sfdouble_t v)
-#else
-int _sfdlen(v)
-Sfdouble_t v;
-#endif
{
#define N_ARRAY (16*sizeof(Sfdouble_t))
reg int n, w;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
+/**
+ * @param f stream where the exception happened
+ * @param type type that was performed
+ * @param io return value that indicated exception
+ * @param disc discipline in use
+ */
int _sfexcept(Sfio_t * f, int type, ssize_t io, Sfdisc_t * disc)
-#else
-int _sfexcept(f, type, io, disc)
-Sfio_t *f; /* stream where the exception happened */
-int type; /* io type that was performed */
-ssize_t io; /* the io return value that indicated exception */
-Sfdisc_t *disc; /* discipline in use */
-#endif
{
reg int ev, local, lock;
reg ssize_t size;
#if !_lib_atexit
#if _lib_onexit
-#if __STD_C
int atexit(void (*exitf) (void))
-#else
-int atexit(exitf)
-void (*exitf) ();
-#endif
{
#if _lib_onexit
return onexit(exitf);
} Exit_t;
static Exit_t *Exit;
-#if __STD_C
atexit(void (*exitf) (void))
-#else
-atexit(exitf)
-void (*exitf) ();
-#endif
{
Exit_t *e;
int rv;
#if _exit_cleanup
/* since exit() calls _cleanup(), we only need to redefine _cleanup() */
-#if __STD_C
_cleanup(void)
-#else
-_cleanup()
-#endif
{
Exit_t *e;
for (e = Exit; e; e = e->next)
#else
/* in this case, we have to redefine exit() itself */
-#if __STD_C
exit(int type)
-#else
-exit(type)
-int type;
-#endif
{
Exit_t *e;
for (e = Exit; e; e = e->next)
static Waitpid_t *Wait;
#ifndef WIN32
-#if __STD_C
waitpid(int pid, int *status, int options)
-#else
-waitpid(pid, status, options)
-int pid;
-int *status;
-int options;
-#endif
{
int id, ps;
Waitpid_t *w;
#include "sfhdr.h"
-#if __STD_C
+/**
+ * @param dval value to convert
+ * @param n_digit number of digits wanted
+ * @param decpt to return decimal point
+ * @param sign to return sign
+ */
char *sffcvt(double dval, int n_digit, int *decpt, int *sign)
-#else
-char *sffcvt(dval, n_digit, decpt, sign)
-double dval; /* value to convert */
-int n_digit; /* number of digits wanted */
-int *decpt; /* to return decimal point */
-int *sign; /* to return sign */
-#endif
{
return _sfcvt(&dval, n_digit, decpt, sign, 0);
}
** Written by Kiem-Phong Vo
*/
-#if __STD_C
+/**
+ * @param f fill the read buffer of this stream
+ * @param n see above
+ */
int _sffilbuf(Sfio_t * f, reg int n)
-#else
-int _sffilbuf(f, n)
-Sfio_t *f; /* fill the read buffer of this stream */
-reg int n; /* see above */
-#endif
{
reg ssize_t r;
reg int first, local, rcrv, rc, justseek;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
+/**
+ * @param f write out the buffered content of this stream
+ * @param c if c>=0, c is also written out
+ */
int _sfflsbuf(reg Sfio_t * f, reg int c)
-#else
-int _sfflsbuf(f, c)
-reg Sfio_t *f; /* write out the buffered content of this stream */
-reg int c; /* if c>=0, c is also written out */
-#endif
{
reg ssize_t n, w;
reg uchar *data;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
Sfdouble_t sfgetd(Sfio_t * f)
-#else
-Sfdouble_t sfgetd(f)
-Sfio_t *f;
-#endif
{
reg uchar *s, *ends, c;
reg int p, sign, exp;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
Sflong_t sfgetl(reg Sfio_t * f)
-#else
-Sflong_t sfgetl(f)
-reg Sfio_t *f;
-#endif
{
Sflong_t v;
reg uchar *s, *ends, c;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
Sfulong_t sfgetm(reg Sfio_t * f, Sfulong_t m)
-#else
-Sfulong_t sfgetm(f, m)
-reg Sfio_t *f;
-Sfulong_t m;
-#endif
{
Sfulong_t v;
reg uchar *s, *ends, c;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
+/**
+ * @param f stream to read from. r11 on vax
+ * @param rc record separator. r10 on Vax
+ * @param type
+ */
char *sfgetr(reg Sfio_t * f, reg int rc, int type)
-#else
-char *sfgetr(f, rc, type)
-reg Sfio_t *f; /* stream to read from. r11 on vax */
-reg int rc; /* record separator. r10 on Vax */
-int type;
-#endif
{
reg ssize_t n;
reg uchar *s, *ends, *us;
** Written by Kiem-Phong Vo
*/
-#if __STD_C
Sfulong_t sfgetu(reg Sfio_t * f)
-#else
-Sfulong_t sfgetu(f)
-reg Sfio_t *f;
-#endif
{
Sfulong_t v;
reg uchar *s, *ends, c;
**
** Written by Kiem-Phong Vo
*/
-#if __STD_C
int _sfllen(Sflong_t v)
-#else
-int _sfllen(v)
-Sflong_t v;
-#endif
{
if (v < 0)
v = -(v + 1);
static int _Sfsigp = 0; /* # of streams needing SIGPIPE protection */
/* done at exiting time */
-#if __STD_C
static void _sfcleanup(void)
-#else
-static void _sfcleanup()
-#endif
{
reg Sfpool_t *p;
reg Sfio_t *f;
}
/* put into discrete pool */
-#if __STD_C
int _sfsetpool(Sfio_t * f)
-#else
-int _sfsetpool(f)
-Sfio_t *f;
-#endif
{
reg Sfpool_t *p;
reg Sfio_t **array;
}
/* create an auxiliary buffer for sfgetr/sfreserve/sfputr */
-#if __STD_C
Sfrsrv_t *_sfrsrv(reg Sfio_t * f, reg ssize_t size)
-#else
-Sfrsrv_t *_sfrsrv(f, size)
-reg Sfio_t *f;
-reg ssize_t size;
-#endif
{
Sfrsrv_t *rsrv, *rs;
}
#ifdef SIGPIPE
-#if __STD_C
static void ignoresig(int sig)
-#else
-static void ignoresig(sig)
-int sig;
-#endif
{
signal(sig, ignoresig);
}
#endif
-#if __STD_C
+/**
+ * @param f
+ * @param fd
+ * @param pid
+ * @param stdio stdio popen() does not reset SIGPIPE handler
+ */
int _sfpopen(reg Sfio_t * f, int fd, int pid, int stdio)
-#else
-int _sfpopen(f, fd, pid, stdio)
-reg Sfio_t *f;
-int fd;
-int pid;
-int stdio; /* stdio popen() does not reset SIGPIPE handler */
-#endif
{
reg Sfproc_t *p;
return 0;
}
-#if __STD_C
+/**
+ * @param f stream to close
+ */
int _sfpclose(reg Sfio_t * f)
-#else
-int _sfpclose(f)
-reg Sfio_t *f; /* stream to close */
-#endif
{
Sfproc_t *p;
int pid, status;
return status;
}
-#if __STD_C
static int _sfpmode(Sfio_t * f, int type)
-#else
-static int _sfpmode(f, type)
-Sfio_t *f;
-int type;
-#endif
{
Sfproc_t *p;
return 0;
}
-#if __STD_C
+/**
+ * @param f change r/w mode and sync file pointer for this stream
+ * @param wanted desired mode
+ * @param local a local call
+ */
int _sfmode(reg Sfio_t * f, reg int wanted, reg int local)
-#else
-int _sfmode(f, wanted, local)
-reg Sfio_t *f; /* change r/w mode and sync file pointer for this stream */
-reg int wanted; /* desired mode */
-reg int local; /* a local call */
-#endif
{
reg int n;
Sfoff_t addr;
*/
#define MAX_SSIZE ((ssize_t)((~((size_t)0)) >> 1))
-#if __STD_C
+/**
+ * @param fr moving data from this stream
+ * @param fw moving data to this stream
+ * @param n number of bytes/records to move. <0 for unbounded move
+ * @param rc record separator
+ */
Sfoff_t sfmove(Sfio_t * fr, Sfio_t * fw, Sfoff_t n, reg int rc)
-#else
-Sfoff_t sfmove(fr, fw, n, rc)
-Sfio_t *fr; /* moving data from this stream */
-Sfio_t *fw; /* moving data to this stream */
-Sfoff_t n; /* number of bytes/records to move. <0 for unbounded move */
-reg int rc; /* record separator */
-#endif
{
reg uchar *cp, *next;
reg ssize_t r, w;
*/
/* the main locking/unlocking interface */
-#if __STD_C
int sfmutex(Sfio_t * f, int type)
-#else
-int sfmutex(f, type)
-Sfio_t *f;
-int type;
-#endif
{
#if !vt_threaded
return 0;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param oldf old stream to be reused
+ * @param buf a buffer to read/write, if NULL, will be allocated
+ * @param size buffer size if buf is given or desired buffer size
+ * @param file file descriptor to read/write from
+ * @param flags type of file stream
+ */
Sfio_t *sfnew(Sfio_t * oldf, Void_t * buf, size_t size, int file,
int flags)
-#else
-Sfio_t *sfnew(oldf, buf, size, file, flags)
-Sfio_t *oldf; /* old stream to be reused */
-Void_t *buf; /* a buffer to read/write, if NULL, will be allocated */
-size_t size; /* buffer size if buf is given or desired buffer size */
-int file; /* file descriptor to read/write from */
-int flags; /* type of file stream */
-#endif
{
reg Sfio_t *f;
reg int sflags;
**
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
int sfnotify(void (*notify) (Sfio_t *, int, int))
-#else
-int sfnotify(notify)
-void (*notify) ();
-#endif
{
_Sfnotify = notify;
return 0;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f file to write
+ * @param c char to be written
+ * @param number of time to repeat
+ */
ssize_t sfnputc(reg Sfio_t * f, reg int c, reg size_t n)
-#else
-ssize_t sfnputc(f, c, n)
-reg Sfio_t *f; /* file to write */
-reg int c; /* char to be written */
-reg size_t n; /* number of time to repeat */
-#endif
{
reg uchar *ps;
reg ssize_t p, w;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f old stream structure
+ * @param file file/string to be opened
+ * @param mode mode of the stream
+ */
Sfio_t *sfopen(reg Sfio_t * f, const char *file, const char *mode)
-#else
-Sfio_t *sfopen(f, file, mode)
-reg Sfio_t *f; /* old stream structure */
-char *file; /* file/string to be opened */
-reg char *mode; /* mode of the stream */
-#endif
{
int fd, oldfd, oflags, sflags;
return f;
}
-#if __STD_C
int _sftype(reg const char *mode, int *oflagsp, int *uflagp)
-#else
-int _sftype(mode, oflagsp, uflagp)
-reg char *mode;
-int *oflagsp;
-int *uflagp;
-#endif
{
reg int sflags, oflags, uflag;
#define STREAM_PEEK 001
#define SOCKET_PEEK 002
-#if __STD_C
+/**
+ * @param fd file descriptor
+ * @param argbuf buffer to read data
+ * @param n buffer size
+ * @param rc record character
+ * @param tm time-out
+ * @param action >0: peeking, if rc>=0, get action records,
+ * <0: no peeking, if rc>=0, get -action records,
+ * =0: no peeking, if rc>=0, must get a single record
+ */
ssize_t sfpkrd(int fd, Void_t * argbuf, size_t n, int rc, long tm,
int action)
-#else
-ssize_t sfpkrd(fd, argbuf, n, rc, tm, action)
-int fd; /* file descriptor */
-Void_t *argbuf; /* buffer to read data */
-size_t n; /* buffer size */
-int rc; /* record character */
-long tm; /* time-out */
-int action; /* >0: peeking, if rc>=0, get action records,
- <0: no peeking, if rc>=0, get -action records,
- =0: no peeking, if rc>=0, must get a single record
- */
-#endif
{
reg ssize_t r;
reg int ntry, t;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param fa array of streams to poll
+ * @param n number of streams in array
+ * @param tm the amount of time in ms to wait for selecting
+ */
int sfpoll(Sfio_t ** fa, reg int n, int tm)
-#else
-int sfpoll(fa, n, tm)
-Sfio_t **fa; /* array of streams to poll */
-reg int n; /* number of streams in array */
-int tm; /* the amount of time in ms to wait for selecting */
-#endif
{
reg int r, c, m;
reg Sfio_t *f;
** link list and during such walks may free up streams&pools. Free pools will be
** reused in newpool().
*/
-#if __STD_C
static int delpool(reg Sfpool_t * p)
-#else
-static int delpool(p)
-reg Sfpool_t *p;
-#endif
{
POOLMTXSTART(p);
POOLMTXRETURN(p, 0);
}
-#if __STD_C
static Sfpool_t *newpool(reg int mode)
-#else
-static Sfpool_t *newpool(mode)
-reg int mode;
-#endif
{
reg Sfpool_t *p, *last = &_Sfpool;
}
/* move a stream to head */
-#if __STD_C
+/**
+ * @param p the pool
+ * @param f the stream
+ * @param n current position in pool
+ */
static int _sfphead(Sfpool_t * p, Sfio_t * f, int n)
-#else
-static int _sfphead(p, f, n)
-Sfpool_t *p; /* the pool */
-Sfio_t *f; /* the stream */
-int n; /* current position in pool */
-#endif
{
reg Sfio_t *head;
reg ssize_t k, w, v;
}
/* delete a stream from its pool */
-#if __STD_C
+/**
+ * @param p the pool
+ * @param f the stream
+ * @param n position in pool
+ */
static int _sfpdelete(Sfpool_t * p, Sfio_t * f, int n)
-#else
-static int _sfpdelete(p, f, n)
-Sfpool_t *p; /* the pool */
-Sfio_t *f; /* the stream */
-int n; /* position in pool */
-#endif
{
POOLMTXSTART(p);
POOLMTXRETURN(p, 0);
}
-#if __STD_C
+/**
+ * @param f
+ * @param type <0 : deleting, 0: move-to-front, >0: inserting
+ */
static int _sfpmove(reg Sfio_t * f, reg int type)
-#else
-static int _sfpmove(f, type)
-reg Sfio_t *f;
-reg int type; /* <0 : deleting, 0: move-to-front, >0: inserting */
-#endif
{
reg Sfpool_t *p;
reg int n;
}
}
-#if __STD_C
Sfio_t *sfpool(reg Sfio_t * f, reg Sfio_t * pf, reg int mode)
-#else
-Sfio_t *sfpool(f, pf, mode)
-reg Sfio_t *f;
-reg Sfio_t *pf;
-reg int mode;
-#endif
{
reg Sfpool_t *p;
reg Sfio_t *rv;
static char Meta[1 << CHAR_BIT], **Path;
/* execute command directly if possible; else use the shell */
-#if __STD_C
static void execute(const char *argcmd)
-#else
-static void execute(argcmd)
-char *argcmd;
-#endif
{
reg char *s, *cmd, **argv, **p, *interp;
reg int n;
#endif /*defined(_PACKAGE_ast)*/
#ifndef WIN32
-#if __STD_C
+/**
+ * @param f
+ * @param command command to execute
+ * @param mode mode of the stream
+ */
Sfio_t *sfpopen(Sfio_t * f, const char *command, const char *mode)
-#else
-Sfio_t *sfpopen(f, command, mode)
-Sfio_t *f;
-char *command; /* command to execute */
-char *mode; /* mode of the stream */
-#endif
{
#if defined(_PACKAGE_ast)
reg Proc_t *proc;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
int sfprintf(Sfio_t * f, const char *form, ...)
-#else
-int sfprintf(va_alist)
-va_dcl
-#endif
{
va_list args;
reg int rv;
return rv;
}
-#if __STD_C
int sfvsprintf(char *s, int n, const char *form, va_list args)
-#else
-int sfvsprintf(s, n, form, args)
-char *s;
-int n;
-char *form;
-va_list args;
-#endif
{
Sfio_t f;
reg int rv;
return rv;
}
-#if __STD_C
int sfsprintf(char *s, int n, const char *form, ...)
-#else
-int sfsprintf(va_alist)
-va_dcl
-#endif
{
va_list args;
reg int rv;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
char *sfprints(const char *form, ...)
-#else
-char *sfprints(va_alist)
-va_dcl
-#endif
{
va_list args;
reg int rv;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
int sfpurge(reg Sfio_t * f)
-#else
-int sfpurge(f)
-reg Sfio_t *f;
-#endif
{
reg int mode;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
int _sfputd(Sfio_t * f, Sfdouble_t v)
-#else
-int _sfputd(f, v)
-Sfio_t *f;
-Sfdouble_t v;
-#endif
{
#define N_ARRAY (16*sizeof(Sfdouble_t))
reg ssize_t n, w;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f write a portable long to this stream
+ * @param v the value to be written
+ */
int _sfputl(reg Sfio_t * f, Sflong_t v)
-#else
-int _sfputl(f, v)
-reg Sfio_t *f; /* write a portable long to this stream */
-Sflong_t v; /* the value to be written */
-#endif
{
#define N_ARRAY (2*sizeof(Sflong_t))
reg uchar *s, *ps;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f write a portable ulong to this stream
+ * @param v the unsigned value to be written
+ * @param max the max value of the range
+ */
int _sfputm(reg Sfio_t * f, Sfulong_t v, Sfulong_t max)
-#else
-int _sfputm(f, v, max)
-reg Sfio_t *f; /* write a portable ulong to this stream */
-Sfulong_t v; /* the unsigned value to be written */
-Sfulong_t max; /* the max value of the range */
-#endif
{
#define N_ARRAY (2*sizeof(Sfulong_t))
reg uchar *s, *ps;
**
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f write to this stream
+ * @param s string to write
+ * @param rc record separator
+ */
ssize_t sfputr(reg Sfio_t * f, const char *s, reg int rc)
-#else
-ssize_t sfputr(f, s, rc)
-reg Sfio_t *f; /* write to this stream */
-char *s; /* string to write */
-reg int rc; /* record separator. */
-#endif
{
reg ssize_t p, n, w;
reg uchar *ps;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f write a portable ulong to this stream
+ * @param v the unsigned value to be written
+ * @param
+ * @param
+ */
int _sfputu(reg Sfio_t * f, Sfulong_t v)
-#else
-int _sfputu(f, v)
-reg Sfio_t *f; /* write a portable ulong to this stream */
-Sfulong_t v; /* the unsigned value to be written */
-#endif
{
#define N_ARRAY (2*sizeof(Sfulong_t))
reg uchar *s, *ps;
**
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f stream
+ * @param type type of event
+ * @param data associated data
+ * @param
+ */
int sfraise(Sfio_t * f, int type, Void_t * data)
-#else
-int sfraise(f, type, data)
-Sfio_t *f; /* stream */
-int type; /* type of event */
-Void_t *data; /* associated data */
-#endif
{
reg Sfdisc_t *disc, *next, *d;
reg int local, rv;
*/
/* synchronize unseekable write streams */
-#if __STD_C
static void _sfwrsync(void)
-#else
-static void _sfwrsync()
-#endif
{
reg Sfpool_t *p;
reg Sfio_t *f;
}
}
-#if __STD_C
ssize_t sfrd(reg Sfio_t * f, reg Void_t * buf, reg size_t n,
Sfdisc_t * disc)
-#else
-ssize_t sfrd(f, buf, n, disc)
-reg Sfio_t *f;
-reg Void_t *buf;
-reg size_t n;
-Sfdisc_t *disc;
-#endif
{
Sfoff_t r;
reg Sfdisc_t *dc;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f read from this stream
+ * @param buf buffer to read into
+ * @param n number of bytes to be read
+ * @param
+ */
ssize_t sfread(reg Sfio_t * f, Void_t * buf, reg size_t n)
-#else
-ssize_t sfread(f, buf, n)
-reg Sfio_t *f; /* read from this stream. */
-Void_t *buf; /* buffer to read into */
-reg size_t n; /* number of bytes to be read. */
-#endif
{
reg uchar *s, *begs;
reg ssize_t r;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f file to peek
+ * @param size size of peek
+ * @param type LOCKR: lock stream, LASTR: last record
+ */
Void_t *sfreserve(reg Sfio_t * f, ssize_t size, int type)
-#else
-Void_t *sfreserve(f, size, type)
-reg Sfio_t *f; /* file to peek */
-ssize_t size; /* size of peek */
-int type; /* LOCKR: lock stream, LASTR: last record */
-#endif
{
reg ssize_t n, sz;
reg Sfrsrv_t *rsrv;
Written by Kiem-Phong Vo.
*/
-#if __STD_C
int sfresize(Sfio_t * f, Sfoff_t size)
-#else
-int sfresize(f, size)
-Sfio_t *f;
-Sfoff_t size;
-#endif
{
SFMTXSTART(f, -1);
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
int sfscanf(Sfio_t * f, const char *form, ...)
-#else
-int sfscanf(va_alist)
-va_dcl
-#endif
{
va_list args;
reg int rv;
return rv;
}
-#if __STD_C
int sfvsscanf(const char *s, const char *form, va_list args)
-#else
-int sfvsscanf(s, form, args)
-char *s;
-char *form;
-va_list args;
-#endif
{
Sfio_t f;
return sfvscanf(&f, form, args);
}
-#if __STD_C
int sfsscanf(const char *s, const char *form, ...)
-#else
-int sfsscanf(va_alist)
-va_dcl
-#endif
{
va_list args;
reg int rv;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
static void newpos(Sfio_t * f, Sfoff_t p)
-#else
-static void newpos(f, p)
-Sfio_t *f;
-Sfoff_t p;
-#endif
{
#ifdef MAP_TYPE
if ((f->bits & SF_MMAP) && f->data) {
}
}
-#if __STD_C
+/**
+ * @param f seek to a new location in this stream
+ * @param p place to seek to
+ * @param type 0: from org, 1: from here, 2: from end
+ */
Sfoff_t sfseek(Sfio_t * f, Sfoff_t p, int type)
-#else
-Sfoff_t sfseek(f, p, type)
-Sfio_t *f; /* seek to a new location in this stream */
-Sfoff_t p; /* place to seek to */
-int type; /* 0: from org, 1: from here, 2: from end */
-#endif
{
Sfoff_t r, s;
size_t a, b, c;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
int sfset(reg Sfio_t * f, reg int flags, reg int set)
-#else
-int sfset(f, flags, set)
-reg Sfio_t *f;
-reg int flags;
-reg int set;
-#endif
{
reg int oflags;
#define fstat(fd,st) (-1)
#endif /*_sys_stat*/
-#if __STD_C
+/**
+ * @param f stream to be buffered
+ * @param buf new buffer
+ * @param size buffer size, -1 for default size
+ */
Void_t *sfsetbuf(reg Sfio_t * f, reg Void_t * buf, reg size_t size)
-#else
-Void_t *sfsetbuf(f, buf, size)
-reg Sfio_t *f; /* stream to be buffered */
-reg Void_t *buf; /* new buffer */
-reg size_t size; /* buffer size, -1 for default size */
-#endif
{
reg int sf_malloc;
reg uchar *obuf;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
static int _sfdup(reg int fd, reg int newfd)
-#else
-static int _sfdup(fd, newfd)
-reg int fd;
-reg int newfd;
-#endif
{
reg int dupfd;
#endif
}
-#if __STD_C
int sfsetfd(reg Sfio_t * f, reg int newfd)
-#else
-int sfsetfd(f, newfd)
-reg Sfio_t *f;
-reg int newfd;
-#endif
{
reg int oldfd;
**
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
Sfoff_t sfsize(reg Sfio_t * f)
-#else
-Sfoff_t sfsize(f)
-reg Sfio_t *f;
-#endif
{
Sfdisc_t *disc;
reg int mode;
**
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
Sfoff_t sfsk(reg Sfio_t * f, Sfoff_t addr, reg int type, Sfdisc_t * disc)
-#else
-Sfoff_t sfsk(f, addr, type, disc)
-reg Sfio_t *f;
-Sfoff_t addr;
-reg int type;
-Sfdisc_t *disc;
-#endif
{
Sfoff_t p;
reg Sfdisc_t *dc;
return(rv); \
}
-#if __STD_C
+/**
+ * @param f1 base of stack
+ * @param f2 top of stack
+ */
Sfio_t *sfstack(Sfio_t * f1, Sfio_t * f2)
-#else
-Sfio_t *sfstack(f1, f2)
-Sfio_t *f1; /* base of stack */
-Sfio_t *f2; /* top of stack */
-#endif
{
reg int n;
reg Sfio_t *rf;
#define FPART 1 /* doing fractional part */
#define EPART 2 /* doing exponent part */
-#if __STD_C
static Sfdouble_t sfpow10(reg int n)
-#else
-static Sfdouble_t sfpow10(n)
-reg int n;
-#endif
{
Sfdouble_t dval;
return dval;
}
-#if __STD_C
+/**
+ * @param s string to convert
+ * @param retp to return the remainder of string
+ */
Sfdouble_t _sfstrtod(reg const char *s, char **retp)
-#else
-Sfdouble_t _sfstrtod(s, retp)
-reg char *s; /* string to convert */
-char **retp; /* to return the remainder of string */
-#endif
{
reg int n, c, m;
reg int mode, fexp, sign, expsign;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
Sfio_t *sfswap(reg Sfio_t * f1, reg Sfio_t * f2)
-#else
-Sfio_t *sfswap(f1, f2)
-reg Sfio_t *f1;
-reg Sfio_t *f2;
-#endif
{
Sfio_t tmp;
int f1pool, f2pool, f1mode, f2mode, f1flags, f2flags;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
static int _sfall(void)
-#else
-static int _sfall()
-#endif
{
reg Sfpool_t *p, *next;
reg Sfio_t *f;
return rv;
}
-#if __STD_C
+/**
+ * @param f stream to be synchronized
+ */
int sfsync(reg Sfio_t * f)
-#else
-int sfsync(f)
-reg Sfio_t *f; /* stream to be synchronized */
-#endif
{
int local, rv, mode;
Sfio_t *origf;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
static char *sffmtint(const char *str, int *v)
-#else
-static char *sffmtint(str, v)
-char *str;
-int *v;
-#endif
{
for (*v = 0; isdigit(*str); ++str)
*v = *v * 10 + (*str - '0');
return (char *) str;
}
-#if __STD_C
static Fmtpos_t *sffmtpos(Sfio_t * f, const char *form, va_list args,
int type)
-#else
-static Fmtpos_t *sffmtpos(f, form, args, type)
-Sfio_t *f;
-char *form;
-va_list args;
-int type;
-#endif
{
int base, fmt, flags, dot, width, precis;
ssize_t n_str, size = 0;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
Sfoff_t sftell(reg Sfio_t * f)
-#else
-Sfoff_t sftell(f)
-reg Sfio_t *f;
-#endif
{
reg int mode;
Sfoff_t p;
static File_t *File; /* list pf temp files */
-#if __STD_C
static int _tmprmfile(Sfio_t * f, int type, Void_t * val, Sfdisc_t * disc)
-#else
-static int _tmprmfile(f, type, val, disc)
-Sfio_t *f;
-int type;
-Void_t *val;
-Sfdisc_t *disc;
-#endif
{
reg File_t *ff, *last;
return 0;
}
-#if __STD_C
static void _rmfiles(void)
-#else
-static void _rmfiles()
-#endif
{
reg File_t *ff, *next;
#endif /*_tmp_rmfail*/
-#if __STD_C
static int _rmtmp(Sfio_t * f, char *file)
-#else
-static int _rmtmp(f, file)
-Sfio_t *f;
-char *file;
-#endif
{
#if _tmp_rmfail /* remove only when stream is closed */
reg File_t *ff;
#define TMPDFLT "/tmp"
static char **Tmppath, **Tmpcur;
-#if __STD_C
char **_sfgetpath(char *path)
-#else
-char **_sfgetpath(path)
-char *path;
-#endif
{
reg char *p, **dirs;
reg int n;
#endif /*!defined(_PACKAGE_ast) */
-#if __STD_C
static int _tmpfd(Sfio_t * f)
-#else
-static int _tmpfd(f)
-Sfio_t *f;
-#endif
{
reg char *file;
reg int fd;
return fd;
}
-#if __STD_C
static int _tmpexcept(Sfio_t * f, int type, Void_t * val, Sfdisc_t * disc)
-#else
-static int _tmpexcept(f, type, val, disc)
-Sfio_t *f;
-int type;
-Void_t *val;
-Sfdisc_t *disc;
-#endif
{
reg int fd, m;
reg Sfio_t *sf;
return 1;
}
-#if __STD_C
Sfio_t *sftmp(reg size_t s)
-#else
-Sfio_t *sftmp(s)
-reg size_t s;
-#endif
{
reg Sfio_t *f;
static Sfdisc_t Tmpdisc =
**
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
static int _uexcept(reg Sfio_t * f, reg int type, Void_t * val,
reg Sfdisc_t * disc)
-#else
-static int _uexcept(f, type, val, disc)
-reg Sfio_t *f;
-reg int type;
-Void_t *val;
-reg Sfdisc_t *disc;
-#endif
{
NOTUSED(val);
return 1;
}
-#if __STD_C
+/**
+ * @param f push back one byte to this stream
+ * @param c the value to be pushed back
+ */
int sfungetc(reg Sfio_t * f, reg int c)
-#else
-int sfungetc(f, c)
-reg Sfio_t *f; /* push back one byte to this stream */
-reg int c; /* the value to be pushed back */
-#endif
{
reg Sfio_t *uf;
#define FPRECIS 6 /* default precision for floats */
-#if __STD_C
+/**
+ * @param f file to print to
+ * @param form format to use
+ * @param args arg list if !argf
+ */
int sfvprintf(Sfio_t * f, const char *form, va_list args)
-#else
-int sfvprintf(f, form, args)
-Sfio_t *f; /* file to print to */
-char *form; /* format to use */
-va_list args; /* arg list if !argf */
-#endif
{
reg int v = 0, n_s, base, fmt, flags;
Sflong_t lv;
#define MAXWIDTH (int)(((uint)~0)>>1) /* max amount to scan */
-#if __STD_C
+/**
+ * @param form format string
+ * @param accept accepted characters are set to 1
+ */
static char *setclass(reg char *form, reg char *accept)
-#else
-static char *setclass(form, accept)
-reg char *form; /* format string */
-reg char *accept; /* accepted characters are set to 1 */
-#endif
{
reg int fmt, c, yes;
return form;
}
-#if __STD_C
static void _sfbuf(Sfio_t * f, int *rs)
-#else
-static void _sfbuf(f, rs)
-Sfio_t *f;
-int *rs;
-#endif
{
if (f->next >= f->endb) {
if (*rs > 0) { /* try peeking for a share stream if possible */
}
}
-#if __STD_C
+/**
+ * @param f file to be scanned
+ * @param form scanning format
+ * @param args
+ */
int sfvscanf(Sfio_t * f, reg const char *form, va_list args)
-#else
-int sfvscanf(f, form, args)
-Sfio_t *f; /* file to be scanned */
-reg char *form; /* scanning format */
-va_list args;
-#endif
{
reg uchar *d, *endd, *data;
reg int inp, shift, base, width;
*/
/* hole preserving writes */
-#if __STD_C
static ssize_t sfoutput(Sfio_t * f, reg char *buf, reg size_t n)
-#else
-static ssize_t sfoutput(f, buf, n)
-Sfio_t *f;
-reg char *buf;
-reg size_t n;
-#endif
{
reg char *sp, *wbuf, *endbuf;
reg ssize_t s, w, wr;
return w > 0 ? w : -1;
}
-#if __STD_C
ssize_t sfwr(reg Sfio_t * f, reg const Void_t * buf, reg size_t n,
reg Sfdisc_t * disc)
-#else
-ssize_t sfwr(f, buf, n, disc)
-reg Sfio_t *f;
-reg Void_t *buf;
-reg size_t n;
-reg Sfdisc_t *disc;
-#endif
{
reg ssize_t w;
reg Sfdisc_t *dc;
** Written by Kiem-Phong Vo.
*/
-#if __STD_C
+/**
+ * @param f write to this stream
+ * @param buf buffer to be written
+ * @param n number of bytes
+ */
ssize_t sfwrite(reg Sfio_t * f, const Void_t * buf, reg size_t n)
-#else
-ssize_t sfwrite(f, buf, n)
-reg Sfio_t *f; /* write to this stream. */
-Void_t *buf; /* buffer to be written. */
-reg size_t n; /* number of bytes. */
-#endif
{
reg uchar *s, *begs, *next;
reg ssize_t w;