aboutsummaryrefslogtreecommitdiffstats
path: root/libcmap.h
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-12-21 15:16:20 +0100
committerMattias Andrée <m@maandree.se>2025-12-21 15:16:39 +0100
commit83f32ab6a37ce137cb0ac7c9ffc3f8e66a6fe104 (patch)
treef9895565a5811d1fae9b8487b430335eea7328da /libcmap.h
parentAdd documentation (diff)
downloadlibcmap-83f32ab6a37ce137cb0ac7c9ffc3f8e66a6fe104.tar.gz
libcmap-83f32ab6a37ce137cb0ac7c9ffc3f8e66a6fe104.tar.bz2
libcmap-83f32ab6a37ce137cb0ac7c9ffc3f8e66a6fe104.tar.xz
Add libcmap_fprint_range, libcmap_print_range, libcmap_dprint_range
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--libcmap.h50
1 files changed, 48 insertions, 2 deletions
diff --git a/libcmap.h b/libcmap.h
index 324f790..a04b38e 100644
--- a/libcmap.h
+++ b/libcmap.h
@@ -4,6 +4,8 @@
#include <stddef.h>
#include <stdint.h>
+#include <stdio.h>
+
#if defined(__GNUC__)
# define LIBCMAP_PURE_ __attribute__((__pure__))
@@ -224,6 +226,7 @@ const struct libcmap_block *libcmap_find_block(uint32_t codepoint, size_t *offse
*/
const struct libcmap_script *libcmap_find_script(uint32_t codepoint, size_t *offset_out, size_t *subrange_out);
+
/**
* Print a string representing a Unicode codepoint range
*
@@ -233,7 +236,9 @@ const struct libcmap_script *libcmap_find_script(uint32_t codepoint, size_t *off
* @param endash Desired delimiter between the first and the last
* codepoint, or `NULL` for the default (not ASCII)
* @return The number of bytes in the string, excluding the
- * terminating NUL byte
+ * terminating NUL byte, -1 on failure
+ *
+ * @throws Any error specified for sprintf(3)
*
* A NUL byte will added to the end of the string, but this byte
* will not be counted in the return value
@@ -250,7 +255,9 @@ int libcmap_sprint_range(char *buf, const struct libcmap_range *range, const cha
* @param endash Desired delimiter between the first and the last
* codepoint, or `NULL` for the default (not ASCII)
* @return The number of bytes in the string, excluding the
- * terminating NUL byte
+ * terminating NUL byte, -1 on failure
+ *
+ * @throws Any error specified for snprintf(3)
*
* A NUL byte will added to the end of the string, but this byte
* will not be counted in the return value
@@ -268,6 +275,45 @@ int libcmap_sprint_range(char *buf, const struct libcmap_range *range, const cha
*/
int libcmap_snprint_range(char *buf, size_t bufsize, const struct libcmap_range *range, const char *endash);
+/**
+ * Print a string representing a Unicode codepoint range
+ *
+ * @param fp The file to write to
+ * @param range The range to print a representation of
+ * @param endash Desired delimiter between the first and the last
+ * codepoint, or `NULL` for the default (not ASCII)
+ * @return The number of bytes in the string, -1 on failure
+ *
+ * @throws Any error specified for fprintf(3)
+ */
+int libcmap_fprint_range(FILE *fp, const struct libcmap_range *range, const char *endash);
+
+/**
+ * Print, to standard output, a string representing a
+ * Unicode codepoint range
+ *
+ * @param range The range to print a representation of
+ * @param endash Desired delimiter between the first and the last
+ * codepoint, or `NULL` for the default (not ASCII)
+ * @return The number of bytes in the string, -1 on failure
+ *
+ * @throws Any error specified for fprintf(3)
+ */
+int libcmap_print_range(const struct libcmap_range *range, const char *endash);
+
+/**
+ * Print a string representing a Unicode codepoint range
+ *
+ * @param fd The file descriptor
+ * @param range The range to print a representation of
+ * @param endash Desired delimiter between the first and the last
+ * codepoint, or `NULL` for the default (not ASCII)
+ * @return The number of bytes in the string, -1 on failure
+ *
+ * @throws Any error specified for dprintf(3)
+ */
+int libcmap_dprint_range(int fd, const struct libcmap_range *range, const char *endash);
+
#undef LIBCMAP_PURE_
#undef LIBCMAP_CONST_