Various modules solving daily C developer tasks
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.

62 lines
1.6 KiB

  1. /******************************************************************************
  2. *
  3. * Copyright (c) 2017-2019 by Löwenware Ltd
  4. * Please, refer LICENSE file for legal information
  5. *
  6. ******************************************************************************/
  7. /**
  8. * @file string.h
  9. * @author Ilja Kartašov <ik@lowenware.com>
  10. * @brief String module declarations
  11. *
  12. * @see https://lowenware.com/
  13. */
  14. #ifndef CSTUFF_STRING_H_938B242C_B750_40E9_8B67_A69F2F37EB87
  15. #define CSTUFF_STRING_H_938B242C_B750_40E9_8B67_A69F2F37EB87
  16. #include <stdarg.h>
  17. #include "retcode.h"
  18. /** @brief Copies in string to newly allocated out buffer
  19. * @param out a pointer to an address where new pointer must be stored
  20. * @param in an input string
  21. * @return length of string or -1 if out of memory
  22. */
  23. int
  24. cstuff_strcpy(char **out, const char *in);
  25. int
  26. cstuff_strncpy(char **out, const char *in, int len);
  27. /** @brief Overwrites content of out buffer with in string using realloc
  28. * @param out a pointer to an address where new string must be stored
  29. * @param in an input string
  30. * @return length of string or -1 if out of memory
  31. */
  32. int
  33. cstuff_strset(char **out, const char *in);
  34. int
  35. cstuff_strnset(char **out, const char *in, int len);
  36. /** @brief Allocates memory and prints a formatted string into it
  37. * @param out a pointer to an address where new string must be stored
  38. * @param format a format for string (see manual for stdlib sprintf)
  39. * @return length of string or -1 if out of memory
  40. */
  41. int
  42. cstuff_sprintf(char **out, const char *format, ...);
  43. int
  44. cstuff_vsprintf(char **out, const char *format, va_list args);
  45. #endif /* !CSTUFF_STRING_H */