run GNU protoize
protect header files nuke some dead code regenerate configure script let silly code die
This commit is contained in:
109
shf.c
109
shf.c
@@ -1,4 +1,4 @@
|
||||
/** $MirBSD: shf.c,v 1.5 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: shf.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: shf.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include "ksh_limval.h"
|
||||
|
||||
__RCSID("$MirBSD: shf.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: shf.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
/* flags to shf_emptybuf() */
|
||||
#define EB_READSW 0x01 /* about to switch to reading */
|
||||
@@ -29,11 +29,7 @@ static int shf_emptybuf(struct shf *shf, int flags);
|
||||
* fails.
|
||||
*/
|
||||
struct shf *
|
||||
shf_open(name, oflags, mode, sflags)
|
||||
const char *name;
|
||||
int oflags;
|
||||
int mode;
|
||||
int sflags;
|
||||
shf_open(const char *name, int oflags, int mode, int sflags)
|
||||
{
|
||||
struct shf *shf;
|
||||
int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
|
||||
@@ -73,10 +69,7 @@ shf_open(name, oflags, mode, sflags)
|
||||
|
||||
/* Set up the shf structure for a file descriptor. Doesn't fail. */
|
||||
struct shf *
|
||||
shf_fdopen(fd, sflags, shf)
|
||||
int fd;
|
||||
int sflags;
|
||||
struct shf *shf;
|
||||
shf_fdopen(int fd, int sflags, struct shf *shf)
|
||||
{
|
||||
int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
|
||||
|
||||
@@ -126,10 +119,7 @@ shf_fdopen(fd, sflags, shf)
|
||||
|
||||
/* Set up an existing shf (and buffer) to use the given fd */
|
||||
struct shf *
|
||||
shf_reopen(fd, sflags, shf)
|
||||
int fd;
|
||||
int sflags;
|
||||
struct shf *shf;
|
||||
shf_reopen(int fd, int sflags, struct shf *shf)
|
||||
{
|
||||
int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
|
||||
|
||||
@@ -176,11 +166,7 @@ shf_reopen(fd, sflags, shf)
|
||||
* When writing, a byte is reserved for a trailing null - see shf_sclose().
|
||||
*/
|
||||
struct shf *
|
||||
shf_sopen(buf, bsize, sflags, shf)
|
||||
char *buf;
|
||||
int bsize;
|
||||
int sflags;
|
||||
struct shf *shf;
|
||||
shf_sopen(char *buf, int bsize, int sflags, struct shf *shf)
|
||||
{
|
||||
/* can't have a read+write string */
|
||||
if (!(sflags & (SHF_RD | SHF_WR))
|
||||
@@ -213,8 +199,7 @@ shf_sopen(buf, bsize, sflags, shf)
|
||||
|
||||
/* Flush and close file descriptor, free the shf structure */
|
||||
int
|
||||
shf_close(shf)
|
||||
struct shf *shf;
|
||||
shf_close(struct shf *shf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -233,8 +218,7 @@ shf_close(shf)
|
||||
|
||||
/* Flush and close file descriptor, don't free file structure */
|
||||
int
|
||||
shf_fdclose(shf)
|
||||
struct shf *shf;
|
||||
shf_fdclose(struct shf *shf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -256,8 +240,7 @@ shf_fdclose(shf)
|
||||
* (does not free string if it was allocated).
|
||||
*/
|
||||
char *
|
||||
shf_sclose(shf)
|
||||
struct shf *shf;
|
||||
shf_sclose(struct shf *shf)
|
||||
{
|
||||
unsigned char *s = shf->buf;
|
||||
|
||||
@@ -273,8 +256,7 @@ shf_sclose(shf)
|
||||
|
||||
/* Flush and free file structure, don't close file descriptor */
|
||||
int
|
||||
shf_finish(shf)
|
||||
struct shf *shf;
|
||||
shf_finish(struct shf *shf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -292,8 +274,7 @@ shf_finish(shf)
|
||||
* buffered. Returns 0 for success, EOF for (write) error.
|
||||
*/
|
||||
int
|
||||
shf_flush(shf)
|
||||
struct shf *shf;
|
||||
shf_flush(struct shf *shf)
|
||||
{
|
||||
if (shf->flags & SHF_STRING)
|
||||
return (shf->flags & SHF_WR) ? EOF : 0;
|
||||
@@ -324,9 +305,7 @@ shf_flush(shf)
|
||||
* buffer. Returns 0 for success, EOF for (write) error.
|
||||
*/
|
||||
static int
|
||||
shf_emptybuf(shf, flags)
|
||||
struct shf *shf;
|
||||
int flags;
|
||||
shf_emptybuf(struct shf *shf, int flags)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -406,8 +385,7 @@ shf_emptybuf(shf, flags)
|
||||
|
||||
/* Fill up a read buffer. Returns EOF for a read error, 0 otherwise. */
|
||||
static int
|
||||
shf_fillbuf(shf)
|
||||
struct shf *shf;
|
||||
shf_fillbuf(struct shf *shf)
|
||||
{
|
||||
if (shf->flags & SHF_STRING)
|
||||
return 0;
|
||||
@@ -453,10 +431,7 @@ shf_fillbuf(shf)
|
||||
* buffer. Returns 0 for success, EOF otherwise.
|
||||
*/
|
||||
int
|
||||
shf_seek(shf, where, from)
|
||||
struct shf *shf;
|
||||
off_t where;
|
||||
int from;
|
||||
shf_seek(struct shf *shf, off_t where, int from)
|
||||
{
|
||||
if (shf->fd < 0) {
|
||||
errno = EINVAL;
|
||||
@@ -501,10 +476,7 @@ shf_seek(shf, where, from)
|
||||
* a read error occurred.
|
||||
*/
|
||||
int
|
||||
shf_read(buf, bsize, shf)
|
||||
char *buf;
|
||||
int bsize;
|
||||
struct shf *shf;
|
||||
shf_read(char *buf, int bsize, struct shf *shf)
|
||||
{
|
||||
int orig_bsize = bsize;
|
||||
int ncopy;
|
||||
@@ -538,10 +510,7 @@ shf_read(buf, bsize, shf)
|
||||
* end of file, returns a pointer to the null byte in buf otherwise.
|
||||
*/
|
||||
char *
|
||||
shf_getse(buf, bsize, shf)
|
||||
char *buf;
|
||||
int bsize;
|
||||
struct shf *shf;
|
||||
shf_getse(char *buf, int bsize, struct shf *shf)
|
||||
{
|
||||
unsigned char *end;
|
||||
int ncopy;
|
||||
@@ -588,8 +557,7 @@ shf_getse(buf, bsize, shf)
|
||||
|
||||
/* Returns the char read. Returns EOF for error and end of file. */
|
||||
int
|
||||
shf_getchar(shf)
|
||||
struct shf *shf;
|
||||
shf_getchar(struct shf *shf)
|
||||
{
|
||||
if (!(shf->flags & SHF_RD))
|
||||
internal_errorf(1, "shf_getchar: flags %x", shf->flags);
|
||||
@@ -604,9 +572,7 @@ shf_getchar(shf)
|
||||
* successful, EOF if there is no room.
|
||||
*/
|
||||
int
|
||||
shf_ungetc(c, shf)
|
||||
int c;
|
||||
struct shf *shf;
|
||||
shf_ungetc(int c, struct shf *shf)
|
||||
{
|
||||
if (!(shf->flags & SHF_RD))
|
||||
internal_errorf(1, "shf_ungetc: flags %x", shf->flags);
|
||||
@@ -641,9 +607,7 @@ shf_ungetc(c, shf)
|
||||
* the char could not be written.
|
||||
*/
|
||||
int
|
||||
shf_putchar(c, shf)
|
||||
int c;
|
||||
struct shf *shf;
|
||||
shf_putchar(int c, struct shf *shf)
|
||||
{
|
||||
if (!(shf->flags & SHF_WR))
|
||||
internal_errorf(1, "shf_putchar: flags %x", shf->flags);
|
||||
@@ -685,9 +649,7 @@ shf_putchar(c, shf)
|
||||
* the string could not be written.
|
||||
*/
|
||||
int
|
||||
shf_puts(s, shf)
|
||||
const char *s;
|
||||
struct shf *shf;
|
||||
shf_puts(const char *s, struct shf *shf)
|
||||
{
|
||||
if (!s)
|
||||
return EOF;
|
||||
@@ -697,10 +659,7 @@ shf_puts(s, shf)
|
||||
|
||||
/* Write a buffer. Returns nbytes if successful, EOF if there is an error. */
|
||||
int
|
||||
shf_write(buf, nbytes, shf)
|
||||
const char *buf;
|
||||
int nbytes;
|
||||
struct shf *shf;
|
||||
shf_write(const char *buf, int nbytes, struct shf *shf)
|
||||
{
|
||||
int orig_nbytes = nbytes;
|
||||
int n;
|
||||
@@ -761,14 +720,7 @@ shf_write(buf, nbytes, shf)
|
||||
}
|
||||
|
||||
int
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shf_fprintf(struct shf *shf, const char *fmt, ...)
|
||||
#else
|
||||
shf_fprintf(shf, fmt, va_alist)
|
||||
struct shf *shf;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
int n;
|
||||
@@ -781,15 +733,7 @@ shf_fprintf(shf, fmt, va_alist)
|
||||
}
|
||||
|
||||
int
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shf_snprintf(char *buf, int bsize, const char *fmt, ...)
|
||||
#else
|
||||
shf_snprintf(buf, bsize, fmt, va_alist)
|
||||
char *buf;
|
||||
int bsize;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
struct shf shf;
|
||||
va_list args;
|
||||
@@ -808,13 +752,7 @@ shf_snprintf(buf, bsize, fmt, va_alist)
|
||||
}
|
||||
|
||||
char *
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shf_smprintf(const char *fmt, ...)
|
||||
#else
|
||||
shf_smprintf(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
struct shf shf;
|
||||
va_list args;
|
||||
@@ -884,10 +822,7 @@ my_ceil(d)
|
||||
#endif /* FP */
|
||||
|
||||
int
|
||||
shf_vfprintf(shf, fmt, args)
|
||||
struct shf *shf;
|
||||
const char *fmt;
|
||||
va_list args;
|
||||
shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
||||
{
|
||||
char c, *s;
|
||||
int UNINITIALIZED(tmp);
|
||||
|
Reference in New Issue
Block a user