cxutils.h
/*
* This file is part of the ESO C Extension Library
* Copyright (C) 2001-2026 European Southern Observatory
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CX_UTILS_H
#define CX_UTILS_H
#include <stdarg.h>
#include "cxmacros.h"
#include "cxtypes.h"
CX_BEGIN_DECLS
/*
* Static information retrieval
*/
const cxchar *cx_program_get_name(void);
void cx_program_set_name(const cxchar *);
cxlong cx_line_max(void);
/*
* Bit tests
*/
cxint cx_bits_find(cxuint32, cxint);
cxint cx_bits_rfind(cxuint32, cxint);
/*
* Miscellaneous utility functions
*/
cxint cx_snprintf(cxchar *, cxsize, const cxchar *, ...) CX_GNUC_PRINTF(3, 4);
cxint cx_vsnprintf(cxchar *, cxsize, const cxchar *, va_list)
CX_GNUC_PRINTF(3, 0);
cxint cx_asprintf(cxchar **, const cxchar *, ...) CX_GNUC_PRINTF(2, 3);
cxint cx_vasprintf(cxchar **, const cxchar *, va_list) CX_GNUC_PRINTF(2, 0);
cxchar *cx_line_alloc(void);
CX_END_DECLS
#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:381
cx_line_max
cxlong cx_line_max(void)
Get the maximum length of a line supported by the system.
Definition cxutils.c:464
cx_bits_find
cxint cx_bits_find(cxuint32, cxint)
Get the position of the first bit set, searching from left to right.
Definition cxutils.c:154
cx_vsnprintf
cxint cx_vsnprintf(cxchar *string, cxsize n, const cxchar *format, va_list args)
Safe version of vsprintf().
Definition cxutils.c:287
cx_line_alloc
cxchar * cx_line_alloc(void)
Allocate a line buffer with the maximum size supported by the system.
Definition cxutils.c:489
cx_program_get_name
const cxchar * cx_program_get_name(void)
Get the name of the application.
Definition cxutils.c:98
cx_program_set_name
void cx_program_set_name(const cxchar *)
Set the name of the application.
Definition cxutils.c:124
cx_asprintf
cxint cx_asprintf(cxchar **string, const cxchar *format,...)
Write formatted output to a newly allocated string.
Definition cxutils.c:338
cx_bits_rfind
cxint cx_bits_rfind(cxuint32, cxint)
Get the position of the first bit set, searching from right to left.
Definition cxutils.c:193
cx_snprintf
cxint cx_snprintf(cxchar *string, cxsize n, const cxchar *format,...)
Safe version of sprintf().
Definition cxutils.c:243