Open Source Tomb Raider Engine
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.

strings.h 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*!
  2. * \file include/utils/strings.h
  3. * \brief String handling utilities
  4. *
  5. * \author xythobuz
  6. * \author Mongoose
  7. */
  8. #ifndef _UTILS_STRINGS_H_
  9. #define _UTILS_STRINGS_H_
  10. /*!
  11. * \brief Check if a string ends with another string.
  12. * \param str string to check
  13. * \param suffix suffix for which to check
  14. * \returns true if str ends with suffix
  15. */
  16. bool stringEndsWith(const char *str, const char *suffix);
  17. /*!
  18. * \brief Generates a buffered string for the printf call
  19. * \param string format string like for printf
  20. * \param args arguments matching format string
  21. * \returns string in a buffer
  22. */
  23. char *bufferString(const char *string, va_list args) __attribute__((format(printf, 1, 0)));
  24. /*!
  25. * \brief Generates a buffered string for the printf call
  26. * \param string format string like for printf
  27. * \returns string in a buffer
  28. */
  29. char *bufferString(const char *string, ...) __attribute__((format(printf, 1, 2)));
  30. /*!
  31. * \brief Expansion of unix home enviroment char.
  32. * Also makes sure string ends in "end" char.
  33. * \param path path string
  34. * \param end end character. 0 appends no additional char
  35. * \returns allocated string of path with expansions
  36. */
  37. char *fullPath(const char *path, char end);
  38. /*!
  39. * \brief Checks if Command matches Symbol.
  40. * Returns the rest of the argument list back in command buffer, if any
  41. * \param symbol command string
  42. * \param command with arguments
  43. * \returns true if command matches symbol
  44. */
  45. bool rc_command(const char *symbol, char *command);
  46. /*!
  47. * \brief Interpret a string as a bool
  48. * \param buffer "true" or "false"
  49. * \param val is set to boolean interpretation of buffer
  50. * \returns -1 for null string, -2 if string is not "true" or "false"
  51. */
  52. int rc_get_bool(const char *buffer, bool *val);
  53. #endif