string-extras.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* string-extras.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /**
  17. * \file string-extras.h
  18. * \author Daniel Otte
  19. * \date 2006-05-16
  20. * \license GPLv3 or later
  21. *
  22. */
  23. #include <stdint.h>
  24. /** \fn stridentcnt_P(char* a, PGM_P b)
  25. * \brief counts the number of identic chars
  26. *
  27. * This function compares the supplied strings and returns the index of the
  28. * first char where the strings differ.
  29. * \param a pointer to string in RAM
  30. * \param b pointer to string in Flash
  31. * \return index of the first char where \c a and \c b differ
  32. */
  33. uint32_t stridentcnt(const char* a, const char* b);
  34. /** \fn firstword_length(char* s)
  35. * \brief compute the length of the first word in supplied string
  36. *
  37. * This function searches for the first whitespace in the string and returns the
  38. * number of chars before the first whitespace.
  39. * \param s string
  40. * \return number of chars in first word
  41. */
  42. uint16_t firstword_length(const char* s);
  43. /** \fn strstrip(char* str)
  44. * \brief removes whitespace at the beginning and the end of a string
  45. *
  46. * This function removes whitespaces at the end of a string.
  47. * \param str sting
  48. * \return pointer to the first non-whitespace char in string
  49. */
  50. char* strstrip(char* str);
  51. void str_reverse(char* buffer);
  52. char* ultoa(unsigned long a, char* buffer, uint8_t radix);
  53. char* ulltoa(unsigned long long a, char* buffer, uint8_t radix);
  54. char* utoa(unsigned a, char* buffer, uint8_t radix);
  55. char* ustoa(unsigned short a, char* buffer, uint8_t radix);
  56. // void strlwr(char* s);