diff options
| -rw-r--r-- | lasso/xml/private.h | 1 | ||||
| -rw-r--r-- | lasso/xml/tools.c | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lasso/xml/private.h b/lasso/xml/private.h index 82c056d3..38ab9886 100644 --- a/lasso/xml/private.h +++ b/lasso/xml/private.h @@ -114,6 +114,7 @@ void lasso_build_random_sequence(char *buffer, unsigned int size); char* lasso_build_unique_id(unsigned int size); char* lasso_get_current_time(void); char* lasso_time_to_iso_8601_gmt(time_t now); +time_t lasso_iso_8601_gmt_to_time_t(char *xsdtime); LassoPemFileType lasso_get_pem_file_type(const char *file); xmlSecKeyPtr lasso_get_public_key_from_pem_file(const char *file); diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c index f01a4c77..1c18c751 100644 --- a/lasso/xml/tools.c +++ b/lasso/xml/tools.c @@ -22,6 +22,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* permit importation of strptime for glibc2 */ +#define _XOPEN_SOURCE #include "private.h" #include <string.h> #include <time.h> @@ -162,6 +164,28 @@ lasso_get_current_time() } /** + * lasso_iso_8601_gmt_to_time_t: + * @xsdtime: an xsd time value + * + * Return value: a corresponding time_t value if possible. + */ +time_t +lasso_iso_8601_gmt_to_time_t(char *xsdtime) +{ + struct tm tm; + char *strptime_ret; + + if (xsdtime == NULL) { + return -1; + } + strptime_ret = strptime (xsdtime, "%Y-%m-%dT%H:%M:%SZ", &tm); + if (strptime_ret == NULL) { + return -1; + } + return mktime(&tm); +} + +/** * lasso_get_pem_file_type: * @pem_file: a pem file * |
