Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /*- |
| 2 | * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef _GeneralizedTime_H_ |
| 6 | #define _GeneralizedTime_H_ |
| 7 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 8 | #include <OCTET_STRING.h> |
| 9 | |
Lev Walkin | 11c3e17 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 10 | typedef OCTET_STRING_t GeneralizedTime_t; /* Implemented via OCTET STRING */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 11 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 12 | extern asn_TYPE_descriptor_t asn_DEF_GeneralizedTime; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 13 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 14 | asn_struct_print_f GeneralizedTime_print; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 15 | asn_constr_check_f GeneralizedTime_constraint; |
Lev Walkin | 9900636 | 2004-08-07 03:52:26 +0000 | [diff] [blame] | 16 | der_type_encoder_f GeneralizedTime_encode_der; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 17 | xer_type_encoder_f GeneralizedTime_encode_xer; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 18 | |
| 19 | /*********************** |
| 20 | * Some handy helpers. * |
| 21 | ***********************/ |
| 22 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 23 | struct tm; /* <time.h> */ |
Lev Walkin | 9900636 | 2004-08-07 03:52:26 +0000 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Convert a GeneralizedTime structure into time_t |
| 27 | * and optionally into struct tm. |
| 28 | * If as_gmt is given, the resulting _optional_tm4fill will have a GMT zone, |
| 29 | * instead of default local one. |
| 30 | * On error returns -1 and errno set to EINVAL |
| 31 | */ |
| 32 | time_t asn_GT2time(const GeneralizedTime_t *, struct tm *_optional_tm4fill, |
| 33 | int as_gmt); |
| 34 | |
| 35 | /* |
| 36 | * Convert a struct tm into GeneralizedTime. |
| 37 | * If __opt_gt is not given, this function will try to allocate one. |
| 38 | * If force_gmt is given, the resulting GeneralizedTime will be forced |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 39 | * into a GMT time zone (encoding ends with a "Z"). |
Lev Walkin | 9900636 | 2004-08-07 03:52:26 +0000 | [diff] [blame] | 40 | * On error, this function returns 0 and sets errno. |
| 41 | */ |
| 42 | GeneralizedTime_t *asn_time2GT(GeneralizedTime_t *__opt_gt, const struct tm *, |
| 43 | int force_gmt); |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 44 | |
| 45 | #endif /* _GeneralizedTime_H_ */ |