#ifndef MUPDF_FITZ_STRING_H1#define MUPDF_FITZ_STRING_H23#include "mupdf/fitz/system.h"45/*6Safe string functions7*/89/*10fz_strsep: Given a pointer to a C string (or a pointer to NULL) break11it at the first occurence of a delimiter char (from a given set).1213stringp: Pointer to a C string pointer (or NULL). Updated on exit to14point to the first char of the string after the delimiter that was15found. The string pointed to by stringp will be corrupted by this16call (as the found delimiter will be overwritten by 0).1718delim: A C string of acceptable delimiter characters.1920Returns a pointer to a C string containing the chars of stringp up21to the first delimiter char (or the end of the string), or NULL.22*/23char *fz_strsep(char **stringp, const char *delim);2425/*26fz_strlcpy: Copy at most n-1 chars of a string into a destination27buffer with null termination, returning the real length of the28initial string (excluding terminator).2930dst: Destination buffer, at least n bytes long.3132src: C string (non-NULL).3334n: Size of dst buffer in bytes.3536Returns the length (excluding terminator) of src.37*/38int fz_strlcpy(char *dst, const char *src, int n);3940/*41fz_strlcat: Concatenate 2 strings, with a maximum length.4243dst: pointer to first string in a buffer of n bytes.4445src: pointer to string to concatenate.4647n: Size (in bytes) of buffer that dst is in.4849Returns the real length that a concatenated dst + src would have been50(not including terminator).51*/52int fz_strlcat(char *dst, const char *src, int n);5354/*55fz_dirname: extract the directory component from a path.56*/57void fz_dirname(char *dir, const char *path, int dirsize);5859/*60fz_cleanname: rewrite path to the shortest string that names the same path.6162Eliminates multiple and trailing slashes, interprets "." and "..".63Overwrites the string in place.64*/65char *fz_cleanname(char *name);6667/*68fz_chartorune: UTF8 decode a single rune from a sequence of chars.6970rune: Pointer to an int to assign the decoded 'rune' to.7172str: Pointer to a UTF8 encoded string.7374Returns the number of bytes consumed. Does not throw exceptions.75*/76int fz_chartorune(int *rune, const char *str);7778/*79fz_runetochar: UTF8 encode a rune to a sequence of chars.8081str: Pointer to a place to put the UTF8 encoded character.8283rune: Pointer to a 'rune'.8485Returns the number of bytes the rune took to output. Does not throw86exceptions.87*/88int fz_runetochar(char *str, int rune);8990/*91fz_runelen: Count how many chars are required to represent a rune.9293rune: The rune to encode.9495Returns the number of bytes required to represent this run in UTF8.96*/97int fz_runelen(int rune);9899/*100fz_strtod: Locale-independent implementation of strtod().101*/102double fz_strtod(const char *s, char **es);103104/*105fz_ftoa: Compute decimal integer m, exp such that:106f = m * 10^exp107m is as short as possible without losing exactness108Assumes special cases (NaN, +Inf, -Inf) have been handled.109*/110void fz_ftoa(float f, char *s, int *exp, int *neg, int *ns);111112#endif113114115