Commit 42848e71 authored by Brian Wellington's avatar Brian Wellington
Browse files

Move some shared code to the shared file.

parent 8447ecf6
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-makekeyset.c,v 1.35 2000/08/14 20:39:23 bwelling Exp $ */
/* $Id: dnssec-makekeyset.c,v 1.36 2000/09/08 08:38:55 bwelling Exp $ */
#include <config.h>
......@@ -64,31 +64,6 @@ static isc_entropy_t *ectx = NULL;
static keylist_t keylist;
static isc_stdtime_t
strtotime(char *str, isc_int64_t now, isc_int64_t base) {
isc_int64_t val, offset;
isc_result_t result;
char *endp;
if (str[0] == '+') {
offset = strtol(str + 1, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = base + offset;
} else if (strncmp(str, "now+", 4) == 0) {
offset = strtol(str + 4, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = now + offset;
} else {
result = dns_time64_fromtext(str, &val);
if (result != ISC_R_SUCCESS)
fatal("time %s must be numeric", str);
}
return ((isc_stdtime_t) val);
}
static void
usage(void) {
fprintf(stderr, "Usage:\n");
......
......@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-signzone.c,v 1.95 2000/09/07 15:53:15 bwelling Exp $ */
/* $Id: dnssec-signzone.c,v 1.96 2000/09/08 08:38:57 bwelling Exp $ */
#include <config.h>
......@@ -1175,31 +1175,6 @@ loadzonekeys(dns_db_t *db) {
dns_db_closeversion(db, &currentversion, ISC_FALSE);
}
static isc_stdtime_t
strtotime(char *str, isc_int64_t now, isc_int64_t base) {
isc_int64_t val, offset;
isc_result_t result;
char *endp;
if (str[0] == '+') {
offset = strtol(str + 1, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = base + offset;
} else if (strncmp(str, "now+", 4) == 0) {
offset = strtol(str + 4, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = now + offset;
} else {
result = dns_time64_fromtext(str, &val);
if (result != ISC_R_SUCCESS)
fatal("time %s must be numeric", str);
}
return ((isc_stdtime_t) val);
}
static void
usage(void) {
fprintf(stderr, "Usage:\n");
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssectool.c,v 1.20 2000/08/17 19:17:57 bwelling Exp $ */
/* $Id: dnssectool.c,v 1.21 2000/09/08 08:38:58 bwelling Exp $ */
#include <config.h>
......@@ -35,6 +35,7 @@
#include <dns/rdatatype.h>
#include <dns/result.h>
#include <dns/secalg.h>
#include <dns/time.h>
#include "dnssectool.h"
......@@ -283,3 +284,28 @@ cleanup_entropy(isc_entropy_t **ectx) {
isc_entropy_destroysource(&source);
isc_entropy_detach(ectx);
}
isc_stdtime_t
strtotime(char *str, isc_int64_t now, isc_int64_t base) {
isc_int64_t val, offset;
isc_result_t result;
char *endp;
if (str[0] == '+') {
offset = strtol(str + 1, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = base + offset;
} else if (strncmp(str, "now+", 4) == 0) {
offset = strtol(str + 4, &endp, 0);
if (*endp != '\0')
fatal("time value %s is invalid", str);
val = now + offset;
} else {
result = dns_time64_fromtext(str, &val);
if (result != ISC_R_SUCCESS)
fatal("time %s must be numeric", str);
}
return ((isc_stdtime_t) val);
}
......@@ -15,12 +15,13 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssectool.h,v 1.10 2000/08/14 04:43:17 bwelling Exp $ */
/* $Id: dnssectool.h,v 1.11 2000/09/08 08:38:59 bwelling Exp $ */
#ifndef DNSSECTOOL_H
#define DNSSECTOOL_H 1
#include <isc/log.h>
#include <isc/stdtime.h>
#include <dns/rdatastruct.h>
#include <dst/dst.h>
......@@ -58,4 +59,7 @@ setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx);
void
cleanup_entropy(isc_entropy_t **ectx);
isc_stdtime_t
strtotime(char *str, isc_int64_t now, isc_int64_t base);
#endif /* DNSSEC_DNSSECTOOL_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment