笔者今天是节后最后一班,想总结一些tomcat里面经常提及的RFC规范,于是用工具从github检出tomcat代码,

地址https://github.com/apache/tomcat/,搜索了一些RFC偶尔发现以下代码

org.apache.tomcat.jni.Time.java
/**
   * Formats dates in the RFC822
   * format in an efficient manner.
   * @param t the time to convert
   * @return the formatted date
*/
public static native String rfc822(long t);

 

 

 大意:以高效的方式将日期格式化成RFC822标准的格式。在java里面native方法全部都是通过对应的本地代码(C语言)实现的。

笔者在tomcat相关的本地库(Tomcat Native、Tomcat Connectors)最终在tomcat-native中找到相关代码。

关于Tomcat Native的官方描述:

The Apache Tomcat Native Library is an optional component for use with Apache Tomcat that allows Tomcat to use certain native

resources for performance, compatibility, etc.Specifically, the Apache Tomcat Native Library gives Tomcat access to the Apache

Portable Runtime (APR) library's network connection (socket) implementation and random-number generator. See the Apache Tomcat

documentation for more information on how to configure Tomcat to use the APR connector.

大意:

Apache Tomcat本地库是一个可选组件,可用于Apache Tomcat,为了性能和兼容性等,允许Tomcat使用
某些本机资源。

具体而言,Apache Tomcat本地库允许Tomcat访问Apache Portable Runtime(APR)库的网络连接(套接字)实现
和随机数生成器。有关如何配置Tomcat使用APR连接器的详细信息,请参阅Apache Tomcat文档。

 

代码位置如下

tomcat-native-1.2.23-src/native/src/misc.c

/* 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.
 */

#include "tcn.h"
#include "apr_time.h"

TCN_IMPLEMENT_CALL(void, Time, sleep)(TCN_STDARGS, jlong t)
{

    UNREFERENCED_STDARGS;
    apr_sleep((apr_interval_time_t)t);
}

TCN_IMPLEMENT_CALL(jint, OS, random)(TCN_STDARGS, jbyteArray buf,
                                     jint len)
{
#if APR_HAS_RANDOM
    apr_status_t rv;
    jbyte *b = (*e)->GetPrimitiveArrayCritical(e, buf, NULL);

    UNREFERENCED(o);
    if ((rv = apr_generate_random_bytes((unsigned char *)b,
            (apr_size_t)len)) == APR_SUCCESS)
        (*e)->ReleasePrimitiveArrayCritical(e, buf, b, 0);
    else
        (*e)->ReleasePrimitiveArrayCritical(e, buf, b, JNI_ABORT);

    if ((*e)->ExceptionCheck(e)) {
        (*e)->ExceptionClear(e);
        rv = APR_EGENERAL;
    }
    return (jint)rv;
#else
    return APR_ENOTIMPL;
#endif
}

TCN_IMPLEMENT_CALL(jlong, Time, now)(TCN_STDARGS)
{
    UNREFERENCED_STDARGS;
    return (jlong)apr_time_now();
}

TCN_IMPLEMENT_CALL(jstring, Time, rfc822)(TCN_STDARGS, jlong t)
{
    char ts[APR_RFC822_DATE_LEN];
    UNREFERENCED(o);
    if (apr_rfc822_date(ts, J2T(t)) == APR_SUCCESS)
        return AJP_TO_JSTRING(ts);
    else
        return NULL;
}

TCN_IMPLEMENT_CALL(jstring, Time, ctime)(TCN_STDARGS, jlong t)
{
    char ts[APR_CTIME_LEN];
    UNREFERENCED(o);
    if (apr_ctime(ts, J2T(t)) == APR_SUCCESS)
        return AJP_TO_JSTRING(ts);
    else
        return NULL;
}

其中有rfc822关键字,再比对一下我们Time.java对应的类

/*
 *  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.
 */

package org.apache.tomcat.jni;

/** Time
 *
 * @author Mladen Turk
 */
public class Time {

    /** number of microseconds per second */
    public static final long APR_USEC_PER_SEC  = 1000000L;
    /** number of milliseconds per microsecond */
    public static final long APR_MSEC_PER_USEC = 1000L;

    /**
     * @param t The time
     * @return apr_time_t as a second
     */
    public static long sec(long t)
    {
        return t / APR_USEC_PER_SEC;
    }

    /**
     * @param t The time
     * @return apr_time_t as a msec
     */
    public static long msec(long t)
    {
        return t / APR_MSEC_PER_USEC;
    }

    /**
     * number of microseconds since 00:00:00 January 1, 1970 UTC
     * @return the current time
     */
    public static native long now();

    /**
     * Formats dates in the RFC822
     * format in an efficient manner.
     * @param t the time to convert
     * @return the formatted date
     */
    public static native String rfc822(long t);

    /**
     * Formats dates in the ctime() format
     * in an efficient manner.
     * Unlike ANSI/ISO C ctime(), apr_ctime() does not include
     * a \n at the end of the string.
     * @param t the time to convert
     * @return the formatted date
     */
    public static native String ctime(long t);

    /**
     * Sleep for the specified number of micro-seconds.
     * <br><b>Warning :</b> May sleep for longer than the specified time.
     * @param t desired amount of time to sleep.
     */
    public static native void sleep(long t);

}

其中sleep、ctime、rfc822、now都在这里,这类应该和Time.java代码有关系了。再看了一下这个c语言类,他使用的apr库,

APR(Apache Portable Runtime)的库地址:https://apr.apache.org/

APR官方介绍:

The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predictable and consistent

interface to underlying platform-specific implementations. The primary goal is to provide an API to which software developers may code and be

assured of predictable if not identical behaviour regardless of the platform on which their software is built, relieving them of the need to code

special-case conditions to work around or take advantage of platform-specific deficiencies or features.

大意:

Apache 可移植运行时 (APR) 项目的任务是创建和维护软件库,为底层特定于平台的实现提供可预测且一致的接口。
主要目标是提供一个 API,软件开发人员可以对此进行编码,并确保无论软件构建的平台如何,都能实现可预测的
(如果不是相同的行为),从而免除了为了正常工作而编写特定情形、或者使用依赖于特定平台的缺陷或者特性的代码。

再对比以上Tomcat Native Library官方说明,一一对应。于是我们就可以认为misc.c封装了特定平台的细节,我们通过这个结果就能实现跨平台的本地代码功能。

至此,笔者想起8年前的前同事写的一段代码,他也用apr写的,能跨平台,瞬间也明白了apr的作用,为跨平台而生。

 

快速学习思路

笔者目前对apr还不熟悉,特别以上的misc.c中宏/形参,笔者知道一种方法:使用IDA反汇编可以看到函数原型(方法签名),于是尝试在linux环境(比windows方便,

windows编译麻烦,可以快速实现目的,实际上windows编译时候默认会把调试信息放到同级目录,反汇编效果更好)下编译了一下tomcat-native代码,在linux下编译

了结果,然后把中间文件、调试信息等拿回来到本地,使用DA_Pro_v7.0逆向一下tomcat-native-1.2.21-src\native\.libs目录文件libtcnative-1.so,使用F5插件得到伪代码。

Time.java中rfc822、ctime、sleep对应的JNI代码

//----- (0000000000015690) ----------------------------------------------------
jstring __fastcall Java_org_apache_tomcat_jni_Time_rfc822(JNIEnv *e, jobject o, jlong t)
{
  int v3; // edx
  jstring result; // rax
  char ts[30]; // [rsp+0h] [rbp-38h]

  v3 = apr_rfc822_date(ts, t);
  result = 0LL;
  if ( !v3 )
    result = (jstring)((__int64 (__fastcall *)(JNIEnv *, char *))(*e)->NewStringUTF)(e, ts);
  return result;
}
//----- (00000000000156D0) ----------------------------------------------------
jstring __fastcall Java_org_apache_tomcat_jni_Time_ctime(JNIEnv *e, jobject o, jlong t)
{
  int v3; // edx
  jstring result; // rax
  char ts[25]; // [rsp+0h] [rbp-38h]

  v3 = apr_ctime(ts, t);
  result = 0LL;
  if ( !v3 )
    result = (jstring)((__int64 (__fastcall *)(JNIEnv *, char *))(*e)->NewStringUTF)(e, ts);
  return result;
}
// 11A20: using guessed type __int64 __fastcall apr_ctime(_QWORD, _QWORD);
void __fastcall Java_org_apache_tomcat_jni_Time_sleep(JNIEnv *e, jobject o, jlong t)
{
  apr_sleep(t, o);
}

OS.java中对应于random的JNI代码

