Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=30a7279c8ad2dc94f8d7ac50cc9e725c29853379

commit 30a7279c8ad2dc94f8d7ac50cc9e725c29853379
Author: Michel Hermier <herm...@frugalware.org>
Date:   Tue May 14 20:57:08 2013 +0200

libpacman: Move MD5 implementation from libpacman to libflib.

diff --git a/lib/libflib/Makefile.am b/lib/libflib/Makefile.am
index 5b15a9f..7c10a1c 100644
--- a/lib/libflib/Makefile.am
+++ b/lib/libflib/Makefile.am
@@ -10,13 +10,24 @@ AM_CFLAGS = $(DEFINES)
noinst_LTLIBRARIES = libflib.la
#lib_LTLIBRARIES = libflib.la

+libflib_crypto_hash_SOURCES = \
+       fmd5.c
+
+libflib_crypto_SOURCES = \
+       $(libflib_crypto_hash_SOURCES)
+
+libflib_posix_SOURCES = \
+       fstdlib.c \
+       fstring.c
+
libflib_la_SOURCES = \
+       $(libflib_crypto_SOURCES) \
+       $(libflib_posix_SOURCES) \
flist.c \
flistaccumulator.c \
fobject.c \
-       fstdlib.c \
-       fstring.c \
fstringlist.c \
fvalue.c

#libflib_la_LDFLAGS = -L. -version-info $(SOVER)
+libflib_la_LIBADD =
diff --git a/lib/libpacman/md5.c b/lib/libflib/fmd5.c
similarity index 97%
rename from lib/libpacman/md5.c
rename to lib/libflib/fmd5.c
index e544b76..30ce600 100644
--- a/lib/libpacman/md5.c
+++ b/lib/libflib/fmd5.c
@@ -24,7 +24,8 @@ documentation and/or software.
*/

#include <string.h>
-#include "md5.h"
+
+#include "fmd5.h"

/* Constants for MD5Transform routine.
*/
@@ -93,7 +94,7 @@ Rotation is separate from addition to prevent recomputation.

