summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt190
-rwxr-xr-xConfig10
-rw-r--r--data/CMakeLists.txt3
-rw-r--r--include/CMakeLists.txt56
-rw-r--r--include/extern.h4
-rw-r--r--include/modules.h4
-rw-r--r--include/services.h10
-rw-r--r--include/sysconf.h.cmake54
-rw-r--r--include/version.sh11
-rw-r--r--include/version.sh.c38
-rw-r--r--lang/CMakeLists.txt62
-rw-r--r--lang/langtool.c18
-rw-r--r--src/CMakeLists.txt22
-rw-r--r--src/bin/CMakeLists.txt15
-rw-r--r--src/core/CMakeLists.txt15
-rw-r--r--src/misc.c16
-rw-r--r--src/modulemanager.cpp24
-rw-r--r--src/modules/CMakeLists.txt15
-rw-r--r--src/protocol/CMakeLists.txt15
-rw-r--r--src/timeout.c4
-rw-r--r--src/tools/CMakeLists.txt26
-rw-r--r--src/tools/anopesmtp.c4
-rw-r--r--src/tools/db-convert.c6
-rw-r--r--src/tools/db-merger.c16
-rw-r--r--src/tools/smtp.h6
25 files changed, 414 insertions, 230 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e5ea631fd..778a45898 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,10 +20,26 @@ include(CheckTypeSize)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
-option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF)
-
-set(CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_CFLAGS} -Wall -ansi -pedantic -Wshadow -fno-leading-underscore -export-dynamic -I${Anope_SOURCE_DIR}/include -I${Anope_BINARY_DIR}/include -I${Anope_BINARY_DIR}/lang")
-#message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
+if(NOT WIN32)
+ option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF)
+endif(NOT WIN32)
+
+if(WIN32 AND MSVC)
+ set(CXXFLAGS "${CXXFLAGS} /W4 /MD /GR /EHs /D_WIN32 /DMSVCPP /I${Anope_SOURCE_DIR}/include /I${Anope_BINARY_DIR}/include /I${Anope_BINARY_DIR}/lang")
+ set(MODULE_CXXFLAGS "${CXXFLAGS} /DMODULE_COMPILE")
+else(WIN32 AND MSVC)
+ set(CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_FLAGS} -Wall -Wshadow -I${Anope_SOURCE_DIR}/include -I${Anope_BINARY_DIR}/include -I${Anope_BINARY_DIR}/lang")
+ if(UNIX)
+ set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic -fno-leading-underscore")
+ else(UNIX)
+ set(CXXFLAGS "${CXXFLAGS} -D_WIN32")
+ if(MINGW)
+ set(CXXFLAGS "${CXXFLAGS} -DMINGW")
+ endif(MINGW)
+ endif(UNIX)
+ set(MODULE_CXXFLAGS "${CXXFLAGS}")
+endif(WIN32 AND MSVC)
+message(STATUS "CMAKE_CXX_CREATE_SHARED_MODULE: ${CMAKE_CXX_CREATE_SHARED_MODULE}")
if(CMAKE_BUILD_TYPE)
set(CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
endif(CMAKE_BUILD_TYPE)
@@ -31,40 +47,48 @@ endif(CMAKE_BUILD_TYPE)
if(CMAKE_DL_LIBS)
set(LDFLAGS "${LDFLAGS} ${CMAKE_DL_LIBS}")
endif(CMAKE_DL_LIBS)
+if(MINGW)
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -Wl,--enable-auto-import")
+endif(MINGW)
#set(MY_COMPILER ${CMAKE_CXX_COMPILER})
#set(MY_COMP_ARG)
-set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${LDFLAGS}")
-set(CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> ${LDFLAGS}")
-
-check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG)
-if(HAVE_PIPE_FLAG)
- set(CXXFLAGS "${CXXFLAGS} -pipe")
-endif(HAVE_PIPE_FLAG)
-
-check_library_exists(nsl inet_ntoa "" HAVE_NSL_LIB)
-if(HAVE_NSL_LIB)
- set(LDFLAGS "${LDFLAGS} -lnsl")
-endif(HAVE_NSL_LIB)
-check_library_exists(socket socket "" HAVE_SOCKET_LIB)
-if(HAVE_SOCKET_LIB)
- set(LDFLAGS "${LDFLAGS} -lsocket")
-endif(HAVE_SOCKET_LIB)
-check_library_exists(resolv res_query "" HAVE_RESOLV_LIB)
-if(HAVE_RESOLV_LIB)
- set(LDFLAGS "${LDFLAGS} -lresolv")
-endif(HAVE_RESOLV_LIB)
-check_library_exists(bsd revoke "" HAVE_BSD_LIB)
-if(HAVE_BSD_LIB)
- set(LDFLAGS "${LDFLAGS} -lbsd")
-endif(HAVE_BSD_LIB)
-
-try_run(RUN_VA_LIST_AS_ARRAY COMPILE_VA_LIST_AS_ARRAY
- ${Anope_SOURCE_DIR} ${Anope_SOURCE_DIR}/va_list_check.c
-)
-if(COMPILE_VA_LIST_AS_ARRAY AND NOT RUN_VA_LIST_AS_ARRAY)
- set(HAVE_VA_LIST_AS_ARRAY 1)
-endif(COMPILE_VA_LIST_AS_ARRAY AND NOT RUN_VA_LIST_AS_ARRAY)
+if(WIN32)
+else(WIN32)
+ #set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${LDFLAGS}")
+ #set(CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> ${LDFLAGS}")
+endif(WIN32)
+
+if(NOT WIN32)
+ check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG)
+ if(HAVE_PIPE_FLAG)
+ set(CXXFLAGS "${CXXFLAGS} -pipe")
+ endif(HAVE_PIPE_FLAG)
+
+ check_library_exists(nsl inet_ntoa "" HAVE_NSL_LIB)
+ if(HAVE_NSL_LIB)
+ set(LDFLAGS "${LDFLAGS} -lnsl")
+ endif(HAVE_NSL_LIB)
+ check_library_exists(socket socket "" HAVE_SOCKET_LIB)
+ if(HAVE_SOCKET_LIB)
+ set(LDFLAGS "${LDFLAGS} -lsocket")
+ endif(HAVE_SOCKET_LIB)
+ check_library_exists(resolv res_query "" HAVE_RESOLV_LIB)
+ if(HAVE_RESOLV_LIB)
+ set(LDFLAGS "${LDFLAGS} -lresolv")
+ endif(HAVE_RESOLV_LIB)
+ check_library_exists(bsd revoke "" HAVE_BSD_LIB)
+ if(HAVE_BSD_LIB)
+ set(LDFLAGS "${LDFLAGS} -lbsd")
+ endif(HAVE_BSD_LIB)
+
+ try_run(RUN_VA_LIST_AS_ARRAY COMPILE_VA_LIST_AS_ARRAY
+ ${Anope_SOURCE_DIR} ${Anope_SOURCE_DIR}/va_list_check.c
+ )
+ if(COMPILE_VA_LIST_AS_ARRAY AND NOT RUN_VA_LIST_AS_ARRAY)
+ set(HAVE_VA_LIST_AS_ARRAY 1)
+ endif(COMPILE_VA_LIST_AS_ARRAY AND NOT RUN_VA_LIST_AS_ARRAY)
+endif(NOT WIN32)
if(NOT DEFUMASK)
if(RUNGROUP)
@@ -85,6 +109,8 @@ check_function_exists(strlcat HAVE_STRLCAT)
check_function_exists(strlcpy HAVE_STRLCPY)
check_include_file(sys/select.h HAVE_SYS_SELECT_H)
check_function_exists(umask HAVE_UMASK)
+check_type_size(uint8_t UINT8_T)
+check_type_size(u_int8_t U_INT8_T)
check_type_size(int16_t INT16_T)
check_type_size(uint16_t UINT16_T)
check_type_size(u_int16_t U_INT16_T)
@@ -92,25 +118,6 @@ check_type_size(int32_t INT32_T)
check_type_size(uint32_t UINT32_T)
check_type_size(u_int32_t U_INT32_T)
-if(BINDIR)
- set(SERVICES_BIN "${BINDIR}/services")
-else(BINDIR)
- set(SERVICES_BIN "$ENV{HOME}/services/services")
- set(BINDIR "$ENV{HOME}/services")
-endif(BINDIR)
-
-if(DATADIR)
- set(SERVICES_DIR "${DATADIR}")
- #set(MODULE_PATH "${DATADIR}/modules/")
-else(DATADIR)
- set(SERVICES_DIR "$ENV{HOME}/services")
- #set(MODULE_PATH "$ENV{HOME}/services/modules/")
- set(DATADIR "$ENV{HOME}/services")
-endif(DATADIR)
-
-configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_SOURCE_DIR}/include/sysconf.h)
-configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.cmake ${Anope_SOURCE_DIR}/src/bin/anoperc)
-
if(CXXFLAGS)
string(STRIP ${CXXFLAGS} CXXFLAGS)
endif(CXXFLAGS)
@@ -118,21 +125,23 @@ if(LDFLAGS)
string(STRIP ${LDFLAGS} LDFLAGS)
endif(LDFLAGS)
-find_program(GREP grep)
-find_program(SH sh)
-find_program(CHGRP chgrp)
-find_program(CHMOD chmod)
-#message(STATUS "grep: ${GREP}")
-find_program(PERL perl)
-if(PERL)
- if(USE_RUN_CC_PL)
- #set(MY_COMPILER ${Anope_SOURCE_DIR}/run-cc.pl)
- #set(MY_COMP_ARG ${CMAKE_CXX_COMPILER})
- set(CMAKE_CXX_COMPILE_OBJECT "${Anope_SOURCE_DIR}/run-cc.pl <CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
- set(CMAKE_CXX_LINK_EXECUTABLE "${Anope_SOURCE_DIR}/run-cc.pl <CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> ${LDFLAGS}")
- set(CMAKE_CXX_CREATE_SHARED_MODULE "${Anope_SOURCE_DIR}/run-cc.pl <CMAKE_CXX_COMPILER> ${CXXFLAGS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> ${LDFLAGS}")
- endif(USE_RUN_CC_PL)
-endif(PERL)
+if(NOT WIN32)
+ find_program(GREP grep)
+ find_program(SH sh)
+ find_program(CHGRP chgrp)
+ find_program(CHMOD chmod)
+ #message(STATUS "grep: ${GREP}")
+ find_program(PERL perl)
+ if(PERL)
+ if(USE_RUN_CC_PL)
+ #set(MY_COMPILER ${Anope_SOURCE_DIR}/run-cc.pl)
+ #set(MY_COMP_ARG ${CMAKE_CXX_COMPILER})
+ set(CMAKE_CXX_COMPILE_OBJECT "${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_COMPILE_OBJECT}")
+ set(CMAKE_CXX_LINK_EXECUTABLE "${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_LINK_EXECUTABLE}")
+ set(CMAKE_CXX_CREATE_SHARED_MODULE "${Anope_SOURCE_DIR}/run-cc.pl ${CMAKE_CXX_CREATE_SHARED_MODULE}")
+ endif(USE_RUN_CC_PL)
+ endif(PERL)
+endif(NOT WIN32)
#set(CMAKE_BUILD_TYPE DEBUG)
#message(STATUS "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
@@ -150,17 +159,48 @@ endif(PERL)
# CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS: -shared
# CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG: -Wl,-soname,
+if(NOT BINDIR)
+ set(BINDIR "$ENV{HOME}/services")
+endif(NOT BINDIR)
+
+if(DATADIR)
+ set(SERVICES_DIR "${DATADIR}")
+else(DATADIR)
+ set(SERVICES_DIR "$ENV{HOME}/services")
+ #set(MODULE_PATH "$ENV{HOME}/services/modules/")
+ #set(DATADIR "${SERVICES_DIR}")
+endif(DATADIR)
+if(WIN32)
+ set(SERVICES_DIR "${SERVICES_DIR}/data")
+endif(WIN32)
+if(NOT DATADIR)
+ set(DATADIR "${SERVICES_DIR}")
+endif(NOT DATADIR)
+
+#set(SERVICES_BINARY "")
+
add_subdirectory(data)
add_subdirectory(lang)
add_subdirectory(src)
add_subdirectory(include)
+#message("[in root] SERVICES_BIN: ${SERVICES_BIN}")
+
+#if(BINDIR)
+# set(SERVICES_BIN "${BINDIR}/${SERVICES_BINARY}")
+#else(BINDIR)
+# set(SERVICES_BIN "$ENV{HOME}/services/${SERVICES_BINARY}")
+# set(BINDIR "$ENV{HOME}/services")
+#endif(BINDIR)
+
install(CODE "file(MAKE_DIRECTORY \"${DATADIR}/backups\")")
install(CODE "file(MAKE_DIRECTORY \"${DATADIR}/logs\")")
install(CODE "file(MAKE_DIRECTORY \"${DATADIR}/modules/runtime\")")
-if(RUNGROUP)
- install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/backups\")")
- install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/logs\")")
- install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/modules/runtime\")")
- install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}\")")
-endif(RUNGROUP)
+if(NOT WIN32)
+ if(RUNGROUP)
+ install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/backups\")")
+ install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/logs\")")
+ install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/modules/runtime\")")
+ install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}\")")
+ endif(RUNGROUP)
+endif(NOT WIN32)
diff --git a/Config b/Config
index 74a32a8aa..37fb95300 100755
--- a/Config
+++ b/Config
@@ -100,7 +100,7 @@ DATDEST=$HOME/services
RUNGROUP=
UMASK=
DEBUG="no"
-RUN_CC_PL="no"
+USE_RUN_CC_PL="no"
CAN_QUICK="no"
###########################################################################
@@ -302,7 +302,7 @@ echo ""
####
TEMP_YN="n"
-if [ "$RUN_CC_PL" = "yes" ] ; then
+if [ "$USE_RUN_CC_PL" = "yes" ] ; then
TEMP_YN="y"
fi
echo "You can optionally have the build run through run-cc.pl, which will"
@@ -314,9 +314,9 @@ echo2 "[$TEMP_YN] "
read YN
if [ "$YN" ] ; then
if [ "$YN" = "y" ] ; then
- RUN_CC_PL="yes"
+ USE_RUN_CC_PL="yes"
else
- RUN_CC_PL="no"
+ USE_RUN_CC_PL="no"
fi
fi
echo ""
@@ -335,7 +335,7 @@ DATDEST="$DATDEST"
RUNGROUP="$RUNGROUP"
UMASK=$UMASK
DEBUG="$DEBUG"
-RUN_CC_PL="$RUN_CC_PL"
+USE_RUN_CC_PL="$USE_RUN_CC_PL"
EOT
echo "done."
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index cecdad423..e0eb5e9cd 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,5 +1,4 @@
-file(GLOB DATA RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*")
-list(REMOVE_ITEM DATA CMakeLists.txt CMakeFiles Makefile cmake_install.cmake)
+set(DATA example.chk example.conf)
install(FILES ${DATA}
DESTINATION "${DATADIR}"
)
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 8deeef120..bfdbadee6 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -8,32 +8,45 @@ set(messages.h_HEADERS modules.h)
set(module.h_HEADERS services.h commands.h ${Anope_BINARY_DIR}/lang/language.h modules.h ${CMAKE_CURRENT_BINARY_DIR}/version.h)
set(modules.h_HEADERS services.h)
set(pseudo.h_HEADERS commands.h ${Anope_BINARY_DIR}/lang/language.h timeout.h encrypt.h datafiles.h slist.h)
-set(services.h_HEADERS sysconf.h config.h sockets.h defs.h slist.h events.h bots.h account.h regchannel.h users.h extern.h configreader.h)
+set(services.h_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/sysconf.h config.h sockets.h defs.h slist.h events.h bots.h account.h regchannel.h users.h extern.h configreader.h)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
- #COMMAND ${CMAKE_COMMAND} -E copy ${Anope_SOURCE_DIR}/version.log ../
- COMMAND ${SH} ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${Anope_SOURCE_DIR}/version.log
- #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_SOURCE_DIR}/
- #COMMAND ${CMAKE_COMMAND} -E remove ../version.log
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS}
-# MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h
-)
+if(WIN32)
+ set_source_files_properties(version.sh.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
+ add_executable(version.sh version.sh.c)
+ set_target_properties(version.sh PROPERTIES LINK_FLAGS "${LDFLAGS}")
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ COMMAND version.sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ MAIN_DEPENDENCY version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS}
+ )
+else(WIN32)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ #COMMAND ${CMAKE_COMMAND} -E copy ${Anope_SOURCE_DIR}/version.log ../
+ COMMAND ${SH} ${CMAKE_CURRENT_SOURCE_DIR}/version.sh ${Anope_SOURCE_DIR}/version.log ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_SOURCE_DIR}/
+ #COMMAND ${CMAKE_COMMAND} -E remove ../version.log
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h ${SRC_SRCS}
+ # MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/version.sh DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/services.h ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.h ${CMAKE_CURRENT_SOURCE_DIR}/messages.h
+ )
+endif(WIN32)
foreach(HEADER ${HEADERS_REL})
- add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
- COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
- )
+ if(NOT WIN32)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
+ COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}
+ )
+ endif(NOT WIN32)
set(HEADERS_FULL ${HEADERS_FULL} ${CMAKE_CURRENT_SOURCE_DIR}/${HEADER})
set(HEADERS)
if(${HEADER}_HEADERS)
- foreach(HEADER ${${HEADER}_HEADERS})
- string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- if(FIRST_CHAR STREQUAL "/")
- set(HEADERS ${HEADERS} ${HEADER})
- else(FIRST_CHAR STREQUAL "/")
- set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- endif(FIRST_CHAR STREQUAL "/")
- endforeach(HEADER)
+ foreach(HEADER_REL ${${HEADER}_HEADERS})
+ string(SUBSTRING ${HEADER_REL} 0 1 FIRST_CHAR)
+ string(SUBSTRING ${HEADER_REL} 1 1 SECOND_CHAR)
+ if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
+ set(HEADERS ${HEADERS} ${HEADER_REL})
+ else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
+ set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER_REL})
+ endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
+ endforeach(HEADER_REL)
endif(${HEADER}_HEADERS)
if(HEADERS)
set_source_files_properties(${HEADER} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
@@ -66,4 +79,5 @@ message(STATUS "HEADERS_FULL: ${HEADERS_FULL}")
add_custom_target(headers DEPENDS ${HEADERS_FULL})
#add_dependencies(include include_version_h)
-set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM yes ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/language.h")
+set(HEADERS_CLEAN ${CMAKE_CURRENT_BINARY_DIR}/version.h)
+set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM yes ADDITIONAL_MAKE_CLEAN_FILES "${HEADERS_CLEAN}")
diff --git a/include/extern.h b/include/extern.h
index 0e913413a..8bbf3fde5 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -670,8 +670,8 @@ E int nickIsServices(const char *nick, int bot);
E void add_entropy_userkeys();
E void rand_init();
E unsigned char getrandom8();
-E u_int16_t getrandom16();
-E u_int32_t getrandom32();
+E uint16 getrandom16();
+E uint32 getrandom32();
E char *str_signed(unsigned char *str);
diff --git a/include/modules.h b/include/modules.h
index 05ef6b524..dc00807c9 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -24,10 +24,10 @@ typedef HMODULE ano_module_t;
#define ano_modopen(file) LoadLibrary(file)
/* ano_moderr in modules.c */
-#define ano_modsym(file, symbol) (void *)GetProcAddress(file, symbol)
+#define ano_modsym(file, symbol) (HMODULE)GetProcAddress(file, symbol)
#define ano_modclose(file) FreeLibrary(file) ? 0 : 1
#define ano_modclearerr() SetLastError(0)
-#define MODULE_EXT ".dll"
+#define MODULE_EXT ".so"
#else
typedef void * ano_module_t;
diff --git a/include/services.h b/include/services.h
index 66e12aeb2..7d504e3a2 100644
--- a/include/services.h
+++ b/include/services.h
@@ -81,7 +81,7 @@
#include <sys/stat.h> /* for umask() on some systems */
#include <sys/types.h>
-#ifndef _WIN32
+#ifdef HAVE_GETTIMEOFDAY
#include <sys/time.h>
#endif
@@ -197,7 +197,8 @@ extern int strncasecmp(const char *, const char *, size_t);
*/
#ifdef _WIN32
#define MODULE_INIT(x, y) \
- extern "C" DllExport Module *init_module(const std::string &modname, const std::string &creator) \
+ extern "C" DllExport Module *init_module(const std::string &, const std::string &); \
+ extern "C" Module *init_module(const std::string &modname, const std::string &creator) \
{ \
return new y(x, creator); \
} \
@@ -211,9 +212,10 @@ extern int strncasecmp(const char *, const char *, size_t);
} \
return TRUE; \
} \
- extern "C" DllExport void destroy_module(y *m) \
+ extern "C" DllExport void destroy_module(y *); \
+ extern "C" void destroy_module(y *m) \
{ \
- delete m; \
+ delete m; \
}
#else
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index b4241f4b2..e7464492d 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -26,6 +26,8 @@
// Temporary, remove from here later as well as elsewhere in the code
#define DL_PREFIX ""
+#cmakedefine HAVE_UINT8_T 1
+#cmakedefine HAVE_U_INT8_T 1
#cmakedefine HAVE_INT16_T 1
#cmakedefine HAVE_UINT16_T 1
#cmakedefine HAVE_U_INT16_T 1
@@ -43,10 +45,28 @@
# include <stddef.h>
#endif
+#ifdef HAVE_UINT8_T
+typedef uint8_t uint8;
+#else
+# ifdef HAVE_U_INT8_T
+typedef u_int8_t uint8;
+# else
+# ifdef _WIN32
+typedef unsigned __int8 uint8;
+# else
+typedef unsigned short uint8;
+# endif
+# endif
+#endif
+
#ifdef HAVE_INT16_T
typedef int16_t int16;
#else
-typedef short int16;
+# ifdef _WIN32
+typedef signed __int16 int16;
+# else
+typedef int int16;
+# endif
#endif
#ifdef HAVE_UINT16_T
@@ -55,14 +75,22 @@ typedef uint16_t uint16;
# ifdef HAVE_U_INT16_T
typedef u_int16_t uint16;
# else
-typedef unsigned short uint16;
+# ifdef _WIN32
+typedef unsigned __int16 uint16;
+# else
+typedef unsigned int uint16;
+# endif
# endif
#endif
#ifdef HAVE_INT32_T
typedef int32_t int32;
#else
+# ifdef _WIN32
+typedef signed __int32 int32;
+# else
typedef long int32;
+# endif
#endif
#ifdef HAVE_UINT32_T
@@ -71,8 +99,30 @@ typedef uint32_t uint32;
# ifdef HAVE_U_INT32_T
typedef u_int32_t uint32;
# else
+# ifdef _WIN32
+typedef unsigned __int32 uint32;
+# else
typedef unsigned long uint32;
+# endif
+# endif
+#endif
+
+#ifdef _WIN32
+# ifdef MSVCPP
+# define snprintf _snprintf
+# endif
+# define popen _popen
+# define pclose _pclose
+# define ftruncate _chsize
+# ifdef MSVCPP
+# define PATH_MAX MAX_PATH
+# endif
+# define MAXPATHLEN MAX_PATH
+# define bzero(buf, size) memset(buf, 0, size)
+# ifdef MSVCPP
+# define strcasecmp stricmp
# endif
+# define sleep(x) Sleep(x * 1000)
#endif
#endif
diff --git a/include/version.sh b/include/version.sh
index 962896e6b..77e2d5f3a 100644
--- a/include/version.sh
+++ b/include/version.sh
@@ -3,8 +3,8 @@
# Build version string and increment Services build number.
#
-if [ $# -lt 1 ] ; then
- echo "Syntax: $0 <version.log>"
+if [ $# -lt 2 ] ; then
+ echo "Syntax: $0 <version.log> <version.h>"
exit 1
fi
# Grab version information from the version control file.
@@ -19,8 +19,9 @@ fi
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_EXTRA} (${VERSION_BUILD})"
VERSIONDOTTED="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_EXTRA}.${VERSION_BUILD}"
-if [ -f version.h ] ; then
- BUILD=`fgrep '#define BUILD' version.h | cut -f2 -d\"`
+VERSIONH="$2"
+if [ -f $VERSIONH ] ; then
+ BUILD=`fgrep '#define BUILD' $VERSIONH | cut -f2 -d\"`
BUILD=`expr $BUILD + 1 2>/dev/null`
else
BUILD=1
@@ -28,7 +29,7 @@ fi
if [ ! "$BUILD" ] ; then
BUILD=1
fi
-cat >version.h <<EOF
+cat >$VERSIONH <<EOF
/* Version information for Services.
*
* (C) 2003-2008 Anope Team
diff --git a/include/version.sh.c b/include/version.sh.c
index f95ae7d63..2b2f0c198 100644
--- a/include/version.sh.c
+++ b/include/version.sh.c
@@ -19,8 +19,6 @@
#include <cstdlib>
#include <cctype>
-#define CTRL "version.log"
-
long version_major, version_minor, version_patch, version_build, build;
char *version_extra = NULL;
char version[1024];
@@ -32,16 +30,20 @@ long get_value(char *);
char *get_value_str(char *);
char *strip(char *);
void parse_version(FILE *);
-void write_version(FILE *);
+void write_version(FILE *, const char *);
void parse_line(FILE *, char *);
-int main()
+int main(int argc, char *argv[])
{
- FILE *fd = fopen(CTRL, "r");
+ if (argc < 4) {
+ fprintf(stderr, "Syntax: %s <version.log> <version.sh> <version.h>\n", argv[0]);
+ exit(1);
+ }
+ FILE *fd = fopen(argv[1], "r");
if (!fd) {
- fprintf(stderr, "Error: Unable to find control file: " CTRL "\n");
+ fprintf(stderr, "Error: Unable to find control file: %s\n", argv[1]);
exit(0);
}
@@ -54,7 +56,7 @@ int main()
_snprintf(version_dotted, 1024, "%ld.%ld.%ld%s.%ld", version_major, version_minor,
version_patch, (version_extra ? version_extra : ""), version_build);
- fd = fopen("version.h", "r");
+ fd = fopen(argv[3], "r");
if (fd) {
parse_version(fd);
@@ -63,10 +65,10 @@ int main()
build = 1;
- fd = fopen("version.h", "w");
- write_version(fd);
+ fd = fopen(argv[3], "w");
+ write_version(fd, argv[2]);
fclose(fd);
-
+
if (version_extra)
free(version_extra);
}
@@ -109,7 +111,7 @@ char *strip(char *str)
long get_value(char *string)
{
// XXX : if the fields in version.log are empty strtok returns a double quote, dont try to atol it then
- if (*string != '"')
+ if (string[1] != '"')
return atol(get_value_str(string));
else
return 0;
@@ -118,6 +120,7 @@ long get_value(char *string)
char *get_value_str(char *string)
{
int len;
+ char *newstr;
if (*string == '"')
string++;
@@ -128,7 +131,10 @@ char *get_value_str(char *string)
string[len - 1] = 0;
if (!*string)
return NULL;
- return strdup(string);
+ newstr = (char *)malloc(len + 1);
+ strcpy(newstr, string);
+ return newstr;
+ //return strdup(string);
}
void parse_version(FILE * fd)
@@ -161,9 +167,9 @@ void parse_version(FILE * fd)
build = 1;
}
-void write_version(FILE * fd)
+void write_version(FILE * fd, const char *input)
{
- FILE *fdin = fopen("include\\version.sh", "r");
+ FILE *fdin = fopen(input, "r");
char buf[1024];
short until_eof = 0;
@@ -178,7 +184,7 @@ void write_version(FILE * fd)
parse_line(fd, buf);
}
- if (!strcmp(buf, "cat >version.h <<EOF"))
+ if (!strcmp(buf, "cat >$VERSIONH <<EOF"))
until_eof = 1;
}
@@ -221,7 +227,7 @@ void parse_line(FILE * fd, char *line)
fprintf(fd, "%s", version);
else if (!strcmp(varbegin, "VERSIONDOTTED"))
fprintf(fd, "%s", version_dotted);
- fputc(tmp, fd);
+ if (tmp) fputc(tmp, fd);
}
c = var;
} else
diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt
index e4d75bf0d..874c9f763 100644
--- a/lang/CMakeLists.txt
+++ b/lang/CMakeLists.txt
@@ -1,9 +1,9 @@
-if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
- set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
-else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
- file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
- set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
-endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
+#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
+# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
+#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
+# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
+# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
+#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
#add_custom_command(OUTPUT ${BUILD_DIR}/langcomp
# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} langcomp.c -o ${BUILD_DIR}/langcomp
@@ -13,6 +13,7 @@ endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
set_source_files_properties(langcomp.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
#add_executable(${BUILD_DIR}/langcomp langcomp.c)
add_executable(langcomp langcomp.c)
+set_target_properties(langcomp PROPERTIES LINK_FLAGS "${LDFLAGS}")
#set_target_properties(langcomp PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
#set_target_properties(${BUILD_DIR}/langcomp PROPERTIES LINKER_LANGUAGE CXX)
@@ -20,10 +21,20 @@ add_executable(langcomp langcomp.c)
# COMMAND ${GREP} '^[A-Z]' en_us.l > ${BUILD_DIR}/index
# MAIN_DEPENDENCY en_us.l
#)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
- COMMAND ${GREP} '^[A-Z]' ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l > ${CMAKE_CURRENT_BINARY_DIR}/index
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l
-)
+if(WIN32)
+ set_source_files_properties(langtool.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
+ add_executable(langtool langtool.c)
+ set_target_properties(langtool PROPERTIES LINK_FLAGS "${LDFLAGS}")
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
+ COMMAND langtool index ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l ${CMAKE_CURRENT_BINARY_DIR}/index
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l DEPENDS langtool
+ )
+else(WIN32)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
+ COMMAND ${GREP} '^[A-Z]' ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l > ${CMAKE_CURRENT_BINARY_DIR}/index
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l
+ )
+endif(WIN32)
#add_custom_target(lang_index DEPENDS ${BUILD_DIR}/index)
#add_custom_target(language)
@@ -56,11 +67,18 @@ endforeach(LANG_L)
# COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/language.h ${Anope_SOURCE_DIR}/include/
# MAIN_DEPENDENCY ${BUILD_DIR}/index
#)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
- COMMAND ${PERL} -e < ${CMAKE_CURRENT_BINARY_DIR}/index > ${CMAKE_CURRENT_BINARY_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;'
- #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/language.h ${Anope_SOURCE_DIR}/include/
- MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index
-)
+if(WIN32)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
+ COMMAND langtool language.h ${CMAKE_CURRENT_BINARY_DIR}/index ${CMAKE_CURRENT_BINARY_DIR}/language.h
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index DEPENDS langtool
+ )
+else(WIN32)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
+ COMMAND ${PERL} -e < ${CMAKE_CURRENT_BINARY_DIR}/index > ${CMAKE_CURRENT_BINARY_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;'
+ #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/language.h ${Anope_SOURCE_DIR}/include/
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index
+ )
+endif(WIN32)
#add_custom_target(lang_language_h DEPENDS ${BUILD_DIR}/language.h)
#add_dependencies(language lang_language_h)
#add_dependencies(language ${BUILD_DIR}/language.h)
@@ -76,9 +94,11 @@ install(FILES ${LANGS}
DESTINATION "${DATADIR}/languages"
PERMISSIONS ${PERMS}
)
-if(RUNGROUP)
- #install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}/languages\")")
- install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/languages\")")
-else(RUNGROUP)
- install(CODE "execute_process(COMMAND ${CHMOD} 0700 \"${DATADIR}/languages\")")
-endif(RUNGROUP)
+if(NOT WIN32)
+ if(RUNGROUP)
+ #install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}/languages\")")
+ install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/languages\")")
+ else(RUNGROUP)
+ install(CODE "execute_process(COMMAND ${CHMOD} 0700 \"${DATADIR}/languages\")")
+ endif(RUNGROUP)
+endif(NOT WIN32)
diff --git a/lang/langtool.c b/lang/langtool.c
index 21890c054..3efae3c1b 100644
--- a/lang/langtool.c
+++ b/lang/langtool.c
@@ -6,8 +6,8 @@
* Please read COPYING and README for furhter details.
*
* Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
+ * Based on the original code of Services by Andy Church.
+ *
* Written by Dominick Meglio <codemastr@unrealircd.com>
*
*/
@@ -29,14 +29,14 @@ char *strip(char *str)
int main(int argc, char *argv[])
{
- if (argc < 2)
+ if (argc < 4)
exit(1);
/* Build the index file */
if (!strcmp(argv[1], "index"))
{
- FILE *fd = fopen("en_us.l", "rb");
- FILE *fdout = fopen("index", "wb");
+ FILE *fd = fopen(argv[2], "rb");
+ FILE *fdout = fopen(argv[3], "wb");
char buf[1024];
if (!fd || !fdout)
exit(2);
@@ -52,10 +52,10 @@ int main(int argc, char *argv[])
/* Build the language.h file */
else if (!strcmp(argv[1], "language.h"))
{
- FILE *fd = fopen("index", "r");
- FILE *fdout = fopen("language.h", "w");
+ FILE *fd = fopen(argv[2], "r");
+ FILE *fdout = fopen(argv[3], "w");
char buf[1024];
- int i = 0;
+ int i = 0;
if (!fd || !fdout)
exit(2);
@@ -72,5 +72,5 @@ int main(int argc, char *argv[])
fclose(fdout);
}
return 0;
-
+
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 334492c5b..02f3df75d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -77,11 +77,12 @@ foreach(SRC ${SRC_SRCS})
if(${SRC}_HEADERS)
foreach(HEADER ${${SRC}_HEADERS})
string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- if(FIRST_CHAR STREQUAL "/")
+ string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
+ if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${HEADER})
- else(FIRST_CHAR STREQUAL "/")
+ else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- endif(FIRST_CHAR STREQUAL "/")
+ endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
endforeach(HEADER)
endif(${SRC}_HEADERS)
if(HEADERS)
@@ -100,9 +101,24 @@ endforeach(SRC)
#add_custom_target(build ALL)
#add_dependencies(build language headers src_services)
add_executable(services ${SRC_SRCS})
+set_target_properties(services PROPERTIES LINK_FLAGS "${LDFLAGS}")
+ set_target_properties(services PROPERTIES ENABLE_EXPORTS ON)
+if(WIN32)
+ target_link_libraries(services wsock32)
+endif(WIN32)
#set_target_properties(services PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
add_dependencies(services language headers)
+get_target_property(SERVICES_BINARY services LOCATION)
+file(RELATIVE_PATH SERVICES_BINARY ${CMAKE_CURRENT_BINARY_DIR} ${SERVICES_BINARY})
+ set(SERVICES_BIN "${BINDIR}/${SERVICES_BINARY}")
+message("[in src] SERVICES_BIN: ${SERVICES_BIN}")
+
+configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/include/sysconf.h)
+if(NOT WIN32)
+ configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.cmake ${Anope_BINARY_DIR}/src/bin/anoperc)
+endif(NOT WIN32)
+
add_subdirectory(bin)
add_subdirectory(core)
add_subdirectory(modules)
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
index 7aa28c1cd..b587479c6 100644
--- a/src/bin/CMakeLists.txt
+++ b/src/bin/CMakeLists.txt
@@ -1,8 +1,9 @@
-install(PROGRAMS anoperc
- DESTINATION "${BINDIR}"
-)
-install(PROGRAMS mydbgen
- DESTINATION "${DATADIR}"
-)
-
+if(NOT WIN32)
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc
+ DESTINATION "${BINDIR}"
+ )
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/mydbgen
+ DESTINATION "${DATADIR}"
+ )
+endif(NOT WIN32)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index eaf6ac36a..c0942b62e 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -14,7 +14,7 @@ list(SORT CORE_SRCS)
#add_custom_target(core)
#add_dependencies(core build)
-set_source_files_properties(${CORE_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
+set_source_files_properties(${CORE_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
set(cs_set.c_HEADERS encrypt.h)
set(ns_register.c_HEADERS encrypt.h)
@@ -44,11 +44,12 @@ foreach(SRC ${CORE_SRCS})
if(${SRC}_HEADERS)
foreach(HEADER ${${SRC}_HEADERS})
string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- if(FIRST_CHAR STREQUAL "/")
+ string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
+ if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${HEADER})
- else(FIRST_CHAR STREQUAL "/")
+ else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- endif(FIRST_CHAR STREQUAL "/")
+ endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
endforeach(HEADER)
endif(${SRC}_HEADERS)
if(HEADERS)
@@ -57,7 +58,11 @@ foreach(SRC ${CORE_SRCS})
add_library(${SO} MODULE ${SRC})
add_dependencies(${SO} services)
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
- set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
+ set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" LINK_FLAGS "${LDFLAGS}")
+ if(WIN32)
+ target_link_libraries(${SO} services wsock32)
+ endif(WIN32)
+ #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
diff --git a/src/misc.c b/src/misc.c
index b3adc6ae4..5e6f4a4b8 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -21,9 +21,9 @@
#define issp(c) ((c) == 32)
struct arc4_stream {
- u_int8_t i;
- u_int8_t j;
- u_int8_t s[256];
+ uint8 i;
+ uint8 j;
+ uint8 s[256];
} rs;
/*************************************************************************/
@@ -931,7 +931,7 @@ static void arc4_init()
static void arc4_addrandom(void *dat, int datlen)
{
int n;
- u_int8_t si;
+ uint8 si;
rs.i--;
for (n = 0; n < 256; n++) {
@@ -1034,9 +1034,9 @@ unsigned char getrandom8()
* Get the random numbers 16 byte deep
* @return char
*/
-u_int16_t getrandom16()
+uint16 getrandom16()
{
- u_int16_t val;
+ uint16 val;
val = getrandom8() << 8;
val |= getrandom8();
@@ -1049,9 +1049,9 @@ u_int16_t getrandom16()
* Get the random numbers 32 byte deep
* @return char
*/
-u_int32_t getrandom32()
+uint32 getrandom32()
{
- u_int32_t val;
+ uint32 val;
val = getrandom8() << 24;
val |= getrandom8() << 16;
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 4fd6043e3..cfbcc9794 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -111,10 +111,26 @@ static bool IsOneOfModuleTypeLoaded(MODType mt)
return false;
}
+/* This code was found online at http://www.linuxjournal.com/article/3687#comment-26593
+ *
+ * This function will take a pointer from either dlsym or GetProcAddress and cast it in
+ * a way that won't cause C++ warnings/errors to come up.
+ */
+template <class TYPE>
+TYPE function_cast(ano_module_t symbol)
+{
+ union {
+ ano_module_t symbol;
+ TYPE function;
+ } cast;
+ cast.symbol = symbol;
+ return cast.function;
+}
+
int ModuleManager::LoadModule(const std::string &modname, User * u)
{
const char *err;
- Module * (*func) (const std::string &);
+ Module *(*func)(const std::string &);
int ret = 0;
if (modname.empty())
@@ -158,7 +174,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
}
ano_modclearerr();
- func = reinterpret_cast<Module *(*)(const std::string &)>(ano_modsym(handle, "init_module"));
+ func = function_cast<Module *(*)(const std::string &)>(ano_modsym(handle, "init_module"));
if (func == NULL && (err = ano_moderr()) != NULL)
{
alog("No magical init function found, not an Anope module");
@@ -255,11 +271,11 @@ void ModuleManager::DeleteModule(Module *m)
handle = m->handle;
ano_modclearerr();
- destroy_func = reinterpret_cast<void (*)(Module *)>(ano_modsym(m->handle, "destroy_module"));
+ destroy_func = function_cast<void (*)(Module *)>(ano_modsym(m->handle, "destroy_module"));
if (destroy_func == NULL && (err = ano_moderr()) != NULL)
{
alog("No magical destroy function found, chancing delete...");
- delete m; /* we just have to change they haven't overwrote the delete operator then... */
+ delete m; /* we just have to chance they haven't overwrote the delete operator then... */
}
else
{
diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt
index 1e153a933..dc7a2f54e 100644
--- a/src/modules/CMakeLists.txt
+++ b/src/modules/CMakeLists.txt
@@ -14,7 +14,7 @@ list(SORT MODULES_SRCS)
#add_custom_target(modules)
#add_dependencies(modules build)
-set_source_files_properties(${MODULES_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
+set_source_files_properties(${MODULES_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
foreach(SRC ${MODULES_SRCS})
string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
@@ -39,11 +39,12 @@ foreach(SRC ${MODULES_SRCS})
if(${SRC}_HEADERS)
foreach(HEADER ${${SRC}_HEADERS})
string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- if(FIRST_CHAR STREQUAL "/")
+ string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
+ if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${HEADER})
- else(FIRST_CHAR STREQUAL "/")
+ else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- endif(FIRST_CHAR STREQUAL "/")
+ endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
endforeach(HEADER)
endif(${SRC}_HEADERS)
if(HEADERS)
@@ -52,7 +53,11 @@ foreach(SRC ${MODULES_SRCS})
add_library(${SO} MODULE ${SRC})
add_dependencies(${SO} services)
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
- set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
+ set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" LINK_FLAGS "${LDFLAGS}")
+ if(WIN32)
+ target_link_libraries(${SO} services wsock32)
+ endif(WIN32)
+ #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt
index 403348704..bb94e116a 100644
--- a/src/protocol/CMakeLists.txt
+++ b/src/protocol/CMakeLists.txt
@@ -14,7 +14,7 @@ list(SORT PROTOCOL_SRCS)
#add_custom_target(modules)
#add_dependencies(protocol build)
-set_source_files_properties(${PROTOCOL_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
+set_source_files_properties(${PROTOCOL_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
foreach(SRC ${PROTOCOL_SRCS})
string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
@@ -39,11 +39,12 @@ foreach(SRC ${PROTOCOL_SRCS})
if(${SRC}_HEADERS)
foreach(HEADER ${${SRC}_HEADERS})
string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- if(FIRST_CHAR STREQUAL "/")
+ string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
+ if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${HEADER})
- else(FIRST_CHAR STREQUAL "/")
+ else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- endif(FIRST_CHAR STREQUAL "/")
+ endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
endforeach(HEADER)
endif(${SRC}_HEADERS)
if(HEADERS)
@@ -52,7 +53,11 @@ foreach(SRC ${PROTOCOL_SRCS})
add_library(${SO} MODULE ${SRC})
add_dependencies(${SO} services)
#set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
- set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
+ set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" LINK_FLAGS "${LDFLAGS}")
+ if(WIN32)
+ target_link_libraries(${SO} services wsock32)
+ endif(WIN32)
+ #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
diff --git a/src/timeout.c b/src/timeout.c
index b8f31765e..d34ca9afb 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -17,6 +17,8 @@
static Timeout *timeouts = NULL;
+typedef void (*voidF)();
+
/*************************************************************************/
/* Check the timeout list for any pending actions. */
@@ -37,7 +39,7 @@ void check_timeouts()
}
if (debug >= 4) {
alog("debug: Running timeout 0x%p (code=0x%p repeat=%d)",
- static_cast<void *>(to), reinterpret_cast<void *>(to->code), to->repeat);
+ static_cast<void *>(to), reinterpret_cast<voidF>(to->code), to->repeat);
}
to->code(to);
if (to->repeat) {
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index f73a671b4..18a064683 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -10,9 +10,9 @@ list(SORT TOOLS_SRCS)
set_source_files_properties(${TOOLS_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
-set(anopesmtp.c_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/smtp.h)
-set(db-convert.c_HEADERS sysconf.h)
-set(db-merger.c_HEADERS sysconf.h)
+set(anopesmtp.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h ${CMAKE_CURRENT_SOURCE_DIR}/smtp.h)
+set(db-convert.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h)
+set(db-merger.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h)
foreach(SRC ${TOOLS_SRCS})
#string(REGEX REPLACE "\\." "_" SRC_TARGET ${SRC})
@@ -34,17 +34,19 @@ foreach(SRC ${TOOLS_SRCS})
if(${SRC}_HEADERS)
foreach(HEADER ${${SRC}_HEADERS})
string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- if(FIRST_CHAR STREQUAL "/")
+ string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
+ if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${HEADER})
- else(FIRST_CHAR STREQUAL "/")
+ else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- endif(FIRST_CHAR STREQUAL "/")
+ endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
endforeach(HEADER)
endif(${SRC}_HEADERS)
if(HEADERS)
set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
endif(HEADERS)
add_executable(${EXE} ${SRC})
+ set_target_properties(${EXE} PROPERTIES LINK_FLAGS "${LDFLAGS}")
add_dependencies(${EXE} services)
#set_target_properties(${EXE} PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
install(TARGETS ${EXE}
@@ -52,6 +54,12 @@ foreach(SRC ${TOOLS_SRCS})
)
endforeach(SRC)
-if(RUNGROUP)
- install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${BINDIR}/tools\")")
-endif(RUNGROUP)
+if(WIN32)
+ target_link_libraries(anopesmtp wsock32)
+endif(WIN32)
+
+if(NOT WIN32)
+ if(RUNGROUP)
+ install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${BINDIR}/tools\")")
+ endif(RUNGROUP)
+endif(NOT WIN32)
diff --git a/src/tools/anopesmtp.c b/src/tools/anopesmtp.c
index c775921bd..6101fb4a9 100644
--- a/src/tools/anopesmtp.c
+++ b/src/tools/anopesmtp.c
@@ -20,7 +20,7 @@ static int curday = 0;
/*************************************************************************/
-#ifdef _WIN32
+/*#ifdef _WIN32
int strcasecmp(const char *s1, const char *s2)
{
register int c;
@@ -35,7 +35,7 @@ int strcasecmp(const char *s1, const char *s2)
return -1;
return 1;
}
-#endif
+#endif*/
static int get_logname(char *name, int count, struct tm *tm)
{
diff --git a/src/tools/db-convert.c b/src/tools/db-convert.c
index 38c2e675d..d561c5333 100644
--- a/src/tools/db-convert.c
+++ b/src/tools/db-convert.c
@@ -25,10 +25,10 @@
#ifndef _WIN32
#include <unistd.h>
#else
-#include "sysconf.h"
#include <windows.h>
#include <io.h>
#endif
+#include "sysconf.h"
#include <string>
#include <iostream>
@@ -63,10 +63,6 @@
} \
} while (0)
-typedef int16_t int16;
-typedef u_int16_t uint16;
-typedef int32_t int32;
-typedef u_int32_t uint32;
typedef struct memo_ Memo;
typedef struct dbFILE_ dbFILE;
typedef struct nickalias_ NickAlias;
diff --git a/src/tools/db-merger.c b/src/tools/db-merger.c
index 81d03bba8..63bdb48a4 100644
--- a/src/tools/db-merger.c
+++ b/src/tools/db-merger.c
@@ -55,11 +55,11 @@
#ifndef _WIN32
#include <unistd.h>
#else
-#include "sysconf.h"
#include <windows.h>
#include <io.h>
#define open _open
#endif
+#include "sysconf.h"
/* Some SUN fixs */
#ifdef __sun
@@ -131,10 +131,6 @@
} \
} while (0)
-typedef int16_t int16;
-typedef u_int16_t uint16;
-typedef int32_t int32;
-typedef u_int32_t uint32;
typedef struct memo_ Memo;
typedef struct dbFILE_ dbFILE;
typedef struct nickalias_ NickAlias;
@@ -270,7 +266,7 @@ struct botinfo_ {
struct badword_ {
uint16 in_use;
char *word;
- uint16 type;
+ uint16 type;
};
struct hostcore_ {
@@ -575,7 +571,7 @@ int main(int argc, char *argv[])
scanf("%s", input);
}
if (input[0] == '1') { /* get alias #2 out of the list, then free() it, then add #1 to the list */
- printf("Deleting nick alias %s (#2).\n", naptr->nick);
+ printf("Deleting nick alias %s (#2).\n", naptr->nick);
naptr->nc->aliascount--; /* tell the core it has one alias less */
delnick(naptr, 0); /* removes the alias from the list and free()s it */
na->nc = ncptr;
@@ -620,7 +616,7 @@ int main(int argc, char *argv[])
free(s);
} /* getc_db() */
} /* for() loop */
- close_db(f); /* End of section Ib */
+ close_db(f); /* End of section Ib */
} else
nonick = 1;
}
@@ -632,7 +628,7 @@ int main(int argc, char *argv[])
for (NickCore *nc = nclists[i]; nc; nc = ncnext) {
ncnext = nc->next;
if (nc->aliascount < 1) {
- printf("Deleting core %s (%s).\n", nc->display, nc->email);
+ printf("Deleting core %s (%s).\n", nc->display, nc->email);
delcore(nc);
}
}
@@ -718,7 +714,7 @@ int main(int argc, char *argv[])
last = &chanlists[i];
prev = NULL;
-
+
while ((c = getc_db(f)) == 1) {
int j;
diff --git a/src/tools/smtp.h b/src/tools/smtp.h
index ef6a0d0aa..70a9a2033 100644
--- a/src/tools/smtp.h
+++ b/src/tools/smtp.h
@@ -14,6 +14,8 @@
#ifndef SMTP_H
#define SMTP_H
+#include "sysconf.h"
+
/*************************************************************************/
/* Some Linux boxes (or maybe glibc includes) require this for the
@@ -82,10 +84,10 @@ extern int connect(int, struct sockaddr *, int);
#endif
-#ifdef _WIN32
+/*#ifdef _WIN32
#define PATH_MAX MAX_PATH
#define snprintf _snprintf
-#endif
+#endif*/
/*************************************************************************/