comparison libmlk-core/core/util.h @ 253:c4da052c0def

core: goodbye doxygen
author David Demelier <markand@malikania.fr>
date Thu, 03 Dec 2020 09:06:52 +0100
parents 71b3b7036de7
children bfde372bf152
comparison
equal deleted inserted replaced
252:95c2c4a72410 253:c4da052c0def
17 */ 17 */
18 18
19 #ifndef MOLKO_CORE_UTIL_H 19 #ifndef MOLKO_CORE_UTIL_H
20 #define MOLKO_CORE_UTIL_H 20 #define MOLKO_CORE_UTIL_H
21 21
22 /**
23 * \file util.h
24 * \brief Utilities.
25 * \ingroup basics
26 *
27 * This file contains several utilities.
28 *
29 * \note In contrast to other files, identifiers are not prefixed with `util_`
30 * for convenience.
31 */
32
33 #include <stdarg.h> 22 #include <stdarg.h>
34 #include <stddef.h> 23 #include <stddef.h>
35 24
36 /**
37 * Get the number of elements in a static array.
38 *
39 * \param x the array
40 * \return the number of elements
41 */
42 #define NELEM(x) sizeof ((x)) / sizeof ((x)[0]) 25 #define NELEM(x) sizeof ((x)) / sizeof ((x)[0])
43 26
44 /**
45 * Put the thread to sleep for a given amount of milliseconds.
46 *
47 * \param ms the number of milliseconds to wait
48 */
49 void 27 void
50 delay(unsigned int ms); 28 delay(unsigned int ms);
51 29
52 /**
53 * Construct a temporary path to a file that can fit in a PATH_MAX array.
54 *
55 * This function is useful when specifying paths into a function invocation such
56 * as `fopen(pprintf("%s.png", i), "r"))`.
57 *
58 * \pre fmt != NULL
59 * \param fmt the format string
60 * \warning This function is not reentrant, it returns a static storage path.
61 * \return A non null path to a file.
62 * \post Returned string is never NULL.
63 */
64 const char * 30 const char *
65 pprintf(const char *fmt, ...); 31 pprintf(const char *fmt, ...);
66 32
67 /**
68 * Generate a random number between lower and upper (included).
69 *
70 * \pre upper must be <= RAND_MAX
71 * \param lower the lower bound
72 * \param upper the upper bound
73 * \return The generated number.
74 */
75 unsigned int 33 unsigned int
76 nrand(unsigned int lower, unsigned int upper); 34 nrand(unsigned int lower, unsigned int upper);
77 35
78 #endif /* !MOLKO_CORE_UTIL_H */ 36 #endif /* !MOLKO_CORE_UTIL_H */