You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

printf.h 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef PRINTF_H_
  17. #define PRINTF_H_
  18. #include "config.h"
  19. #include "fstring.h"
  20. /*
  21. * supported formats:
  22. * %[0][width][x][X]O off_t
  23. * %[0][width]T time_t
  24. * %[0][width][u][x|X|h|H]z ssize_t/size_t
  25. * %[0][width][u][x|X|h|H]d gint/guint
  26. * %[0][width][u][x|X|h|H]l long
  27. * %[0][width][u][x|X|h|H]D gint32/guint32
  28. * %[0][width][u][x|X|h|H]L gint64/guint64
  29. * %[0][width][.width]f double
  30. * %[0][width][.width]F long double
  31. * %[0][width][.width]g double
  32. * %[0][width][.width]G long double
  33. * %P pid_t
  34. * %r rlim_t
  35. * %p void *
  36. * %V rspamd_fstring_t *
  37. * %T rspamd_ftok_t
  38. * %v GString *
  39. * %s null-terminated string
  40. * %xs hex encoded string
  41. * %bs base32 encoded string
  42. * %Bs base64 encoded string
  43. * %*s length and string
  44. * %Z '\0'
  45. * %N '\n'
  46. * %c gchar
  47. * %t time_t
  48. * %e GError *
  49. * %% %
  50. *
  51. */
  52. /**
  53. * Callback used for common printf operations
  54. * @param buf buffer to append
  55. * @param buflen length of the buffer
  56. * @param ud opaque pointer
  57. * @return number of characters written
  58. */
  59. typedef glong (*rspamd_printf_append_func)(const gchar *buf, glong buflen,
  60. gpointer ud);
  61. glong rspamd_fprintf (FILE *f, const gchar *fmt, ...);
  62. glong rspamd_printf (const gchar *fmt, ...);
  63. glong rspamd_log_fprintf (FILE *f, const gchar *fmt, ...);
  64. glong rspamd_snprintf (gchar *buf, glong max, const gchar *fmt, ...);
  65. gchar * rspamd_vsnprintf (gchar *buf, glong max, const gchar *fmt,
  66. va_list args);
  67. glong rspamd_printf_gstring (GString *s, const gchar *fmt, ...);
  68. glong rspamd_vprintf_gstring (GString *s, const gchar *fmt, va_list args);
  69. glong rspamd_printf_fstring (rspamd_fstring_t **s, const gchar *fmt, ...);
  70. glong rspamd_vprintf_fstring (rspamd_fstring_t **s, const gchar *fmt, va_list args);
  71. glong rspamd_vprintf_common (rspamd_printf_append_func func,
  72. gpointer apd,
  73. const gchar *fmt,
  74. va_list args);
  75. #endif /* PRINTF_H_ */