From dace178f2582f77037b05c75874b7624c0bae2b2 Mon Sep 17 00:00:00 2001 From: leitner Date: Sun, 28 Feb 2016 12:26:05 +0000 Subject: [PATCH] add base64url support (forgot header) compile byte/* with -O3 --- GNUmakefile | 24 ++++++++++++++++++++---- Makefile | 28 ++++++++++++++++++++++------ textcode.h | 5 +++++ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e2f0727..c52af71 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -18,7 +18,23 @@ all: ent $(LIBS) libowfat.a libsocket t CROSS= #CROSS=i686-mingw- CC=$(CROSS)gcc -CFLAGS=-pipe -W -Wall -Wextra -O2 -fomit-frame-pointer +WERROR= +WARN=-W -Wall -Wextra $(WERROR) + +# Use the second version if you are building for a binary that is only +# supposed to run on this machine. It tells gcc to use CPU instructions +# that are specific to the CPU the code is compiled on. +NATIVE= +#NATIVE=-march=native -mtune=native + +OPT_REG=-O2 -fomit-leaf-frame-pointer +OPT_PLUS=-O3 -fomit-leaf-frame-pointer $(NATIVE) + +DEFINE=-D_REENTRANT + +CFLAGS=-pipe $(WARN) $(DEFINE) $(OPT_REG) +CFLAGS_OPT=-pipe $(WARN) $(DEFINE) $(OPT_PLUS) + #CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall ent: ent.c haveuint128.h @@ -26,9 +42,6 @@ ent: ent.c haveuint128.h # CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -WERROR= -CFLAGS += -D_REENTRANT $(WERROR) - # startrip ifneq ($(DEBUG),) CFLAGS=-pipe -Wall -g -Og @@ -149,6 +162,9 @@ libowfat.a: $(ALL_OBJS) CFLAGS+=-I. +%.o: byte/%.c + $(DIET) $(CC) -c $< $(CFLAGS_OPT) + %.o: %.c $(DIET) $(CC) -c $< $(CFLAGS) diff --git a/Makefile b/Makefile index ab87054..f3cc9f7 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,23 @@ all: ent $(LIBS) libowfat.a libsocket t CROSS= #CROSS=i686-mingw- CC=$(CROSS)gcc -CFLAGS=-pipe -W -Wall -Wextra -O2 -fomit-frame-pointer +WERROR= +WARN=-W -Wall -Wextra $(WERROR) + +# Use the second version if you are building for a binary that is only +# supposed to run on this machine. It tells gcc to use CPU instructions +# that are specific to the CPU the code is compiled on. +NATIVE= +#NATIVE=-march=native -mtune=native + +OPT_REG=-O2 -fomit-leaf-frame-pointer +OPT_PLUS=-O3 -fomit-leaf-frame-pointer $(NATIVE) + +DEFINE=-D_REENTRANT + +CFLAGS=-pipe $(WARN) $(DEFINE) $(OPT_REG) +CFLAGS_OPT=-pipe $(WARN) $(DEFINE) $(OPT_PLUS) + #CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall ent: ent.c haveuint128.h @@ -27,9 +43,6 @@ ent: ent.c haveuint128.h # CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -WERROR= -CFLAGS += -D_REENTRANT $(WERROR) - array_allocate.o: array/array_allocate.c likely.h safemult.h uint16.h \ uint32.h uint64.h array.h byte.h array_bytes.o: array/array_bytes.c array.h uint64.h @@ -638,8 +651,8 @@ fmt_yenc.o: textcode/fmt_yenc.c fmt.h byte.h textcode.h scan_base64.o: textcode/scan_base64.c textcode.h haveinline.h scan_cescape.o: textcode/scan_cescape.c fmt.h byte.h textcode.h scan.h scan_hexdump.o: textcode/scan_hexdump.c fmt.h byte.h textcode.h scan.h -scan_html.o: textcode/scan_html.c entities.h fmt.h byte.h textcode.h \ - haveinline.h scan.h case.h str.h +scan_html.o: textcode/scan_html.c fmt.h byte.h textcode.h haveinline.h \ + scan.h case.h str.h scan_jsonescape.o: textcode/scan_jsonescape.c fmt.h byte.h textcode.h \ scan.h scan_ldapescape.o: textcode/scan_ldapescape.c fmt.h byte.h textcode.h \ @@ -739,6 +752,9 @@ libowfat.a: $(ALL_OBJS) CFLAGS+=-I. +%.o: byte/%.c + $(DIET) $(CC) -c $< $(CFLAGS_OPT) + %.o: $(DIET) $(CC) -c $< $(CFLAGS) diff --git a/textcode.h b/textcode.h index 2bb1132..71829fe 100644 --- a/textcode.h +++ b/textcode.h @@ -15,6 +15,7 @@ extern "C" { size_t fmt_uuencoded(char* dest,const char* src,size_t len); /* Needs len/3*4 bytes */ size_t fmt_base64(char* dest,const char* src,size_t len); +size_t fmt_base64url(char* dest,const char* src,size_t len); /* Worst case: len*3 */ size_t fmt_quotedprintable(char* dest,const char* src,size_t len); /* Worst case: len*3 */ @@ -59,6 +60,7 @@ size_t fmt_base85(char* dest,const char* src,size_t len); * should be able to hold strlen(src) bytes as a rule of thumb. */ size_t scan_uuencoded(const char* src,char* dest,size_t* destlen); size_t scan_base64(const char* src,char* dest,size_t* destlen); +size_t scan_base64url(const char* src,char* dest,size_t* destlen); size_t scan_quotedprintable(const char* src,char* dest,size_t* destlen); size_t scan_urlencoded(const char* src,char* dest,size_t* destlen); size_t scan_urlencoded2(const char* src,char* dest,size_t* destlen); @@ -93,6 +95,7 @@ size_t scan_to_sa(size_t (*func)(const char*,char*,size_t*), #define fmt_uuencoded_sa(sa,src,len) fmt_to_sa(fmt_uuencoded,sa,src,len) #define fmt_base64_sa(sa,src,len) fmt_to_sa(fmt_base64,sa,src,len) +#define fmt_base64url_sa(sa,src,len) fmt_to_sa(fmt_base64url,sa,src,len) #define fmt_quotedprintable_sa(sa,src,len) fmt_to_sa(fmt_quotedprintable,sa,src,len) #define fmt_urlencoded_sa(sa,src,len) fmt_to_sa(fmt_urlencoded,sa,src,len) #define fmt_yenc_sa(sa,src,len) fmt_to_sa(fmt_yenc,sa,src,len) @@ -108,6 +111,7 @@ size_t scan_to_sa(size_t (*func)(const char*,char*,size_t*), #define scan_uuencoded_sa(src,sa) scan_to_sa(scan_uuencoded,src,sa) #define scan_base64_sa(src,sa) scan_to_sa(scan_base64,src,sa) +#define scan_base64url_sa(src,sa) scan_to_sa(scan_base64url,src,sa) #define scan_quotedprintable_sa(src,sa) scan_to_sa(scan_quotedprintable,src,sa) #define scan_urlencoded_sa(src,sa) scan_to_sa(scan_urlencoded,src,sa) #define scan_yenc_sa(src,sa) scan_to_sa(scan_yenc,src,sa) @@ -139,6 +143,7 @@ size_t scan_tofrom_array(size_t (*func)(const char*,char*,size_t*), #endif extern const char base64[64]; +extern const char base64url[64]; #ifdef __cplusplus }