diff --git a/Makefile b/Makefile index 77b62b9..94fa16e 100644 --- a/Makefile +++ b/Makefile @@ -40,8 +40,6 @@ WARNINGS = -Wstrict-prototypes -Wsign-compare -Wshadow \ -Wchar-subscripts -Wmissing-declarations -Wnested-externs \ -Wpointer-arith -Wcast-align -Wsign-compare -Wmissing-prototypes CFLAGS += $(WARNINGS) -LDFLAGS += -Wl,-warn-common,--as-needed - ifeq ($(strip $(V)),) E = @echo @@ -58,7 +56,7 @@ export E Q # We need -lssl and -lcrypto when using libcurl with SSL support # We need -lpthread for the pthread example #LIB_OBJS = -lcurl -lnsl -lssl -lcrypto -LIB_OBJS = -lcurl -lnsl +LIB_OBJS = -lcurl all: $(PROGRAM) $(MAN_PAGES) @@ -88,13 +86,13 @@ bti_version.h: clean: $(E) " CLEAN " - $(Q) - find . -type f -name '*.orig' -print0 | xargs -0r rm -f - $(Q) - find . -type f -name '*.rej' -print0 | xargs -0r rm -f - $(Q) - find . -type f -name '*~' -print0 | xargs -0r rm -f - $(Q) - find . -type f -name '*.[oas]' -print0 | xargs -0r rm -f - $(Q) - find . -type f -name "*.gcno" -print0 | xargs -0r rm -f - $(Q) - find . -type f -name "*.gcda" -print0 | xargs -0r rm -f - $(Q) - find . -type f -name "*.gcov" -print0 | xargs -0r rm -f + $(Q) - find . -type f -name '*.orig' -print0 | xargs -0 rm -f + $(Q) - find . -type f -name '*.rej' -print0 | xargs -0 rm -f + $(Q) - find . -type f -name '*~' -print0 | xargs -0 rm -f + $(Q) - find . -type f -name '*.[oas]' -print0 | xargs -0 rm -f + $(Q) - find . -type f -name "*.gcno" -print0 | xargs -0 rm -f + $(Q) - find . -type f -name "*.gcda" -print0 | xargs -0 rm -f + $(Q) - find . -type f -name "*.gcov" -print0 | xargs -0 rm -f $(Q) - rm -f core $(PROGRAM) $(GEN_HEADERS) .PHONY: clean diff --git a/bti.c b/bti.c index feaab36..ebd1d40 100644 --- a/bti.c +++ b/bti.c @@ -58,6 +58,39 @@ struct bti_curl_buffer { int length; }; +#ifdef __APPLE__ +static char *strchrnul(const char *s, int c) +{ + char *res = strchr(s, c); + if (res) + return res; + return (char *)s + strlen(s); +} + +static inline ssize_t +getline(char **outbuf, size_t *outsize, FILE *fp) +{ + char *buf; + size_t len; + + buf = fgetln(fp, &len); + if (buf == NULL) + return (-1); + + /* Assumes realloc() accepts NULL for ptr (C99) */ + if (*outbuf == NULL || *outsize < len + 1) { + void *tmp = realloc(*outbuf, len + 1); + if (tmp == NULL) + return (-1); + *outbuf = tmp; + *outsize = len + 1; + } + memcpy(*outbuf, buf, len); + (*outbuf)[len] = '\0'; + return (len); +} +#endif + static void display_help(void) { fprintf(stdout, "bti - send tweet to twitter\n");