Skip to content

Commit

Permalink
Upgrade MHD version and CMake files for macOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
silvioprog committed Jan 27, 2024
1 parent bdd812c commit 355103e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# Cross-platform library which helps to develop web servers or frameworks.
#
# Copyright (C) 2016-2020 Silvio Clecio <[email protected]>
# Copyright (C) 2016-2024 Silvio Clecio <[email protected]>
#
# Sagui library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -71,8 +71,9 @@ else()
set(CC "CC=${CMAKE_C_COMPILER}")
endif()

if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_COMPILER_IS_CLANG ON)
if(CMAKE_C_COMPILER_LOADED AND CMAKE_C_COMPILER_ID MATCHES ".*[Cc][Ll][Aa][Nn][Gg].*")
set(CMAKE_COMPILER_IS_CLANG ON)
set(CMAKE_COMPILER_IS_GNUCC OFF)
endif()

if(NOT CMAKE_C_MACHINE)
Expand Down
6 changes: 3 additions & 3 deletions cmake/SgMHD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# Cross-platform library which helps to develop web servers or frameworks.
#
# Copyright (C) 2016-2023 Silvio Clecio <[email protected]>
# Copyright (C) 2016-2024 Silvio Clecio <[email protected]>
#
# Sagui library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -43,11 +43,11 @@ endif()
set(__SG_MHD_INCLUDED ON)

set(MHD_NAME "libmicrohttpd")
set(MHD_VER "0.9.76")
set(MHD_VER "0.9.77")
set(MHD_FULL_NAME "${MHD_NAME}-${MHD_VER}")
set(MHD_URL "https://ftp.gnu.org/gnu/libmicrohttpd/${MHD_FULL_NAME}.tar.gz")
set(MHD_URL_MIRROR "https://ftp.gnu.org/gnu/libmicrohttpd/${MHD_FULL_NAME}.tar.gz")
set(MHD_SHA256 "f0b1547b5a42a6c0f724e8e1c1cb5ce9c4c35fb495e7d780b9930d35011ceb4c")
set(MHD_SHA256 "9e7023a151120060d2806a6ea4c13ca9933ece4eacfc5c9464d20edddb76b0a0")
set(_libdir ${CMAKE_BINARY_DIR}/${MHD_FULL_NAME}/lib)
if(${CMAKE_VERSION} VERSION_LESS "3.7")
unset(MHD_URL_MIRROR)
Expand Down
4 changes: 2 additions & 2 deletions include/sagui.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Cross-platform library which helps to develop web servers or frameworks.
*
* Copyright (C) 2016-2023 Silvio Clecio <[email protected]>
* Copyright (C) 2016-2024 Silvio Clecio <[email protected]>
*
* Sagui library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -74,7 +74,7 @@ extern "C" {

#define SG_VERSION_MAJOR 3
#define SG_VERSION_MINOR 4
#define SG_VERSION_PATCH 1
#define SG_VERSION_PATCH 2
#define SG_VERSION_HEX \
((SG_VERSION_MAJOR << 16) | (SG_VERSION_MINOR << 8) | (SG_VERSION_PATCH))

Expand Down
23 changes: 12 additions & 11 deletions src/sg_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Cross-platform library which helps to develop web servers or frameworks.
*
* Copyright (C) 2016-2023 Silvio Clecio <[email protected]>
* Copyright (C) 2016-2024 Silvio Clecio <[email protected]>
*
* Sagui library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -135,7 +135,7 @@ int sg__rename(const char *old, const char *new) {
#endif /* _WIN32 */

#if defined(_WIN32) || defined(__ANDROID__) || \
(defined(__linux__) && !defined(__gnu_linux__))
(defined(__linux__) && !defined(__gnu_linux__)) || defined(__APPLE__)

char *sg__basename(const char *path) {
char *s1 = strrchr(path, '/');
Expand All @@ -149,7 +149,7 @@ char *sg__basename(const char *path) {
return (char *) path;
}

#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) */
#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */

char *sg__strdup(const char *str) {
return str ? strdup(str) : NULL;
Expand Down Expand Up @@ -295,36 +295,37 @@ double sg__fmod(double x, double y) {

char *sg_strerror(int errnum, char *errmsg, size_t errlen) {
#if defined(_WIN32) || defined(__ANDROID__) || \
(defined(__linux__) && !defined(__gnu_linux__))
(defined(__linux__) && !defined(__gnu_linux__)) || defined(__APPLE__)
int saved_errno;
#else /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) */
#else /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */
char *res;
#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) */
#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */
if (!errmsg || errlen < 1)
return NULL;
#if defined(_WIN32) || defined(__ANDROID__) || \
(defined(__linux__) && !defined(__gnu_linux__))
(defined(__linux__) && !defined(__gnu_linux__)) || defined(__APPLE__)
saved_errno = errno;
#else /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) */
#else /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */
res = strerror_r(errnum, errmsg, errlen - 1);
memcpy(errmsg, res, errlen - 1);
errmsg[errlen - 1] = '\0';
return errmsg;
#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) */
#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */
#ifdef _WIN32
errnum = strerror_s(errmsg, errlen, errnum);
errno = saved_errno;
if ((errnum != 0) && (errnum != EINVAL))
return "?";
return errmsg;
#endif /* _WIN32 */
#if defined(__ANDROID__) || (defined(__linux__) && !defined(__gnu_linux__))
#if defined(__ANDROID__) || (defined(__linux__) && !defined(__gnu_linux__)) || \
defined(__APPLE__)
errnum = strerror_r(errnum, errmsg, errlen);
errno = saved_errno;
if ((errnum != 0) && (errnum != EINVAL) && (errnum != ERANGE))
return "?";
return errmsg;
#endif /* __ANDROID__ || (__linux__ && !__gnu_linux__) */
#endif /* __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */
}

bool sg_is_post(const char *method) {
Expand Down
8 changes: 4 additions & 4 deletions src/sg_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Cross-platform library which helps to develop web servers or frameworks.
*
* Copyright (C) 2016-2021 Silvio Clecio <[email protected]>
* Copyright (C) 2016-2024 Silvio Clecio <[email protected]>
*
* Sagui library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -66,15 +66,15 @@ SG__EXTERN int sg__rename(const char *old, const char *new);
#endif /* _WIN32 */

#if defined(_WIN32) || defined(__ANDROID__) || \
(defined(__linux__) && !defined(__gnu_linux__))
(defined(__linux__) && !defined(__gnu_linux__)) || defined(__APPLE__)

SG__EXTERN char *sg__basename(const char *path);

#else /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) */
#else /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */

#define sg__basename basename

#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) */
#endif /* _WIN32 || __ANDROID__ || (__linux__ && !__gnu_linux__) || __APPLE__ */

SG__EXTERN char *sg__strdup(const char *str);

Expand Down

0 comments on commit 355103e

Please sign in to comment.