C Standard Library Extensions  1.2.3
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 */
cx_vasprintf
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
cx_line_alloc
cxchar * cx_line_alloc(void)
Allocate a line buffer with the maximum size supported by the system.
Definition: cxutils.c:497
cx_memory_is_system_malloc
cxbool cx_memory_is_system_malloc(void)
Check if the system's defaults are used for memory allocation.
Definition: cxmemory.c:526
cx_program_set_name
void cx_program_set_name(const cxchar *name)
Set the name of the application.
Definition: cxutils.c:125
cx_vsnprintf
cxint cx_vsnprintf(cxchar *string, cxsize n, const cxchar *format, va_list args)
Safe version of vsprintf().
Definition: cxutils.c:285
cx_asprintf
cxint cx_asprintf(cxchar **string, const cxchar *format,...)
Write formatted output to a newly allocated string.
Definition: cxutils.c:336
cx_malloc
cxptr cx_malloc(cxsize nbytes)
Allocate nbytes bytes.
Definition: cxmemory.c:280
cx_free
void cx_free(cxptr memory)
Memory block deallocation.
Definition: cxmemory.c:486
cx_program_get_name
const cxchar * cx_program_get_name(void)
Get the name of the application.
Definition: cxutils.c:97
cx_calloc
cxptr cx_calloc(cxsize natoms, cxsize nbytes)
Allocate memory for natoms elements of size size.
Definition: cxmemory.c:380
cx_bits_rfind
cxint cx_bits_rfind(cxuint32 mask, cxint start)
Get the position of the first bit set, searching from right to left.
Definition: cxutils.c:192
cx_line_max
cxlong cx_line_max(void)
Get the maximum length of a line supported by the system.
Definition: cxutils.c:470
cx_bits_find
cxint cx_bits_find(cxuint32 mask, cxint start)
Get the position of the first bit set, searching from left to right.
Definition: cxutils.c:156
cx_strdup
cxchar * cx_strdup(const cxchar *string)
Duplicate a string.
Definition: cxstrutils.c:497
cx_snprintf
cxint cx_snprintf(cxchar *string, cxsize n, const cxchar *format,...)
Safe version of sprintf().
Definition: cxutils.c:240