From cc9e2019e791c91926916629c58ba572af7ea31b Mon Sep 17 00:00:00 2001 From: Nishi Date: Thu, 22 Aug 2024 02:15:44 +0000 Subject: [PATCH] add md5 for avatar generation git-svn-id: file:///raid/svn-personal/repoview/trunk@33 7e8b2a19-8934-dd40-8cb3-db22cdd5a80f --- CGI/Makefile | 2 +- CGI/md5.c | 22 ++++++++++++++++++++++ CGI/rv_md5.h | 8 ++++++++ Platform/freebsd.mk | 2 +- Platform/generic.mk | 2 +- Platform/netbsd.mk | 2 +- 6 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 CGI/md5.c create mode 100644 CGI/rv_md5.h diff --git a/CGI/Makefile b/CGI/Makefile index 47eba8b..28bebfe 100644 --- a/CGI/Makefile +++ b/CGI/Makefile @@ -5,7 +5,7 @@ include $(PWD)/Platform/$(PLATFORM).mk .PHONY: all clean .SUFFIXES: .c .o -OBJS = main.o sanity.o version.o util.o query.o page.o sha512.o repo.o $(EXTOBJS) +OBJS = main.o sanity.o version.o util.o query.o page.o sha512.o md5.o repo.o $(EXTOBJS) all: repoview.cgi diff --git a/CGI/md5.c b/CGI/md5.c new file mode 100644 index 0000000..cdaa2a7 --- /dev/null +++ b/CGI/md5.c @@ -0,0 +1,22 @@ +/* $Id$ */ + +#include "rv_md5.h" + +#include + +#include +#include + +char* rv_md5(const char* string) { + const char hex[] = "0123456789abcdef"; + unsigned char* hash = malloc(MD5_DIGEST_LENGTH); + MD5((const unsigned char*)string, strlen(string), hash); + char* str = malloc(128 / 4 + 1); + int i; + for(i = 0; i < 128 / 8; i++) { + str[2 * i + 0] = hex[(hash[i] >> 4) & 0xf]; + str[2 * i + 1] = hex[(hash[i] & 0xf)]; + } + free(hash); + return str; +} diff --git a/CGI/rv_md5.h b/CGI/rv_md5.h new file mode 100644 index 0000000..8f67f48 --- /dev/null +++ b/CGI/rv_md5.h @@ -0,0 +1,8 @@ +/* $Id$ */ + +#ifndef __RV_MD5_H__ +#define __RV_MD5_H__ + +char* rv_md5(const char* string); + +#endif diff --git a/Platform/freebsd.mk b/Platform/freebsd.mk index 8f4c2dd..6fe342b 100644 --- a/Platform/freebsd.mk +++ b/Platform/freebsd.mk @@ -1,6 +1,6 @@ # $Id$ CC = cc -CFLAGS = -std=c99 -I /usr/local/include -I /usr/local/include/GraphicsMagick +CFLAGS = -std=c99 -I /usr/local/include -I /usr/local/include/GraphicsMagick -DOPENSSL_SUPPRESS_DEPRECATED LDFLAGS = -L /usr/local/lib LIBS = -lcrypto diff --git a/Platform/generic.mk b/Platform/generic.mk index f8f14af..a9d6d80 100644 --- a/Platform/generic.mk +++ b/Platform/generic.mk @@ -1,6 +1,6 @@ # $Id$ CC = cc -CFLAGS = -std=c99 +CFLAGS = -std=c99 -DOPENSSL_SUPPRESS_DEPRECATED LDFLAGS = LIBS = -lcrypto diff --git a/Platform/netbsd.mk b/Platform/netbsd.mk index 5c20647..db9f2af 100644 --- a/Platform/netbsd.mk +++ b/Platform/netbsd.mk @@ -1,6 +1,6 @@ # $Id$ CC = cc -CFLAGS = -std=c99 -I /usr/pkg/include -I /usr/pkg/include/GraphicsMagick +CFLAGS = -std=c99 -I /usr/pkg/include -I /usr/pkg/include/GraphicsMagick -DOPENSSL_SUPPRESS_DEPRECATED LDFLAGS = -L /usr/pkg/lib -Wl,-R/usr/pkg/lib LIBS = -lcrypto -- 2.45.2