/* MD5 initialization. Begins an MD5 operation, writing a new context.
*/
-void _pacman_MD5Init (context)
+void f_MD5Init (context)
MD5_CTX *context;                                        /* context */
{
context->count[0] = context->count[1] = 0;
@@ -109,7 +110,7 @@ MD5_CTX *context;                                        /* 
context */
operation, processing another message block, and updating the
context.
*/
-void _pacman_MD5Update (context, input, inputLen)
+void f_MD5Update (context, input, inputLen)
MD5_CTX *context;                                        /* context */
unsigned char *input;                                /* input block */
unsigned int inputLen;                     /* length of input block */
@@ -149,7 +150,7 @@ unsigned int inputLen;                     /* length of 
input block */
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context.
*/
-void _pacman_MD5Final (digest, context)
+void f_MD5Final (digest, context)
unsigned char digest[16];                         /* message digest */
MD5_CTX *context;                                       /* context */
{
@@ -163,10 +164,10 @@ MD5_CTX *context;                                       
/* context */
*/
md5_index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (md5_index < 56) ? (56 - md5_index) : (120 - md5_index);
-  _pacman_MD5Update (context, PADDING, padLen);
+  f_MD5Update (context, PADDING, padLen);

/* Append length (before padding) */
-  _pacman_MD5Update (context, bits, 8);
+  f_MD5Update (context, bits, 8);

/* Store state in digest */
Encode (digest, context->state, 16);
diff --git a/lib/libflib/fmd5.h b/lib/libflib/fmd5.h
new file mode 100644
index 0000000..f303e9d
--- /dev/null
+++ b/lib/libflib/fmd5.h
@@ -0,0 +1,47 @@
+/* MD5.H - header file for MD5C.C
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+rights reserved.
+
+License to copy and use this software is granted provided that it
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+Algorithm" in all material mentioning or referencing this software
+or this function.
+
+License is also granted to make and use derivative works provided
+that such works are identified as "derived from the RSA Data
+Security, Inc. MD5 Message-Digest Algorithm" in all material
+mentioning or referencing the derived work.
+
+RSA Data Security, Inc. makes no representations concerning either
+the merchantability of this software or the suitability of this
+software for any particular purpose. It is provided "as is"
+without express or implied warranty of any kind.
+
+These notices must be retained in any copies of any part of this
+documentation and/or software.
+ */
+
+/* POINTER defines a generic pointer type */
+typedef unsigned char *POINTER;
+
+/* UINT2 defines a two byte word */
+typedef unsigned short int UINT2;
+
+/* UINT4 defines a four byte word */
+typedef unsigned int UINT4;
+
+
+/* MD5 context. */
+typedef struct {
+  UINT4 state[4];                                   /* state (ABCD) */
+  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
+  unsigned char buffer[64];                         /* input buffer */
+} MD5_CTX;
+
+void f_MD5Init(MD5_CTX *);
+void f_MD5Update(MD5_CTX *, unsigned char *, unsigned int);
+void f_MD5Final(unsigned char [16], MD5_CTX *);
+
+/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libpacman/Makefile.am b/lib/libpacman/Makefile.am
index 79712ab..31eb0b3 100644
--- a/lib/libpacman/Makefile.am
+++ b/lib/libpacman/Makefile.am
@@ -9,7 +9,6 @@ localedir = $(datadir)/locale
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@

TARGETS = md5driver.c \
-       md5.c \
sha1.c \
util.c \
log.c \
diff --git a/lib/libpacman/md5.h b/lib/libpacman/md5.h
index 31d613e..ee7ba72 100644
--- a/lib/libpacman/md5.h
+++ b/lib/libpacman/md5.h
@@ -23,27 +23,6 @@ These notices must be retained in any copies of any part of 
this
documentation and/or software.
*/

-/* POINTER defines a generic pointer type */
-typedef unsigned char *POINTER;
-
-/* UINT2 defines a two byte word */
-typedef unsigned short int UINT2;
-
-/* UINT4 defines a four byte word */
-typedef unsigned int UINT4;
-
-
-/* MD5 context. */
-typedef struct {
-  UINT4 state[4];                                   /* state (ABCD) */
-  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
-  unsigned char buffer[64];                         /* input buffer */
-} MD5_CTX;
-
-void _pacman_MD5Init(MD5_CTX *);
-void _pacman_MD5Update(MD5_CTX *, unsigned char *, unsigned int);
-void _pacman_MD5Final(unsigned char [16], MD5_CTX *);
-
char* _pacman_MDFile(char *);
void  _pacman_MDPrint(unsigned char [16]);

diff --git a/lib/libpacman/md5driver.c b/lib/libpacman/md5driver.c
index 279a127..97e9be4 100644
--- a/lib/libpacman/md5driver.c
+++ b/lib/libpacman/md5driver.c
@@ -26,7 +26,8 @@ documentation and/or software.
#include <time.h>
#include <string.h>

-#include "md5.h"
+#include "global.h"
+#include "fmd5.h"

#include "util.h"

@@ -36,9 +37,9 @@ documentation and/or software.
#define TEST_BLOCK_COUNT 1000

#define MD_CTX MD5_CTX
-#define MDInit _pacman_MD5Init
-#define MDUpdate _pacman_MD5Update
-#define MDFinal _pacman_MD5Final
+#define MDInit f_MD5Init
+#define MDUpdate f_MD5Update
+#define MDFinal f_MD5Final

char* _pacman_MDFile(char *filename)
{
diff --git a/lib/libpacman/po/POTFILES.in b/lib/libpacman/po/POTFILES.in
index ed11f7c..c510583 100644
--- a/lib/libpacman/po/POTFILES.in
+++ b/lib/libpacman/po/POTFILES.in
@@ -9,7 +9,6 @@ error.c
group.c
handle.c
log.c
-md5.c
md5driver.c
package.c
provide.c
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to