~ubuntu-branches/ubuntu/natty/bind9/natty-updates

« back to all changes in this revision

Viewing changes to lib/dns/dst_api.c

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, Internet Software Consortium, Inc, LaMont Jones
  • Date: 2010-06-21 09:53:30 UTC
  • mfrom: (1.6.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100621095330-k6874kbj59lfo3xm
Tags: 1:9.7.1.dfsg-1
[Internet Software Consortium, Inc]

* 9.7.1

[LaMont Jones]

* Add freebsd support.  Closes: #578447
* soname changes
* freshen root cache.  LP: #596363

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
/*
33
33
 * Principal Author: Brian Wellington
34
 
 * $Id: dst_api.c,v 1.47.22.1 2010/01/13 19:31:52 each Exp $
 
34
 * $Id: dst_api.c,v 1.47.22.3 2010/05/13 03:09:56 marka Exp $
35
35
 */
36
36
 
37
37
/*! \file */
49
49
#include <isc/lex.h>
50
50
#include <isc/mem.h>
51
51
#include <isc/once.h>
 
52
#include <isc/platform.h>
52
53
#include <isc/print.h>
53
54
#include <isc/random.h>
54
55
#include <isc/string.h>
1346
1347
static void
1347
1348
printtime(const dst_key_t *key, int type, const char *tag, FILE *stream) {
1348
1349
        isc_result_t result;
 
1350
#ifdef ISC_PLATFORM_USETHREADS
 
1351
        char output[26]; /* Minimum buffer as per ctime_r() specification. */
 
1352
#else
1349
1353
        const char *output;
 
1354
#endif
1350
1355
        isc_stdtime_t when;
1351
1356
        time_t t;
 
1357
        char utc[sizeof("YYYYMMDDHHSSMM")];
 
1358
        isc_buffer_t b;
 
1359
        isc_region_t r;
1352
1360
 
1353
1361
        result = dst_key_gettime(key, type, &when);
1354
1362
        if (result == ISC_R_NOTFOUND)
1356
1364
 
1357
1365
        /* time_t and isc_stdtime_t might be different sizes */
1358
1366
        t = when;
 
1367
#ifdef ISC_PLATFORM_USETHREADS
 
1368
#ifdef WIN32
 
1369
        if (ctime_s(output, sizeof(output), &t) != 0)
 
1370
                goto error;
 
1371
#else
 
1372
        if (ctime_r(&t, output) == NULL)
 
1373
                goto error;
 
1374
#endif
 
1375
#else
1359
1376
        output = ctime(&t);
1360
 
        fprintf(stream, "%s: %s", tag, output);
 
1377
#endif
 
1378
 
 
1379
        isc_buffer_init(&b, utc, sizeof(utc));
 
1380
        result = dns_time32_totext(when, &b);
 
1381
        if (result != ISC_R_SUCCESS)
 
1382
                goto error;
 
1383
 
 
1384
        isc_buffer_usedregion(&b, &r);
 
1385
        fprintf(stream, "%s: %.*s (%.*s)\n", tag, (int)r.length, r.base,
 
1386
                 (int)strlen(output) - 1, output);
 
1387
        return;
 
1388
 
 
1389
 error:
 
1390
        fprintf(stream, "%s: (set, unable to display)\n", tag);
1361
1391
}
1362
1392
 
1363
1393
/*%