mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Fix copyright date, and make minor formatting changes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1792 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9dee60b7f5
commit
96f048c9a2
2 changed files with 57 additions and 56 deletions
|
@ -1,5 +1,5 @@
|
||||||
/* objc_streams - C-function interface to Objective-C streams
|
/* ostream.h - C-function interface to GNUstep Objective-C streams
|
||||||
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
||||||
Date: Jun 1996
|
Date: Jun 1996
|
||||||
|
@ -27,7 +27,8 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <objc/typedstream.h>
|
#include <objc/typedstream.h>
|
||||||
|
|
||||||
typedef struct _ostream {
|
typedef struct _ostream
|
||||||
|
{
|
||||||
void* stream_obj;
|
void* stream_obj;
|
||||||
int flags;
|
int flags;
|
||||||
} ostream;
|
} ostream;
|
||||||
|
@ -50,30 +51,30 @@ typedef struct _ostream {
|
||||||
#define OSTREAM_USER_OWNS_BUF (1 << 3)
|
#define OSTREAM_USER_OWNS_BUF (1 << 3)
|
||||||
#define OSTREAM_CANSEEK (1 << 4)
|
#define OSTREAM_CANSEEK (1 << 4)
|
||||||
|
|
||||||
extern int ostream_getc(ostream* s);
|
extern int ostream_getc (ostream* s);
|
||||||
extern void ostream_ungetc(ostream* s);
|
extern void ostream_ungetc (ostream* s);
|
||||||
extern int ostream_putc(ostream* s, int c);
|
extern int ostream_putc (ostream* s, int c);
|
||||||
extern BOOL ostream_at_eos(ostream* s);
|
extern BOOL ostream_at_eos (ostream* s);
|
||||||
extern char* ostream_gets(ostream* s, char* buf, int count);
|
extern char* ostream_gets (ostream* s, char* buf, int count);
|
||||||
|
|
||||||
extern int ostream_flush(ostream *s);
|
extern int ostream_flush (ostream *s);
|
||||||
extern void ostream_seek(ostream *s, long offset, int mode);
|
extern void ostream_seek (ostream *s, long offset, int mode);
|
||||||
extern long ostream_tell(ostream *s);
|
extern long ostream_tell (ostream *s);
|
||||||
extern int ostream_read(ostream* s, void* buf, int count);
|
extern int ostream_read (ostream* s, void* buf, int count);
|
||||||
extern int ostream_write(ostream* s, const void* buf, int count);
|
extern int ostream_write (ostream* s, const void* buf, int count);
|
||||||
extern void ostream_printf(ostream *s, const char *format, ...);
|
extern void ostream_printf (ostream *s, const char *format, ...);
|
||||||
extern void ostream_vprintf(ostream *s, const char *format, va_list argList);
|
extern void ostream_vprintf (ostream *s, const char *format, va_list argList);
|
||||||
extern int ostream_scanf(ostream *s, const char *format, ...);
|
extern int ostream_scanf (ostream *s, const char *format, ...);
|
||||||
extern int ostream_vscanf(ostream *s, const char *format, va_list argList);
|
extern int ostream_vscanf (ostream *s, const char *format, va_list argList);
|
||||||
|
|
||||||
extern ostream *ostream_open_descriptor(int fd, int mode);
|
extern ostream *ostream_open_descriptor (int fd, int mode);
|
||||||
extern ostream *ostream_open_memory(const char *addr, int size, int mode);
|
extern ostream *ostream_open_memory (const char *addr, int size, int mode);
|
||||||
extern ostream *ostream_map_file(const char *name, int mode);
|
extern ostream *ostream_map_file (const char *name, int mode);
|
||||||
extern int ostream_save_to_file(ostream *s, const char *name);
|
extern int ostream_save_to_file (ostream *s, const char *name);
|
||||||
extern void ostream_get_memory_buffer(ostream *s, char **addr,
|
extern void ostream_get_memory_buffer (ostream *s, char **addr,
|
||||||
int *len, int *maxlen);
|
int *len, int *maxlen);
|
||||||
extern void ostream_close_memory(ostream *s, int option);
|
extern void ostream_close_memory (ostream *s, int option);
|
||||||
extern void ostream_close(ostream *s);
|
extern void ostream_close (ostream *s);
|
||||||
|
|
||||||
#define OSTREAM_FREEBUFFER 0
|
#define OSTREAM_FREEBUFFER 0
|
||||||
#define OSTREAM_TRUNCATEBUFFER 1
|
#define OSTREAM_TRUNCATEBUFFER 1
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* objc_streams - C-function interface to Objective-C streams
|
/* objc_streams - C-function interface to Objective-C streams
|
||||||
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
||||||
Date: Aug 1996
|
Date: Aug 1996
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "gnustep/base/objc_streams.h"
|
#include "gnustep/base/ostream.h"
|
||||||
#include "gnustep/base/MemoryStream.h"
|
#include "gnustep/base/MemoryStream.h"
|
||||||
#include "gnustep/base/StdioStream.h"
|
#include "gnustep/base/StdioStream.h"
|
||||||
#include "gnustep/base/String.h"
|
#include "gnustep/base/String.h"
|
||||||
|
@ -31,13 +31,13 @@
|
||||||
/* Handle a stream error - FIXME: not sure if this should throw an exception
|
/* Handle a stream error - FIXME: not sure if this should throw an exception
|
||||||
or what... */
|
or what... */
|
||||||
static void
|
static void
|
||||||
_ostream_error(const char* message)
|
_ostream_error (const char* message)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ostream error: %s\n", message);
|
fprintf (stderr, "ostream error: %s\n", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ostream_getc(ostream* s)
|
ostream_getc (ostream* s)
|
||||||
{
|
{
|
||||||
char c = 0;
|
char c = 0;
|
||||||
if (s->flags & OSTREAM_READFLAG)
|
if (s->flags & OSTREAM_READFLAG)
|
||||||
|
@ -48,7 +48,7 @@ ostream_getc(ostream* s)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ostream_ungetc(ostream* s)
|
ostream_ungetc (ostream* s)
|
||||||
{
|
{
|
||||||
if ((s->flags & OSTREAM_READFLAG) && (s->flags & OSTREAM_CANSEEK))
|
if ((s->flags & OSTREAM_READFLAG) && (s->flags & OSTREAM_CANSEEK))
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ ostream_ungetc(ostream* s)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ostream_putc(ostream* s, int c)
|
ostream_putc (ostream* s, int c)
|
||||||
{
|
{
|
||||||
if (s->flags & OSTREAM_WRITEFLAG)
|
if (s->flags & OSTREAM_WRITEFLAG)
|
||||||
return [(id <Streaming>)s->stream_obj writeByte: c];
|
return [(id <Streaming>)s->stream_obj writeByte: c];
|
||||||
|
@ -69,14 +69,14 @@ ostream_putc(ostream* s, int c)
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
ostream_at_eos(ostream* s)
|
ostream_at_eos (ostream* s)
|
||||||
{
|
{
|
||||||
return [(id <Streaming>)s->stream_obj isAtEof];
|
return [(id <Streaming>)s->stream_obj isAtEof];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ostream_flush(ostream *s)
|
ostream_flush (ostream *s)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
pos = [(id <Streaming>)s->stream_obj streamPosition];
|
pos = [(id <Streaming>)s->stream_obj streamPosition];
|
||||||
|
@ -85,7 +85,7 @@ ostream_flush(ostream *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ostream_seek(ostream *s, long offset, int mode)
|
ostream_seek (ostream *s, long offset, int mode)
|
||||||
{
|
{
|
||||||
if (!(s->flags & OSTREAM_CANSEEK))
|
if (!(s->flags & OSTREAM_CANSEEK))
|
||||||
return;
|
return;
|
||||||
|
@ -95,13 +95,13 @@ ostream_seek(ostream *s, long offset, int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
ostream_tell(ostream *s)
|
ostream_tell (ostream *s)
|
||||||
{
|
{
|
||||||
return [(id <Streaming>)s->stream_obj streamPosition];
|
return [(id <Streaming>)s->stream_obj streamPosition];
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ostream_read(ostream* s, void* buf, int count)
|
ostream_read (ostream* s, void* buf, int count)
|
||||||
{
|
{
|
||||||
assert(buf); /* xxxFIXME: should be an exception ? */
|
assert(buf); /* xxxFIXME: should be an exception ? */
|
||||||
if (s->flags & OSTREAM_READFLAG)
|
if (s->flags & OSTREAM_READFLAG)
|
||||||
|
@ -109,7 +109,7 @@ ostream_read(ostream* s, void* buf, int count)
|
||||||
return OSTREAM_EOF;
|
return OSTREAM_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ostream_gets(ostream* s, char* buf, int count)
|
char* ostream_gets (ostream* s, char* buf, int count)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -131,7 +131,7 @@ char* ostream_gets(ostream* s, char* buf, int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ostream_write(ostream* s, const void* buf, int count)
|
ostream_write (ostream* s, const void* buf, int count)
|
||||||
{
|
{
|
||||||
assert(buf); /* xxxFIXME: should be an exception ? */
|
assert(buf); /* xxxFIXME: should be an exception ? */
|
||||||
if (s->flags & OSTREAM_WRITEFLAG)
|
if (s->flags & OSTREAM_WRITEFLAG)
|
||||||
|
@ -140,7 +140,7 @@ ostream_write(ostream* s, const void* buf, int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ostream_printf(ostream *s, const char *format, ...)
|
ostream_printf (ostream *s, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
@ -149,7 +149,7 @@ ostream_printf(ostream *s, const char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ostream_vprintf(ostream *s, const char *format, va_list argList)
|
ostream_vprintf (ostream *s, const char *format, va_list argList)
|
||||||
{
|
{
|
||||||
id <String> str = [String stringWithCString: format];
|
id <String> str = [String stringWithCString: format];
|
||||||
if (s->flags & OSTREAM_WRITEFLAG)
|
if (s->flags & OSTREAM_WRITEFLAG)
|
||||||
|
@ -159,7 +159,7 @@ ostream_vprintf(ostream *s, const char *format, va_list argList)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ostream_scanf(ostream *s, const char *format, ...)
|
ostream_scanf (ostream *s, const char *format, ...)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -170,7 +170,7 @@ ostream_scanf(ostream *s, const char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ostream_vscanf(ostream *s, const char *format, va_list argList)
|
ostream_vscanf (ostream *s, const char *format, va_list argList)
|
||||||
{
|
{
|
||||||
id <String> str = [String stringWithCString: format];
|
id <String> str = [String stringWithCString: format];
|
||||||
if (s->flags & OSTREAM_READFLAG)
|
if (s->flags & OSTREAM_READFLAG)
|
||||||
|
@ -181,7 +181,7 @@ ostream_vscanf(ostream *s, const char *format, va_list argList)
|
||||||
}
|
}
|
||||||
|
|
||||||
static ostream *
|
static ostream *
|
||||||
_ostream_new_stream_struct(int mode, char** cmode)
|
_ostream_new_stream_struct (int mode, char** cmode)
|
||||||
{
|
{
|
||||||
char* fmode;
|
char* fmode;
|
||||||
ostream* stream;
|
ostream* stream;
|
||||||
|
@ -216,7 +216,7 @@ _ostream_new_stream_struct(int mode, char** cmode)
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream *
|
ostream *
|
||||||
ostream_open_descriptor(int fd, int mode)
|
ostream_open_descriptor (int fd, int mode)
|
||||||
{
|
{
|
||||||
char* fmode;
|
char* fmode;
|
||||||
ostream* stream = _ostream_new_stream_struct(mode, &fmode);
|
ostream* stream = _ostream_new_stream_struct(mode, &fmode);
|
||||||
|
@ -228,7 +228,7 @@ ostream_open_descriptor(int fd, int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream *
|
ostream *
|
||||||
ostream_open_memory(const char *addr, int size, int mode)
|
ostream_open_memory (const char *addr, int size, int mode)
|
||||||
{
|
{
|
||||||
char* fmode;
|
char* fmode;
|
||||||
ostream* stream = _ostream_new_stream_struct(mode, &fmode);
|
ostream* stream = _ostream_new_stream_struct(mode, &fmode);
|
||||||
|
@ -259,7 +259,7 @@ ostream_open_memory(const char *addr, int size, int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream *
|
ostream *
|
||||||
ostream_map_file(const char *name, int mode)
|
ostream_map_file (const char *name, int mode)
|
||||||
{
|
{
|
||||||
char* fmode;
|
char* fmode;
|
||||||
String* str = [String stringWithCString: name];
|
String* str = [String stringWithCString: name];
|
||||||
|
@ -279,7 +279,7 @@ ostream_map_file(const char *name, int mode)
|
||||||
/* Would like to use NSData for this, but it's to hard to pass the buffer
|
/* Would like to use NSData for this, but it's to hard to pass the buffer
|
||||||
and tell NSData not to free it */
|
and tell NSData not to free it */
|
||||||
int
|
int
|
||||||
ostream_save_to_file(ostream *s, const char *name)
|
ostream_save_to_file (ostream *s, const char *name)
|
||||||
{
|
{
|
||||||
StdioStream* output;
|
StdioStream* output;
|
||||||
if (!(s->flags & OSTREAM_ISBUFFER))
|
if (!(s->flags & OSTREAM_ISBUFFER))
|
||||||
|
@ -303,7 +303,7 @@ ostream_save_to_file(ostream *s, const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ostream_get_memory_buffer(ostream *s, char **addr, int *len, int *maxlen)
|
ostream_get_memory_buffer (ostream *s, char **addr, int *len, int *maxlen)
|
||||||
{
|
{
|
||||||
if (!(s->flags & OSTREAM_ISBUFFER))
|
if (!(s->flags & OSTREAM_ISBUFFER))
|
||||||
{
|
{
|
||||||
|
@ -321,7 +321,7 @@ ostream_get_memory_buffer(ostream *s, char **addr, int *len, int *maxlen)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ostream_close_memory(ostream *s, int option)
|
ostream_close_memory (ostream *s, int option)
|
||||||
{
|
{
|
||||||
if (s->flags & OSTREAM_ISBUFFER)
|
if (s->flags & OSTREAM_ISBUFFER)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +333,7 @@ ostream_close_memory(ostream *s, int option)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ostream_close(ostream *s)
|
ostream_close (ostream *s)
|
||||||
{
|
{
|
||||||
[(id <Streaming>)s->stream_obj close];
|
[(id <Streaming>)s->stream_obj close];
|
||||||
[(id)s->stream_obj release];
|
[(id)s->stream_obj release];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue