OutputByteStream.cxx revision 7c478bd95313f5f23a4c958a745db2134aa03244
// Copyright (c) 1997 James Clark
// See the file COPYING for copying permission.
#pragma ident "%Z%%M% %I% %E% SMI"
#include "splib.h"
#include "OutputByteStream.h"
#ifdef SP_INCLUDE_IO_H
#include <io.h> // for open, fstat, lseek, read prototypes
#endif
#ifdef SP_INCLUDE_UNISTD_H
#include <unistd.h>
#endif
#ifdef SP_INCLUDE_OSFCN_H
#include <osfcn.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#ifdef SP_WIDE_SYSTEM
#define STRICT
#include <windows.h>
#endif
#ifndef O_CREAT
#ifdef _O_CREAT
#endif
#endif
#ifndef O_WRONLY
#ifdef _O_WRONLY
#endif
#endif
#ifndef O_TRUNC
#ifdef _O_TRUNC
#endif
#endif
#ifndef O_BINARY
#ifdef _O_BINARY
#else
#define O_BINARY 0
#endif
#endif
#ifndef S_IRUSR
#if defined(S_IREAD)
#else
#define S_IRUSR 0400
#endif
#endif
#ifndef S_IWUSR
#if defined(S_IWRITE)
#else
#define S_IWUSR 0200
#endif
#endif
#ifndef S_IRGRP
#if defined(S_IREAD)
#else
#define S_IRGRP 0040
#endif
#endif
#ifndef S_IWGRP
#if defined(S_IWRITE)
#else
#define S_IWGRP 0020
#endif
#endif
#ifndef S_IROTH
#if defined(S_IREAD)
#else
#define S_IROTH 0004
#endif
#endif
#ifndef S_IWOTH
#if defined(S_IWRITE)
#else
#define S_IWOTH 0002
#endif
#endif
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
const int bufSize = 8192;
{
}
{
}
{
for (; n > 0; n--, s++)
sputc(*s);
}
OutputByteStream &OutputByteStream::operator<<(long n)
{
char buf[32];
return *this << buf;
}
OutputByteStream &OutputByteStream::operator<<(unsigned long n)
{
char buf[32];
return *this << buf;
}
OutputByteStream &OutputByteStream::operator<<(const char *s)
{
while (*s)
sputc(*s++);
return *this;
}
{
}
{
if (ptr_)
}
void StrOutputByteStream::flush()
{
}
void StrOutputByteStream::flushBuf(char c)
{
if (!ptr_) {
}
else {
}
*ptr_++ = c;
}
: fd_(-1)
{
}
: fd_(-1)
{
}
{
close();
}
#ifdef SP_WIDE_SYSTEM
{
if (fd >= 0)
// _wopen will always fail on Windows 95
}
#else /* not SP_WIDE_SYSTEM */
{
}
#endif /* not SP_WIDE_SYSTEM */
{
close();
return fd_ >= 0;
}
{
if (fd_ < 0)
return 0;
flush();
fd_ = -1;
if (!closeFd_)
return 1;
}
void FileOutputByteStream::flush()
{
if (fd_ < 0)
return;
}
while (n > 0) {
if (nw < 0)
break;
n -= nw;
s += nw;
}
}
void FileOutputByteStream::flushBuf(char c)
{
flush();
*ptr_++ = c;
}
#ifdef SP_NAMESPACE
}
#endif