Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
799668c1
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
9
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
799668c1
编写于
4月 15, 2010
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
oops revert patch not part of Configure diff
上级
7f7f1551
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
99 deletion
+35
-99
crypto/o_time.c
crypto/o_time.c
+35
-98
crypto/o_time.h
crypto/o_time.h
+0
-1
未找到文件。
crypto/o_time.c
浏览文件 @
799668c1
...
...
@@ -228,73 +228,9 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
static
long
date_to_julian
(
int
y
,
int
m
,
int
d
);
static
void
julian_to_date
(
long
jd
,
int
*
y
,
int
*
m
,
int
*
d
);
static
int
julian_adj
(
struct
tm
*
tm
,
int
off_day
,
long
offset_sec
,
long
*
pday
,
int
*
psec
);
int
OPENSSL_gmtime_adj
(
struct
tm
*
tm
,
int
off_day
,
long
offset_sec
)
{
int
time_sec
,
time_year
,
time_month
,
time_day
;
long
time_jd
;
/* Convert time and offset into julian day and seconds */
if
(
!
julian_adj
(
tm
,
off_day
,
offset_sec
,
&
time_jd
,
&
time_sec
))
return
0
;
/* Convert Julian day back to date */
julian_to_date
(
time_jd
,
&
time_year
,
&
time_month
,
&
time_day
);
if
(
time_year
<
1900
||
time_year
>
9999
)
return
0
;
/* Update tm structure */
tm
->
tm_year
=
time_year
-
1900
;
tm
->
tm_mon
=
time_month
-
1
;
tm
->
tm_mday
=
time_day
;
tm
->
tm_hour
=
time_sec
/
3600
;
tm
->
tm_min
=
(
time_sec
/
60
)
%
60
;
tm
->
tm_sec
=
time_sec
%
60
;
return
1
;
}
int
OPENSSL_gmtime_diff
(
struct
tm
*
from
,
struct
tm
*
to
,
int
*
pday
,
int
*
psec
)
{
int
from_sec
,
to_sec
,
diff_sec
;
long
from_jd
,
to_jd
,
diff_day
;
if
(
!
julian_adj
(
from
,
0
,
0
,
&
from_jd
,
&
from_sec
))
return
0
;
if
(
!
julian_adj
(
to
,
0
,
0
,
&
to_jd
,
&
to_sec
))
return
0
;
diff_day
=
to_jd
-
from_jd
;
diff_sec
=
to_sec
-
from_sec
;
/* Adjust differences so both positive or both negative */
if
(
diff_day
>
0
&&
diff_sec
<
0
)
{
diff_day
--
;
diff_sec
+=
SECS_PER_DAY
;
}
if
(
diff_day
<
0
&&
diff_sec
>
0
)
{
diff_day
++
;
diff_sec
-=
SECS_PER_DAY
;
}
*
pday
=
(
int
)
diff_day
;
*
psec
=
diff_sec
;
return
1
;
}
/* Convert tm structure and offset into julian day and seconds */
static
int
julian_adj
(
struct
tm
*
tm
,
int
off_day
,
long
offset_sec
,
long
*
pday
,
int
*
psec
)
{
int
offset_hms
,
offset_day
;
long
time_jd
;
int
time_year
,
time_month
,
time_day
;
...
...
@@ -332,11 +268,26 @@ static int julian_adj(struct tm *tm, int off_day, long offset_sec,
if
(
time_jd
<
0
)
return
0
;
*
pday
=
time_jd
;
*
psec
=
offset_hms
;
return
1
;
}
/* Convert Julian day back to date */
julian_to_date
(
time_jd
,
&
time_year
,
&
time_month
,
&
time_day
);
if
(
time_year
<
1900
||
time_year
>
9999
)
return
0
;
/* Update tm structure */
tm
->
tm_year
=
time_year
-
1900
;
tm
->
tm_mon
=
time_month
-
1
;
tm
->
tm_mday
=
time_day
;
tm
->
tm_hour
=
offset_hms
/
3600
;
tm
->
tm_min
=
(
offset_hms
/
60
)
%
60
;
tm
->
tm_sec
=
offset_hms
%
60
;
return
1
;
}
/* Convert date to and from julian day
* Uses Fliegel & Van Flandern algorithm
...
...
@@ -388,42 +339,28 @@ int main(int argc, char **argv)
int
check_time
(
long
offset
)
{
struct
tm
tm1
,
tm2
,
o1
;
int
off_day
,
off_sec
;
long
toffset
;
struct
tm
tm1
,
tm2
;
time_t
t1
,
t2
;
time
(
&
t1
);
t2
=
t1
+
offset
;
OPENSSL_gmtime
(
&
t2
,
&
tm2
);
OPENSSL_gmtime
(
&
t1
,
&
tm1
);
o1
=
tm1
;
OPENSSL_gmtime_adj
(
&
tm1
,
0
,
offset
);
if
((
tm1
.
tm_year
!=
tm2
.
tm_year
)
||
(
tm1
.
tm_mon
!=
tm2
.
tm_mon
)
||
(
tm1
.
tm_mday
!=
tm2
.
tm_mday
)
||
(
tm1
.
tm_hour
!=
tm2
.
tm_hour
)
||
(
tm1
.
tm_min
!=
tm2
.
tm_min
)
||
(
tm1
.
tm_sec
!=
tm2
.
tm_sec
))
{
fprintf
(
stderr
,
"TIME ERROR!!
\n
"
);
fprintf
(
stderr
,
"Time1: %d/%d/%d, %d:%02d:%02d
\n
"
,
tm2
.
tm_mday
,
tm2
.
tm_mon
+
1
,
tm2
.
tm_year
+
1900
,
tm2
.
tm_hour
,
tm2
.
tm_min
,
tm2
.
tm_sec
);
fprintf
(
stderr
,
"Time2: %d/%d/%d, %d:%02d:%02d
\n
"
,
tm1
.
tm_mday
,
tm1
.
tm_mon
+
1
,
tm1
.
tm_year
+
1900
,
tm1
.
tm_hour
,
tm1
.
tm_min
,
tm1
.
tm_sec
);
return
0
;
}
OPENSSL_gmtime_diff
(
&
o1
,
&
tm1
,
&
off_day
,
&
off_sec
);
toffset
=
(
long
)
off_day
*
SECS_PER_DAY
+
off_sec
;
if
(
offset
!=
toffset
)
{
fprintf
(
stderr
,
"TIME OFFSET ERROR!!
\n
"
);
fprintf
(
stderr
,
"Expected %ld, Got %ld (%d:%d)
\n
"
,
offset
,
toffset
,
off_day
,
off_sec
);
return
0
;
}
return
1
;
if
((
tm1
.
tm_year
==
tm2
.
tm_year
)
&&
(
tm1
.
tm_mon
==
tm2
.
tm_mon
)
&&
(
tm1
.
tm_mday
==
tm2
.
tm_mday
)
&&
(
tm1
.
tm_hour
==
tm2
.
tm_hour
)
&&
(
tm1
.
tm_min
==
tm2
.
tm_min
)
&&
(
tm1
.
tm_sec
==
tm2
.
tm_sec
))
return
1
;
fprintf
(
stderr
,
"TIME ERROR!!
\n
"
);
fprintf
(
stderr
,
"Time1: %d/%d/%d, %d:%02d:%02d
\n
"
,
tm2
.
tm_mday
,
tm2
.
tm_mon
+
1
,
tm2
.
tm_year
+
1900
,
tm2
.
tm_hour
,
tm2
.
tm_min
,
tm2
.
tm_sec
);
fprintf
(
stderr
,
"Time2: %d/%d/%d, %d:%02d:%02d
\n
"
,
tm1
.
tm_mday
,
tm1
.
tm_mon
+
1
,
tm1
.
tm_year
+
1900
,
tm1
.
tm_hour
,
tm1
.
tm_min
,
tm1
.
tm_sec
);
return
0
;
}
#endif
crypto/o_time.h
浏览文件 @
799668c1
...
...
@@ -63,6 +63,5 @@
struct
tm
*
OPENSSL_gmtime
(
const
time_t
*
timer
,
struct
tm
*
result
);
int
OPENSSL_gmtime_adj
(
struct
tm
*
tm
,
int
offset_day
,
long
offset_sec
);
int
OPENSSL_gmtime_diff
(
struct
tm
*
from
,
struct
tm
*
to
,
int
*
pday
,
int
*
psec
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录