/**
  * Generate random bytes.
  * @param buf Buffer to fill with random bytes
  * @param len Length of buffer in bytes
  * @return the operation status
*/
public static native int random(byte [] buf, int len);
jint __fastcall Java_org_apache_tomcat_jni_OS_random(JNIEnv *e, jobject o, jbyteArray buf, jint len)
{
  jbyteArray v4; // r12
  jint v5; // ebp
  __int64 v6; // r13
  jint v7; // ebp
  JNIEnv v8; // rax

  v4 = buf;
  v5 = len;
  v6 = ((__int64 (__fastcall *)(JNIEnv *, jbyteArray, _QWORD))(*e)->GetPrimitiveArrayCritical)(e, buf, 0LL);
  v7 = apr_generate_random_bytes(v6, v5);
  v8 = *e;
  if ( v7 )
    ((void (__fastcall *)(JNIEnv *, jbyteArray, __int64, signed __int64))v8->ReleasePrimitiveArrayCritical)(
      e,
      v4,
      v6,
      2LL);
  else
    ((void (__fastcall *)(JNIEnv *, jbyteArray, __int64, _QWORD))v8->ReleasePrimitiveArrayCritical)(e, v4, v6, 0LL);
  if ( ((unsigned __int8 (__fastcall *)(JNIEnv *))(*e)->ExceptionCheck)(e) )
  {
    v7 = 20014;
    ((void (__fastcall *)(JNIEnv *))(*e)->ExceptionClear)(e);
  }
  return v7;
}

还有一些其他java类对应的JNI代码,方法签名如下,供有兴趣的朋友了解

