utils.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * utils.h
  3. * Miscellaneous utilities for string manipulation
  4. *
  5. * Copyright (c) 2013 Federico Mena Quintero
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef __UTILS_H
  22. #define __UTILS_H
  23. #ifdef HAVE_CONFIG_H
  24. #include <config.h>
  25. #endif
  26. #ifdef WIN32
  27. #include <windows.h>
  28. #endif
  29. #include <stdio.h>
  30. #include <plist/plist.h>
  31. #ifndef HAVE_STPCPY
  32. char *stpcpy(char *s1, const char *s2);
  33. #endif
  34. char *string_concat(const char *str, ...);
  35. char *string_build_path(const char *elem, ...);
  36. char *string_format_size(uint64_t size);
  37. char *string_toupper(char *str);
  38. char *generate_uuid(void);
  39. void buffer_read_from_filename(const char *filename, char **buffer, uint64_t *length);
  40. void buffer_write_to_filename(const char *filename, const char *buffer, uint64_t length);
  41. enum plist_format_t {
  42. PLIST_FORMAT_XML,
  43. PLIST_FORMAT_BINARY
  44. };
  45. int plist_read_from_filename(plist_t *plist, const char *filename);
  46. int plist_write_to_filename(plist_t plist, const char *filename, enum plist_format_t format);
  47. void plist_print_to_stream(plist_t plist, FILE* stream);
  48. #endif