]>
git.zerfleddert.de Git - proxmark3-svn/blob - armsrc/string.c
1 //-----------------------------------------------------------------------------
2 // Jonathan Westhues, Sept 2005
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // Common string.h functions
9 //-----------------------------------------------------------------------------
12 RAMFUNC
void *memcpy(void *dest
, const void *src
, int len
)
15 const uint8_t *s
= src
;
24 void *memset(void *dest
, int c
, int len
)
34 RAMFUNC
int memcmp(const void *av
, const void *bv
, int len
)
36 const uint8_t *a
= av
;
37 const uint8_t *b
= bv
;
49 void memxor(uint8_t * dest
, uint8_t * src
, size_t len
) {
50 for( ; len
> 0; len
--,dest
++,src
++)
54 int strlen(const char *str
)
64 char* strncat(char *dest
, const char *src
, unsigned int n
)
66 unsigned int dest_len
= strlen(dest
);
69 for (i
= 0 ; i
< n
&& src
[i
] != '\0' ; i
++)
70 dest
[dest_len
+ i
] = src
[i
];
71 dest
[dest_len
+ i
] = '\0';
76 char* strcat(char *dest
, const char *src
)
78 unsigned int dest_len
= strlen(dest
);
81 for (i
= 0 ; src
[i
] != '\0' ; i
++)
82 dest
[dest_len
+ i
] = src
[i
];
83 dest
[dest_len
+ i
] = '\0';
87 ////////////////////////////////////////// code to do 'itoa'
89 /* reverse: reverse string s in place */
90 void strreverse(char s
[])
94 for (i
= 0, j
= strlen(s
)-1; i
<j
; i
++, j
--) {
101 /* itoa: convert n to characters in s */
102 void itoa(int n
, char s
[])
106 if ((sign
= n
) < 0) /* record sign */
107 n
= -n
; /* make n positive */
109 do { /* generate digits in reverse order */
110 s
[i
++] = n
% 10 + '0'; /* get next digit */
111 } while ((n
/= 10) > 0); /* delete it */
118 //////////////////////////////////////// END 'itoa' CODE