Angband
z-util.h
Go to the documentation of this file.
1 
19 #ifndef INCLUDED_Z_UTIL_H
20 #define INCLUDED_Z_UTIL_H
21 
22 #include "h-basic.h"
23 
24 
34 extern char *argv0;
35 
36 
40 extern size_t (*text_mbcs_hook)(wchar_t *dest, const char *src, int n);
41 extern void (*plog_aux)(const char *);
42 extern void (*quit_aux)(const char *);
43 
44 
54 #define PLURAL(n) ((n) == 1 ? "" : "s")
55 
59 #define VERB_AGREEMENT(count, singular, plural) (((count) == 1) ? (singular) : (plural))
60 
61 
65 size_t utf8_strlen(char *s);
66 
71 void utf8_clipto(char *s, size_t n);
72 
76 extern int my_stricmp(const char *s1, const char *s2);
77 
81 extern int my_strnicmp(const char *a, const char *b, int n);
82 
86 extern char *my_stristr(const char *string, const char *pattern);
87 
98 extern size_t my_strcpy(char *buf, const char *src, size_t bufsize);
99 
111 extern size_t my_strcat(char *buf, const char *src, size_t bufsize);
112 
116 void my_strcap(char *buf);
117 
121 extern bool streq(const char *s, const char *t);
122 extern bool prefix(const char *s, const char *t);
123 extern bool prefix_i(const char *s, const char *t);
124 extern bool suffix(const char *s, const char *t);
125 
126 #define streq(s, t) (!strcmp(s, t))
127 
131 extern void strskip(char *s, const char c, const char e);
132 extern void strescape(char *s, const char c);
133 
137 bool contains_only_spaces(const char* s);
138 
142 bool is_a_vowel(int ch);
143 
144 
148 size_t text_mbstowcs(wchar_t *dest, const char *src, int n);
149 
153 extern void plog(const char *str);
154 
158 extern void quit(const char *str);
159 
160 
164 extern void sort(void *array, size_t nmemb, size_t smemb,
165  int (*comp)(const void *a, const void *b));
166 
170 u32b djb2_hash(const char *str);
171 
175 int mean(int *nums, int size);
176 int variance(int *nums, int size);
177 
178 #endif /* INCLUDED_Z_UTIL_H */
int mean(int *nums, int size)
Mathematical functions.
Definition: z-util.c:437
int n
Definition: z-type.h:45
#define streq(s, t)
Definition: z-util.h:126
typedef void(PNGAPI *png_error_ptr) PNGARG((png_structp
uint32_t u32b
Definition: h-basic.h:172
bool prefix_i(const char *s, const char *t)
Determine if string "t" is a prefix of string "s" - case insensitive.
Definition: z-util.c:274
png_voidp s1
Definition: libpng12/png.h:2142
char * my_stristr(const char *string, const char *pattern)
Case-insensitive strstr.
Definition: z-util.c:133
bool prefix(const char *s, const char *t)
Determine if string "t" is a prefix of string "s".
Definition: z-util.c:257
size_t text_mbstowcs(wchar_t *dest, const char *src, int n)
Allow override of the multi-byte to wide char conversion.
Definition: z-util.c:381
void sort(void *array, size_t nmemb, size_t smemb, int(*comp)(const void *a, const void *b))
Sorting functions.
int variance(int *nums, int size)
Variance of the first 'size' entries of the array 'nums'.
Definition: z-util.c:449
size_t my_strcpy(char *buf, const char *src, size_t bufsize)
Copy up to 'bufsize'-1 characters from 'src' to 'buf' and NULL-terminate the result.
Definition: z-util.c:172
The lowest level header.
void(* quit_aux)(const char *)
Redefinable "quit" action.
Definition: z-util.c:412
png_bytep buf
Definition: libpng12/png.h:2815
void strskip(char *s, const char c, const char e)
Skip occurrences of a characters.
Definition: z-util.c:296
void(* plog_aux)(const char *)
Redefinable "plog" action.
Definition: z-util.c:392
png_voidp png_voidp s2
Definition: libpng12/png.h:2142
char * argv0
Available variables
Definition: z-util.c:26
size_t utf8_strlen(char *s)
Count the number of characters in a UTF-8 encoded string.
Definition: z-util.c:38
void plog(const char *str)
Print an error message.
Definition: z-util.c:398
void utf8_clipto(char *s, size_t n)
Clip a null-terminated UTF-8 string 's' to 'n' unicode characters.
Definition: z-util.c:52
int my_stricmp(const char *s1, const char *s2)
Case insensitive comparison between two strings.
Definition: z-util.c:78
int my_strnicmp(const char *a, const char *b, int n)
Case insensitive comparison between two strings, up to n characters long.
Definition: z-util.c:110
size_t(* text_mbcs_hook)(wchar_t *dest, const char *src, int n)
Aux functions.
Definition: z-util.c:31
void my_strcap(char *buf)
Capitalise string 'buf'.
Definition: z-util.c:221
bool suffix(const char *s, const char *t)
Determine if string "t" is a suffix of string "s".
Definition: z-util.c:241
u32b djb2_hash(const char *str)
Create a hash for a string.
Definition: z-util.c:470
png_uint_32 size
Definition: libpng12/png.h:1546
bool is_a_vowel(int ch)
Check if a char is a vowel.
Definition: z-util.c:361
bool contains_only_spaces(const char *s)
Determines if a string is "empty".
Definition: z-util.c:348
size_t my_strcat(char *buf, const char *src, size_t bufsize)
Try to append a string to an existing NULL-terminated string, never writing more characters into the ...
Definition: z-util.c:204
void strescape(char *s, const char c)
Rewrite string s in-place removing escape character c note that pairs of c will leave one instance of...
Definition: z-util.c:328
void quit(const char *str)
Exit, with optional message.
Definition: z-util.c:419