From 0269e03b981fd0c3c29b5c78e0a2450ef66d2abe Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 25 Jun 2008 20:35:24 +0200 Subject: [PATCH] More moves of string functions out of lib/lib.h. match_pattern* has been renamed to str_match_pattern*, (word|sep)split has been renamed to str_(word|sep)split, all of them have been moved to lib/string.h. md5_to_hex() and hex_to_md5() have been moved to lib/string.h, but MD5_SIZE and MD5_HEX_SIZE to lib/md5.h. The conversion functions will be replaced by a generic hexdumper soon. --- lib/Makefile | 2 +- lib/lib.h | 18 ------------------ lib/md5.h | 3 +++ lib/md5hex.c | 2 ++ lib/patimatch.c | 2 +- lib/patmatch.c | 2 +- lib/patmatch.h | 2 ++ lib/sorter/sort-test.c | 3 ++- lib/string.h | 15 +++++++++++++++ lib/wordsplit.c | 5 +++-- 10 files changed, 30 insertions(+), 24 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 470feabc..6df66820 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -41,7 +41,7 @@ LIBUCW_INCLUDES= \ arraysort.h \ lists.h clists.h slists.h simple-lists.h \ string.h stkstring.h unicode.h chartype.h regex.h \ - wildmatch.h patmatch.h \ + wildmatch.h \ unaligned.h prefetch.h \ bbuf.h gbuf.h bitarray.h bitsig.h \ hashfunc.h hashtable.h \ diff --git a/lib/lib.h b/lib/lib.h index cd3ba862..3dfea337 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -165,24 +165,6 @@ char *xstrdup(const char *) LIKE_MALLOC; int match_ct_patt(const char *, const char *); -/* wordsplit.c */ - -int sepsplit(char *str, uns sep, char **rec, uns max); -int wordsplit(char *str, char **rec, uns max); - -/* pat(i)match.c: Matching of shell patterns */ - -int match_pattern(const char *patt, const char *str); -int match_pattern_nocase(const char *patt, const char *str); - -/* md5hex.c */ - -void md5_to_hex(const byte *s, char *d); -void hex_to_md5(const char *s, byte *d); - -#define MD5_SIZE 16 -#define MD5_HEX_SIZE 33 - /* prime.c */ int isprime(uns x); diff --git a/lib/md5.h b/lib/md5.h index be51a525..0bb64593 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -21,4 +21,7 @@ void MD5Update(struct MD5Context *context, unsigned char const *buf, void MD5Final(unsigned char digest[16], struct MD5Context *context); void MD5Transform(uint32 buf[4], uint32 const in[16]); +#define MD5_HEX_SIZE 33 +#define MD5_SIZE 16 + #endif /* !_UCW_MD5_H */ diff --git a/lib/md5hex.c b/lib/md5hex.c index 93987b00..d0722f3e 100644 --- a/lib/md5hex.c +++ b/lib/md5hex.c @@ -9,6 +9,8 @@ #include "lib/lib.h" #include "lib/chartype.h" +#include "lib/md5.h" +#include "lib/string.h" #include diff --git a/lib/patimatch.c b/lib/patimatch.c index a0e29af9..ea5a4be9 100644 --- a/lib/patimatch.c +++ b/lib/patimatch.c @@ -11,6 +11,6 @@ #include "lib/chartype.h" #define Convert(x) Cupcase(x) -#define MATCH_FUNC_NAME match_pattern_nocase +#define MATCH_FUNC_NAME str_match_pattern_nocase #include "lib/patmatch.h" diff --git a/lib/patmatch.c b/lib/patmatch.c index bfd8aa50..373054ad 100644 --- a/lib/patmatch.c +++ b/lib/patmatch.c @@ -10,6 +10,6 @@ #include "lib/lib.h" #define Convert(x) (x) -#define MATCH_FUNC_NAME match_pattern +#define MATCH_FUNC_NAME str_match_pattern #include "lib/patmatch.h" diff --git a/lib/patmatch.h b/lib/patmatch.h index a47669f9..ef8508a1 100644 --- a/lib/patmatch.h +++ b/lib/patmatch.h @@ -7,6 +7,8 @@ * of the GNU Lesser General Public License. */ +#include "lib/string.h" + int MATCH_FUNC_NAME(const char *p, const char *s) { diff --git a/lib/sorter/sort-test.c b/lib/sorter/sort-test.c index e7d58730..896013fb 100644 --- a/lib/sorter/sort-test.c +++ b/lib/sorter/sort-test.c @@ -14,6 +14,7 @@ #include "lib/ff-binary.h" #include "lib/hashfunc.h" #include "lib/md5.h" +#include "lib/string.h" #include #include @@ -674,7 +675,7 @@ main(int argc, char **argv) case 't': { char *w[32]; - int f = sepsplit(optarg, ',', w, ARRAY_SIZE(w)); + int f = str_sepsplit(optarg, ',', w, ARRAY_SIZE(w)); if (f < 0) goto usage; t = 0; diff --git a/lib/string.h b/lib/string.h index c60a14d0..a9de082f 100644 --- a/lib/string.h +++ b/lib/string.h @@ -14,4 +14,19 @@ char *str_unesc(char *dest, const char *src); char *str_format_flags(char *dest, const char *fmt, uns flags); +/* wordsplit.c */ + +int str_sepsplit(char *str, uns sep, char **rec, uns max); +int str_wordsplit(char *str, char **rec, uns max); + +/* pat(i)match.c: Matching of shell patterns */ + +int str_match_pattern(const char *patt, const char *str); +int str_match_pattern_nocase(const char *patt, const char *str); + +/* md5hex.c */ + +void md5_to_hex(const byte *s, char *d); +void hex_to_md5(const char *s, byte *d); + #endif diff --git a/lib/wordsplit.c b/lib/wordsplit.c index 2e50edc1..97ce242a 100644 --- a/lib/wordsplit.c +++ b/lib/wordsplit.c @@ -10,11 +10,12 @@ #include "lib/lib.h" #include "lib/chartype.h" +#include "lib/string.h" #include int -sepsplit(char *str, uns sep, char **rec, uns max) +str_sepsplit(char *str, uns sep, char **rec, uns max) { uns cnt = 0; while (1) @@ -30,7 +31,7 @@ sepsplit(char *str, uns sep, char **rec, uns max) } int -wordsplit(char *src, char **dst, uns max) +str_wordsplit(char *src, char **dst, uns max) { uns cnt = 0; -- 2.39.2