GME
13
|
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef ATIME_H 00018 #define ATIME_H 00019 00020 #include "apr_private.h" 00021 #include "apr_time.h" 00022 #if APR_HAVE_TIME_H 00023 #include <time.h> 00024 #endif 00025 00026 struct atime_t { 00027 apr_pool_t *cntxt; 00028 apr_time_t currtime; 00029 SYSTEMTIME *explodedtime; 00030 }; 00031 00032 00033 /* Number of micro-seconds between the beginning of the Windows epoch 00034 * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970) 00035 */ 00036 #define APR_DELTA_EPOCH_IN_USEC APR_TIME_C(11644473600000000); 00037 00038 00039 static APR_INLINE void FileTimeToAprTime(apr_time_t *result, FILETIME *input) 00040 { 00041 /* Convert FILETIME one 64 bit number so we can work with it. */ 00042 *result = input->dwHighDateTime; 00043 *result = (*result) << 32; 00044 *result |= input->dwLowDateTime; 00045 *result /= 10; /* Convert from 100 nano-sec periods to micro-seconds. */ 00046 *result -= APR_DELTA_EPOCH_IN_USEC; /* Convert from Windows epoch to Unix epoch */ 00047 return; 00048 } 00049 00050 00051 static APR_INLINE void AprTimeToFileTime(LPFILETIME pft, apr_time_t t) 00052 { 00053 LONGLONG ll; 00054 t += APR_DELTA_EPOCH_IN_USEC; 00055 ll = t * 10; 00056 pft->dwLowDateTime = (DWORD)ll; 00057 pft->dwHighDateTime = (DWORD) (ll >> 32); 00058 return; 00059 } 00060 00061 00062 #endif /* ! ATIME_H */ 00063