* Indexes into this table are used when generating type
* tags for smobjects (if you know a tag you can get an index and conversely).
*/
-scm_ptob_descriptor_t *scm_ptobs;
+scm_t_ptob_descriptor *scm_ptobs;
long scm_numptob;
/* GC marker for a port with stream of SCM type. */
{
}
-scm_bits_t
+scm_t_bits
scm_make_port_type (char *name,
int (*fill_input) (SCM port),
void (*write) (SCM port, const void *data, size_t size))
SCM_DEFER_INTS;
SCM_SYSCALL (tmp = (char *) realloc ((char *) scm_ptobs,
(1 + scm_numptob)
- * sizeof (scm_ptob_descriptor_t)));
+ * sizeof (scm_t_ptob_descriptor)));
if (tmp)
{
- scm_ptobs = (scm_ptob_descriptor_t *) tmp;
+ scm_ptobs = (scm_t_ptob_descriptor *) tmp;
scm_ptobs[scm_numptob].name = name;
scm_ptobs[scm_numptob].mark = 0;
"interactive port that has no ready characters.}")
#define FUNC_NAME s_scm_char_ready_p
{
- scm_port_t *pt;
+ scm_t_port *pt;
if (SCM_UNBNDP (port))
port = scm_cur_inp;
return SCM_BOOL_T;
else
{
- scm_ptob_descriptor_t *ptob = &scm_ptobs[SCM_PTOBNUM (port)];
+ scm_t_ptob_descriptor *ptob = &scm_ptobs[SCM_PTOBNUM (port)];
if (ptob->input_waiting)
return SCM_BOOL(ptob->input_waiting (port));
into memory starting at dest. returns the number of chars moved. */
size_t scm_take_from_input_buffers (SCM port, char *dest, size_t read_len)
{
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
size_t chars_read = 0;
size_t from_buf = min (pt->read_end - pt->read_pos, read_len);
#define FUNC_NAME s_scm_drain_input
{
SCM result;
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
long count;
SCM_VALIDATE_OPINPORT (1,port);
\f
/* The port table --- an array of pointers to ports. */
-scm_port_t **scm_port_table;
+scm_t_port **scm_t_portable;
-long scm_port_table_size = 0; /* Number of ports in scm_port_table. */
-long scm_port_table_room = 20; /* Size of the array. */
+long scm_t_portable_size = 0; /* Number of ports in scm_t_portable. */
+long scm_t_portable_room = 20; /* Size of the array. */
/* Add a port to the table. */
-scm_port_t *
+scm_t_port *
scm_add_to_port_table (SCM port)
#define FUNC_NAME "scm_add_to_port_table"
{
- scm_port_t *entry;
+ scm_t_port *entry;
- if (scm_port_table_size == scm_port_table_room)
+ if (scm_t_portable_size == scm_t_portable_room)
{
/* initial malloc is in gc.c. this doesn't use scm_must_malloc etc.,
since it can never be freed during gc. */
- void *newt = realloc ((char *) scm_port_table,
- (size_t) (sizeof (scm_port_t *)
- * scm_port_table_room * 2));
+ void *newt = realloc ((char *) scm_t_portable,
+ (size_t) (sizeof (scm_t_port *)
+ * scm_t_portable_room * 2));
if (newt == NULL)
scm_memory_error ("scm_add_to_port_table");
- scm_port_table = (scm_port_t **) newt;
- scm_port_table_room *= 2;
+ scm_t_portable = (scm_t_port **) newt;
+ scm_t_portable_room *= 2;
}
- entry = (scm_port_t *) scm_must_malloc (sizeof (scm_port_t), FUNC_NAME);
+ entry = (scm_t_port *) scm_must_malloc (sizeof (scm_t_port), FUNC_NAME);
entry->port = port;
- entry->entry = scm_port_table_size;
+ entry->entry = scm_t_portable_size;
entry->revealed = 0;
entry->stream = 0;
entry->file_name = SCM_BOOL_F;
entry->rw_active = SCM_PORT_NEITHER;
entry->rw_random = 0;
- scm_port_table[scm_port_table_size] = entry;
- scm_port_table_size++;
+ scm_t_portable[scm_t_portable_size] = entry;
+ scm_t_portable_size++;
return entry;
}
scm_remove_from_port_table (SCM port)
#define FUNC_NAME "scm_remove_from_port_table"
{
- scm_port_t *p = SCM_PTAB_ENTRY (port);
+ scm_t_port *p = SCM_PTAB_ENTRY (port);
long i = p->entry;
- if (i >= scm_port_table_size)
+ if (i >= scm_t_portable_size)
SCM_MISC_ERROR ("Port not in table: ~S", SCM_LIST1 (port));
if (p->putback_buf)
scm_must_free (p->putback_buf);
scm_must_free (p);
/* Since we have just freed slot i we can shrink the table by moving
the last entry to that slot... */
- if (i < scm_port_table_size - 1)
+ if (i < scm_t_portable_size - 1)
{
- scm_port_table[i] = scm_port_table[scm_port_table_size - 1];
- scm_port_table[i]->entry = i;
+ scm_t_portable[i] = scm_t_portable[scm_t_portable_size - 1];
+ scm_t_portable[i]->entry = i;
}
SCM_SETPTAB_ENTRY (port, 0);
- scm_port_table_size--;
+ scm_t_portable_size--;
}
#undef FUNC_NAME
"is only included in @code{--enable-guile-debug} builds.")
#define FUNC_NAME s_scm_pt_size
{
- return SCM_MAKINUM (scm_port_table_size);
+ return SCM_MAKINUM (scm_t_portable_size);
}
#undef FUNC_NAME
{
long i;
SCM_VALIDATE_INUM_COPY (1,index,i);
- if (i < 0 || i >= scm_port_table_size)
+ if (i < 0 || i >= scm_t_portable_size)
return SCM_BOOL_F;
else
- return scm_port_table[i]->port;
+ return scm_t_portable[i]->port;
}
#undef FUNC_NAME
#endif
void
-scm_port_non_buffer (scm_port_t *pt)
+scm_port_non_buffer (scm_t_port *pt)
{
pt->read_pos = pt->read_buf = pt->read_end = &pt->shortbuf;
pt->write_buf = pt->write_pos = &pt->shortbuf;
SCM_DEFER_INTS;
scm_block_gc++;
ports = SCM_EOL;
- for (i = 0; i < scm_port_table_size; i++)
- ports = scm_cons (scm_port_table[i]->port, ports);
+ for (i = 0; i < scm_t_portable_size; i++)
+ ports = scm_cons (scm_t_portable[i]->port, ports);
scm_block_gc--;
SCM_ALLOW_INTS;
{
long i = 0;
SCM_VALIDATE_REST_ARGUMENT (ports);
- while (i < scm_port_table_size)
+ while (i < scm_t_portable_size)
{
- SCM thisport = scm_port_table[i]->port;
+ SCM thisport = scm_t_portable[i]->port;
int found = 0;
SCM ports_ptr = ports;
{
size_t i;
- for (i = 0; i < scm_port_table_size; i++)
+ for (i = 0; i < scm_t_portable_size; i++)
{
- if (SCM_OPOUTPORTP (scm_port_table[i]->port))
- scm_flush (scm_port_table[i]->port);
+ if (SCM_OPOUTPORTP (scm_t_portable[i]->port))
+ scm_flush (scm_t_portable[i]->port);
}
return SCM_UNSPECIFIED;
}
int
scm_fill_input (SCM port)
{
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
if (pt->read_buf == pt->putback_buf)
{
scm_getc (SCM port)
{
int c;
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
if (pt->rw_active == SCM_PORT_WRITE)
{
void
scm_lfwrite (const char *ptr, size_t size, SCM port)
{
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
- scm_ptob_descriptor_t *ptob = &scm_ptobs[SCM_PTOBNUM (port)];
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
+ scm_t_ptob_descriptor *ptob = &scm_ptobs[SCM_PTOBNUM (port)];
if (pt->rw_active == SCM_PORT_READ)
scm_end_input (port);
size_t
scm_c_read (SCM port, void *buffer, size_t size)
{
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
size_t n_read = 0, n_available;
if (pt->rw_active == SCM_PORT_WRITE)
void
scm_c_write (SCM port, const void *ptr, size_t size)
{
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
- scm_ptob_descriptor_t *ptob = &scm_ptobs[SCM_PTOBNUM (port)];
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
+ scm_t_ptob_descriptor *ptob = &scm_ptobs[SCM_PTOBNUM (port)];
if (pt->rw_active == SCM_PORT_READ)
scm_end_input (port);
scm_end_input (SCM port)
{
long offset;
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
if (pt->read_buf == pt->putback_buf)
{
scm_ungetc (int c, SCM port)
#define FUNC_NAME "scm_ungetc"
{
- scm_port_t *pt = SCM_PTAB_ENTRY (port);
+ scm_t_port *pt = SCM_PTAB_ENTRY (port);
if (pt->read_buf == pt->putback_buf)
/* already using the put-back buffer. */
SCM_OUT_OF_RANGE (3, whence);
if (SCM_OPPORTP (fd_port))
{
- scm_ptob_descriptor_t *ptob = scm_ptobs + SCM_PTOBNUM (fd_port);
+ scm_t_ptob_descriptor *ptob = scm_ptobs + SCM_PTOBNUM (fd_port);
if (!ptob->seek)
SCM_MISC_ERROR ("port is not seekable",
}
else if (SCM_OPOUTPORTP (object))
{
- scm_port_t *pt = SCM_PTAB_ENTRY (object);
- scm_ptob_descriptor_t *ptob = scm_ptobs + SCM_PTOBNUM (object);
+ scm_t_port *pt = SCM_PTAB_ENTRY (object);
+ scm_t_ptob_descriptor *ptob = scm_ptobs + SCM_PTOBNUM (object);
if (!ptob->truncate)
SCM_MISC_ERROR ("port is not truncatable", SCM_EOL);
scm_ports_prehistory ()
{
scm_numptob = 0;
- scm_ptobs = (scm_ptob_descriptor_t *) malloc (sizeof (scm_ptob_descriptor_t));
+ scm_ptobs = (scm_t_ptob_descriptor *) malloc (sizeof (scm_t_ptob_descriptor));
}
\f
/* Void ports. */
-scm_bits_t scm_tc16_void_port = 0;
+scm_t_bits scm_tc16_void_port = 0;
static int fill_input_void_port (SCM port SCM_UNUSED)
{
{
int mode_bits;
SCM answer;
- scm_port_t * pt;
+ scm_t_port * pt;
SCM_NEWCELL (answer);
SCM_DEFER_INTS;