C Standard Library Extensions 1.3.1
cxutils.h
1/*
2 * This file is part of the ESO C Extension Library
3 * Copyright (C) 2001-2026 European Southern Observatory
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef CX_UTILS_H
20#define CX_UTILS_H
21
22#include <stdarg.h>
23
24#include "cxmacros.h"
25#include "cxtypes.h"
26
27
28CX_BEGIN_DECLS
29
30/*
31 * Static information retrieval
32 */
33
34const cxchar *cx_program_get_name(void);
35void cx_program_set_name(const cxchar *);
36
37cxlong cx_line_max(void);
38
39
40/*
41 * Bit tests
42 */
43
44cxint cx_bits_find(cxuint32, cxint);
45cxint cx_bits_rfind(cxuint32, cxint);
46
47
48/*
49 * Miscellaneous utility functions
50 */
51
52cxint cx_snprintf(cxchar *, cxsize, const cxchar *, ...) CX_GNUC_PRINTF(3, 4);
53cxint cx_vsnprintf(cxchar *, cxsize, const cxchar *, va_list)
54 CX_GNUC_PRINTF(3, 0);
55cxint cx_asprintf(cxchar **, const cxchar *, ...) CX_GNUC_PRINTF(2, 3);
56cxint cx_vasprintf(cxchar **, const cxchar *, va_list) CX_GNUC_PRINTF(2, 0);
57
58cxchar *cx_line_alloc(void);
59
60CX_END_DECLS
61
62#endif /* CX_UTILS_H */
cxlong cx_line_max(void)
Get the maximum length of a line supported by the system.
Definition cxutils.c:464
cxint cx_bits_find(cxuint32, cxint)
Get the position of the first bit set, searching from left to right.
Definition cxutils.c:154
cxint cxint cxint cxint cxchar * cx_line_alloc(void)
Allocate a line buffer with the maximum size supported by the system.
Definition cxutils.c:489
const cxchar * cx_program_get_name(void)
Get the name of the application.
Definition cxutils.c:98
void cx_program_set_name(const cxchar *)
Set the name of the application.
Definition cxutils.c:124
cxint cx_bits_rfind(cxuint32, cxint)
Get the position of the first bit set, searching from right to left.
Definition cxutils.c:193
cxint cx_snprintf(cxchar *string, cxsize n, const cxchar *format,...)
Safe version of sprintf().
Definition cxutils.c:243