1 #ifndef MUPDF_FITZ_STRING_H
2 #define MUPDF_FITZ_STRING_H
4 #include "mupdf/fitz/system.h"
11 fz_strsep: Given a pointer to a C string (or a pointer to NULL) break
12 it at the first occurence of a delimiter char (from a given set).
14 stringp: Pointer to a C string pointer (or NULL). Updated on exit to
15 point to the first char of the string after the delimiter that was
16 found. The string pointed to by stringp will be corrupted by this
17 call (as the found delimiter will be overwritten by 0).
19 delim: A C string of acceptable delimiter characters.
21 Returns a pointer to a C string containing the chars of stringp up
22 to the first delimiter char (or the end of the string), or NULL.
24 char *fz_strsep(char **stringp, const char *delim);
27 fz_strlcpy: Copy at most n-1 chars of a string into a destination
28 buffer with null termination, returning the real length of the
29 initial string (excluding terminator).
31 dst: Destination buffer, at least n bytes long.
33 src: C string (non-NULL).
35 n: Size of dst buffer in bytes.
37 Returns the length (excluding terminator) of src.
39 int fz_strlcpy(char *dst, const char *src, int n);
42 fz_strlcat: Concatenate 2 strings, with a maximum length.
44 dst: pointer to first string in a buffer of n bytes.
46 src: pointer to string to concatenate.
48 n: Size (in bytes) of buffer that dst is in.
50 Returns the real length that a concatenated dst + src would have been
51 (not including terminator).
53 int fz_strlcat(char *dst, const char *src, int n);
56 fz_dirname: extract the directory component from a path.
58 void fz_dirname(char *dir, const char *path, int dirsize);
61 fz_cleanname: rewrite path to the shortest string that names the same path.
63 Eliminates multiple and trailing slashes, interprets "." and "..".
64 Overwrites the string in place.
66 char *fz_cleanname(char *name);
69 fz_chartorune: UTF8 decode a single rune from a sequence of chars.
71 rune: Pointer to an int to assign the decoded 'rune' to.
73 str: Pointer to a UTF8 encoded string.
75 Returns the number of bytes consumed. Does not throw exceptions.
77 int fz_chartorune(int *rune, const char *str);
80 fz_runetochar: UTF8 encode a rune to a sequence of chars.
82 str: Pointer to a place to put the UTF8 encoded character.
84 rune: Pointer to a 'rune'.
86 Returns the number of bytes the rune took to output. Does not throw
89 int fz_runetochar(char *str, int rune);
92 fz_runelen: Count how many chars are required to represent a rune.
94 rune: The rune to encode.
96 Returns the number of bytes required to represent this run in UTF8.
98 int fz_runelen(int rune);
101 fz_strtod: Locale-independent implementation of strtod().
103 double fz_strtod(const char *s, char **es);
106 fz_ftoa: Compute decimal integer m, exp such that:
108 m is as short as possible without losing exactness
109 Assumes special cases (NaN, +Inf, -Inf) have been handled.
111 void fz_ftoa(float f, char *s, int *exp, int *neg, int *ns);