ports.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. /* classes: h_files */
  2. #ifndef SCM_PORTS_H
  3. #define SCM_PORTS_H
  4. /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
  5. * 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 3 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #include "libguile/__scm.h"
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <unistd.h>
  26. #include "libguile/gc.h"
  27. #include "libguile/tags.h"
  28. #include "libguile/error.h"
  29. #include "libguile/print.h"
  30. #include "libguile/struct.h"
  31. #include "libguile/threads.h"
  32. #include "libguile/strings.h"
  33. #define SCM_INITIAL_PUTBACK_BUF_SIZE 4
  34. /* values for the rw_active flag. */
  35. typedef enum scm_t_port_rw_active {
  36. SCM_PORT_NEITHER = 0,
  37. SCM_PORT_READ = 1,
  38. SCM_PORT_WRITE = 2
  39. } scm_t_port_rw_active;
  40. typedef enum scm_t_port_encoding_mode {
  41. SCM_PORT_ENCODING_MODE_UTF8,
  42. SCM_PORT_ENCODING_MODE_ICONV
  43. } scm_t_port_encoding_mode;
  44. /* This is a separate object so that only those ports that use iconv
  45. cause finalizers to be registered. */
  46. typedef struct scm_t_iconv_descriptors
  47. {
  48. /* input/output iconv conversion descriptors */
  49. void *input_cd;
  50. void *output_cd;
  51. } scm_t_iconv_descriptors;
  52. /* C representation of a Scheme port. */
  53. typedef struct
  54. {
  55. SCM port; /* Link back to the port object. */
  56. scm_i_pthread_mutex_t *lock; /* A recursive lock for this port. */
  57. int revealed; /* 0 not revealed, > 1 revealed.
  58. * Revealed ports do not get GC'd.
  59. */
  60. /* data for the underlying port implementation as a raw C value. */
  61. scm_t_bits stream;
  62. SCM file_name; /* debugging support. */
  63. long line_number; /* debugging support. */
  64. int column_number; /* debugging support. */
  65. /* port buffers. the buffer(s) are set up for all ports.
  66. in the case of string ports, the buffer is the string itself.
  67. in the case of unbuffered file ports, the buffer is a
  68. single char: shortbuf. */
  69. /* this buffer is filled from read_buf to read_end using the ptob
  70. buffer_fill. then input requests are taken from read_pos until
  71. it reaches read_end. */
  72. unsigned char *read_buf; /* buffer start. */
  73. const unsigned char *read_pos;/* the next unread char. */
  74. unsigned char *read_end; /* pointer to last buffered char + 1. */
  75. scm_t_off read_buf_size; /* size of the buffer. */
  76. /* when chars are put back into the buffer, e.g., using peek-char or
  77. unread-string, the read-buffer pointers are switched to cbuf.
  78. the original pointers are saved here and restored when the put-back
  79. chars have been consumed. */
  80. unsigned char *saved_read_buf;
  81. const unsigned char *saved_read_pos;
  82. unsigned char *saved_read_end;
  83. scm_t_off saved_read_buf_size;
  84. /* write requests are saved into this buffer at write_pos until it
  85. reaches write_buf + write_buf_size, then the ptob flush is
  86. called. */
  87. unsigned char *write_buf; /* buffer start. */
  88. unsigned char *write_pos; /* pointer to last buffered char + 1. */
  89. unsigned char *write_end; /* pointer to end of buffer + 1. */
  90. scm_t_off write_buf_size; /* size of the buffer. */
  91. unsigned char shortbuf; /* buffer for "unbuffered" streams. */
  92. int rw_random; /* true if the port is random access.
  93. implies that the buffers must be
  94. flushed before switching between
  95. reading and writing, seeking, etc. */
  96. scm_t_port_rw_active rw_active; /* for random access ports,
  97. indicates which of the buffers
  98. is currently in use. can be
  99. SCM_PORT_WRITE, SCM_PORT_READ,
  100. or SCM_PORT_NEITHER. */
  101. /* a buffer for un-read chars and strings. */
  102. unsigned char *putback_buf;
  103. size_t putback_buf_size; /* allocated size of putback_buf. */
  104. /* Character encoding support */
  105. char *encoding;
  106. scm_t_port_encoding_mode encoding_mode;
  107. scm_t_string_failed_conversion_handler ilseq_handler;
  108. scm_t_iconv_descriptors *iconv_descriptors;
  109. } scm_t_port;
  110. SCM_INTERNAL SCM scm_i_port_weak_set;
  111. #define SCM_READ_BUFFER_EMPTY_P(c_port) (c_port->read_pos >= c_port->read_end)
  112. #define SCM_EOF_OBJECT_P(x) (scm_is_eq ((x), SCM_EOF_VAL))
  113. /* PORT FLAGS
  114. * A set of flags characterizes a port.
  115. * Note that we reserve the bits 1 << 24 and above for use by the
  116. * routines in the port's scm_ptobfuns structure.
  117. */
  118. #define SCM_OPN (1L<<16) /* Is the port open? */
  119. #define SCM_RDNG (2L<<16) /* Is it a readable port? */
  120. #define SCM_WRTNG (4L<<16) /* Is it writable? */
  121. #define SCM_BUF0 (8L<<16) /* Is it unbuffered? */
  122. #define SCM_BUFLINE (64L<<16) /* Is it line-buffered? */
  123. #define SCM_PORTP(x) (SCM_HAS_TYP7 (x, scm_tc7_port))
  124. #define SCM_OPPORTP(x) (SCM_PORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_OPN))
  125. #define SCM_INPUT_PORT_P(x) (SCM_PORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_RDNG))
  126. #define SCM_OUTPUT_PORT_P(x) (SCM_PORTP (x) && (SCM_CELL_WORD_0 (x) & SCM_WRTNG))
  127. #define SCM_OPINPORTP(x) (SCM_OPPORTP (x) && SCM_INPUT_PORT_P (x))
  128. #define SCM_OPOUTPORTP(x) (SCM_OPPORTP (x) && SCM_OUTPUT_PORT_P (x))
  129. #define SCM_OPENP(x) (SCM_OPPORTP (x))
  130. #define SCM_CLOSEDP(x) (!SCM_OPENP (x))
  131. #define SCM_CLR_PORT_OPEN_FLAG(p) \
  132. SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) & ~SCM_OPN)
  133. #define SCM_PTAB_ENTRY(x) ((scm_t_port *) SCM_CELL_WORD_1 (x))
  134. #define SCM_PORT_DESCRIPTOR(port) ((scm_t_ptob_descriptor *) SCM_CELL_WORD_2 (port))
  135. #define SCM_SETPTAB_ENTRY(x, ent) (SCM_SET_CELL_WORD_1 ((x), (scm_t_bits) (ent)))
  136. #define SCM_STREAM(x) (SCM_PTAB_ENTRY(x)->stream)
  137. #define SCM_SETSTREAM(x, s) (SCM_PTAB_ENTRY(x)->stream = (scm_t_bits) (s))
  138. #define SCM_FILENAME(x) (SCM_PTAB_ENTRY(x)->file_name)
  139. #define SCM_SET_FILENAME(x, n) (SCM_PTAB_ENTRY(x)->file_name = (n))
  140. #define SCM_LINUM(x) (SCM_PTAB_ENTRY(x)->line_number)
  141. #define SCM_COL(x) (SCM_PTAB_ENTRY(x)->column_number)
  142. #define SCM_REVEALED(x) (SCM_PTAB_ENTRY(x)->revealed)
  143. #define SCM_SETREVEALED(x, s) (SCM_PTAB_ENTRY(x)->revealed = (s))
  144. #define SCM_INCLINE(port) do {SCM_LINUM (port) += 1; SCM_COL (port) = 0;} while (0)
  145. #define SCM_ZEROCOL(port) do {SCM_COL (port) = 0;} while (0)
  146. #define SCM_INCCOL(port) do {SCM_COL (port) += 1;} while (0)
  147. #define SCM_DECCOL(port) do {if (SCM_COL (port) > 0) SCM_COL (port) -= 1;} while (0)
  148. #define SCM_TABCOL(port) do {SCM_COL (port) += 8 - SCM_COL (port) % 8;} while (0)
  149. /* Maximum number of port types. */
  150. #define SCM_I_MAX_PORT_TYPE_COUNT 256
  151. typedef enum scm_t_port_type_flags {
  152. SCM_PORT_TYPE_HAS_FLUSH = 1 << 0
  153. } scm_t_port_type_flags;
  154. /* port-type description. */
  155. typedef struct scm_t_ptob_descriptor
  156. {
  157. char *name;
  158. SCM (*mark) (SCM);
  159. size_t (*free) (SCM);
  160. int (*print) (SCM exp, SCM port, scm_print_state *pstate);
  161. SCM (*equalp) (SCM, SCM);
  162. int (*close) (SCM port);
  163. void (*write) (SCM port, const void *data, size_t size);
  164. void (*flush) (SCM port);
  165. void (*end_input) (SCM port, int offset);
  166. int (*fill_input) (SCM port);
  167. int (*input_waiting) (SCM port);
  168. scm_t_off (*seek) (SCM port, scm_t_off OFFSET, int WHENCE);
  169. void (*truncate) (SCM port, scm_t_off length);
  170. unsigned flags;
  171. } scm_t_ptob_descriptor;
  172. #define SCM_TC2PTOBNUM(x) (0x0ff & ((x) >> 8))
  173. #define SCM_PTOBNUM(x) (SCM_TC2PTOBNUM (SCM_CELL_TYPE (x)))
  174. /* SCM_PTOBNAME can be 0 if name is missing */
  175. #define SCM_PTOBNAME(ptobnum) (scm_c_port_type_ref (ptobnum)->name)
  176. /* Port types, and their vtables. */
  177. SCM_INTERNAL long scm_c_num_port_types (void);
  178. SCM_API scm_t_ptob_descriptor* scm_c_port_type_ref (long ptobnum);
  179. SCM_API long scm_c_port_type_add_x (scm_t_ptob_descriptor *desc);
  180. SCM_API scm_t_bits scm_make_port_type (char *name,
  181. int (*fill_input) (SCM port),
  182. void (*write) (SCM port,
  183. const void *data,
  184. size_t size));
  185. SCM_API void scm_set_port_mark (scm_t_bits tc, SCM (*mark) (SCM));
  186. SCM_API void scm_set_port_free (scm_t_bits tc, size_t (*free) (SCM));
  187. SCM_API void scm_set_port_print (scm_t_bits tc,
  188. int (*print) (SCM exp,
  189. SCM port,
  190. scm_print_state *pstate));
  191. SCM_API void scm_set_port_equalp (scm_t_bits tc, SCM (*equalp) (SCM, SCM));
  192. SCM_API void scm_set_port_close (scm_t_bits tc, int (*close) (SCM));
  193. SCM_API void scm_set_port_flush (scm_t_bits tc, void (*flush) (SCM port));
  194. SCM_API void scm_set_port_end_input (scm_t_bits tc,
  195. void (*end_input) (SCM port,
  196. int offset));
  197. SCM_API void scm_set_port_seek (scm_t_bits tc,
  198. scm_t_off (*seek) (SCM port,
  199. scm_t_off OFFSET,
  200. int WHENCE));
  201. SCM_API void scm_set_port_truncate (scm_t_bits tc,
  202. void (*truncate) (SCM port,
  203. scm_t_off length));
  204. SCM_API void scm_set_port_input_waiting (scm_t_bits tc, int (*input_waiting) (SCM));
  205. /* The input, output, error, and load ports. */
  206. SCM_API SCM scm_current_input_port (void);
  207. SCM_API SCM scm_current_output_port (void);
  208. SCM_API SCM scm_current_error_port (void);
  209. SCM_API SCM scm_current_warning_port (void);
  210. SCM_API SCM scm_current_load_port (void);
  211. SCM_API SCM scm_set_current_input_port (SCM port);
  212. SCM_API SCM scm_set_current_output_port (SCM port);
  213. SCM_API SCM scm_set_current_error_port (SCM port);
  214. SCM_API SCM scm_set_current_warning_port (SCM port);
  215. SCM_API void scm_dynwind_current_input_port (SCM port);
  216. SCM_API void scm_dynwind_current_output_port (SCM port);
  217. SCM_API void scm_dynwind_current_error_port (SCM port);
  218. SCM_INTERNAL void scm_i_dynwind_current_load_port (SCM port);
  219. /* Mode bits. */
  220. SCM_INTERNAL long scm_i_mode_bits (SCM modes);
  221. SCM_API long scm_mode_bits (char *modes);
  222. SCM_API SCM scm_port_mode (SCM port);
  223. /* Low-level constructors. */
  224. SCM_API SCM
  225. scm_c_make_port_with_encoding (scm_t_bits tag,
  226. unsigned long mode_bits,
  227. const char *encoding,
  228. scm_t_string_failed_conversion_handler handler,
  229. scm_t_bits stream);
  230. SCM_API SCM scm_c_make_port (scm_t_bits tag, unsigned long mode_bits,
  231. scm_t_bits stream);
  232. SCM_API SCM scm_new_port_table_entry (scm_t_bits tag);
  233. /* Predicates. */
  234. SCM_API SCM scm_port_p (SCM x);
  235. SCM_API SCM scm_input_port_p (SCM x);
  236. SCM_API SCM scm_output_port_p (SCM x);
  237. SCM_API SCM scm_port_closed_p (SCM port);
  238. SCM_API SCM scm_eof_object_p (SCM x);
  239. /* Closing ports. */
  240. SCM_API SCM scm_close_port (SCM port);
  241. SCM_API SCM scm_close_input_port (SCM port);
  242. SCM_API SCM scm_close_output_port (SCM port);
  243. /* Encoding characters to byte streams, and decoding byte streams to
  244. characters. */
  245. SCM_INTERNAL const char *scm_i_default_port_encoding (void);
  246. SCM_INTERNAL void scm_i_set_default_port_encoding (const char *);
  247. SCM_INTERNAL scm_t_iconv_descriptors *scm_i_port_iconv_descriptors (SCM port);
  248. SCM_INTERNAL void scm_i_set_port_encoding_x (SCM port, const char *str);
  249. SCM_API SCM scm_port_encoding (SCM port);
  250. SCM_API SCM scm_set_port_encoding_x (SCM port, SCM encoding);
  251. SCM_INTERNAL scm_t_string_failed_conversion_handler scm_i_get_conversion_strategy (SCM port);
  252. SCM_INTERNAL void scm_i_set_conversion_strategy_x (SCM port,
  253. scm_t_string_failed_conversion_handler h);
  254. SCM_API SCM scm_port_conversion_strategy (SCM port);
  255. SCM_API SCM scm_set_port_conversion_strategy_x (SCM port, SCM behavior);
  256. /* Acquiring and releasing the port lock. */
  257. SCM_API void scm_dynwind_lock_port (SCM port);
  258. SCM_INLINE int scm_c_lock_port (SCM port, scm_i_pthread_mutex_t **lock);
  259. SCM_INLINE int scm_c_try_lock_port (SCM port, scm_i_pthread_mutex_t **lock);
  260. /* Revealed counts. */
  261. SCM_API int scm_revealed_count (SCM port);
  262. SCM_API SCM scm_port_revealed (SCM port);
  263. SCM_API SCM scm_set_port_revealed_x (SCM port, SCM rcount);
  264. SCM_API SCM scm_adjust_port_revealed_x (SCM port, SCM addend);
  265. /* Input. */
  266. SCM_API int scm_get_byte_or_eof (SCM port);
  267. SCM_INLINE int scm_get_byte_or_eof_unlocked (SCM port);
  268. SCM_API int scm_peek_byte_or_eof (SCM port);
  269. SCM_INLINE int scm_peek_byte_or_eof_unlocked (SCM port);
  270. SCM_API size_t scm_c_read (SCM port, void *buffer, size_t size);
  271. SCM_API size_t scm_c_read_unlocked (SCM port, void *buffer, size_t size);
  272. SCM_API scm_t_wchar scm_getc (SCM port);
  273. SCM_API scm_t_wchar scm_getc_unlocked (SCM port);
  274. SCM_API SCM scm_read_char (SCM port);
  275. /* Pushback. */
  276. SCM_INTERNAL void scm_unget_byte (int c, SCM port);
  277. SCM_INTERNAL void scm_unget_byte_unlocked (int c, SCM port);
  278. SCM_API void scm_ungetc (scm_t_wchar c, SCM port);
  279. SCM_API void scm_ungetc_unlocked (scm_t_wchar c, SCM port);
  280. SCM_API void scm_ungets (const char *s, int n, SCM port);
  281. SCM_API void scm_ungets_unlocked (const char *s, int n, SCM port);
  282. SCM_API SCM scm_peek_char (SCM port);
  283. SCM_API SCM scm_unread_char (SCM cobj, SCM port);
  284. SCM_API SCM scm_unread_string (SCM str, SCM port);
  285. /* Manipulating the buffers. */
  286. SCM_API void scm_port_non_buffer (scm_t_port *pt);
  287. SCM_API int scm_fill_input (SCM port);
  288. SCM_API int scm_fill_input_unlocked (SCM port);
  289. SCM_INTERNAL size_t scm_take_from_input_buffers (SCM port, char *dest, size_t read_len);
  290. SCM_API SCM scm_drain_input (SCM port);
  291. SCM_API void scm_end_input (SCM port);
  292. SCM_API void scm_end_input_unlocked (SCM port);
  293. SCM_API SCM scm_force_output (SCM port);
  294. SCM_API void scm_flush (SCM port);
  295. SCM_API void scm_flush_unlocked (SCM port);
  296. /* Output. */
  297. SCM_API void scm_putc (char c, SCM port);
  298. SCM_INLINE void scm_putc_unlocked (char c, SCM port);
  299. SCM_API void scm_puts (const char *str_data, SCM port);
  300. SCM_INLINE void scm_puts_unlocked (const char *str_data, SCM port);
  301. SCM_API void scm_c_write (SCM port, const void *buffer, size_t size);
  302. SCM_API void scm_c_write_unlocked (SCM port, const void *buffer, size_t size);
  303. SCM_API void scm_lfwrite (const char *ptr, size_t size, SCM port);
  304. SCM_API void scm_lfwrite_unlocked (const char *ptr, size_t size, SCM port);
  305. SCM_INTERNAL void scm_lfwrite_substr (SCM str, size_t start, size_t end,
  306. SCM port);
  307. /* Querying and setting positions, and character availability. */
  308. SCM_API SCM scm_char_ready_p (SCM port);
  309. SCM_API SCM scm_seek (SCM object, SCM offset, SCM whence);
  310. SCM_API SCM scm_truncate_file (SCM object, SCM length);
  311. SCM_API SCM scm_port_line (SCM port);
  312. SCM_API SCM scm_set_port_line_x (SCM port, SCM line);
  313. SCM_API SCM scm_port_column (SCM port);
  314. SCM_API SCM scm_set_port_column_x (SCM port, SCM line);
  315. SCM_API SCM scm_port_filename (SCM port);
  316. SCM_API SCM scm_set_port_filename_x (SCM port, SCM filename);
  317. /* Implementation helpers for port printing functions. */
  318. SCM_API int scm_port_print (SCM exp, SCM port, scm_print_state *);
  319. SCM_API void scm_print_port_mode (SCM exp, SCM port);
  320. /* Iterating over all ports. */
  321. SCM_API SCM scm_port_for_each (SCM proc);
  322. SCM_API void scm_c_port_for_each (void (*proc)(void *data, SCM p), void *data);
  323. SCM_API SCM scm_flush_all_ports (void);
  324. /* Void ports. */
  325. SCM_API SCM scm_void_port (char * mode_str);
  326. SCM_API SCM scm_sys_make_void_port (SCM mode);
  327. /* Initialization. */
  328. SCM_INTERNAL void scm_init_ports (void);
  329. /* Inline function implementations. */
  330. #if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
  331. SCM_INLINE_IMPLEMENTATION int
  332. scm_c_lock_port (SCM port, scm_i_pthread_mutex_t **lock)
  333. {
  334. *lock = SCM_PTAB_ENTRY (port)->lock;
  335. if (*lock)
  336. return scm_i_pthread_mutex_lock (*lock);
  337. else
  338. return 0;
  339. }
  340. SCM_INLINE_IMPLEMENTATION int
  341. scm_c_try_lock_port (SCM port, scm_i_pthread_mutex_t **lock)
  342. {
  343. *lock = SCM_PTAB_ENTRY (port)->lock;
  344. if (*lock)
  345. {
  346. int ret = scm_i_pthread_mutex_trylock (*lock);
  347. if (ret != 0)
  348. *lock = NULL;
  349. return ret;
  350. }
  351. else
  352. return 0;
  353. }
  354. SCM_INLINE_IMPLEMENTATION int
  355. scm_get_byte_or_eof_unlocked (SCM port)
  356. {
  357. int c;
  358. scm_t_port *pt = SCM_PTAB_ENTRY (port);
  359. if (pt->rw_active == SCM_PORT_WRITE)
  360. /* may be marginally faster than calling scm_flush. */
  361. SCM_PORT_DESCRIPTOR (port)->flush (port);
  362. if (pt->rw_random)
  363. pt->rw_active = SCM_PORT_READ;
  364. if (pt->read_pos >= pt->read_end)
  365. {
  366. if (SCM_UNLIKELY (scm_fill_input_unlocked (port) == EOF))
  367. return EOF;
  368. }
  369. c = *(pt->read_pos++);
  370. return c;
  371. }
  372. /* Like `scm_get_byte_or_eof' but does not change PORT's `read_pos'. */
  373. SCM_INLINE_IMPLEMENTATION int
  374. scm_peek_byte_or_eof_unlocked (SCM port)
  375. {
  376. int c;
  377. scm_t_port *pt = SCM_PTAB_ENTRY (port);
  378. if (pt->rw_active == SCM_PORT_WRITE)
  379. /* may be marginally faster than calling scm_flush. */
  380. SCM_PORT_DESCRIPTOR (port)->flush (port);
  381. if (pt->rw_random)
  382. pt->rw_active = SCM_PORT_READ;
  383. if (pt->read_pos >= pt->read_end)
  384. {
  385. if (SCM_UNLIKELY (scm_fill_input_unlocked (port) == EOF))
  386. return EOF;
  387. }
  388. c = *pt->read_pos;
  389. return c;
  390. }
  391. SCM_INLINE_IMPLEMENTATION void
  392. scm_putc_unlocked (char c, SCM port)
  393. {
  394. SCM_ASSERT_TYPE (SCM_OPOUTPORTP (port), port, 0, NULL, "output port");
  395. scm_lfwrite_unlocked (&c, 1, port);
  396. }
  397. SCM_INLINE_IMPLEMENTATION void
  398. scm_puts_unlocked (const char *s, SCM port)
  399. {
  400. SCM_ASSERT_TYPE (SCM_OPOUTPORTP (port), port, 0, NULL, "output port");
  401. scm_lfwrite_unlocked (s, strlen (s), port);
  402. }
  403. #endif /* SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES */
  404. #endif /* SCM_PORTS_H */
  405. /*
  406. Local Variables:
  407. c-file-style: "gnu"
  408. End:
  409. */