blob: 06b4ca5f71fc0a490f70bec624108a67870e6369 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
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
8#include <constr_TYPE.h>
9#include <OCTET_STRING.h>
10
11typedef OCTET_STRING_t GeneralizedTime_t; /* Implemented using OCTET STRING */
12
13extern asn1_TYPE_descriptor_t asn1_DEF_GeneralizedTime;
14
Lev Walkina9cc46e2004-09-22 16:06:28 +000015asn_struct_print_f GeneralizedTime_print;
Lev Walkinf15320b2004-06-03 03:38:44 +000016asn_constr_check_f GeneralizedTime_constraint;
Lev Walkin99006362004-08-07 03:52:26 +000017der_type_encoder_f GeneralizedTime_encode_der;
Lev Walkina9cc46e2004-09-22 16:06:28 +000018xer_type_encoder_f GeneralizedTime_encode_xer;
Lev Walkinf15320b2004-06-03 03:38:44 +000019
20/***********************
21 * Some handy helpers. *
22 ***********************/
23
Lev Walkinf15320b2004-06-03 03:38:44 +000024struct tm; /* <time.h> */
Lev Walkin99006362004-08-07 03:52:26 +000025
26/*
27 * Convert a GeneralizedTime structure into time_t
28 * and optionally into struct tm.
29 * If as_gmt is given, the resulting _optional_tm4fill will have a GMT zone,
30 * instead of default local one.
31 * On error returns -1 and errno set to EINVAL
32 */
33time_t asn_GT2time(const GeneralizedTime_t *, struct tm *_optional_tm4fill,
34 int as_gmt);
35
36/*
37 * Convert a struct tm into GeneralizedTime.
38 * If __opt_gt is not given, this function will try to allocate one.
39 * If force_gmt is given, the resulting GeneralizedTime will be forced
40 * into a GMT time zone (encoding ends with 'Z').
41 * On error, this function returns 0 and sets errno.
42 */
43GeneralizedTime_t *asn_time2GT(GeneralizedTime_t *__opt_gt, const struct tm *,
44 int force_gmt);
Lev Walkinf15320b2004-06-03 03:38:44 +000045
46#endif /* _GeneralizedTime_H_ */