Skip to content

Commit

Permalink
reserve trailing speces
Browse files Browse the repository at this point in the history
  • Loading branch information
kimim committed Nov 9, 2021
1 parent 573a8aa commit cb7b19d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/bio_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

#include <mqtt.h>
#include "templates/bio_sockets.h"
Expand Down
1 change: 1 addition & 0 deletions examples/openssl_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>

#include <mqtt.h>
#include "templates/openssl_sockets.h"
Expand Down
2 changes: 2 additions & 0 deletions examples/templates/posix_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#if !defined(WIN32)
#include <sys/socket.h>
#include <netdb.h>
#else
#include <ws2tcpip.h>
#endif
#if defined(__VMS)
#include <ioctl.h>
Expand Down
2 changes: 1 addition & 1 deletion include/mqtt_pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extern "C" {
typedef int mqtt_pal_socket_handle;
#endif
#endif
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) || defined(WIN32)
#include <limits.h>
#include <winsock2.h>
#include <windows.h>
Expand Down
17 changes: 11 additions & 6 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
UNAME = $(shell uname -o)

CC = gcc
CFLAGS = -Wextra -Wall -std=gnu99 -Iinclude -Wno-unused-parameter -Wno-unused-variable -Wno-duplicate-decl-specifier

ifeq ($(UNAME), Msys)
MSFLAGS = -lws2_32
endif

MQTT_C_SOURCES = src/mqtt.c src/mqtt_pal.c
MQTT_C_EXAMPLES = bin/simple_publisher bin/simple_subscriber bin/reconnect_subscriber bin/bio_publisher bin/openssl_publisher
MQTT_C_UNITTESTS = bin/tests
Expand All @@ -10,25 +15,25 @@ BINDIR = bin
all: $(BINDIR) $(MQTT_C_UNITTESTS) $(MQTT_C_EXAMPLES)

bin/simple_%: examples/simple_%.c $(MQTT_C_SOURCES)
$(CC) $(CFLAGS) $^ -lpthread -o $@
$(CC) $(CFLAGS) $^ -lpthread $(MSFLAGS) -o $@

bin/reconnect_%: examples/reconnect_%.c $(MQTT_C_SOURCES)
$(CC) $(CFLAGS) $^ -lpthread -o $@
$(CC) $(CFLAGS) $^ -lpthread $(MSFLAGS) -o $@

bin/bio_%: examples/bio_%.c $(MQTT_C_SOURCES)
$(CC) $(CFLAGS) `pkg-config --cflags openssl` -D MQTT_USE_BIO $^ -lpthread `pkg-config --libs openssl` -o $@
$(CC) $(CFLAGS) `pkg-config --cflags openssl` -D MQTT_USE_BIO $^ -lpthread $(MSFLAGS) `pkg-config --libs openssl` -o $@

bin/openssl_%: examples/openssl_%.c $(MQTT_C_SOURCES)
$(CC) $(CFLAGS) `pkg-config --cflags openssl` -D MQTT_USE_BIO $^ -lpthread `pkg-config --libs openssl` -o $@
$(CC) $(CFLAGS) `pkg-config --cflags openssl` -D MQTT_USE_BIO $^ -lpthread $(MSFLAGS) `pkg-config --libs openssl` -o $@

$(BINDIR):
mkdir -p $(BINDIR)

$(MQTT_C_UNITTESTS): tests.c $(MQTT_C_SOURCES)
$(CC) $(CFLAGS) $^ -lcmocka -o $@
$(CC) $(CFLAGS) $^ -lcmocka $(MSFLAGS) -o $@

clean:
rm -rf $(BINDIR)

check: all
./$(MQTT_C_UNITTESTS)
./$(MQTT_C_UNITTESTS)
2 changes: 1 addition & 1 deletion src/mqtt_pal.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int
return buf - start;
}

#elif defined(_MSC_VER)
#elif defined(_MSC_VER) || defined(WIN32)

#include <errno.h>

Expand Down

0 comments on commit cb7b19d

Please sign in to comment.