$(SRC_LF) \
appmain.c printf.c \
util.c \
+ string.c \
usb.c
# These are to be compiled in ARM mode
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
+#include "printf.h"
+#include "string.h"
+
+#include <stdarg.h>
#include "legicrf.h"
# 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) )
//=============================================================================
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
+#include "string.h"
//-----------------------------------------------------------------------------
// Set up the Serial Peripheral Interface as master
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
-
#include "hitag2.h"
+#include "string.h"
struct hitag2_cipher_state {
uint64_t state;
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
+#include "string.h"
#include "iso14443crc.h"
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
+#include "string.h"
+
#include "iso14443crc.h"
static uint8_t *trace = (uint8_t *) BigBuf;
#include "proxmark3.h"
#include "util.h"
#include "apps.h"
+#include "string.h"
// FROM winsrc\prox.h //////////////////////////////////
#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
#include "proxmark3.h"
#include "apps.h"
#include "util.h"
+#include "string.h"
#include "legicrf.h"
#include "legic_prng.h"
#include "util.h"
#include "hitag2.h"
#include "crc16.h"
+#include "string.h"
void AcquireRawAdcSamples125k(int at134khz)
{
#include <stdarg.h>
#include "printf.h"
#include "util.h"
+#include "string.h"
typedef uint32_t uintmax_t;
typedef int32_t intmax_t;
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
\ No newline at end of file
--- /dev/null
+/* 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;
+}
--- /dev/null
+#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 */
\ No newline at end of file
//-----------------------------------------------------------------------------
#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)
{
#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);