Add der_parse_heim_oid
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18444 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		| @@ -105,7 +105,7 @@ der_print_hex_heim_integer (const heim_integer *data, char **p) | |||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| der_print_heim_oid (const heim_oid *oid, char **str) | der_print_heim_oid (const heim_oid *oid, char delim, char **str) | ||||||
| { | { | ||||||
|     struct rk_strpool *p = NULL; |     struct rk_strpool *p = NULL; | ||||||
|     int i; |     int i; | ||||||
| @@ -125,3 +125,40 @@ der_print_heim_oid (const heim_oid *oid, char **str) | |||||||
| 	return ENOMEM; | 	return ENOMEM; | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int | ||||||
|  | der_parse_heim_oid (const char *str, const char *sep, heim_oid *data) | ||||||
|  | { | ||||||
|  |     char *s, *w, *brkt, *endptr; | ||||||
|  |     unsigned int *c; | ||||||
|  |     long l; | ||||||
|  |  | ||||||
|  |     data->length = 0; | ||||||
|  |     data->components = NULL; | ||||||
|  |  | ||||||
|  |     if (sep == NULL) | ||||||
|  | 	sep = "."; | ||||||
|  |  | ||||||
|  |     s = strdup(str); | ||||||
|  |  | ||||||
|  |     for (w = strtok_r(s, sep, &brkt);  | ||||||
|  | 	 w != NULL;  | ||||||
|  | 	 w = strtok_r(NULL, sep, &brkt)) { | ||||||
|  |  | ||||||
|  | 	c = realloc(data->components, | ||||||
|  | 		    (data->length + 1) * sizeof(data->components[0])); | ||||||
|  | 	if (c == NULL) { | ||||||
|  | 	    der_free_oid(data); | ||||||
|  | 	    return ENOMEM; | ||||||
|  | 	} | ||||||
|  | 	data->components = c; | ||||||
|  |  | ||||||
|  | 	l = strtol(w, &endptr, 10); | ||||||
|  | 	if (*endptr != '\0' || l < 0 || l > INT_MAX) { | ||||||
|  | 	    der_free_oid(data); | ||||||
|  | 	    return EINVAL; | ||||||
|  | 	} | ||||||
|  | 	data->components[data->length++] = l; | ||||||
|  |     } | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Love Hörnquist Åstrand
					Love Hörnquist Åstrand