X-Git-Url: http://git.hcoop.net/bpt/guile.git/blobdiff_plain/843524cc2079e6fb23554eac366a87faf0d720f3..167d89cff92a301875e21ee31e35d6f8f3c3036e:/libguile/ports.h diff --git a/libguile/ports.h b/libguile/ports.h index f8c56fa32..b39c27fc1 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -2,7 +2,7 @@ #ifndef PORTSH #define PORTSH -/* Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999, 2000 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -74,9 +74,8 @@ typedef struct int revealed; /* 0 not revealed, > 1 revealed. * Revealed ports do not get GC'd. */ - /* data for the underlying port implementation. may be an SCM cell or - cast to a pointer to C data. */ - SCM stream; + /* data for the underlying port implementation as a raw C value. */ + scm_bits_t stream; SCM file_name; /* debugging support. */ int line_number; /* debugging support. */ @@ -139,7 +138,7 @@ extern int scm_port_table_size; /* Number of ports in scm_port_table. */ -#define SCM_EOF_OBJECT_P(x) ((x) == SCM_EOF_VAL) +#define SCM_EOF_OBJECT_P(x) (SCM_EQ_P ((x), SCM_EOF_VAL)) /* PORT FLAGS * A set of flags characterizes a port. @@ -150,22 +149,25 @@ extern int scm_port_table_size; /* Number of ports in scm_port_table. */ #define SCM_RDNG (2L<<16) /* Is it a readable port? */ #define SCM_WRTNG (4L<<16) /* Is it writable? */ #define SCM_BUF0 (8L<<16) /* Is it unbuffered? */ -/* #define SCM_CRDY (32L<<16) obsolete, for pushed back characters */ #define SCM_BUFLINE (64L<<16) /* Is it line-buffered? */ #define SCM_PORTP(x) (SCM_NIMP(x) && (SCM_TYP7(x)==scm_tc7_port)) -#define SCM_OPPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN) & SCM_UNPACK_CAR(x))==(scm_tc7_port | SCM_OPN))) -#define SCM_OPINPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_RDNG) & SCM_UNPACK_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG))) -#define SCM_OPOUTPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_WRTNG) & SCM_UNPACK_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG))) -#define SCM_INPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_RDNG) & SCM_UNPACK_CAR(x))==(scm_tc7_port | SCM_RDNG))) -#define SCM_OUTPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_WRTNG) & SCM_UNPACK_CAR(x))==(scm_tc7_port | SCM_WRTNG))) -#define SCM_OPENP(x) (SCM_NIMP(x) && (SCM_OPN & SCM_UNPACK_CAR (x))) +#define SCM_OPPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_OPN))) +#define SCM_OPINPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_RDNG) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG))) +#define SCM_OPOUTPORTP(x) (SCM_NIMP(x) && (((0x7f | SCM_OPN | SCM_WRTNG) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_OPN | SCM_WRTNG))) +#define SCM_INPUT_PORT_P(x) \ + (SCM_NIMP(x) \ + && (((0x7f | SCM_RDNG) & SCM_CELL_WORD_0(x)) == (scm_tc7_port | SCM_RDNG))) +#define SCM_OUTPUT_PORT_P(x) \ + (SCM_NIMP(x) \ + && (((0x7f | SCM_WRTNG) & SCM_CELL_WORD_0(x))==(scm_tc7_port | SCM_WRTNG))) +#define SCM_OPENP(x) (SCM_NIMP(x) && (SCM_OPN & SCM_CELL_WORD_0 (x))) #define SCM_CLOSEDP(x) (!SCM_OPENP(x)) #define SCM_PTAB_ENTRY(x) ((scm_port *) SCM_CELL_WORD_1 (x)) -#define SCM_SETPTAB_ENTRY(x,ent) (SCM_SET_CELL_WORD_1 ((x), (ent))) +#define SCM_SETPTAB_ENTRY(x,ent) (SCM_SET_CELL_WORD_1 ((x), (scm_bits_t) (ent))) #define SCM_STREAM(x) (SCM_PTAB_ENTRY(x)->stream) -#define SCM_SETSTREAM(x,s) (SCM_PTAB_ENTRY(x)->stream = (SCM) (s)) +#define SCM_SETSTREAM(x,s) (SCM_PTAB_ENTRY(x)->stream = (scm_bits_t) (s)) #define SCM_FILENAME(x) (SCM_PTAB_ENTRY(x)->file_name) #define SCM_LINUM(x) (SCM_PTAB_ENTRY(x)->line_number) #define SCM_COL(x) (SCM_PTAB_ENTRY(x)->column_number) @@ -200,8 +202,8 @@ typedef struct scm_ptob_descriptor } scm_ptob_descriptor; -#define SCM_TC2PTOBNUM(x) (0x0ff & (SCM_UNPACK(x) >> 8)) -#define SCM_PTOBNUM(x) (SCM_TC2PTOBNUM (SCM_CAR (x))) +#define SCM_TC2PTOBNUM(x) (0x0ff & ((x) >> 8)) +#define SCM_PTOBNUM(x) (SCM_TC2PTOBNUM (SCM_CELL_TYPE (x))) /* SCM_PTOBNAME can be 0 if name is missing */ #define SCM_PTOBNAME(ptobnum) scm_ptobs[ptobnum].name @@ -260,6 +262,8 @@ extern SCM scm_port_revealed (SCM port); extern SCM scm_set_port_revealed_x (SCM port, SCM rcount); extern long scm_mode_bits (char *modes); extern SCM scm_port_mode (SCM port); +extern SCM scm_close_input_port (SCM port); +extern SCM scm_close_output_port (SCM port); extern SCM scm_close_port (SCM port); extern SCM scm_close_all_ports_except (SCM ports); extern SCM scm_input_port_p (SCM x); @@ -281,7 +285,6 @@ extern void scm_ungets (const char *s, int n, SCM port); extern SCM scm_peek_char (SCM port); extern SCM scm_unread_char (SCM cobj, SCM port); extern SCM scm_unread_string (SCM str, SCM port); -extern char *scm_generic_fgets (SCM port, int *len); extern SCM scm_seek (SCM object, SCM offset, SCM whence); extern SCM scm_truncate_file (SCM object, SCM length); extern SCM scm_port_line (SCM port); @@ -302,6 +305,16 @@ extern SCM scm_pt_size (void); extern SCM scm_pt_member (SCM member); #endif /* GUILE_DEBUG */ + + +#if (SCM_DEBUG_DEPRECATED == 0) + +/* #define SCM_CRDY (32L<<16) obsolete, for pushed back characters */ +#define SCM_INPORTP(x) SCM_INPUT_PORT_P (x) +#define SCM_OUTPORTP(x) SCM_OUTPUT_PORT_P (x) + +#endif /* SCM_DEBUG_DEPRECATED == 0 */ + #endif /* PORTSH */ /*