
7 changed files with 139 additions and 72 deletions
@ -1,43 +1,32 @@ |
|||||
|
|
||||
|
# Build config |
||||
|
/build.conf |
||||
|
/.idea |
||||
|
|
||||
# Prerequisites |
# Prerequisites |
||||
*.d |
*.d |
||||
|
|
||||
# Object files |
# Object files |
||||
*.o |
*.o |
||||
*.ko |
|
||||
*.obj |
|
||||
*.elf |
|
||||
|
|
||||
# Linker output |
|
||||
*.ilk |
|
||||
*.map |
|
||||
*.exp |
|
||||
|
|
||||
# Precompiled Headers |
# Precompiled Headers |
||||
*.gch |
*.gch |
||||
*.pch |
*.pch |
||||
|
|
||||
# Libraries |
# Libraries |
||||
*.lib |
|
||||
*.a |
*.a |
||||
*.la |
|
||||
*.lo |
|
||||
|
|
||||
# Shared objects (inc. Windows DLLs) |
|
||||
*.dll |
|
||||
*.so |
|
||||
*.so.* |
|
||||
*.dylib |
|
||||
|
|
||||
# Executables |
# Executables |
||||
*.exe |
/src/main_cli |
||||
*.out |
/src/main_tui |
||||
*.app |
|
||||
*.i*86 |
|
||||
*.x86_64 |
|
||||
*.hex |
|
||||
|
|
||||
# Debug files |
# Debug files |
||||
*.dSYM/ |
*.dSYM/ |
||||
*.su |
*.su |
||||
*.idb |
*.idb |
||||
*.pdb |
*.pdb |
||||
|
|
||||
|
#Test |
||||
|
/test/test_main |
||||
|
/test/test_main2 |
||||
|
/test/test_log |
||||
|
@ -1,53 +1,32 @@ |
|||||
# Copyright 2022, pEp Foundation
|
|
||||
# This file is part of libpEpCxx11
|
|
||||
# This file may be used under the terms of the GNU General Public License version 3
|
|
||||
# see LICENSE
|
|
||||
|
|
||||
include ../Makefile.conf |
include ../Makefile.conf |
||||
|
|
||||
EXE_MAIN_CLI:=cli_main |
SRC:=$(wildcard *.c*) |
||||
EXE_MAIN_TUI:=tui_main |
SRC_EXE:=$(filter main_%, $(SRC)) |
||||
EXE_MAIN_TEST:=test_main |
SRC_LIB=$(filter-out main_%, $(SRC)) |
||||
|
OBJS:=$(addsuffix .o, $(basename $(SRC))) |
||||
OBJ_MAIN_CLI:=$(EXE_MAIN_CLI).o |
OBJS_LIB:=$(addsuffix .o, $(basename $(SRC_LIB))) |
||||
OBJ_MAIN_TUI:=$(EXE_MAIN_TUI).o |
EXE:=$(basename $(SRC_EXE)) |
||||
OBJ_MAIN_TEST:=$(EXE_MAIN_TEST).o |
DEPS:=$(addsuffix .d, $(basename $(SRC))) |
||||
|
|
||||
C_SOURCES:=$(wildcard *.c) |
|
||||
CXX_SOURCES+=$(wildcard *.cc) |
|
||||
HEADERS:=$(wildcard *.h) |
|
||||
|
|
||||
OBJECTS:=$(subst .c,.o,$(C_SOURCES)) |
|
||||
OBJECTS+=$(subst .cc,.o,$(CXX_SOURCES)) |
|
||||
OBJECTS:=$(filter-out $(OBJ_MAIN_CLI),$(OBJECTS)) |
|
||||
OBJECTS:=$(filter-out $(OBJ_MAIN_TUI),$(OBJECTS)) |
|
||||
OBJECTS:=$(filter-out $(OBJ_MAIN_TEST),$(OBJECTS)) |
|
||||
|
|
||||
DEPENDS:=$(subst .c,.d,$(SOURCE)) |
|
||||
CFLAGS+= -MMD -MP |
|
||||
|
|
||||
ifneq ($(MAKECMDGOALS),clean) |
|
||||
-include $(DEPENDS) |
|
||||
endif |
|
||||
|
|
||||
.PHONY: all install uninstall clean |
.PHONY: all install uninstall clean |
||||
.DEFAULT_GOAL:= all |
.DEFAULT_GOAL:= all |
||||
|
|
||||
#all: $(EXE_MAIN_CLI) $(EXE_MAIN_TUI) $(EXE_MAIN_TEST)
|
ifneq ($(MAKECMDGOALS),clean) |
||||
all: $(EXE_MAIN_CLI) $(EXE_MAIN_TUI) |
-include $(DEPS) |
||||
|
endif |
||||
|
|
||||
$(EXE_MAIN_CLI): $(OBJECTS) $(OBJ_MAIN_CLI) |
all: $(EXE) |
||||
|
|
||||
$(EXE_MAIN_TUI): $(OBJECTS) $(OBJ_MAIN_TUI) |
$(LIB): $(OBJS) |
||||
|
$(AR) -rc $@ $(OBJS_LIB) |
||||
|
|
||||
$(EXE_MAIN_TEST): $(OBJECTS) $(OBJ_MAIN_TEST) |
$(EXE) : $(LIB) |
||||
|
|
||||
clean: |
clean: |
||||
rm -vf \
|
rm -rf \
|
||||
$(DEPENDS) \
|
$(OBJS) \
|
||||
$(OBJECTS) \
|
$(EXE) \
|
||||
$(OBJ_MAIN_TUI) \
|
$(LIB) \
|
||||
$(OBJ_MAIN_CLI) \
|
$(DEPS) \
|
||||
$(EXE_MAIN_TUI) \
|
*.dSYM \
|
||||
$(EXE_MAIN_CLI) \
|
*.h.gch |
||||
$(EXE_MAIN_TEST) |
|
@ -0,0 +1,31 @@ |
|||||
|
include ../Makefile.conf |
||||
|
|
||||
|
SRC:=$(wildcard *.c*) |
||||
|
SRC_EXE:=$(filter test_%, $(SRC)) |
||||
|
EXE:=$(basename $(SRC_EXE)) |
||||
|
|
||||
|
$(info src exe: $(SRC_EXE)) |
||||
|
$(info lib: $(LIB)) |
||||
|
$(info exe: $(EXE)) |
||||
|
|
||||
|
LDFLAGS+=-L../src |
||||
|
CFLAGS+=-I../src |
||||
|
CXXFLAGS+=-I../src |
||||
|
|
||||
|
.PHONY: lib all clean ../src/$(LIB) |
||||
|
.DEFAULT_GOAL := all |
||||
|
|
||||
|
all: $(EXE) |
||||
|
|
||||
|
../src/$(LIB): |
||||
|
$(MAKE) -C ../src $(LIB) |
||||
|
|
||||
|
$(EXE): ../src/$(LIB) |
||||
|
|
||||
|
clean: |
||||
|
rm -rf \
|
||||
|
$(OBJS) \
|
||||
|
$(EXE) \
|
||||
|
$(DEPS) \
|
||||
|
*.dSYM \
|
||||
|
*.h.gch |
@ -0,0 +1,61 @@ |
|||||
|
#include <cstdlib> |
||||
|
#include <iostream> |
||||
|
#include <cstdio> |
||||
|
#include <cerrno> |
||||
|
#include <unistd.h> |
||||
|
#include <sys/types.h> |
||||
|
#include <sys/socket.h> |
||||
|
#include <netinet/in.h> |
||||
|
#include <pEp/pEpLog.hh> |
||||
|
#include <netdb.h> |
||||
|
|
||||
|
#define SOKOL_IMPL |
||||
|
#include "sokol_time.h" |
||||
|
#undef SOKOL_IMPL |
||||
|
|
||||
|
|
||||
|
void init_sockaddr(sockaddr_in *name, std::string hostname, uint16_t port) |
||||
|
{ |
||||
|
|
||||
|
hostent *hostinfo = nullptr; |
||||
|
name->sin_family = AF_INET; |
||||
|
name->sin_port = htons(port); |
||||
|
hostinfo = gethostbyname(hostname.c_str()); |
||||
|
if (hostinfo == nullptr) { |
||||
|
pEpLog("Unknown host: " + hostname); |
||||
|
exit(1); |
||||
|
} |
||||
|
name->sin_addr = *(struct in_addr *)hostinfo->h_addr; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
int make_socket(uint16_t port) |
||||
|
{ |
||||
|
int sock; |
||||
|
sockaddr_in name; |
||||
|
|
||||
|
sock = socket(PF_INET, SOCK_STREAM, 0); |
||||
|
if (sock < 0) { |
||||
|
pEpLog(strerror(errno)); |
||||
|
exit(1); |
||||
|
} |
||||
|
|
||||
|
name.sin_family = AF_INET; |
||||
|
name.sin_port = htons(port); |
||||
|
name.sin_addr.s_addr = htonl(INADDR_ANY); |
||||
|
if (bind(sock, (struct sockaddr *)&name, sizeof(name)) < 0) { |
||||
|
pEpLog(strerror(errno)); |
||||
|
exit(1); |
||||
|
} |
||||
|
|
||||
|
return sock; |
||||
|
} |
||||
|
|
||||
|
int main(int argc, char *argv[]) |
||||
|
{ |
||||
|
pEp::Adapter::pEpLog::set_enabled(true); |
||||
|
pEpLog("fdsfsd"); |
||||
|
int socket = make_socket(23232); |
||||
|
|
||||
|
return 0; |
||||
|
} |
Loading…
Reference in new issue