OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #include "prtypes.h" | 5 #include "prtypes.h" |
6 #include "prtime.h" | 6 #include "prtime.h" |
7 #include "secder.h" | 7 #include "secder.h" |
8 #include "prlong.h" | 8 #include "prlong.h" |
9 #include "secerr.h" | 9 #include "secerr.h" |
10 | 10 |
11 #define HIDIGIT(v) (((v) / 10) + '0') | 11 #define HIDIGIT(v) (((v) / 10) + '0') |
12 #define LODIGIT(v) (((v) % 10) + '0') | 12 #define LODIGIT(v) (((v) % 10) + '0') |
13 | 13 |
14 #define ISDIGIT(dig) (((dig) >= '0') && ((dig) <= '9')) | 14 #define ISDIGIT(dig) (((dig) >= '0') && ((dig) <= '9')) |
15 #define CAPTURE(var,p,label) \ | 15 #define CAPTURE(var,p,label) \ |
16 { \ | 16 { \ |
17 if (!ISDIGIT((p)[0]) || !ISDIGIT((p)[1])) goto label; \ | 17 if (!ISDIGIT((p)[0]) || !ISDIGIT((p)[1])) goto label; \ |
18 (var) = ((p)[0] - '0') * 10 + ((p)[1] - '0'); \ | 18 (var) = ((p)[0] - '0') * 10 + ((p)[1] - '0'); \ |
19 p += 2; \ | 19 p += 2; \ |
20 } | 20 } |
21 | 21 |
22 static const PRTime January1st1 = (PRTime) LL_INIT(0xff234001U, 0x00d44000U)
; | 22 static const PRTime January1st1 = PR_INT64(0xff23400100d44000); |
23 static const PRTime January1st1950 = (PRTime) LL_INIT(0xfffdc1f8U, 0x793da000U)
; | 23 static const PRTime January1st1950 = PR_INT64(0xfffdc1f8793da000); |
24 static const PRTime January1st2050 = LL_INIT(0x0008f81e, 0x1b098000); | 24 static const PRTime January1st2050 = PR_INT64(0x0008f81e1b098000); |
25 static const PRTime January1st10000 = LL_INIT(0x0384440c, 0xcc736000); | 25 static const PRTime January1st10000 = PR_INT64(0x0384440ccc736000); |
26 | 26 |
27 /* gmttime must contains UTC time in micro-seconds unit */ | 27 /* gmttime must contains UTC time in micro-seconds unit */ |
28 SECStatus | 28 SECStatus |
29 DER_TimeToUTCTimeArena(PLArenaPool* arenaOpt, SECItem *dst, PRTime gmttime) | 29 DER_TimeToUTCTimeArena(PLArenaPool* arenaOpt, SECItem *dst, PRTime gmttime) |
30 { | 30 { |
31 PRExplodedTime printableTime; | 31 PRExplodedTime printableTime; |
32 unsigned char *d; | 32 unsigned char *d; |
33 | 33 |
34 if ( (gmttime < January1st1950) || (gmttime >= January1st2050) ) { | 34 if ( (gmttime < January1st1950) || (gmttime >= January1st2050) ) { |
35 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 35 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 * for the implode time call. | 301 * for the implode time call. |
302 */ | 302 */ |
303 genTime.tm_params.tp_gmt_offset = (PRInt32)((hourOff * 60L + minOff) * 60L); | 303 genTime.tm_params.tp_gmt_offset = (PRInt32)((hourOff * 60L + minOff) * 60L); |
304 *dst = PR_ImplodeTime(&genTime); | 304 *dst = PR_ImplodeTime(&genTime); |
305 return SECSuccess; | 305 return SECSuccess; |
306 | 306 |
307 loser: | 307 loser: |
308 PORT_SetError(SEC_ERROR_INVALID_TIME); | 308 PORT_SetError(SEC_ERROR_INVALID_TIME); |
309 return SECFailure; | 309 return SECFailure; |
310 } | 310 } |
OLD | NEW |