diff options
author | Gilad Arnold <garnold@google.com> | 2015-08-24 18:00:44 -0700 |
---|---|---|
committer | Gilad Arnold <garnold@google.com> | 2015-08-25 15:20:29 -0700 |
commit | 47194ce69c05cd9bb636e13810afec732ff4067b (patch) | |
tree | e90fec913b394102453f88f46b53e531cfc58f3a | |
parent | ae3f6773ded9386e679aaa49e6b0c49ec35ad173 (diff) | |
download | tlsdate-47194ce69c05cd9bb636e13810afec732ff4067b.tar.gz |
Remove src/common/android.{h,c}.
1) Get rid of strchrnul use; this is a non-standard GNU extension that's
being used in one place.
2) Move MIN into src/common/fmemopen.c, where it's actually being used.
Thereafter, remove all includes of src/common/android.h and any mention
of android.c in the build files.
Bug: 22373707
Change-Id: Ide6e47a24291e6971d08b4abae2f1cad9c151e0e
-rw-r--r-- | src/common/android.c | 18 | ||||
-rw-r--r-- | src/common/android.h | 25 | ||||
-rw-r--r-- | src/common/fmemopen.c | 5 | ||||
-rw-r--r-- | src/conf.c | 38 | ||||
-rw-r--r-- | src/include.am | 35 |
5 files changed, 13 insertions, 108 deletions
diff --git a/src/common/android.c b/src/common/android.c deleted file mode 100644 index 655eb0b..0000000 --- a/src/common/android.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "android.h" - -#include <string.h> - -char *strchrnul(const char *s, int c) -{ - char * matched_char = strchr(s, c); - if (matched_char == NULL) { - matched_char = (char*) s + strlen(s); - } - return matched_char; -} - -int MIN(int a, int b) { - return a < b ? a : b; -} - - diff --git a/src/common/android.h b/src/common/android.h deleted file mode 100644 index f2908c2..0000000 --- a/src/common/android.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Android's libc lacks fmemopen, so here is our implementation. - */ - -#include <stdio.h> - -/** - * fmemopen expects this function - * defined in android.c - */ -int MIN(int a, int b); - - -/* - * Android's libc does not provide strchrnul, so here - * is our own implementation. strchrnul behaves like - * strchr except instead of returning NULL if c is not - * in s, strchrnul returns a pointer to the \0 byte at - * the end of s. - * defined in android.c - */ -char *strchrnul(const char *s, int c); - -/* defined in fmemopen.c */ -FILE *fmemopen(void *buf, size_t size, const char *mode); diff --git a/src/common/fmemopen.c b/src/common/fmemopen.c index d42fc30..99f6740 100644 --- a/src/common/fmemopen.c +++ b/src/common/fmemopen.c @@ -3,7 +3,6 @@ http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/fmemopen.c on 26/04/2013 by Abel Luck for inclusion in tlsdate for the Android port. */ -#include "android.h" /* $NetBSD: fmemopen.c,v 1.4 2010/09/27 16:50:13 tnozaki Exp $ */ /*- @@ -44,6 +43,10 @@ //#include "local.h" //#include "priv_stdio.h" +int MIN(int a, int b) { + return a < b ? a : b; +} + struct fmemopen_cookie { char *head, *tail, *cur, *eob; }; @@ -1,8 +1,5 @@ /* conf.c - config file parser */ -#ifndef _GNU_SOURCE -#define _GNU_SOURCE /* strchrnul */ -#endif #include "config.h" #include <ctype.h> #include <stdio.h> @@ -11,36 +8,17 @@ #include "src/conf.h" -#ifdef TARGET_OS_NETBSD -#include "src/common/android.h" // XXX: Dirty hack - make this more generic later -#endif - -#ifdef TARGET_OS_OPENBSD -#include "src/common/android.h" // XXX: Dirty hack - make this more generic later -#endif - -#ifdef TARGET_OS_DRAGONFLYBSD -#include "src/common/android.h" // XXX: Dirty hack - make this more generic later -#endif - -#ifdef TARGET_OS_HAIKU -#include "src/common/android.h" // XXX: Dirty hack - make this more generic later -#endif - -#ifdef TARGET_OS_FREEBSD -#ifndef HAVE_STRCHRNUL -#include "src/common/android.h" // XXX: Dirty hack - make this more generic later -#endif -#endif - -#ifdef HAVE_ANDROID -#include "src/common/android.h" -#endif +void strip_char (char *line, char c) +{ + char *p = strchr (line, c); + if (p) + *p = '\0'; +} void strip_newlines (char *line) { - *strchrnul (line, '\n') = '\0'; - *strchrnul (line, '\r') = '\0'; + strip_char (line, '\n'); + strip_char (line, '\r'); } char *eat_whitespace (char *line) diff --git a/src/include.am b/src/include.am index ec091e5..6e1e321 100644 --- a/src/include.am +++ b/src/include.am @@ -24,7 +24,7 @@ src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c if HAVE_ANDROID -src_conf_unittest_SOURCES+= src/common/android.c src/common/fmemopen.c +src_conf_unittest_SOURCES+= src/common/fmemopen.c endif check_PROGRAMS+= src/conf_unittest @@ -37,9 +37,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -if !HAVE_STRCHRNUL -src_conf_unittest_SOURCES+= src/common/android.c -endif check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -50,9 +47,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -if !HAVE_STRCHRNUL -src_conf_unittest_SOURCES+= src/common/android.c -endif check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -63,7 +57,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c # XXX This conditional should apply for any system where we're building # conf_unittest, but I don't know how to tell that to automake. @@ -83,7 +76,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c src_conf_unittest_SOURCES+= src/common/fmemopen.c check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest @@ -95,7 +87,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -120,7 +111,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -131,7 +121,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -142,7 +131,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -153,7 +141,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -194,10 +181,6 @@ endif src_tlsdated_LDADD = @SSL_LIBS@ $(RT_LIB) $(DBUS_LIBS) $(LIBEVENT_LIBS) src_tlsdated_SOURCES = src/conf.c -if HAVE_ANDROID -src_tlsdated_SOURCES+= src/common/android.c -endif - # This doesn't work on Mac OS X or FreeBSD if TARGET_LINUX src_tlsdated_SOURCES+= src/routeup.c @@ -262,9 +245,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -if !HAVE_STRCHRNUL -src_proxy_bio_unittest_SOURCES+= src/common/android.c -endif check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest endif @@ -284,7 +264,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c # XXX This conditional should apply for any system where we're building # proxy_bio_unittest, but I don't know how to tell that to automake. @@ -304,7 +283,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c src_proxy_bio_unittest_SOURCES+= src/common/fmemopen.c check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest @@ -318,7 +296,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest endif @@ -347,7 +324,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest endif @@ -360,7 +336,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest endif @@ -373,7 +348,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest endif @@ -386,7 +360,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest endif @@ -408,10 +381,6 @@ noinst_HEADERS+= src/conf.h noinst_HEADERS+= src/dbus.h noinst_HEADERS+= src/platform.h -if HAVE_ANDROID -noinst_HEADERS+= src/common/android.h -endif - # This is our explicit target list # We do not attempt to build with PolarSSL if !POLARSSL @@ -431,7 +400,6 @@ bin_PROGRAMS+= src/tlsdate-helper src_conf_unittest_SOURCES = src/conf.c src_conf_unittest_SOURCES+= src/conf-unittest.c -src_conf_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/conf_unittest noinst_PROGRAMS+= src/conf_unittest endif @@ -465,7 +433,6 @@ src_proxy_bio_unittest_SOURCES = src/proxy-bio.c src_proxy_bio_unittest_SOURCES+= src/proxy-bio-unittest.c src_proxy_bio_unittest_SOURCES+= src/test-bio.c src_proxy_bio_unittest_SOURCES+= src/util.c -src_proxy_bio_unittest_SOURCES+= src/common/android.c check_PROGRAMS+= src/proxy-bio_unittest noinst_PROGRAMS+= src/proxy-bio_unittest |