mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-14 02:26:59 -07:00
Split str* and mem* into string.[ch]
This commit is contained in:
parent
4cd41f34ea
commit
9ab7a6c755
15 changed files with 88 additions and 74 deletions
|
@ -19,6 +19,7 @@ THUMBSRC = start.c \
|
|||
$(SRC_LF) \
|
||||
appmain.c printf.c \
|
||||
util.c \
|
||||
string.c \
|
||||
usb.c
|
||||
|
||||
# These are to be compiled in ARM mode
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "printf.h"
|
||||
#include "string.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "legicrf.h"
|
||||
|
||||
|
@ -16,13 +20,6 @@
|
|||
# include "LCD.h"
|
||||
#endif
|
||||
|
||||
#define va_list __builtin_va_list
|
||||
#define va_start __builtin_va_start
|
||||
#define va_arg __builtin_va_arg
|
||||
#define va_end __builtin_va_end
|
||||
int kvsprintf(char const *fmt, void *arg, int radix, va_list ap);
|
||||
|
||||
|
||||
#define abs(x) ( ((x)<0) ? -(x) : (x) )
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Set up the Serial Peripheral Interface as master
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "hitag2.h"
|
||||
#include "string.h"
|
||||
|
||||
struct hitag2_cipher_state {
|
||||
uint64_t state;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "iso14443crc.h"
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "iso14443crc.h"
|
||||
|
||||
static uint8_t *trace = (uint8_t *) BigBuf;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "proxmark3.h"
|
||||
#include "util.h"
|
||||
#include "apps.h"
|
||||
#include "string.h"
|
||||
|
||||
// FROM winsrc\prox.h //////////////////////////////////
|
||||
#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "proxmark3.h"
|
||||
#include "apps.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "legicrf.h"
|
||||
#include "legic_prng.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "util.h"
|
||||
#include "hitag2.h"
|
||||
#include "crc16.h"
|
||||
#include "string.h"
|
||||
|
||||
void AcquireRawAdcSamples125k(int at134khz)
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <stdarg.h>
|
||||
#include "printf.h"
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
|
||||
typedef uint32_t uintmax_t;
|
||||
typedef int32_t intmax_t;
|
||||
|
|
|
@ -7,6 +7,4 @@ int kvsprintf(const char *format, void *arg, int radix, va_list ap) __attribute_
|
|||
int vsprintf(char *str, const char *format, va_list ap) __attribute__ ((format (printf, 2, 0)));
|
||||
int sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
|
||||
|
||||
|
||||
#endif
|
62
armsrc/string.c
Normal file
62
armsrc/string.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* Implementations of the common string.h functions */
|
||||
#include "string.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void *memcpy(void *dest, const void *src, int len)
|
||||
{
|
||||
uint8_t *d = dest;
|
||||
const uint8_t *s = src;
|
||||
while((len--) > 0) {
|
||||
*d = *s;
|
||||
d++;
|
||||
s++;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *memset(void *dest, int c, int len)
|
||||
{
|
||||
uint8_t *d = dest;
|
||||
while((len--) > 0) {
|
||||
*d = c;
|
||||
d++;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
int memcmp(const void *av, const void *bv, int len)
|
||||
{
|
||||
const uint8_t *a = av;
|
||||
const uint8_t *b = bv;
|
||||
|
||||
while((len--) > 0) {
|
||||
if(*a != *b) {
|
||||
return *a - *b;
|
||||
}
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strlen(const char *str)
|
||||
{
|
||||
int l = 0;
|
||||
while(*str) {
|
||||
l++;
|
||||
str++;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
char* strncat(char *dest, const char *src, unsigned int n)
|
||||
{
|
||||
unsigned int dest_len = strlen(dest);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0 ; i < n && src[i] != '\0' ; i++)
|
||||
dest[dest_len + i] = src[i];
|
||||
dest[dest_len + i] = '\0';
|
||||
|
||||
return dest;
|
||||
}
|
10
armsrc/string.h
Normal file
10
armsrc/string.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef __STRING_H
|
||||
#define __STRING_H
|
||||
|
||||
int strlen(const char *str);
|
||||
void *memcpy(void *dest, const void *src, int len);
|
||||
void *memset(void *dest, int c, int len);
|
||||
int memcmp(const void *av, const void *bv, int len);
|
||||
char *strncat(char *dest, const char *src, unsigned int n);
|
||||
|
||||
#endif /* __STRING_H */
|
|
@ -4,65 +4,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include "proxmark3.h"
|
||||
#include "util.h"
|
||||
|
||||
void *memcpy(void *dest, const void *src, int len)
|
||||
{
|
||||
uint8_t *d = dest;
|
||||
const uint8_t *s = src;
|
||||
while((len--) > 0) {
|
||||
*d = *s;
|
||||
d++;
|
||||
s++;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *memset(void *dest, int c, int len)
|
||||
{
|
||||
uint8_t *d = dest;
|
||||
while((len--) > 0) {
|
||||
*d = c;
|
||||
d++;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
int memcmp(const void *av, const void *bv, int len)
|
||||
{
|
||||
const uint8_t *a = av;
|
||||
const uint8_t *b = bv;
|
||||
|
||||
while((len--) > 0) {
|
||||
if(*a != *b) {
|
||||
return *a - *b;
|
||||
}
|
||||
a++;
|
||||
b++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strlen(const char *str)
|
||||
{
|
||||
int l = 0;
|
||||
while(*str) {
|
||||
l++;
|
||||
str++;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
char* strncat(char *dest, const char *src, unsigned int n)
|
||||
{
|
||||
unsigned int dest_len = strlen(dest);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0 ; i < n && src[i] != '\0' ; i++)
|
||||
dest[dest_len + i] = src[i];
|
||||
dest[dest_len + i] = '\0';
|
||||
|
||||
return dest;
|
||||
}
|
||||
#include "string.h"
|
||||
|
||||
void num_to_bytes(uint64_t n, size_t len, uint8_t* dest)
|
||||
{
|
||||
|
|
|
@ -13,11 +13,7 @@
|
|||
#define BUTTON_SINGLE_CLICK -1
|
||||
#define BUTTON_DOUBLE_CLICK -2
|
||||
#define BUTTON_ERROR -99
|
||||
int strlen(const char *str);
|
||||
void *memcpy(void *dest, const void *src, int len);
|
||||
void *memset(void *dest, int c, int len);
|
||||
int memcmp(const void *av, const void *bv, int len);
|
||||
char *strncat(char *dest, const char *src, unsigned int n);
|
||||
|
||||
void num_to_bytes(uint64_t n, size_t len, uint8_t* dest);
|
||||
uint64_t bytes_to_num(uint8_t* src, size_t len);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue