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