]> cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/string.c
a3d3c04956c8b91700334d533dce443ab0bb9d18
[proxmark3-svn] / armsrc / string.c
1 /* Implementations of the common string.h functions */
2 #include "string.h"
3 #include <stdint.h>
4
5 void *memcpy(void *dest, const void *src, int len)
6 {
7 uint8_t *d = dest;
8 const uint8_t *s = src;
9 while((len--) > 0) {
10 *d = *s;
11 d++;
12 s++;
13 }
14 return dest;
15 }
16
17 void *memset(void *dest, int c, int len)
18 {
19 uint8_t *d = dest;
20 while((len--) > 0) {
21 *d = c;
22 d++;
23 }
24 return dest;
25 }
26
27 int memcmp(const void *av, const void *bv, int len)
28 {
29 const uint8_t *a = av;
30 const uint8_t *b = bv;
31
32 while((len--) > 0) {
33 if(*a != *b) {
34 return *a - *b;
35 }
36 a++;
37 b++;
38 }
39 return 0;
40 }
41
42 int strlen(const char *str)
43 {
44 int l = 0;
45 while(*str) {
46 l++;
47 str++;
48 }
49 return l;
50 }
51
52 char* strncat(char *dest, const char *src, unsigned int n)
53 {
54 unsigned int dest_len = strlen(dest);
55 unsigned int i;
56
57 for (i = 0 ; i < n && src[i] != '\0' ; i++)
58 dest[dest_len + i] = src[i];
59 dest[dest_len + i] = '\0';
60
61 return dest;
62 }
Impressum, Datenschutz