mirror of
https://github.com/open-simh/simtools.git
synced 2026-01-25 19:56:30 +00:00
Import J Hoppe's 20090427 release from http://retrocmp.com/tools/macro-11-on-windows
This commit is contained in:
125
stream2.h
125
stream2.h
@@ -35,76 +35,103 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
struct stream;
|
||||
|
||||
typedef struct stream_vtbl
|
||||
{
|
||||
void (*delete)(struct stream *stream); // Destructor
|
||||
char *(*gets)(struct stream *stream); // "gets" function
|
||||
void (*rewind)(struct stream *stream); // "rewind" function
|
||||
typedef struct stream_vtbl {
|
||||
void (
|
||||
*delete) (
|
||||
struct stream * stream); // Destructor
|
||||
char *(
|
||||
*gets) (
|
||||
struct stream * stream); // "gets" function
|
||||
void (
|
||||
*rewind) (
|
||||
struct stream * stream); // "rewind" function
|
||||
} STREAM_VTBL;
|
||||
|
||||
typedef struct stream
|
||||
{
|
||||
STREAM_VTBL *vtbl; // Pointer to dispatch table
|
||||
char *name; // Stream name
|
||||
int line; // Current line number in stream
|
||||
struct stream *next; // Next stream in stack
|
||||
typedef struct stream {
|
||||
STREAM_VTBL *vtbl; // Pointer to dispatch table
|
||||
char *name; // Stream name
|
||||
int line; // Current line number in stream
|
||||
struct stream *next; // Next stream in stack
|
||||
} STREAM;
|
||||
|
||||
typedef struct file_stream
|
||||
{
|
||||
STREAM stream; // Base class
|
||||
FILE *fp; // File pointer
|
||||
char *buffer; // Line buffer
|
||||
typedef struct file_stream {
|
||||
STREAM stream; // Base class
|
||||
FILE *fp; // File pointer
|
||||
char *buffer; // Line buffer
|
||||
} FILE_STREAM;
|
||||
|
||||
typedef struct buffer
|
||||
{
|
||||
char *buffer; // Pointer to text
|
||||
int size; // Size of buffer
|
||||
int length; // Occupied size of buffer
|
||||
int use; // Number of users of buffer
|
||||
typedef struct buffer {
|
||||
char *buffer; // Pointer to text
|
||||
int size; // Size of buffer
|
||||
int length; // Occupied size of buffer
|
||||
int use; // Number of users of buffer
|
||||
} BUFFER;
|
||||
|
||||
#define GROWBUF_INCR 1024 // Buffers grow by leaps and bounds
|
||||
#define GROWBUF_INCR 1024 // Buffers grow by leaps and bounds
|
||||
|
||||
typedef struct buffer_stream
|
||||
{
|
||||
STREAM stream; // Base class
|
||||
BUFFER *buffer; // text buffer
|
||||
int offset; // Current read offset
|
||||
typedef struct buffer_stream {
|
||||
STREAM stream; // Base class
|
||||
BUFFER *buffer; // text buffer
|
||||
int offset; // Current read offset
|
||||
} BUFFER_STREAM;
|
||||
|
||||
typedef struct stack
|
||||
{
|
||||
STREAM *top; // Top of stacked stream pieces
|
||||
typedef struct stack {
|
||||
STREAM *top; // Top of stacked stream pieces
|
||||
} STACK;
|
||||
|
||||
#define STREAM_BUFFER_SIZE 1024 // This limits the max size of an input line.
|
||||
BUFFER *new_buffer(void);
|
||||
BUFFER *buffer_clone(BUFFER *from);
|
||||
void buffer_resize(BUFFER *buff, int size);
|
||||
void buffer_free(BUFFER *buf);
|
||||
void buffer_appendn(BUFFER *buf, char *str, int len);
|
||||
void buffer_append_line(BUFFER *buf, char *str);
|
||||
#define STREAM_BUFFER_SIZE 1024 // This limits the max size of an input line.
|
||||
BUFFER *new_buffer(
|
||||
void);
|
||||
BUFFER *buffer_clone(
|
||||
BUFFER *from);
|
||||
void buffer_resize(
|
||||
BUFFER *buff,
|
||||
int size);
|
||||
void buffer_free(
|
||||
BUFFER *buf);
|
||||
void buffer_appendn(
|
||||
BUFFER *buf,
|
||||
char *str,
|
||||
int len);
|
||||
void buffer_append_line(
|
||||
BUFFER *buf,
|
||||
char *str);
|
||||
|
||||
STREAM *new_buffer_stream(BUFFER *buf, char *name);
|
||||
void buffer_stream_set_buffer(BUFFER_STREAM *bstr, BUFFER *buf);
|
||||
STREAM *new_buffer_stream(
|
||||
BUFFER *buf,
|
||||
char *name);
|
||||
void buffer_stream_set_buffer(
|
||||
BUFFER_STREAM * bstr,
|
||||
BUFFER *buf);
|
||||
|
||||
/* Provide these so that macro11 can derive from a BUFFER_STREAM */
|
||||
extern STREAM_VTBL buffer_stream_vtbl;
|
||||
void buffer_stream_construct(BUFFER_STREAM *bstr, BUFFER *buf, char *name);
|
||||
char *buffer_stream_gets(STREAM *str);
|
||||
void buffer_stream_delete(STREAM *str);
|
||||
void buffer_stream_rewind(STREAM *str);
|
||||
void buffer_stream_construct(
|
||||
BUFFER_STREAM * bstr,
|
||||
BUFFER *buf,
|
||||
char *name);
|
||||
char *buffer_stream_gets(
|
||||
STREAM *str);
|
||||
void buffer_stream_delete(
|
||||
STREAM *str);
|
||||
void buffer_stream_rewind(
|
||||
STREAM *str);
|
||||
|
||||
STREAM *new_file_stream(char *filename);
|
||||
STREAM *new_file_stream(
|
||||
char *filename);
|
||||
|
||||
void stack_init(STACK *stack);
|
||||
void stack_push(STACK *stack, STREAM *str);
|
||||
void stack_pop(STACK *stack);
|
||||
char *stack_gets(STACK *stack);
|
||||
void stack_init(
|
||||
STACK *stack);
|
||||
void stack_push(
|
||||
STACK *stack,
|
||||
STREAM *str);
|
||||
void stack_pop(
|
||||
STACK *stack);
|
||||
char *stack_gets(
|
||||
STACK *stack);
|
||||
|
||||
#endif /* STREAM2_H */
|
||||
|
||||
Reference in New Issue
Block a user