diff options
| author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-01-04 09:13:55 +0000 |
|---|---|---|
| committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-01-04 09:13:55 +0000 |
| commit | 1d8bd498cd94ce7dc378cd547256ce33ec66083f (patch) | |
| tree | aab9ffc07cc1608740db0c7f9254148cad6efd64 | |
| parent | 4a10bbf9c6288c31853e97602fde477c36d1aef1 (diff) | |
| download | lasso-1d8bd498cd94ce7dc378cd547256ce33ec66083f.tar.gz lasso-1d8bd498cd94ce7dc378cd547256ce33ec66083f.tar.xz lasso-1d8bd498cd94ce7dc378cd547256ce33ec66083f.zip | |
Core XML: in xml/tools.c, add conversion method from iso8601 to time_t
* lasso/xml/tools.c:
add function lasso_iso_8601_gmt_to_time_t
* lasso/xml/private.h:
declare new function.
| -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 * |
