Commit d4856a8a authored by Stefan Eissing's avatar Stefan Eissing
Browse files

first configure+compile version

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/trunk-md@1804123 13f79535-47bb-0310-9956-ffa450edef68
parents f52fccd9 cbaa7919
Loading
Loading
Loading
Loading
+21 −60
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ void h2_util_camel_case_header(char *s, size_t len)
    }
}

/* base64 url encoding ****************************************************************************/

static const int BASE64URL_UINT6[] = {
/*   0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f        */
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*  0 */
@@ -174,6 +176,7 @@ apr_size_t h2_util_base64url_decode(const char **decoded, const char *encoded,
            n = ((BASE64URL_UINT6[ e[mlen+0] ] << 18) +
                 (BASE64URL_UINT6[ e[mlen+1] ] << 12));
            *d++ = n >> 16;
            remain = 1;
            break;
        case 3:
            n = ((BASE64URL_UINT6[ e[mlen+0] ] << 18) +
@@ -181,6 +184,7 @@ apr_size_t h2_util_base64url_decode(const char **decoded, const char *encoded,
                 (BASE64URL_UINT6[ e[mlen+2] ] << 6));
            *d++ = n >> 16;
            *d++ = n >> 8 & 0xffu;
            remain = 2;
            break;
        default: /* do nothing */
            break;
@@ -189,78 +193,35 @@ apr_size_t h2_util_base64url_decode(const char **decoded, const char *encoded,
}

const char *h2_util_base64url_encode(const char *data, 
                                     apr_size_t len, apr_pool_t *pool)
                                     apr_size_t dlen, apr_pool_t *pool)
{
    apr_size_t mlen = ((len+2)/3)*3;
    apr_size_t slen = (mlen/3)*4;
    apr_size_t i;
    long i, len = (int)dlen;
    apr_size_t slen = ((dlen+2)/3)*4 + 1; /* 0 terminated */
    const unsigned char *udata = (const unsigned char*)data;
    char *enc, *p = apr_pcalloc(pool, slen+1); /* 0 terminated */
    char *enc, *p = apr_pcalloc(pool, slen);
    
    enc = p;
    for (i = 0; i < mlen; i+= 3) {
    for (i = 0; i < len-2; i+= 3) {
        *p++ = BASE64URL_CHARS[ (udata[i] >> 2) & 0x3fu ];
        *p++ = BASE64URL_CHARS[ ((udata[i] << 4) + 
                                 ((i+1 < len)? (udata[i+1] >> 4) : 0)) & 0x3fu ];
        *p++ = BASE64URL_CHARS[ ((udata[i+1] << 2) + 
                                 ((i+2 < len)? (udata[i+2] >> 6) : 0)) & 0x3fu ];
        if (i+2 < len) {
        *p++ = BASE64URL_CHARS[ ((udata[i] << 4) + (udata[i+1] >> 4)) & 0x3fu ];
        *p++ = BASE64URL_CHARS[ ((udata[i+1] << 2) + (udata[i+2] >> 6)) & 0x3fu ];
        *p++ = BASE64URL_CHARS[ udata[i+2] & 0x3fu ];
    }
    }
    
    return enc;
}
    
int h2_util_contains_token(apr_pool_t *pool, const char *s, const char *token)
{
    char *c;
    if (s) {
        if (!apr_strnatcasecmp(s, token)) {   /* the simple life */
            return 1;
        }
        
        for (c = ap_get_token(pool, &s, 0); c && *c;
             c = *s? ap_get_token(pool, &s, 0) : NULL) {
            if (!apr_strnatcasecmp(c, token)) { /* seeing the token? */
                return 1;
            }
            while (*s++ == ';') {            /* skip parameters */
                ap_get_token(pool, &s, 0);
            }
            if (*s++ != ',') {               /* need comma separation */
                return 0;
            }
        }
    }
    return 0;
}

const char *h2_util_first_token_match(apr_pool_t *pool, const char *s, 
                                      const char *tokens[], apr_size_t len)
{
    char *c;
    apr_size_t i;
    if (s && *s) {
        for (c = ap_get_token(pool, &s, 0); c && *c;
             c = *s? ap_get_token(pool, &s, 0) : NULL) {
            for (i = 0; i < len; ++i) {
                if (!apr_strnatcasecmp(c, tokens[i])) {
                    return tokens[i];
                }
            }
            while (*s++ == ';') {            /* skip parameters */
                ap_get_token(pool, &s, 0);
            }
            if (*s++ != ',') {               /* need comma separation */
                return 0;
    if (i < len) {
        *p++ = BASE64URL_CHARS[ (udata[i] >> 2) & 0x3fu ];
        if (i == (len - 1)) {
            *p++ = BASE64URL_CHARS[ (udata[i] << 4) & 0x3fu ];
        }
        else {
            *p++ = BASE64URL_CHARS[ ((udata[i] << 4) + (udata[i+1] >> 4)) & 0x3fu ];
            *p++ = BASE64URL_CHARS[ (udata[i+1] << 2) & 0x3fu ];
        }
    }
    return NULL;
    *p++ = '\0';
    return enc;
}


/*******************************************************************************
 * ihash - hash for structs with int identifier
 ******************************************************************************/
+0 −9
Original line number Diff line number Diff line
@@ -337,15 +337,6 @@ unsigned char h2_log2(int n);
 */
apr_size_t h2_util_table_bytes(apr_table_t *t, apr_size_t pair_extra);

/**
 * Return != 0 iff the string s contains the token, as specified in
 * HTTP header syntax, rfc7230.
 */
int h2_util_contains_token(apr_pool_t *pool, const char *s, const char *token);

const char *h2_util_first_token_match(apr_pool_t *pool, const char *s, 
                                      const char *tokens[], apr_size_t len);

/** Match a header value against a string constance, case insensitive */
#define H2_HD_MATCH_LIT(l, name, nlen)  \
    ((nlen == sizeof(l) - 1) && !apr_strnatcasecmp(l, name))
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
 * @macro
 * Version number of the http2 module as c string
 */
#define MOD_HTTP2_VERSION "1.10.10-DEV"
#define MOD_HTTP2_VERSION "1.10.11-DEV"

/**
 * @macro

modules/md/Makefile.in

0 → 100644
+20 −0
Original line number Diff line number Diff line
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
#   standard stuff
#

include $(top_srcdir)/build/special.mk

modules/md/config2.m4

0 → 100644
+296 −0
Original line number Diff line number Diff line
dnl Licensed to the Apache Software Foundation (ASF) under one or more
dnl contributor license agreements.  See the NOTICE file distributed with
dnl this work for additional information regarding copyright ownership.
dnl The ASF licenses this file to You under the Apache License, Version 2.0
dnl (the "License"); you may not use this file except in compliance with
dnl the License.  You may obtain a copy of the License at
dnl
dnl      http://www.apache.org/licenses/LICENSE-2.0
dnl
dnl Unless required by applicable law or agreed to in writing, software
dnl distributed under the License is distributed on an "AS IS" BASIS,
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dnl See the License for the specific language governing permissions and
dnl limitations under the License.

dnl
dnl APACHE_CHECK_CURL
dnl
dnl Configure for libcurl, giving preference to
dnl "--with-curl=<path>" if it was specified.
dnl
AC_DEFUN([APACHE_CHECK_CURL],[
  AC_CACHE_CHECK([for curl], [ac_cv_curl], [
    dnl initialise the variables we use
    ac_cv_curl=no
    ap_curl_found=""
    ap_curl_base=""
    ap_curl_libs=""

    dnl Determine the curl base directory, if any
    AC_MSG_CHECKING([for user-provided curl base directory])
    AC_ARG_WITH(curl, APACHE_HELP_STRING(--with-curl=PATH, curl installation directory), [
      dnl If --with-curl specifies a directory, we use that directory
      if test "x$withval" != "xyes" -a "x$withval" != "x"; then
        dnl This ensures $withval is actually a directory and that it is absolute
        ap_curl_base="`cd $withval ; pwd`"
      fi
    ])
    if test "x$ap_curl_base" = "x"; then
      AC_MSG_RESULT(none)
    else
      AC_MSG_RESULT($ap_curl_base)
    fi

    dnl Run header and version checks
    saved_CPPFLAGS="$CPPFLAGS"
    saved_LIBS="$LIBS"
    saved_LDFLAGS="$LDFLAGS"

    dnl Before doing anything else, load in pkg-config variables
    if test -n "$PKGCONFIG"; then
      saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
      AC_MSG_CHECKING([for pkg-config along $PKG_CONFIG_PATH])
      if test "x$ap_curl_base" != "x" ; then
        if test -f "${ap_curl_base}/lib/pkgconfig/libcurl.pc"; then
          dnl Ensure that the given path is used by pkg-config too, otherwise
          dnl the system libcurl.pc might be picked up instead.
          PKG_CONFIG_PATH="${ap_curl_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
          export PKG_CONFIG_PATH
        elif test -f "${ap_curl_base}/lib64/pkgconfig/libcurl.pc"; then
          dnl Ensure that the given path is used by pkg-config too, otherwise
          dnl the system libcurl.pc might be picked up instead.
          PKG_CONFIG_PATH="${ap_curl_base}/lib64/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
          export PKG_CONFIG_PATH
        fi
      fi
      AC_ARG_ENABLE(curl-staticlib-deps,APACHE_HELP_STRING(--enable-curl-staticlib-deps,[link mod_md with dependencies of libcurl's static libraries (as indicated by "pkg-config --static"). Must be specified in addition to --enable-md.]), [
        if test "$enableval" = "yes"; then
          PKGCONFIG_LIBOPTS="--static"
        fi
      ])
      ap_curl_libs="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-l --silence-errors libcurl`"
      if test $? -eq 0; then
        ap_curl_found="yes"
        pkglookup="`$PKGCONFIG --cflags-only-I libcurl`"
        APR_ADDTO(CPPFLAGS, [$pkglookup])
        APR_ADDTO(MOD_CFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-L libcurl`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-other libcurl`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
      fi
      PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
    fi

    dnl fall back to the user-supplied directory if not found via pkg-config
    if test "x$ap_curl_base" != "x" -a "x$ap_curl_found" = "x"; then
      APR_ADDTO(CPPFLAGS, [-I$ap_curl_base/include])
      APR_ADDTO(MOD_CFLAGS, [-I$ap_curl_base/include])
      APR_ADDTO(LDFLAGS, [-L$ap_curl_base/lib])
      APR_ADDTO(MOD_LDFLAGS, [-L$ap_curl_base/lib])
      if test "x$ap_platform_runtime_link_flag" != "x"; then
        APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_curl_base/lib])
        APR_ADDTO(MOD_LDFLAGS, [$ap_platform_runtime_link_flag$ap_curl_base/lib])
      fi
    fi

    AC_CHECK_HEADERS([curl/curl.h])

    AC_MSG_CHECKING([for curl version >= 7.50])
    AC_TRY_COMPILE([#include <curl/curlver.h>],[
#if !defined(LIBCURL_VERSION_MAJOR)
#error "Missing libcurl version"
#endif
#if LIBCURL_VERSION_MAJOR < 7
#error "Unsupported libcurl version " LIBCURL_VERSION
#endif
#if LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR < 50
#error "Unsupported libcurl version " LIBCURL_VERSION
#endif],
      [AC_MSG_RESULT(OK)
       ac_cv_curl=yes],
      [AC_MSG_RESULT(FAILED)])

    if test "x$ac_cv_curl" = "xyes"; then
      ap_curl_libs="${ap_curl_libs:--lcurl} `$apr_config --libs`"
      APR_ADDTO(MOD_LDFLAGS, [$ap_curl_libs])
      APR_ADDTO(LIBS, [$ap_curl_libs])
    fi

    dnl restore
    CPPFLAGS="$saved_CPPFLAGS"
    LIBS="$saved_LIBS"
    LDFLAGS="$saved_LDFLAGS"
  ])
  if test "x$ac_cv_curl" = "xyes"; then
    AC_DEFINE(HAVE_CURL, 1, [Define if curl is available])
  fi
])


dnl
dnl APACHE_CHECK_JANSSON
dnl
dnl Configure for libjansson, giving preference to
dnl "--with-jansson=<path>" if it was specified.
dnl
AC_DEFUN([APACHE_CHECK_JANSSON],[
  AC_CACHE_CHECK([for jansson], [ac_cv_jansson], [
    dnl initialise the variables we use
    ac_cv_jansson=no
    ap_jansson_found=""
    ap_jansson_base=""
    ap_jansson_libs=""

    dnl Determine the jansson base directory, if any
    AC_MSG_CHECKING([for user-provided jansson base directory])
    AC_ARG_WITH(jansson, APACHE_HELP_STRING(--with-jansson=PATH, jansson installation directory), [
      dnl If --with-jansson specifies a directory, we use that directory
      if test "x$withval" != "xyes" -a "x$withval" != "x"; then
        dnl This ensures $withval is actually a directory and that it is absolute
        ap_jansson_base="`cd $withval ; pwd`"
      fi
    ])
    if test "x$ap_jansson_base" = "x"; then
      AC_MSG_RESULT(none)
    else
      AC_MSG_RESULT($ap_jansson_base)
    fi

    dnl Run header and version checks
    saved_CPPFLAGS="$CPPFLAGS"
    saved_LIBS="$LIBS"
    saved_LDFLAGS="$LDFLAGS"

    dnl Before doing anything else, load in pkg-config variables
    if test -n "$PKGCONFIG"; then
      saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
      AC_MSG_CHECKING([for pkg-config along $PKG_CONFIG_PATH])
      if test "x$ap_jansson_base" != "x" ; then
        if test -f "${ap_jansson_base}/lib/pkgconfig/libjansson.pc"; then
          dnl Ensure that the given path is used by pkg-config too, otherwise
          dnl the system libjansson.pc might be picked up instead.
          PKG_CONFIG_PATH="${ap_jansson_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
          export PKG_CONFIG_PATH
        elif test -f "${ap_jansson_base}/lib64/pkgconfig/libjansson.pc"; then
          dnl Ensure that the given path is used by pkg-config too, otherwise
          dnl the system libjansson.pc might be picked up instead.
          PKG_CONFIG_PATH="${ap_jansson_base}/lib64/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
          export PKG_CONFIG_PATH
        fi
      fi
      AC_ARG_ENABLE(jansson-staticlib-deps,APACHE_HELP_STRING(--enable-jansson-staticlib-deps,[link mod_md with dependencies of libjansson's static libraries (as indicated by "pkg-config --static"). Must be specified in addition to --enable-md.]), [
        if test "$enableval" = "yes"; then
          PKGCONFIG_LIBOPTS="--static"
        fi
      ])
      ap_jansson_libs="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-l --silence-errors libjansson`"
      if test $? -eq 0; then
        ap_jansson_found="yes"
        pkglookup="`$PKGCONFIG --cflags-only-I libjansson`"
        APR_ADDTO(CPPFLAGS, [$pkglookup])
        APR_ADDTO(MOD_CFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-L libjansson`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
        pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-other libjansson`"
        APR_ADDTO(LDFLAGS, [$pkglookup])
        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
      fi
      PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
    fi

    dnl fall back to the user-supplied directory if not found via pkg-config
    if test "x$ap_jansson_base" != "x" -a "x$ap_jansson_found" = "x"; then
      APR_ADDTO(CPPFLAGS, [-I$ap_jansson_base/include])
      APR_ADDTO(MOD_CFLAGS, [-I$ap_jansson_base/include])
      APR_ADDTO(LDFLAGS, [-L$ap_jansson_base/lib])
      APR_ADDTO(MOD_LDFLAGS, [-L$ap_jansson_base/lib])
      if test "x$ap_platform_runtime_link_flag" != "x"; then
        APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_jansson_base/lib])
        APR_ADDTO(MOD_LDFLAGS, [$ap_platform_runtime_link_flag$ap_jansson_base/lib])
      fi
    fi

    # attempts to include jansson.h fail me. So lets make sure we can at least
    # include its other header file
    AC_TRY_COMPILE([#include <jansson_config.h>],[],
      [AC_MSG_RESULT(OK) 
       ac_cv_jansson=yes], 
       [AC_MSG_RESULT(FAILED)])

    if test "x$ac_cv_jansson" = "xyes"; then
      ap_jansson_libs="${ap_jansson_libs:--ljansson} `$apr_config --libs`"
      APR_ADDTO(MOD_LDFLAGS, [$ap_jansson_libs])
      APR_ADDTO(LIBS, [$ap_jansson_libs])
    fi

    dnl restore
    CPPFLAGS="$saved_CPPFLAGS"
    LIBS="$saved_LIBS"
    LDFLAGS="$saved_LDFLAGS"
  ])
  if test "x$ac_cv_jansson" = "xyes"; then
    AC_DEFINE(HAVE_JANSSON, 1, [Define if jansson is available])
  fi
])


dnl #  start of module specific part
APACHE_MODPATH_INIT(md)

dnl #  list of module object files
md_objs="dnl
mod_md.lo dnl
md_config.lo dnl
md_core.lo dnl
md_crypt.lo dnl
md_curl.lo dnl
md_http.lo dnl
md_json.lo dnl
md_jws.lo dnl
md_log.lo dnl
md_os.lo dnl
md_reg.lo dnl
md_store.lo dnl
md_store_fs.lo dnl
md_util.lo dnl
md_acme.lo dnl
md_acme_acct.lo dnl
md_acme_authz.lo dnl
md_acme_drive.lo dnl
"


dnl # hook module into the Autoconf mechanism (--enable-md)
APACHE_MODULE(md, [Managed Domain handling], $md_objs, , most, [
    APACHE_CHECK_OPENSSL
    if test "x$ac_cv_openssl" = "xno" ; then
        AC_MSG_WARN([libssl (or compatible) not found])
        enable_md=no
    fi
    
    APACHE_CHECK_JANSSON
    if test "x$ac_cv_jansson" != "xyes" ; then
        AC_MSG_WARN([libjansson not found])
        enable_md=no
    fi

    APACHE_CHECK_CURL
    if test "x$ac_cv_curl" != "xyes" ; then
        AC_MSG_WARN([libcurl not found])
        enable_md=no
    fi
])

# Ensure that other modules can pick up mod_md.h
APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current])



dnl #  end of module specific part
APACHE_MODPATH_FINISH
Loading