annotate libmlk-core/mlk/core/util.h @ 580:459ff09c09b3

core: animation can be looped
author David Demelier <markand@malikania.fr>
date Sat, 11 Mar 2023 21:20:33 +0100
parents 90302d95cd33
children 76ce31b0151f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 /*
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
2 * util.h -- libmlk-core utilities
39
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 *
445
773a082f0b91 misc: update copyright years
David Demelier <markand@malikania.fr>
parents: 431
diff changeset
4 * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
39
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 *
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 * Permission to use, copy, modify, and/or distribute this software for any
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 * copyright notice and this permission notice appear in all copies.
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 *
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 */
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
366
19782ea1cf4a misc: start rebranding
David Demelier <markand@malikania.fr>
parents: 320
diff changeset
19 #ifndef MLK_CORE_UTIL_H
19782ea1cf4a misc: start rebranding
David Demelier <markand@malikania.fr>
parents: 320
diff changeset
20 #define MLK_CORE_UTIL_H
39
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
21
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
22 /**
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
23 * \file mlk/core/util.h
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
24 * \brief libmlk-core utilities
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
25 */
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
26
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
27 /**
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
28 * Compute the length of an fixed size array.
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
29 *
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
30 * \param x the fixed size array
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
31 * \return the length
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
32 */
474
ca30ff96bbe0 core: util -> mlk_util
David Demelier <markand@malikania.fr>
parents: 462
diff changeset
33 #define MLK_UTIL_SIZE(x) (sizeof ((x)) / sizeof ((x)[0]))
47
f053a9f38c0e core: implement basic scrolling, closes #2459
David Demelier <markand@malikania.fr>
parents: 39
diff changeset
34
517
6e8f6640e05b misc: use extern C manually
David Demelier <markand@malikania.fr>
parents: 474
diff changeset
35 #if defined(__cplusplus)
6e8f6640e05b misc: use extern C manually
David Demelier <markand@malikania.fr>
parents: 474
diff changeset
36 extern "C" {
6e8f6640e05b misc: use extern C manually
David Demelier <markand@malikania.fr>
parents: 474
diff changeset
37 #endif
292
08ab73b32832 misc: add extern "C" {} blocks for C++ friends
David Demelier <markand@malikania.fr>
parents: 261
diff changeset
38
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
39 /**
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
40 * Suspend the calling thread for the specific duration.
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
41 *
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
42 * \param duration time to sleep in milliseconds
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
43 */
39
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 void
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
45 mlk_util_delay(unsigned int duration);
39
9d1421c09dfb core: add more utilities to improve code simplicity
David Demelier <markand@malikania.fr>
parents:
diff changeset
46
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
47 /**
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
48 * Convenient function to create an return a string to a filesystem path using
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
49 * a printf format string.
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
50 *
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
51 * \pre fmt != NULL
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
52 * \param fmt the format string
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
53 * \note The returned string is static thread-local and will be modified on
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
54 * subsequent calls.
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
55 */
236
4896bb07a8db core: add pprintf function
David Demelier <markand@malikania.fr>
parents: 234
diff changeset
56 const char *
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
57 mlk_util_pathf(const char *fmt, ...);
236
4896bb07a8db core: add pprintf function
David Demelier <markand@malikania.fr>
parents: 234
diff changeset
58
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
59 /**
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
60 * Compute a random number between [min-max).
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
61 *
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
62 * \param min the minimum range (included)
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
63 * \param max the maximum range (excluded)
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
64 * \return a random number
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
65 */
185
7103d6574062 core: add nrand function
David Demelier <markand@malikania.fr>
parents: 182
diff changeset
66 unsigned int
567
90302d95cd33 core: doxygenize util
David Demelier <markand@malikania.fr>
parents: 517
diff changeset
67 mlk_util_nrand(unsigned int min, unsigned int max);
185
7103d6574062 core: add nrand function
David Demelier <markand@malikania.fr>
parents: 182
diff changeset
68
517
6e8f6640e05b misc: use extern C manually
David Demelier <markand@malikania.fr>
parents: 474
diff changeset
69 #if defined(__cplusplus)
6e8f6640e05b misc: use extern C manually
David Demelier <markand@malikania.fr>
parents: 474
diff changeset
70 }
6e8f6640e05b misc: use extern C manually
David Demelier <markand@malikania.fr>
parents: 474
diff changeset
71 #endif
292
08ab73b32832 misc: add extern "C" {} blocks for C++ friends
David Demelier <markand@malikania.fr>
parents: 261
diff changeset
72
366
19782ea1cf4a misc: start rebranding
David Demelier <markand@malikania.fr>
parents: 320
diff changeset
73 #endif /* !MLK_CORE_UTIL_H */