#ifndef _XEMACS_MB_MULTIBYTE_H
#define _XEMACS_MB_MULTIBYTE_H
+/************************************************************************/
+/* Operations on individual bytes */
+/* of any format */
+/************************************************************************/
+
+/* Argument `c' should be (unsigned int) or (unsigned char). */
+/* Note that SP and DEL are not included. */
+
+#define BYTE_ASCII_P(c) ((c) < 0x80)
+#define BYTE_C0_P(c) ((c) < 0x20)
+/* Do some forced casting just to make *sure* things are gotten right. */
+#define BYTE_C1_P(c) ((unsigned int) ((unsigned int) (c) - 0x80) < 0x20)
+
+
+/************************************************************************/
+/* Dealing with characters */
+/************************************************************************/
+
+/* Is this character represented by more than one byte in a string? */
+
+#define CHAR_MULTIBYTE_P(c) ((c) >= 0x80)
+
+
/* ---------------------------------------------------------------------- */
/* (A) For working with charptr's (pointers to internally-formatted text) */
/* ---------------------------------------------------------------------- */
#define simple_set_charptr_emchar(ptr, x) ((ptr)[0] = (Bufbyte) (x), 1)
#define simple_charptr_copy_char(ptr, ptr2) ((ptr2)[0] = *(ptr), 1)
-Emchar non_ascii_charptr_emchar (CONST Bufbyte *ptr);
+Emchar non_ascii_charptr_emchar (const Bufbyte *ptr);
Bytecount non_ascii_set_charptr_emchar (Bufbyte *ptr, Emchar c);
-Bytecount non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2);
+Bytecount non_ascii_charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2);
-INLINE Emchar charptr_emchar (CONST Bufbyte *ptr);
-INLINE Emchar
-charptr_emchar (CONST Bufbyte *ptr)
+INLINE_HEADER Emchar charptr_emchar (const Bufbyte *ptr);
+INLINE_HEADER Emchar
+charptr_emchar (const Bufbyte *ptr)
{
return BYTE_ASCII_P (*ptr) ?
simple_charptr_emchar (ptr) :
non_ascii_charptr_emchar (ptr);
}
-INLINE Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x);
-INLINE Bytecount
+INLINE_HEADER Bytecount set_charptr_emchar (Bufbyte *ptr, Emchar x);
+INLINE_HEADER Bytecount
set_charptr_emchar (Bufbyte *ptr, Emchar x)
{
return !CHAR_MULTIBYTE_P (x) ?
non_ascii_set_charptr_emchar (ptr, x);
}
-INLINE Bytecount charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2);
-INLINE Bytecount
-charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2)
+INLINE_HEADER Bytecount
+charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2);
+INLINE_HEADER Bytecount
+charptr_copy_char (const Bufbyte *ptr, Bufbyte *ptr2)
{
return BYTE_ASCII_P (*ptr) ?
simple_charptr_copy_char (ptr, ptr2) :
non_ascii_charptr_copy_char (ptr, ptr2);
}
+
+/************************************************************************/
+/* Exported functions */
+/************************************************************************/
+
+Emchar Lstream_get_emchar_1 (Lstream *stream, int first_char);
+int Lstream_fput_emchar (Lstream *stream, Emchar ch);
+void Lstream_funget_emchar (Lstream *stream, Emchar ch);
+
+int copy_internal_to_external (const Bufbyte *internal, Bytecount len,
+ unsigned char *external);
+Bytecount copy_external_to_internal (const unsigned char *external,
+ int len, Bufbyte *internal);
+
#endif /* _XEMACS_MB_MULTIBYTE_H */