jlong __fastcall Java_org_apache_tomcat_jni_Address_info(JNIEnv *e, jobject o, jstring hostname, jint family, jint port, jint flags, jlong pool);
jstring __fastcall Java_org_apache_tomcat_jni_Address_getnameinfo(JNIEnv *e, jobject o, jlong sa, jint flags);
jstring __fastcall Java_org_apache_tomcat_jni_Address_getip(JNIEnv *e, jobject o, jlong sa);
jlong __fastcall Java_org_apache_tomcat_jni_Address_get(JNIEnv *e, jobject o, jint which, jlong sock);
jboolean __fastcall Java_org_apache_tomcat_jni_Address_equal(JNIEnv *e, jobject o, jlong a, jlong b);
jint __fastcall Java_org_apache_tomcat_jni_Address_getservbyname(JNIEnv *e, jobject o, jlong sa, jstring servname);
jobject __fastcall Java_org_apache_tomcat_jni_Buffer_malloc(JNIEnv *e, jobject o, jint size);
jobject __fastcall Java_org_apache_tomcat_jni_Buffer_calloc(JNIEnv *e, jobject o, jint num, jint size);
jobject __fastcall Java_org_apache_tomcat_jni_Buffer_palloc(JNIEnv *e, jobject o, jlong pool, jint size);
jobject __fastcall Java_org_apache_tomcat_jni_Buffer_pcalloc(JNIEnv *e, jobject o, jlong pool, jint size);
jobject __fastcall Java_org_apache_tomcat_jni_Buffer_create(JNIEnv *e, jobject o, jlong addr, jint size);
void __fastcall Java_org_apache_tomcat_jni_Buffer_free(JNIEnv *e, jobject o, jobject bb);
jlong __fastcall Java_org_apache_tomcat_jni_Buffer_address(JNIEnv *e, jobject o, jobject bb);
jlong __fastcall Java_org_apache_tomcat_jni_Buffer_size(JNIEnv *e, jobject o, jobject bb);
jint __fastcall Java_org_apache_tomcat_jni_Directory_make(JNIEnv *e, jobject o, jstring path, jint perm, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Directory_makeRecursive(JNIEnv *e, jobject o, jstring path, jint perm, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Directory_remove(JNIEnv *e, jobject o, jstring path, jlong pool);
jstring __fastcall Java_org_apache_tomcat_jni_Directory_tempGet(JNIEnv *e, jobject o, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_Directory_open(JNIEnv *e, jobject o, jstring path, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Directory_close(JNIEnv *e, jobject o, jlong dir);
jint __fastcall Java_org_apache_tomcat_jni_Directory_rewind(JNIEnv *e, jobject o, jlong dir);
void __fastcall tcn_ThrowException(JNIEnv *env, const char *msg);
void __fastcall tcn_ThrowMemoryException(JNIEnv *env, const char *file, int line, const char *msg);
void tcn_Throw(JNIEnv *env, const char *fmt, ...);
void __fastcall tcn_ThrowAPRException(JNIEnv *e, apr_status_t err);
jint __fastcall Java_org_apache_tomcat_jni_Error_osError(JNIEnv *e, jobject o);
jint __fastcall Java_org_apache_tomcat_jni_Error_netosError(JNIEnv *e, jobject o);
jstring __fastcall Java_org_apache_tomcat_jni_Error_strerror(JNIEnv *e, jobject o, jint err);
jboolean __fastcall Java_org_apache_tomcat_jni_Status_is(JNIEnv *e, jobject o, jint err, jint idx);
jint __fastcall Java_org_apache_tomcat_jni_File_close(JNIEnv *e, jobject o, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_eof(JNIEnv *e, jobject o, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_flush(JNIEnv *e, jobject o, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_unlock(JNIEnv *e, jobject o, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_flagsGet(JNIEnv *e, jobject o, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_lock(JNIEnv *e, jobject o, jlong file, jint flags);
jint __fastcall Java_org_apache_tomcat_jni_File_trunc(JNIEnv *e, jobject o, jlong file, jlong off);
jlong __fastcall Java_org_apache_tomcat_jni_File_open(JNIEnv *e, jobject o, jstring fname, jint flag, jint perm, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_File_mktemp(JNIEnv *e, jobject o, jstring templ, jint flags, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_remove(JNIEnv *e, jobject o, jstring path, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_rename(JNIEnv *e, jobject o, jstring from, jstring to, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_copy(JNIEnv *e, jobject o, jstring from, jstring to, jint perms, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_append(JNIEnv *e, jobject o, jstring from, jstring to, jint perms, jlong pool);
jstring __fastcall Java_org_apache_tomcat_jni_File_nameGet(JNIEnv *e, jobject o, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_permsSet(JNIEnv *e, jobject o, jstring file, jint perms);
jint __fastcall Java_org_apache_tomcat_jni_File_attrsSet(JNIEnv *e, jobject o, jstring file, jint attrs, jint mask, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_mtimeSet(JNIEnv *e, jobject o, jstring file, jlong mtime, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_File_seek(JNIEnv *e, jobject o, jlong file, jint where, jlong offset);
jint __fastcall Java_org_apache_tomcat_jni_File_putc(JNIEnv *e, jobject o, jbyte c, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_getc(JNIEnv *e, jobject o, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_ungetc(JNIEnv *e, jobject o, jbyte c, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_puts(JNIEnv *e, jobject o, jbyteArray str, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_write(JNIEnv *e, jobject o, jlong file, jbyteArray buf, jint offset, jint towrite);
jint __fastcall Java_org_apache_tomcat_jni_File_writeb(JNIEnv *e, jobject o, jlong file, jobject buf, jint offset, jint towrite);
jint __fastcall Java_org_apache_tomcat_jni_File_writeFull(JNIEnv *e, jobject o, jlong file, jbyteArray buf, jint offset, jint towrite);
jint __fastcall Java_org_apache_tomcat_jni_File_writeFullb(JNIEnv *e, jobject o, jlong file, jobject buf, jint offset, jint towrite);
jint __fastcall Java_org_apache_tomcat_jni_File_writev(JNIEnv *e, jobject o, jlong file, jobjectArray bufs);
jint __fastcall Java_org_apache_tomcat_jni_File_writevFull(JNIEnv *e, jobject o, jlong file, jobjectArray bufs);
jint __fastcall Java_org_apache_tomcat_jni_File_read(JNIEnv *e, jobject o, jlong file, jbyteArray buf, jint offset, jint toread);
jint __fastcall Java_org_apache_tomcat_jni_File_readb(JNIEnv *e, jobject o, jlong file, jobject buf, jint offset, jint toread);
jint __fastcall Java_org_apache_tomcat_jni_File_readFull(JNIEnv *e, jobject o, jlong file, jbyteArray buf, jint offset, jint toread);
jint __fastcall Java_org_apache_tomcat_jni_File_readFullb(JNIEnv *e, jobject o, jlong file, jobject buf, jint offset, jint toread);
jint __fastcall Java_org_apache_tomcat_jni_File_gets(JNIEnv *e, jobject o, jbyteArray buf, jint offset, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_File_pipeCreate(JNIEnv *e, jobject o, jlongArray io, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_pipeTimeoutSet(JNIEnv *e, jobject o, jlong pipe, jlong timeout);
jlong __fastcall Java_org_apache_tomcat_jni_File_pipeTimeoutGet(JNIEnv *e, jobject o, jlong pipe);
jlong __fastcall Java_org_apache_tomcat_jni_File_dup(JNIEnv *e, jobject o, jlong newf, jlong file, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_dup2(JNIEnv *e, jobject o, jlong newf, jlong file, jlong pool);
void __fastcall fill_finfo(JNIEnv *e, jobject obj, apr_finfo_t_0 *info);
void __fastcall fill_ainfo(JNIEnv *e, jobject obj, apr_sockaddr_t_0 *info);
apr_status_t __fastcall tcn_load_finfo_class(JNIEnv *e, jclass finfo);
apr_status_t __fastcall tcn_load_ainfo_class(JNIEnv *e, jclass ainfo);
jint __fastcall Java_org_apache_tomcat_jni_File_stat(JNIEnv *e, jobject o, jobject finfo, jstring fname, jint wanted, jlong pool);
jobject __fastcall Java_org_apache_tomcat_jni_File_getStat(JNIEnv *e, jobject o, jstring fname, jint wanted, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_File_infoGet(JNIEnv *e, jobject o, jobject finfo, jint wanted, jlong file);
jobject __fastcall Java_org_apache_tomcat_jni_File_getInfo(JNIEnv *e, jobject o, jint wanted, jlong file);
jint __fastcall Java_org_apache_tomcat_jni_Directory_read(JNIEnv *e, jobject o, jobject finfo, jint wanted, jlong dir);
jboolean __fastcall Java_org_apache_tomcat_jni_Address_fill(JNIEnv *e, jobject o, jobject addr, jlong info);
jobject __fastcall Java_org_apache_tomcat_jni_Address_getInfo(JNIEnv *e, jobject o, jlong info);
jint __fastcall JNI_OnLoad(JavaVM *vm, void *reserved);
void __fastcall JNI_OnUnload(JavaVM *vm, void *reserved);
jstring __fastcall tcn_new_stringn(JNIEnv *env, const char *str, size_t l);
jbyteArray __fastcall tcn_new_arrayb(JNIEnv *env, const unsigned __int8 *data, size_t len);
jobjectArray __fastcall tcn_new_arrays(JNIEnv *env, size_t len);
jstring __fastcall tcn_new_string(JNIEnv *env, const char *str);
char *__fastcall tcn_get_string(JNIEnv *env, jstring jstr);
char *__fastcall tcn_strdup(JNIEnv *env, jstring jstr);
char *__fastcall tcn_pstrdup(JNIEnv *env, jstring jstr, apr_pool_t_0 *pool);
jboolean __fastcall Java_org_apache_tomcat_jni_Library_initialize(JNIEnv *e, jobject o);
void __fastcall Java_org_apache_tomcat_jni_Library_terminate(JNIEnv *e, jobject o);
jlong __fastcall Java_org_apache_tomcat_jni_Library_globalPool(JNIEnv *e, jobject o);
jint __fastcall Java_org_apache_tomcat_jni_Library_version(JNIEnv *e, jobject o, jint what);
jstring __fastcall Java_org_apache_tomcat_jni_Library_versionString(JNIEnv *e, jobject o);
jstring __fastcall Java_org_apache_tomcat_jni_Library_aprVersionString(JNIEnv *e, jobject o);
jboolean __fastcall Java_org_apache_tomcat_jni_Library_has(JNIEnv *e, jobject o, jint what);
jint __fastcall Java_org_apache_tomcat_jni_Library_size(JNIEnv *e, jobject o, jint what);
apr_pool_t_0 *__cdecl tcn_get_global_pool();
jclass __cdecl tcn_get_string_class();
JavaVM *__cdecl tcn_get_java_vm();
jint __fastcall tcn_get_java_env(JNIEnv **env);
jlong __fastcall Java_org_apache_tomcat_jni_Lock_create(JNIEnv *e, jobject o, jstring fname, jint mech, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_Lock_childInit(JNIEnv *e, jobject o, jstring fname, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Lock_lock(JNIEnv *e, jobject o, jlong mutex);
jint __fastcall Java_org_apache_tomcat_jni_Lock_trylock(JNIEnv *e, jobject o, jlong mutex);
jint __fastcall Java_org_apache_tomcat_jni_Lock_unlock(JNIEnv *e, jobject o, jlong mutex);
jint __fastcall Java_org_apache_tomcat_jni_Lock_destroy(JNIEnv *e, jobject o, jlong mutex);
jstring __fastcall Java_org_apache_tomcat_jni_Lock_lockfile(JNIEnv *e, jobject o, jlong mutex);
jstring __fastcall Java_org_apache_tomcat_jni_Lock_name(JNIEnv *e, jobject o, jlong mutex);
jstring __fastcall Java_org_apache_tomcat_jni_Lock_defname(JNIEnv *e, jobject o);
jlong __fastcall Java_org_apache_tomcat_jni_Global_create(JNIEnv *e, jobject o, jstring fname, jint mech, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_Global_childInit(JNIEnv *e, jobject o, jstring fname, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Global_lock(JNIEnv *e, jobject o, jlong mutex);
jint __fastcall Java_org_apache_tomcat_jni_Global_trylock(JNIEnv *e, jobject o, jlong mutex);
jint __fastcall Java_org_apache_tomcat_jni_Global_unlock(JNIEnv *e, jobject o, jlong mutex);
jint __fastcall Java_org_apache_tomcat_jni_Global_destroy(JNIEnv *e, jobject o, jlong mutex);
void __fastcall Java_org_apache_tomcat_jni_Time_sleep(JNIEnv *e, jobject o, jlong t);
jint __fastcall Java_org_apache_tomcat_jni_OS_random(JNIEnv *e, jobject o, jbyteArray buf, jint len);
jstring __fastcall Java_org_apache_tomcat_jni_Time_rfc822(JNIEnv *e, jobject o, jlong t);
jstring __fastcall Java_org_apache_tomcat_jni_Time_ctime(JNIEnv *e, jobject o, jlong t);
jlong __fastcall Java_org_apache_tomcat_jni_Mmap_create(JNIEnv *e, jobject o, jlong file, jlong offset, jlong size, jint flag, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_Mmap_dup(JNIEnv *e, jobject o, jlong mmap, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Mmap_delete(JNIEnv *e, jobject o, jlong mmap);
jlong __fastcall Java_org_apache_tomcat_jni_Mmap_offset(JNIEnv *e, jobject o, jlong mmap, jlong offset);
jint __fastcall Java_org_apache_tomcat_jni_Multicast_join(JNIEnv *e, jobject o, jlong sock, jlong join, jlong iface, jlong source);
jint __fastcall Java_org_apache_tomcat_jni_Multicast_leave(JNIEnv *e, jobject o, jlong sock, jlong addr, jlong iface, jlong source);
jint __fastcall Java_org_apache_tomcat_jni_Multicast_hops(JNIEnv *e, jobject o, jlong sock, jint ttl);
jint __fastcall Java_org_apache_tomcat_jni_Multicast_loopback(JNIEnv *e, jobject o, jlong sock, jboolean opt);
jint __fastcall Java_org_apache_tomcat_jni_Multicast_ointerface(JNIEnv *e, jobject o, jlong sock, jlong iface);
apr_status_t __fastcall sp_socket_cleanup(void *data);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_create(JNIEnv *e, jobject o, jint family, jint type, jint protocol, jlong pool);
void __fastcall Java_org_apache_tomcat_jni_Socket_destroy(JNIEnv *e, jobject o, jlong sock);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_pool(JNIEnv *e, jobject o, jlong sock);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_get(JNIEnv *e, jobject o, jlong sock, jint what);
jint __fastcall Java_org_apache_tomcat_jni_Socket_shutdown(JNIEnv *e, jobject o, jlong sock, jint how);
jint __fastcall Java_org_apache_tomcat_jni_Socket_close(JNIEnv *e, jobject o, jlong sock);
jint __fastcall Java_org_apache_tomcat_jni_Socket_bind(JNIEnv *e, jobject o, jlong sock, jlong sa);
jint __fastcall Java_org_apache_tomcat_jni_Socket_listen(JNIEnv *e, jobject o, jlong sock, jint backlog);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_acceptx(JNIEnv *e, jobject o, jlong sock, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_accept(JNIEnv *e, jobject o, jlong sock);
jint __fastcall Java_org_apache_tomcat_jni_Socket_connect(JNIEnv *e, jobject o, jlong sock, jlong sa);
jint __fastcall Java_org_apache_tomcat_jni_Socket_send(JNIEnv *e, jobject o, jlong sock, jbyteArray buf, jint offset, jint tosend);
void __fastcall Java_org_apache_tomcat_jni_Socket_setsbb(JNIEnv *e, jobject o, jlong sock, jobject buf);
void __fastcall Java_org_apache_tomcat_jni_Socket_setrbb(JNIEnv *e, jobject o, jlong sock, jobject buf);
jint __fastcall Java_org_apache_tomcat_jni_Socket_sendb(JNIEnv *e, jobject o, jlong sock, jobject buf, jint offset, jint len);
jint __fastcall Java_org_apache_tomcat_jni_Socket_sendib(JNIEnv *e, jobject o, jlong sock, jobject buf, jint offset, jint len);
jint __fastcall Java_org_apache_tomcat_jni_Socket_sendbb(JNIEnv *e, jobject o, jlong sock, jint offset, jint len);
jint __fastcall Java_org_apache_tomcat_jni_Socket_sendibb(JNIEnv *e, jobject o, jlong sock, jint offset, jint len);
jint __fastcall Java_org_apache_tomcat_jni_Socket_sendv(JNIEnv *e, jobject o, jlong sock, jobjectArray bufs);
jint __fastcall Java_org_apache_tomcat_jni_Socket_sendto(JNIEnv *e, jobject o, jlong sock, jlong where, jint flag, jbyteArray buf, jint offset, jint tosend);
jint __fastcall Java_org_apache_tomcat_jni_Socket_recv(JNIEnv *e, jobject o, jlong sock, jbyteArray buf, jint offset, jint toread);
jint __fastcall Java_org_apache_tomcat_jni_Socket_recvt(JNIEnv *e, jobject o, jlong sock, jbyteArray buf, jint offset, jint toread, jlong timeout);
jint __fastcall Java_org_apache_tomcat_jni_Socket_recvb(JNIEnv *e, jobject o, jlong sock, jobject buf, jint offset, jint len);
jint __fastcall Java_org_apache_tomcat_jni_Socket_recvbb(JNIEnv *e, jobject o, jlong sock, jint offset, jint len);
jint __fastcall Java_org_apache_tomcat_jni_Socket_recvbt(JNIEnv *e, jobject o, jlong sock, jobject buf, jint offset, jint len, jlong timeout);
jint __fastcall Java_org_apache_tomcat_jni_Socket_recvbbt(JNIEnv *e, jobject o, jlong sock, jint offset, jint len, jlong timeout);
jint __fastcall Java_org_apache_tomcat_jni_Socket_recvfrom(JNIEnv *e, jobject o, jlong from, jlong sock, jint flags, jbyteArray buf, jint offset, jint toread);
jint __fastcall Java_org_apache_tomcat_jni_Socket_optSet(JNIEnv *e, jobject o, jlong sock, jint opt, jint on);
jint __fastcall Java_org_apache_tomcat_jni_Socket_optGet(JNIEnv *e, jobject o, jlong sock, jint opt);
jint __fastcall Java_org_apache_tomcat_jni_Socket_timeoutSet(JNIEnv *e, jobject o, jlong sock, jlong timeout);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_timeoutGet(JNIEnv *e, jobject o, jlong sock);
jboolean __fastcall Java_org_apache_tomcat_jni_Socket_atmark(JNIEnv *e, jobject o, jlong sock);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_sendfile(JNIEnv *e, jobject o, jlong sock, jlong file, jobjectArray headers, jobjectArray trailers, jlong offset, jlong len, jint flags);
jlong __fastcall Java_org_apache_tomcat_jni_Socket_sendfilen(JNIEnv *e, jobject o, jlong sock, jlong file, jlong offset, jlong len, jint flags);
jint __fastcall Java_org_apache_tomcat_jni_Socket_acceptfilter(JNIEnv *e, jobject o, jlong sock, jstring name, jstring args);
jint __fastcall Java_org_apache_tomcat_jni_Socket_dataSet(JNIEnv *e, jobject o, jlong sock, jstring key, jobject data);
jobject __fastcall Java_org_apache_tomcat_jni_Socket_dataGet(JNIEnv *e, jobject o, jlong socket, jstring key);
jstring __fastcall Java_org_apache_tomcat_jni_OS_defaultEncoding(JNIEnv *e, jobject o, jlong pool);
jstring __fastcall Java_org_apache_tomcat_jni_OS_localeEncoding(JNIEnv *e, jobject o, jlong pool);
apr_status_t __fastcall do_add(tcn_pollset_t *p, tcn_socket_t_0 *s, apr_int16_t reqevents, apr_interval_time_t socket_timeout);
jlong __fastcall Java_org_apache_tomcat_jni_Poll_create(JNIEnv *e, jobject o, jint size, jlong pool, jint flags, jlong default_timeout);
jint __fastcall Java_org_apache_tomcat_jni_Poll_destroy(JNIEnv *e, jobject o, jlong pollset);
jint __fastcall Java_org_apache_tomcat_jni_Poll_add(JNIEnv *e, jobject o, jlong pollset, jlong socket, jint reqevents);
jint __fastcall Java_org_apache_tomcat_jni_Poll_addWithTimeout(JNIEnv *e, jobject o, jlong pollset, jlong socket, jint reqevents, jlong socket_timeout);
jint __fastcall Java_org_apache_tomcat_jni_Poll_remove(JNIEnv *e, jobject o, jlong pollset, jlong socket);
jint __fastcall Java_org_apache_tomcat_jni_Poll_poll(JNIEnv *e, jobject o, jlong pollset, jlong timeout, jlongArray set, jboolean remove);
jint __fastcall Java_org_apache_tomcat_jni_Poll_maintain(JNIEnv *e, jobject o, jlong pollset, jlongArray set, jboolean remove);
void __fastcall Java_org_apache_tomcat_jni_Poll_setTtl(JNIEnv *e, jobject o, jlong pollset, jlong default_timeout);
jlong __fastcall Java_org_apache_tomcat_jni_Poll_getTtl(JNIEnv *e, jobject o, jlong pollset);
jint __fastcall Java_org_apache_tomcat_jni_Poll_pollset(JNIEnv *e, jobject o, jlong pollset, jlongArray set);
jboolean __fastcall Java_org_apache_tomcat_jni_Poll_wakeable(JNIEnv *e, jobject o, jlong pollset);
jint __fastcall Java_org_apache_tomcat_jni_Poll_interrupt(JNIEnv *e, jobject o, jlong pollset);
apr_status_t __fastcall generic_pool_cleanup(void *data);
apr_status_t __fastcall generic_pool_data_cleanup(void *data);
jlong __fastcall Java_org_apache_tomcat_jni_Pool_create(JNIEnv *e, jobject o, jlong parent);
jlong __fastcall Java_org_apache_tomcat_jni_Pool_unmanaged(JNIEnv *e, jobject o);
void __fastcall Java_org_apache_tomcat_jni_Pool_clear(JNIEnv *e, jobject o, jlong pool);
void __fastcall Java_org_apache_tomcat_jni_Pool_destroy(JNIEnv *e, jobject o, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_Pool_parentGet(JNIEnv *e, jobject o, jlong pool);
jboolean __fastcall Java_org_apache_tomcat_jni_Pool_isAncestor(JNIEnv *e, jobject o, jlong a, jlong b);
jlong __fastcall Java_org_apache_tomcat_jni_Pool_palloc(JNIEnv *e, jobject o, jlong pool, jint size);
jlong __fastcall Java_org_apache_tomcat_jni_Pool_pcalloc(JNIEnv *e, jobject o, jlong pool, jint size);
jlong __fastcall Java_org_apache_tomcat_jni_Pool_cleanupRegister(JNIEnv *e, jobject o, jlong pool, jobject obj);
void __fastcall Java_org_apache_tomcat_jni_Pool_cleanupKill(JNIEnv *e, jobject o, jlong pool, jlong data);
jobject __fastcall Java_org_apache_tomcat_jni_Pool_alloc(JNIEnv *e, jobject o, jlong pool, jint size);
jobject __fastcall Java_org_apache_tomcat_jni_Pool_calloc(JNIEnv *e, jobject o, jlong pool, jint size);
jint __fastcall Java_org_apache_tomcat_jni_Pool_dataSet(JNIEnv *e, jobject o, jlong pool, jstring key, jobject data);
jobject __fastcall Java_org_apache_tomcat_jni_Pool_dataGet(JNIEnv *e, jobject o, jlong pool, jstring key);
void __fastcall generic_child_errfn(apr_pool_t_0 *pool, apr_status_t err, const char *description);
apr_status_t __fastcall child_errfn_pool_cleanup(void *data);
jlong __fastcall Java_org_apache_tomcat_jni_Procattr_create(JNIEnv *e, jobject o, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_ioSet(JNIEnv *e, jobject o, jlong attr, jint in, jint out, jint err);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_childInSet(JNIEnv *e, jobject o, jlong attr, jlong in, jlong parent);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_childOutSet(JNIEnv *e, jobject o, jlong attr, jlong out, jlong parent);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_childErrSet(JNIEnv *e, jobject o, jlong attr, jlong err, jlong parent);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_dirSet(JNIEnv *e, jobject o, jlong attr, jstring dir);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_cmdtypeSet(JNIEnv *e, jobject o, jlong attr, jint cmd);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_detachSet(JNIEnv *e, jobject o, jlong attr, jint detach);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_errorCheckSet(JNIEnv *e, jobject o, jlong attr, jint chk);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_addrspaceSet(JNIEnv *e, jobject o, jlong attr, jint addr);
jlong __fastcall Java_org_apache_tomcat_jni_Proc_alloc(JNIEnv *e, jobject o, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Proc_create(JNIEnv *e, jobject o, jlong proc, jstring progname, jobjectArray args, jobjectArray env, jlong attr, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Proc_wait(JNIEnv *e, jobject o, jlong proc, jintArray rvals, jint waithow);
jint __fastcall Java_org_apache_tomcat_jni_Proc_waitAllProcs(JNIEnv *e, jobject o, jlong proc, jintArray rvals, jint waithow, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Proc_detach(JNIEnv *e, jobject o, jint daemonize);
jint __fastcall Java_org_apache_tomcat_jni_Proc_kill(JNIEnv *e, jobject o, jlong proc, jint sig);
void __fastcall Java_org_apache_tomcat_jni_Pool_noteSubprocess(JNIEnv *e, jobject o, jlong pool, jlong proc, jint how);
jint __fastcall Java_org_apache_tomcat_jni_Proc_fork(JNIEnv *e, jobject o, jlongArray proc, jlong pool);
void __fastcall Java_org_apache_tomcat_jni_Procattr_errfnSet(JNIEnv *e, jobject o, jlong attr, jlong pool, jobject obj);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_userSet(JNIEnv *e, jobject o, jlong attr, jstring username, jstring password);
jint __fastcall Java_org_apache_tomcat_jni_Procattr_groupSet(JNIEnv *e, jobject o, jlong attr, jstring group);
jlong __fastcall Java_org_apache_tomcat_jni_Shm_create(JNIEnv *e, jobject o, jlong reqsize, jstring filename, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Shm_remove(JNIEnv *e, jobject o, jstring filename, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Shm_destroy(JNIEnv *e, jobject o, jlong shm);
jlong __fastcall Java_org_apache_tomcat_jni_Shm_attach(JNIEnv *e, jobject o, jstring filename, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Shm_detach(JNIEnv *e, jobject o, jlong shm);
jlong __fastcall Java_org_apache_tomcat_jni_Shm_baseaddr(JNIEnv *e, jobject o, jlong shm);
jlong __fastcall Java_org_apache_tomcat_jni_Shm_size(JNIEnv *e, jobject o, jlong shm);
jobject __fastcall Java_org_apache_tomcat_jni_Shm_buffer(JNIEnv *e, jobject o, jlong shm);
__int64 __fastcall jbs_ctrl(BIO *b, int cmd, __int64 num, void *ptr);
int __fastcall ssl_rand_load_file(const char *file);
apr_status_t __fastcall ssl_thread_cleanup(void *data);
void __fastcall ssl_dyn_destroy_function(CRYPTO_dynlock_value *l, const char *file, int line);
void __fastcall ssl_dyn_lock_function(int mode, CRYPTO_dynlock_value *l, const char *file, int line);
CRYPTO_dynlock_value *__fastcall ssl_dyn_create_function(const char *file, int line);
void __fastcall ssl_set_thread_id(CRYPTO_THREADID *id);
int __fastcall ssl_rand_save_file(const char *file);
int __fastcall ssl_rand_make(const char *file, int len, int base64);
apr_status_t __fastcall generic_bio_cleanup(void *data);
int __fastcall jbs_free(BIO *bi);
int __fastcall jbs_new(BIO *bi);
int __fastcall jbs_write(BIO *b, const char *in, int inl);
apr_status_t __fastcall ssl_con_pool_cleanup(void *data);
void __fastcall ssl_thread_lock(int mode, int type, const char *file, int line);
__int64 __fastcall ssl_init_cleanup_0(void *data);
apr_status_t __fastcall ssl_init_cleanup(void *data);
int __fastcall jbs_gets(BIO *b, char *out, int outl);
int __fastcall jbs_puts(BIO *b, const char *in);
int __fastcall jbs_read(BIO *b, char *out, int outl);
void __fastcall ssl_info_callback(const SSL *ssl, int where, int ret);
int __fastcall DH_set0_pqg(DH *dh_0, BIGNUM *p, BIGNUM *q, BIGNUM *g);
DH *__fastcall SSL_get_dh_params(unsigned int keylen);
jint __fastcall Java_org_apache_tomcat_jni_SSL_version(JNIEnv *e, jobject o);
jstring __fastcall Java_org_apache_tomcat_jni_SSL_versionString(JNIEnv *e, jobject o);
void __cdecl SSL_thread_exit();
void __fastcall ssl_thread_exit(void *data);
unsigned __int64 __cdecl SSL_ERR_get();
void __cdecl SSL_ERR_clear();
int __fastcall SSL_rand_seed(const char *file);
jint __fastcall Java_org_apache_tomcat_jni_SSL_initialize(JNIEnv *e, jobject o, jstring engine);
jboolean __fastcall Java_org_apache_tomcat_jni_SSL_randLoad(JNIEnv *e, jobject o, jstring file);
jboolean __fastcall Java_org_apache_tomcat_jni_SSL_randSave(JNIEnv *e, jobject o, jstring file);
jboolean __fastcall Java_org_apache_tomcat_jni_SSL_randMake(JNIEnv *e, jobject o, jstring file, jint length, jboolean base64);
void __fastcall Java_org_apache_tomcat_jni_SSL_randSet(JNIEnv *e, jobject o, jstring file);
jint __fastcall Java_org_apache_tomcat_jni_SSL_fipsModeSet(JNIEnv *e, jobject o, jint mode);
void __fastcall SSL_BIO_close(BIO *bi);
void __fastcall SSL_BIO_doref(BIO *bi);
jlong __fastcall Java_org_apache_tomcat_jni_SSL_newBIO(JNIEnv *e, jobject o, jlong pool, jobject callback);
jint __fastcall Java_org_apache_tomcat_jni_SSL_closeBIO(JNIEnv *e, jobject o, jlong bio);
void __fastcall Java_org_apache_tomcat_jni_SSL_setPasswordCallback(JNIEnv *e, jobject o, jobject callback);
void __fastcall Java_org_apache_tomcat_jni_SSL_setPassword(JNIEnv *e, jobject o, jstring password);
jstring __fastcall Java_org_apache_tomcat_jni_SSL_getLastError(JNIEnv *e, jobject o);
jboolean __fastcall Java_org_apache_tomcat_jni_SSL_hasOp(JNIEnv *e, jobject o, jint op);
jint __fastcall Java_org_apache_tomcat_jni_SSL_getLastErrorNumber(JNIEnv *e, jobject o);
jlong __fastcall Java_org_apache_tomcat_jni_SSL_newSSL(JNIEnv *e, jobject o, jlong ctx, jboolean server);
void __fastcall Java_org_apache_tomcat_jni_SSL_setBIO(JNIEnv *e, jobject o, jlong ssl, jlong rbio, jlong wbio);
jint __fastcall Java_org_apache_tomcat_jni_SSL_getError(JNIEnv *e, jobject o, jlong ssl, jint ret);
jint __fastcall Java_org_apache_tomcat_jni_SSL_pendingWrittenBytesInBIO(JNIEnv *e, jobject o, jlong bio);
jint __fastcall Java_org_apache_tomcat_jni_SSL_pendingReadableBytesInSSL(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_writeToBIO(JNIEnv *e, jobject o, jlong bio, jlong wbuf, jint wlen);
jint __fastcall Java_org_apache_tomcat_jni_SSL_readFromBIO(JNIEnv *e, jobject o, jlong bio, jlong rbuf, jint rlen);
jint __fastcall Java_org_apache_tomcat_jni_SSL_writeToSSL(JNIEnv *e, jobject o, jlong ssl, jlong wbuf, jint wlen);
jint __fastcall Java_org_apache_tomcat_jni_SSL_readFromSSL(JNIEnv *e, jobject o, jlong ssl, jlong rbuf, jint rlen);
jint __fastcall Java_org_apache_tomcat_jni_SSL_getShutdown(JNIEnv *e, jobject o, jlong ssl);
void __fastcall Java_org_apache_tomcat_jni_SSL_setShutdown(JNIEnv *e, jobject o, jlong ssl, jint mode);
void __fastcall Java_org_apache_tomcat_jni_SSL_freeSSL(JNIEnv *e, jobject o, jlong ssl);
jlong __fastcall Java_org_apache_tomcat_jni_SSL_makeNetworkBIO(JNIEnv *e, jobject o, jlong ssl);
void __fastcall Java_org_apache_tomcat_jni_SSL_freeBIO(JNIEnv *e, jobject o, jlong bio);
jint __fastcall Java_org_apache_tomcat_jni_SSL_shutdownSSL(JNIEnv *e, jobject o, jlong ssl);
jstring __fastcall Java_org_apache_tomcat_jni_SSL_getCipherForSSL(JNIEnv *e, jobject o, jlong ssl);
jstring __fastcall Java_org_apache_tomcat_jni_SSL_getVersion(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_isInInit(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_doHandshake(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_renegotiate(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_renegotiatePending(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_verifyClientPostHandshake(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_getPostHandshakeAuthInProgress(JNIEnv *e, jobject o, jlong ssl);
jstring __fastcall Java_org_apache_tomcat_jni_SSL_getNextProtoNegotiated(JNIEnv *e, jobject o, jlong ssl);
jstring __fastcall Java_org_apache_tomcat_jni_SSL_getAlpnSelected(JNIEnv *e, jobject o, jlong ssl);
jobjectArray __fastcall Java_org_apache_tomcat_jni_SSL_getPeerCertChain(JNIEnv *e, jobject o, jlong ssl);
jbyteArray __fastcall Java_org_apache_tomcat_jni_SSL_getPeerCertificate(JNIEnv *e, jobject o, jlong ssl);
jstring __fastcall Java_org_apache_tomcat_jni_SSL_getErrorString(JNIEnv *e, jobject o, jlong number);
jlong __fastcall Java_org_apache_tomcat_jni_SSL_getTime(JNIEnv *e, jobject o, jlong ssl);
void __fastcall Java_org_apache_tomcat_jni_SSL_setVerify(JNIEnv *e, jobject o, jlong ssl, jint level, jint depth);
void __fastcall Java_org_apache_tomcat_jni_SSL_setOptions(JNIEnv *e, jobject o, jlong ssl, jint opt);
jint __fastcall Java_org_apache_tomcat_jni_SSL_getOptions(JNIEnv *e, jobject o, jlong ssl);
jobjectArray __fastcall Java_org_apache_tomcat_jni_SSL_getCiphers(JNIEnv *e, jobject o, jlong ssl);
jboolean __fastcall Java_org_apache_tomcat_jni_SSL_setCipherSuites(JNIEnv *e, jobject o, jlong ssl, jstring ciphers);
jbyteArray __fastcall Java_org_apache_tomcat_jni_SSL_getSessionId(JNIEnv *e, jobject o, jlong ssl);
jint __fastcall Java_org_apache_tomcat_jni_SSL_getHandshakeCount(JNIEnv *e, jobject o, jlong ssl);
apr_status_t __fastcall ssl_ctx_config_cleanup(void *data);
jlong __fastcall Java_org_apache_tomcat_jni_SSLConf_make(JNIEnv *e, jobject o, jlong pool, jint flags);
void __fastcall Java_org_apache_tomcat_jni_SSLConf_free(JNIEnv *e, jobject o, jlong cctx);
jint __fastcall Java_org_apache_tomcat_jni_SSLConf_check(JNIEnv *e, jobject o, jlong cctx, jstring cmd, jstring value);
void __fastcall Java_org_apache_tomcat_jni_SSLConf_assign(JNIEnv *e, jobject o, jlong cctx, jlong ctx);
jint __fastcall Java_org_apache_tomcat_jni_SSLConf_apply(JNIEnv *e, jobject o, jlong cctx, jstring cmd, jstring value);
jint __fastcall Java_org_apache_tomcat_jni_SSLConf_finish(JNIEnv *e, jobject o, jlong cctx);
int __fastcall ssl_callback_ServerNameIndication(SSL *ssl, int *al_0, tcn_ssl_ctxt_t_0 *c);
apr_status_t __fastcall ssl_context_cleanup(void *data);
int __fastcall SSL_cert_verify(X509_STORE_CTX *ctx, void *arg);
signed __int64 __fastcall initProtocols(JNIEnv *e, const tcn_ssl_ctxt_t_0 *c, unsigned __int8 **proto_data, unsigned int *proto_len, jobjectArray protos);
int __fastcall cb_server_alpn(SSL *ssl, const unsigned __int8 **out, unsigned __int8 *outlen, const unsigned __int8 *in, unsigned int inlen, void *arg);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_make(JNIEnv *e, jobject o, jlong pool, jint protocol, jint mode);
jint __fastcall Java_org_apache_tomcat_jni_SSLContext_free(JNIEnv *e, jobject o, jlong ctx);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setContextId(JNIEnv *e, jobject o, jlong ctx, jstring id);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setBIO(JNIEnv *e, jobject o, jlong ctx, jlong bio, jint dir);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setOptions(JNIEnv *e, jobject o, jlong ctx, jint opt);
jint __fastcall Java_org_apache_tomcat_jni_SSLContext_getOptions(JNIEnv *e, jobject o, jlong ctx);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_clearOptions(JNIEnv *e, jobject o, jlong ctx, jint opt);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setQuietShutdown(JNIEnv *e, jobject o, jlong ctx, jboolean mode);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_setCipherSuite(JNIEnv *e, jobject o, jlong ctx, jstring ciphers);
jobjectArray __fastcall Java_org_apache_tomcat_jni_SSLContext_getCiphers(JNIEnv *e, jobject o, jlong ctx);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_setCARevocation(JNIEnv *e, jobject o, jlong ctx, jstring file, jstring path);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_setCertificateChainFile(JNIEnv *e, jobject o, jlong ctx, jstring file, jboolean skipfirst);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_setCACertificate(JNIEnv *e, jobject o, jlong ctx, jstring file, jstring path);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setTmpDH(JNIEnv *e, jobject o, jlong ctx, jstring file);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setTmpECDHByCurveName(JNIEnv *e, jobject o, jlong ctx, jstring curveName);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setShutdownType(JNIEnv *e, jobject o, jlong ctx, jint type);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setVerify(JNIEnv *e, jobject o, jlong ctx, jint level, jint depth);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setRandom(JNIEnv *e, jobject o, jlong ctx, jstring file);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_setCertificate(JNIEnv *e, jobject o, jlong ctx, jstring cert, jstring key, jstring password, jint idx);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_setCertificateRaw(JNIEnv *e, jobject o, jlong ctx, jbyteArray javaCert, jbyteArray javaKey, jint idx);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_addChainCertificateRaw(JNIEnv *e, jobject o, jlong ctx, jbyteArray javaCert);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_addClientCACertificateRaw(JNIEnv *e, jobject o, jlong ctx, jbyteArray javaCert);
jint __fastcall Java_org_apache_tomcat_jni_SSLContext_setALPN(JNIEnv *e, jobject o, jlong ctx, jbyteArray buf, jint len);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setNpnProtos(JNIEnv *e, jobject o, jlong ctx, jobjectArray next_protos, jint selectorFailureBehavior);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setAlpnProtos(JNIEnv *e, jobject o, jlong ctx, jobjectArray alpn_protos, jint selectorFailureBehavior);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_setSessionCacheMode(JNIEnv *e, jobject o, jlong ctx, jlong mode);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_getSessionCacheMode(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_setSessionCacheTimeout(JNIEnv *e, jobject o, jlong ctx, jlong timeout);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_getSessionCacheTimeout(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_setSessionCacheSize(JNIEnv *e, jobject o, jlong ctx, jlong size);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_getSessionCacheSize(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionNumber(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionConnect(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionConnectGood(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionConnectRenegotiate(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionAccept(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionAcceptGood(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionAcceptRenegotiate(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionHits(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionCbHits(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionMisses(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionTimeouts(JNIEnv *e, jobject o, jlong ctx);
jlong __fastcall Java_org_apache_tomcat_jni_SSLContext_sessionCacheFull(JNIEnv *e, jobject o, jlong ctx);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setSessionTicketKeys(JNIEnv *e, jobject o, jlong ctx, jbyteArray keys);
void __fastcall Java_org_apache_tomcat_jni_SSLContext_setCertVerifyCallback(JNIEnv *e, jobject o, jlong ctx, jobject verifier);
jboolean __fastcall Java_org_apache_tomcat_jni_SSLContext_setSessionIdContext(JNIEnv *e, jobject o, jlong ctx, jbyteArray sidCtx);
unsigned __int8 *__fastcall get_cert_ASN1(X509 *xs, int *len);
char *__fastcall lookup_ssl_cert_dn(X509_NAME *xsname, int dnidx);
char *__fastcall get_cert_valid(ASN1_UTCTIME *tm);
char *__fastcall get_cert_serial(X509 *xs);
char *__fastcall get_cert_PEM(X509 *xs);
jbyteArray __fastcall Java_org_apache_tomcat_jni_SSLSocket_getInfoB(JNIEnv *e, jobject o, jlong sock, jint what);
jstring __fastcall Java_org_apache_tomcat_jni_SSLSocket_getInfoS(JNIEnv *e, jobject o, jlong sock, jint what);
jint __fastcall Java_org_apache_tomcat_jni_SSLSocket_getInfoI(JNIEnv *e, jobject o, jlong sock, jint what);
apr_status_t __fastcall ssl_socket_timeout_get(apr_socket_t_0 *sock, apr_interval_time_t *t);
apr_status_t __fastcall ssl_socket_timeout_set(apr_socket_t_0 *sock, apr_interval_time_t t);
apr_status_t __fastcall ssl_socket_opt_set(apr_socket_t_0 *sock, apr_int32_t opt, apr_int32_t on);
apr_status_t __fastcall ssl_socket_opt_get(apr_socket_t_0 *sock, apr_int32_t opt, apr_int32_t *on);
int __fastcall ssl_smart_shutdown(SSL *ssl, int shutdown_type);
apr_status_t __fastcall ssl_socket_shutdown(apr_socket_t_0 *sock, apr_shutdown_how_e how);
apr_status_t __fastcall ssl_socket_close(apr_socket_t_0 *sock);
apr_status_t __fastcall ssl_cleanup(void *data);
tcn_ssl_conn_t *__fastcall ssl_create(JNIEnv *env, tcn_ssl_ctxt_t_0 *ctx, apr_pool_t_0 *pool);
apr_status_t __fastcall wait_for_io_or_timeout(tcn_ssl_conn_t *con, int for_what, apr_interval_time_t timeout);
apr_status_t __fastcall ssl_socket_recv(apr_socket_t_0 *sock, char *buf, apr_size_t *len);
apr_status_t __fastcall ssl_socket_send(apr_socket_t_0 *sock, const char *buf, apr_size_t *len);
apr_status_t __fastcall ssl_socket_sendv(apr_socket_t_0 *sock, const iovec *vec, apr_int32_t nvec, apr_size_t *len);
jint __fastcall Java_org_apache_tomcat_jni_SSLSocket_handshake(JNIEnv *e, jobject o, jlong sock);
jint __fastcall Java_org_apache_tomcat_jni_SSLSocket_attach(JNIEnv *e, jobject o, jlong ctx, jlong sock);
jint __fastcall Java_org_apache_tomcat_jni_SSLSocket_renegotiate(JNIEnv *e, jobject o, jlong sock);
void __fastcall Java_org_apache_tomcat_jni_SSLSocket_setVerify(JNIEnv *e, jobject o, jlong sock, jint cverify, jint depth);
jint __fastcall Java_org_apache_tomcat_jni_SSLSocket_getALPN(JNIEnv *e, jobject o, jlong sock, jbyteArray buf);
int __fastcall parse_asn1_length(unsigned __int8 **asn1, int *len);
int __fastcall parse_ASN1_Sequence(unsigned __int8 *asn1, char ***ocsp_urls, int *nocsp_urls, apr_pool_t_0 *p);
int __fastcall ocsp_send_req(apr_socket_t_0 *sock, BIO *req);
OCSP_RESPONSE *__fastcall ocsp_get_resp(apr_pool_t_0 *mp, apr_socket_t_0 *sock);
void __cdecl SSL_init_app_data_idx();
void *__fastcall SSL_get_app_data2(SSL *ssl);
void __fastcall SSL_set_app_data2(SSL *ssl, void *arg);
void *__fastcall SSL_get_app_data3(const SSL *ssl);
void __fastcall SSL_set_app_data3(SSL *ssl, void *arg);
void *__fastcall SSL_get_app_data4(const SSL *ssl);
void __fastcall SSL_set_app_data4(SSL *ssl, void *arg);
int __fastcall SSL_password_prompt(tcn_pass_cb_t *data);
int __fastcall SSL_password_callback(char *buf, int bufsiz, int verify, void *cb);
DH *__fastcall SSL_dh_GetParamFromFile(const char *file);
EC_GROUP *__fastcall SSL_ec_GetParamFromFile(const char *file);
DH *__fastcall SSL_callback_tmp_DH(SSL *ssl, int export, int keylen);
int __fastcall SSL_CTX_use_certificate_chain(SSL_CTX *ctx, const char *file, int skipfirst);
int __fastcall SSL_callback_SSL_verify(int ok, X509_STORE_CTX *ctx);
void __fastcall SSL_callback_handshake(const SSL *ssl, int where, int rc);
int __fastcall SSL_callback_next_protos(SSL *ssl, const unsigned __int8 **data, unsigned int *len, void *arg);
int __fastcall select_next_proto(SSL *ssl, const unsigned __int8 **out, unsigned __int8 *outlen, const unsigned __int8 *in, unsigned int inlen, unsigned __int8 *supported_protos, unsigned int supported_protos_len, int failure_behavior);
int __fastcall SSL_callback_select_next_proto(SSL *ssl, unsigned __int8 **out, unsigned __int8 *outlen, const unsigned __int8 *in, unsigned int inlen, void *arg);
int __fastcall SSL_callback_alpn_select_proto(SSL *ssl, const unsigned __int8 **out, unsigned __int8 *outlen, const unsigned __int8 *in, unsigned int inlen, void *arg);
jlong __fastcall Java_org_apache_tomcat_jni_Stdlib_malloc(JNIEnv *e, jobject o, jint size);
jlong __fastcall Java_org_apache_tomcat_jni_Stdlib_realloc(JNIEnv *e, jobject o, jlong mem, jint size);
jlong __fastcall Java_org_apache_tomcat_jni_Stdlib_calloc(JNIEnv *e, jobject o, jint num, jint size);
void __fastcall Java_org_apache_tomcat_jni_Stdlib_free(JNIEnv *e, jobject o, jlong mem);
jboolean __fastcall Java_org_apache_tomcat_jni_Stdlib_memread(JNIEnv *e, jobject o, jbyteArray dst, jlong src, jint sz);
jboolean __fastcall Java_org_apache_tomcat_jni_Stdlib_memwrite(JNIEnv *e, jobject o, jlong dst, jbyteArray src, jint sz);
jboolean __fastcall Java_org_apache_tomcat_jni_Stdlib_memset(JNIEnv *e, jobject o, jlong dst, jint c, jint sz);
jint __fastcall Java_org_apache_tomcat_jni_Stdlib_getppid(JNIEnv *e, jobject o);
jlong __fastcall Java_org_apache_tomcat_jni_User_uidCurrent(JNIEnv *e, jobject o, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_User_gidCurrent(JNIEnv *e, jobject o, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_User_uid(JNIEnv *e, jobject o, jstring uname, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_User_usergid(JNIEnv *e, jobject o, jstring uname, jlong pool);
jlong __fastcall Java_org_apache_tomcat_jni_User_gid(JNIEnv *e, jobject o, jstring gname, jlong pool);
jstring __fastcall Java_org_apache_tomcat_jni_User_username(JNIEnv *e, jobject o, jlong userid, jlong pool);
jstring __fastcall Java_org_apache_tomcat_jni_User_groupname(JNIEnv *e, jobject o, jlong grpid, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_User_uidcompare(JNIEnv *e, jobject o, jlong left, jlong right);
jint __fastcall Java_org_apache_tomcat_jni_User_gidcompare(JNIEnv *e, jobject o, jlong left, jlong right);
jstring __fastcall Java_org_apache_tomcat_jni_User_homepath(JNIEnv *e, jobject o, jstring uname, jlong pool);
jboolean __fastcall Java_org_apache_tomcat_jni_OS_is(JNIEnv *e, jobject o, jint type);
jint __fastcall Java_org_apache_tomcat_jni_OS_info(JNIEnv *e, jobject o, jlongArray inf);
jstring __fastcall Java_org_apache_tomcat_jni_OS_expand(JNIEnv *e, jobject o, jstring val);
void __fastcall Java_org_apache_tomcat_jni_OS_sysloginit(JNIEnv *e, jobject o, jstring domain);
void __fastcall Java_org_apache_tomcat_jni_OS_syslog(JNIEnv *e, jobject o, jint level, jstring msg);
apr_status_t __fastcall uxp_socket_timeout_set(apr_socket_t_0 *sock, apr_interval_time_t t);
apr_status_t __fastcall uxp_socket_timeout_get(apr_socket_t_0 *sock, apr_interval_time_t *t);
apr_status_t __fastcall uxp_socket_cleanup(void *data);
apr_status_t __fastcall uxp_socket_recv(apr_socket_t_0 *sock, char *buf, apr_size_t *len);
apr_status_t __fastcall uxp_socket_sendv(apr_socket_t_0 *sock, const iovec *vec, apr_int32_t nvec, apr_size_t *len);
apr_status_t __fastcall uxp_socket_send(apr_socket_t_0 *sock, const char *buf, apr_size_t *len);
apr_status_t __fastcall uxp_socket_opt_set(apr_socket_t_0 *sock, apr_int32_t opt, apr_int32_t on);
apr_status_t __fastcall uxp_socket_opt_get(apr_socket_t_0 *sock, apr_int32_t opt, apr_int32_t *on);
apr_status_t __fastcall uxp_socket_shutdown(apr_socket_t_0 *sock, apr_shutdown_how_e how);
apr_status_t __fastcall uxp_cleanup(void *data);
jlong __fastcall Java_org_apache_tomcat_jni_Local_create(JNIEnv *e, jobject o, jstring name, jlong pool);
jint __fastcall Java_org_apache_tomcat_jni_Local_bind(JNIEnv *e, jobject o, jlong sock, jlong sa);
jint __fastcall Java_org_apache_tomcat_jni_Local_listen(JNIEnv *e, jobject o, jlong sock, jint backlog);
jlong __fastcall Java_org_apache_tomcat_jni_Local_accept(JNIEnv *e, jobject o, jlong sock);
jint __fastcall Java_org_apache_tomcat_jni_Local_connect(JNIEnv *e, jobject o, jlong sock, jlong sa);
void term_proc();

 

通过作者逐步搜索,终于找到了rfc822对应的unix/win32平台的c代码,不到黄河心不死的人终于翻出来代码。

项目地址:https://github.com/apache/apr

代码里有rfc822、ctime代码,另外一个文件time.c代码里面有sleep相关代码。感兴趣的朋友翻阅apr官方源码吧,也可以根据misc.c去翻阅对应的apr实现。

windows平台代码:https://github.com/apache/apr/blob/trunk/time/win32/timestr.c

/* 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.
 */

#include "apr_arch_atime.h"
#include "apr_portable.h"
#include "apr_strings.h"

#if APR_HAVE_STDLIB_H
#include <stdlib.h>
#endif

APR_DECLARE_DATA const char apr_month_snames[12][4] =
{
    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
APR_DECLARE_DATA const char apr_day_snames[7][4] =
{
    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};

APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t)
{
    apr_time_exp_t xt;
    const char *s;
    int real_year;

    apr_time_exp_gmt(&xt, t);

    /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */
    /*           12345678901234567890123456789  */

    s = &apr_day_snames[xt.tm_wday][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ',';
    *date_str++ = ' ';
    *date_str++ = xt.tm_mday / 10 + '0';
    *date_str++ = xt.tm_mday % 10 + '0';
    *date_str++ = ' ';
    s = &apr_month_snames[xt.tm_mon][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ' ';
    real_year = 1900 + xt.tm_year;
    /* This routine isn't y10k ready. */
    *date_str++ = real_year / 1000 + '0';
    *date_str++ = real_year % 1000 / 100 + '0';
    *date_str++ = real_year % 100 / 10 + '0';
    *date_str++ = real_year % 10 + '0';
    *date_str++ = ' ';
    *date_str++ = xt.tm_hour / 10 + '0';
    *date_str++ = xt.tm_hour % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_min / 10 + '0';
    *date_str++ = xt.tm_min % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_sec / 10 + '0';
    *date_str++ = xt.tm_sec % 10 + '0';
    *date_str++ = ' ';
    *date_str++ = 'G';
    *date_str++ = 'M';
    *date_str++ = 'T';
    *date_str++ = 0;
    return APR_SUCCESS;
}

APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t)
{
    apr_time_exp_t xt;
    const char *s;
    int real_year;

    /* example: "Wed Jun 30 21:49:08 1993" */
    /*           123456789012345678901234  */

    apr_time_exp_lt(&xt, t);
    s = &apr_day_snames[xt.tm_wday][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ' ';
    s = &apr_month_snames[xt.tm_mon][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ' ';
    *date_str++ = xt.tm_mday / 10 + '0';
    *date_str++ = xt.tm_mday % 10 + '0';
    *date_str++ = ' ';
    *date_str++ = xt.tm_hour / 10 + '0';
    *date_str++ = xt.tm_hour % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_min / 10 + '0';
    *date_str++ = xt.tm_min % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_sec / 10 + '0';
    *date_str++ = xt.tm_sec % 10 + '0';
    *date_str++ = ' ';
    real_year = 1900 + xt.tm_year;
    *date_str++ = real_year / 1000 + '0';
    *date_str++ = real_year % 1000 / 100 + '0';
    *date_str++ = real_year % 100 / 10 + '0';
    *date_str++ = real_year % 10 + '0';
    *date_str++ = 0;

    return APR_SUCCESS;
}


#ifndef _WIN32_WCE

static apr_size_t win32_strftime_extra(char *s, size_t max, const char *format,
                                       const struct tm *tm) 
{
   /* If the new format string is bigger than max, the result string won't fit
    * anyway. If format strings are added, made sure the padding below is
    * enough */
    char *new_format = (char *) malloc(max + 11);
    size_t i, j, format_length = strlen(format);
    apr_size_t return_value;
    int length_written;

    for (i = 0, j = 0; (i < format_length && j < max);) {
        if (format[i] != '%') {
            new_format[j++] = format[i++];
            continue;
        }
        switch (format[i+1]) {
            case 'C':
                length_written = apr_snprintf(new_format + j, max - j, "%2d",
                    (tm->tm_year + 1970)/100);
                j = (length_written == -1) ? max : (j + length_written);
                i += 2;
                break;
            case 'D':
                /* Is this locale dependent? Shouldn't be...
                   Also note the year 2000 exposure here */
                memcpy(new_format + j, "%m/%d/%y", 8);
                i += 2;
                j += 8;
                break;
            case 'r':
                memcpy(new_format + j, "%I:%M:%S %p", 11);
                i += 2;
                j += 11;
                break;
            case 'R':
                memcpy(new_format + j, "%H:%M", 5);
                i += 2;
                j += 5;
                break;
            case 'T':
                memcpy(new_format + j, "%H:%M:%S", 8);
                i += 2;
                j += 8;
                break;
            case 'e':
                length_written = apr_snprintf(new_format + j, max - j, "%2d",
                    tm->tm_mday);
                j = (length_written == -1) ? max : (j + length_written);
                i += 2;
                break;
            default:
                /* We know we can advance two characters forward here. Also
                 * makes sure that %% is preserved. */
                new_format[j++] = format[i++];
                new_format[j++] = format[i++];
        }
    }
    if (j >= max) {
        *s = '\0';  /* Defensive programming, okay since output is undefined*/
        return_value = 0;
    } else {
        new_format[j] = '\0';
        return_value = strftime(s, max, new_format, tm);
    }
    free(new_format);
    return return_value;
}

#endif


APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize,
                                       apr_size_t max, const char *format,
                                       apr_time_exp_t *xt)
{
#ifdef _WIN32_WCE
    return APR_ENOTIMPL;
#else
    struct tm tm;
    memset(&tm, 0, sizeof tm);
    tm.tm_sec  = xt->tm_sec;
    tm.tm_min  = xt->tm_min;
    tm.tm_hour = xt->tm_hour;
    tm.tm_mday = xt->tm_mday;
    tm.tm_mon  = xt->tm_mon;
    tm.tm_year = xt->tm_year;
    tm.tm_wday = xt->tm_wday;
    tm.tm_yday = xt->tm_yday;
    tm.tm_isdst = xt->tm_isdst;
    (*retsize) = win32_strftime_extra(s, max, format, &tm);
    return APR_SUCCESS;
#endif
}

 

unix平台代码:https://github.com/apache/apr/blob/trunk/time/unix/timestr.c

/* 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.
 */

#include "apr_portable.h"
#include "apr_time.h"
#include "apr_lib.h"
#include "apr_private.h"
/* System Headers required for time library */
#if APR_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#if APR_HAVE_STRING_H
#include <string.h>
#endif
/* End System Headers */

APR_DECLARE_DATA const char apr_month_snames[12][4] =
{
    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
APR_DECLARE_DATA const char apr_day_snames[7][4] =
{
    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};

apr_status_t apr_rfc822_date(char *date_str, apr_time_t t)
{
    apr_time_exp_t xt;
    const char *s;
    int real_year;

    apr_time_exp_gmt(&xt, t);

    /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */
    /*           12345678901234567890123456789  */

    s = &apr_day_snames[xt.tm_wday][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ',';
    *date_str++ = ' ';
    *date_str++ = xt.tm_mday / 10 + '0';
    *date_str++ = xt.tm_mday % 10 + '0';
    *date_str++ = ' ';
    s = &apr_month_snames[xt.tm_mon][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ' ';
    real_year = 1900 + xt.tm_year;
    /* This routine isn't y10k ready. */
    *date_str++ = real_year / 1000 + '0';
    *date_str++ = real_year % 1000 / 100 + '0';
    *date_str++ = real_year % 100 / 10 + '0';
    *date_str++ = real_year % 10 + '0';
    *date_str++ = ' ';
    *date_str++ = xt.tm_hour / 10 + '0';
    *date_str++ = xt.tm_hour % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_min / 10 + '0';
    *date_str++ = xt.tm_min % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_sec / 10 + '0';
    *date_str++ = xt.tm_sec % 10 + '0';
    *date_str++ = ' ';
    *date_str++ = 'G';
    *date_str++ = 'M';
    *date_str++ = 'T';
    *date_str++ = 0;
    return APR_SUCCESS;
}

apr_status_t apr_ctime(char *date_str, apr_time_t t)
{
    apr_time_exp_t xt;
    const char *s;
    int real_year;

    /* example: "Wed Jun 30 21:49:08 1993" */
    /*           123456789012345678901234  */

    apr_time_exp_lt(&xt, t);
    s = &apr_day_snames[xt.tm_wday][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ' ';
    s = &apr_month_snames[xt.tm_mon][0];
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = *s++;
    *date_str++ = ' ';
    *date_str++ = xt.tm_mday / 10 + '0';
    *date_str++ = xt.tm_mday % 10 + '0';
    *date_str++ = ' ';
    *date_str++ = xt.tm_hour / 10 + '0';
    *date_str++ = xt.tm_hour % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_min / 10 + '0';
    *date_str++ = xt.tm_min % 10 + '0';
    *date_str++ = ':';
    *date_str++ = xt.tm_sec / 10 + '0';
    *date_str++ = xt.tm_sec % 10 + '0';
    *date_str++ = ' ';
    real_year = 1900 + xt.tm_year;
    *date_str++ = real_year / 1000 + '0';
    *date_str++ = real_year % 1000 / 100 + '0';
    *date_str++ = real_year % 100 / 10 + '0';
    *date_str++ = real_year % 10 + '0';
    *date_str++ = 0;

    return APR_SUCCESS;
}

apr_status_t apr_strftime(char *s, apr_size_t *retsize, apr_size_t max, 
                        const char *format, apr_time_exp_t *xt)
{
    struct tm tm;
    memset(&tm, 0, sizeof tm);
    tm.tm_sec  = xt->tm_sec;
    tm.tm_min  = xt->tm_min;
    tm.tm_hour = xt->tm_hour;
    tm.tm_mday = xt->tm_mday;
    tm.tm_mon  = xt->tm_mon;
    tm.tm_year = xt->tm_year;
    tm.tm_wday = xt->tm_wday;
    tm.tm_yday = xt->tm_yday;
    tm.tm_isdst = xt->tm_isdst;
#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
    tm.tm_gmtoff = xt->tm_gmtoff;
#elif defined(HAVE_STRUCT_TM___TM_GMTOFF)
    tm.__tm_gmtoff = xt->tm_gmtoff;
#endif
    (*retsize) = strftime(s, max, format, &tm);
    return APR_SUCCESS;
}

 

posted on 2020-01-17 22:02  你不知道的浪漫  阅读(734)  评论(0编辑  收藏  举报