123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /*
- * Copyright 2024 Vsevolod Stakhov
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #ifndef PRINTF_H_
- #define PRINTF_H_
-
- #include "config.h"
- #include "fstring.h"
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- /*
- * supported formats:
- * %[0][width][x][X]O off_t
- * %[0][width]T time_t
- * %[0][width][u][x|X|h|H|b|B]z ssize_t/size_t
- * %[0][width][u][x|X|h|H|b|B]d int/unsigned int
- * %[0][width][u][x|X|h|H|b|B]l long
- * %[0][width][u][x|X|h|H|b|B]D int32_t/uint32_t
- * %[0][width][u][x|X|h|H|b|B]L int64_t/uint64_t
- * %[0][width][.width]f double
- * %[0][width][.width]F long double
- * %[0][width][.width]g double
- * %[0][width][.width]G long double
- * %P pid_t
- * %r rlim_t
- * %p void *
- * %V rspamd_fstring_t *
- * %T rspamd_ftok_t
- * %v GString *
- * %s null-terminated string
- * %xs hex encoded string
- * %bs base32 encoded string
- * %Bs base64 encoded string
- * %*s length and string
- * %Z '\0'
- * %N '\n'
- * %c char
- * %t time_t
- * %e GError *
- * %% %
- *
- */
-
- /**
- * Callback used for common printf operations
- * @param buf buffer to append
- * @param buflen length of the buffer
- * @param ud opaque pointer
- * @return number of characters written
- */
- typedef glong (*rspamd_printf_append_func)(const char *buf, glong buflen,
- gpointer ud);
-
- glong rspamd_fprintf(FILE *f, const char *fmt, ...);
-
- glong rspamd_printf(const char *fmt, ...);
-
- glong rspamd_log_fprintf(FILE *f, const char *fmt, ...);
-
- glong rspamd_snprintf(char *buf, glong max, const char *fmt, ...);
-
- char *rspamd_vsnprintf(char *buf, glong max, const char *fmt,
- va_list args);
-
- glong rspamd_printf_gstring(GString *s, const char *fmt, ...);
-
- glong rspamd_vprintf_gstring(GString *s, const char *fmt, va_list args);
-
- glong rspamd_printf_fstring(rspamd_fstring_t **s, const char *fmt, ...);
-
- glong rspamd_vprintf_fstring(rspamd_fstring_t **s, const char *fmt, va_list args);
-
- glong rspamd_vprintf_common(rspamd_printf_append_func func,
- gpointer apd,
- const char *fmt,
- va_list args);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* PRINTF_H_ */
|