C Standard Library Extensions  1.2.2
cxutils.h
1 /*
2  * This file is part of the ESO C Extension Library
3  * Copyright (C) 2001-2017 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef CX_UTILS_H
21 #define CX_UTILS_H
22 
23 #include <stdarg.h>
24 #include <cxtypes.h>
25 
26 
27 CX_BEGIN_DECLS
28 
29 /*
30  * Static information retrieval
31  */
32 
33 const cxchar *cx_program_get_name(void);
34 void cx_program_set_name(const cxchar *);
35 
36 cxlong cx_line_max(void);
37 
38 
39 /*
40  * Bit tests
41  */
42 
43 cxint cx_bits_find(cxuint32, cxint);
44 cxint cx_bits_rfind(cxuint32, cxint);
45 
46 
47 /*
48  * Miscellaneous utility functions
49  */
50 
51 cxint cx_snprintf(cxchar *, cxsize,
52  const cxchar *, ...) CX_GNUC_PRINTF(3, 4);
53 cxint cx_vsnprintf(cxchar *, cxsize,
54  const cxchar *, va_list) CX_GNUC_PRINTF(3, 0);
55 cxint cx_asprintf(cxchar **, const cxchar *, ...) CX_GNUC_PRINTF(2, 3);
56 cxint cx_vasprintf(cxchar **, const cxchar *, va_list) CX_GNUC_PRINTF(2, 0);
57 
58 cxchar *cx_line_alloc(void);
59 
60 CX_END_DECLS
61 
62 #endif /* CX_UTILS_H */
cxint cx_vsnprintf(cxchar *string, cxsize n, const cxchar *format, va_list args)
Safe version of vsprintf().
Definition: cxutils.c:285
const cxchar * cx_program_get_name(void)
Get the name of the application.
Definition: cxutils.c:97
cxlong cx_line_max(void)
Get the maximum length of a line supported by the system.
Definition: cxutils.c:470
cxint cx_asprintf(cxchar **string, const cxchar *format,...)
Write formatted output to a newly allocated string.
Definition: cxutils.c:336
cxint cx_bits_rfind(cxuint32, cxint)
Get the position of the first bit set, searching from right to left.
Definition: cxutils.c:192
cxint cx_bits_find(cxuint32, cxint)
Get the position of the first bit set, searching from left to right.
Definition: cxutils.c:156
cxint cxint cxint cxint cxchar * cx_line_alloc(void)
Allocate a line buffer with the maximum size supported by the system.
Definition: cxutils.c:497
void cx_program_set_name(const cxchar *)
Set the name of the application.
Definition: cxutils.c:125
cxint cx_snprintf(cxchar *string, cxsize n, const cxchar *format,...)
Safe version of sprintf().
Definition: cxutils.c:240
cxint cx_vasprintf(cxchar **string, const cxchar *format, va_list args)
Write formatted output to a newly allocated string with a variable-length argument list...
Definition: cxutils.c:380