libtsfuncs is a library for mpeg PSI parsing and generation. https://georgi.unixsol.org/programs/libtsfuncs/

log.c 665B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Logger function
  3. * Copyright (C) 2010-2011 Unix Solutions Ltd.
  4. *
  5. * Released under MIT license.
  6. * See LICENSE-MIT.txt for license terms.
  7. */
  8. #include <stdio.h>
  9. #include <stdarg.h>
  10. #include "log.h"
  11. void ts_LOG_default(const char *msg) {
  12. fprintf(stdout, "%s", msg);
  13. }
  14. static void (*ts_LOG_callback)(const char *msg) = ts_LOG_default;
  15. void ts_LOGf(const char *fmt, ...) {
  16. char msg[1024];
  17. va_list args;
  18. va_start(args, fmt);
  19. vsnprintf(msg, sizeof(msg)-1, fmt, args);
  20. va_end(args);
  21. msg[sizeof(msg)-2] = '\n';
  22. msg[sizeof(msg)-1] = '\0';
  23. ts_LOG_callback(msg);
  24. }
  25. void ts_set_log_func(void (*LOG_func)(const char *msg)) {
  26. ts_LOG_callback = LOG_func;
  27. }