* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dnssec-signzone.c,v 1.135 2001/03/31 01:46:13 bwelling Exp $ */
+/* $Id: dnssec-signzone.c,v 1.136 2001/03/31 02:12:23 bwelling Exp $ */
#include <config.h>
static isc_entropy_t *ectx = NULL;
static dns_ttl_t zonettl;
static FILE *fp;
+static char *tempfile = NULL;
static const dns_master_style_t *masterstyle = &dns_master_style_explicitttl;
static unsigned int nsigned = 0, nretained = 0, ndropped = 0;
static unsigned int nverified = 0, nverifyfailed = 0;
static isc_boolean_t shuttingdown = ISC_FALSE, finished = ISC_FALSE;
static unsigned int assigned = 0, completed = 0;
static isc_boolean_t nokeys = ISC_FALSE;
+static isc_boolean_t removefile = ISC_FALSE;
#define INCSTAT(counter) \
if (printstats) { \
exit(0);
}
+static void
+removetempfile(void) {
+ if (removefile)
+ isc_file_remove(tempfile);
+}
+
int
main(int argc, char *argv[]) {
int i, ch;
char *startstr = NULL, *endstr = NULL, *classname = NULL;
char *origin = NULL, *file = NULL, *output = NULL;
- char *tempfile = NULL;
char *randomfile = NULL;
char *endp;
isc_time_t timer_start, timer_finish;
if (result != ISC_R_SUCCESS)
fatal("failed to open temporary output file: %s",
isc_result_totext(result));
+ removefile = ISC_TRUE;
+ setfatalcallback(&removetempfile);
+
print_time(fp);
print_version(fp);
result = isc_stdio_close(fp);
check_result(result, "isc_stdio_close");
+ removefile = ISC_FALSE;
result = isc_file_rename(tempfile, output);
if (result != ISC_R_SUCCESS)
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dnssectool.c,v 1.27 2001/01/09 21:39:27 bwelling Exp $ */
+/* $Id: dnssectool.c,v 1.28 2001/03/31 02:12:24 bwelling Exp $ */
#include <config.h>
static isc_entropysource_t *source = NULL;
static isc_keyboard_t kbd;
static isc_boolean_t wantkeyboard = ISC_FALSE;
+static fatalcallback_t *fatalcallback = NULL;
void
fatal(const char *format, ...) {
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, "\n");
+ if (fatalcallback != NULL)
+ (*fatalcallback)();
exit(1);
}
+void
+setfatalcallback(fatalcallback_t *callback) {
+ fatalcallback = callback;
+}
+
void
check_result(isc_result_t result, const char *message) {
if (result != ISC_R_SUCCESS) {
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dnssectool.h,v 1.13 2001/01/09 21:39:28 bwelling Exp $ */
+/* $Id: dnssectool.h,v 1.14 2001/03/31 02:12:26 bwelling Exp $ */
#ifndef DNSSECTOOL_H
#define DNSSECTOOL_H 1
#include <dns/rdatastruct.h>
#include <dst/dst.h>
+typedef void (fatalcallback_t)(void);
+
void
fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
+void
+setfatalcallback(fatalcallback_t *callback);
+
void
check_result(isc_result_t result, const char *message);