From e90434ba61be4c0a85a2f9aab7e65afb72afaffa Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 21 Mar 2017 13:36:06 -0500 Subject: [PATCH] strtok_r only by declaration --- Makefile | 2 +- include/multiaddr/string_tokenizer.h | 10 ------- protoutils.c | 7 ++--- string_tokenizer.c | 39 ---------------------------- 4 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 include/multiaddr/string_tokenizer.h delete mode 100644 string_tokenizer.c diff --git a/Makefile b/Makefile index 3464338..f34af02 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ LFLAGS = -lm DEPS = include/multiaddr/base58.h include/multiaddr/endian.h include/multiaddr/multiaddr.h \ include/multiaddr/protocols.h include/multiaddr/protoutils.h include/multiaddr/varhexutils.h \ include/multiaddr/varint.h -OBJS = base58.o varint.o varhexutils.o protoutils.o protocols.o multiaddr.o string_tokenizer.o +OBJS = base58.o varint.o varhexutils.o protoutils.o protocols.o multiaddr.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) diff --git a/include/multiaddr/string_tokenizer.h b/include/multiaddr/string_tokenizer.h deleted file mode 100644 index 893a32e..0000000 --- a/include/multiaddr/string_tokenizer.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -/** - * A replacement strtok_r so we can compile with c99 - * @param str the original string - * @param delim the delimiters - * @param nextp used internally to save state - * @returns a pointer to the next element - */ -char* ma_utils_strtok_r(char *str, const char *delim, char **nextp); diff --git a/protoutils.c b/protoutils.c index 6dc8b38..5690f92 100644 --- a/protoutils.c +++ b/protoutils.c @@ -9,7 +9,8 @@ #include "multiaddr/varhexutils.h" #include "multiaddr/protocols.h" #include "multiaddr/protoutils.h" -#include "multiaddr/string_tokenizer.h" + +extern char *strtok_r(char *, const char *, char **); ////////////////////////////////////////////////////////// char ASCII2bits(char ch) { @@ -683,7 +684,7 @@ int string_to_bytes(uint8_t** finalbytes, size_t* realbbsize, const char* strx, //Starting to extract words and process them: char * wp; char * end; - wp=ma_utils_strtok_r(pstring,"/",&end); + wp=strtok_r(pstring,"/",&end); struct Protocol * protx; while(wp) { @@ -719,7 +720,7 @@ int string_to_bytes(uint8_t** finalbytes, size_t* realbbsize, const char* strx, protx=NULL;//Since right now it doesn't need that assignment anymore. firstorsecond=1;//Since the next word will be an protocol } - wp=ma_utils_strtok_r(NULL,"/",&end); + wp=strtok_r(NULL,"/",&end); } protx=NULL; unload_protocols(head); diff --git a/string_tokenizer.c b/string_tokenizer.c deleted file mode 100644 index 9129bdb..0000000 --- a/string_tokenizer.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -/** - * A replacement strtok_r so we can compile with c99 - * @param str the original string - * @param delim the delimiters - * @param nextp used internally to save state - * @returns a pointer to the next element - */ -char* ma_utils_strtok_r(char *str, const char *delim, char **nextp) -{ - char *ret; - - if (str == NULL) - { - str = *nextp; - } - - str += strspn(str, delim); - - if (*str == '\0') - { - return NULL; - } - - ret = str; - - str += strcspn(str, delim); - - if (*str) - { - *str++ = '\0'; - } - - *nextp = str; - - return ret; -}