~ubuntu-branches/debian/squeeze/ntp/squeeze

« back to all changes in this revision

Viewing changes to ntpd/refclock_jjy.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2010-05-24 11:09:51 UTC
  • mfrom: (1.2.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20100524110951-1o7gh469ygochf4n
Tags: 1:4.2.6.p1+dfsg-1
* New upstream version
  - They no longer ship arlib, adjust dfsg.patch.
  - Drop kfreebsd.patch, applied upstream
  - Update patches for upstream changes.
* Remove the obsolete config files:

  for ntp:
  - /etc/logcheck/ignore.d.server/ntp, removed in 1:4.2.6+dfsg-1
  - /etc/dhcp3/dhclient-enter-hooks.d/ntp, replaced by exit hooks in
    1:4.2.4p4+dfsg-3
  - /etc/network/if-up.d/ntp, removed in 1:4.2.4p0+dfsg-1

  for ntpdate:
  - /etc/dhcp3/dhclient-enter-hooks.d/ntpdate, replaced by exit hooks in
    1:4.2.4p4+dfsg-3

  Use dpkg 1.15.7.2's dpkg-maintscript-helper.  This needs
  a Pre-Depends to work, else it's never going to be removed.
  (Closes: #569530)
* Add "Depends: ${misc:Depends}" to ntp-doc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
250
250
        /*
251
251
         * Open serial port
252
252
         */
253
 
        if ( ! ( pDeviceName = (char*) emalloc ( strlen(DEVICE) + 10 ) ) ) {
254
 
                return RC_START_ERROR ;
255
 
        }
256
 
        sprintf ( pDeviceName, DEVICE, unit ) ;
 
253
        pDeviceName = emalloc ( strlen(DEVICE) + 10 );
 
254
        snprintf ( pDeviceName, strlen(DEVICE) + 10, DEVICE, unit ) ;
257
255
 
258
256
        /*
259
257
         * peer->ttl is a mode number specified by "127.127.40.X mode N" in the ntp.conf
292
290
        /*
293
291
         * Allocate and initialize unit structure
294
292
         */
295
 
        if ( ! ( up = (struct jjyunit *) emalloc (sizeof(struct jjyunit)) ) ) {
296
 
                close ( fd ) ;
297
 
                return RC_START_ERROR ;
298
 
        }
299
 
 
300
 
        memset ( (char*)up, 0, sizeof(struct jjyunit) ) ;
 
293
        up = emalloc (sizeof(*up));
 
294
        memset ( up, 0, sizeof(*up) ) ;
301
295
        up->linediscipline = iDiscipline ;
302
296
 
303
297
        /*
325
319
                up->unittype = UNITTYPE_ECHOKEISOKUKI_LT2000 ;
326
320
                up->operationmode = 2 ;  /* Mode 2 : Continuous mode */
327
321
                up->lineexpect = 1 ;
328
 
        switch ( up->operationmode ) {
329
 
        case 1 :
 
322
                switch ( up->operationmode ) {
 
323
                case 1 :
330
324
                        up->charexpect[0] = 15 ; /* YYMMDDWHHMMSS<BCC1><BCC2><CR> */
331
325
                        break ;
332
326
                case 2 :
334
328
                        break ;
335
329
                }
336
330
                break ;
337
 
    case 4 :
338
 
        up->unittype = UNITTYPE_CITIZENTIC_JJY200 ;
339
 
        up->lineexpect = 1 ;
340
 
        up->charexpect[0] = 23 ; /* 'XX YY/MM/DD W HH:MM:SS<CR> */
341
 
        break ;
 
331
        case 4 :
 
332
                up->unittype = UNITTYPE_CITIZENTIC_JJY200 ;
 
333
                up->lineexpect = 1 ;
 
334
                up->charexpect[0] = 23 ; /* 'XX YY/MM/DD W HH:MM:SS<CR> */
 
335
                break ;
342
336
        default :
343
337
                msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode",
344
338
                          ntoa(&peer->srcadr), peer->ttl ) ;
355
349
        pp->io.fd         = fd ;
356
350
        if ( ! io_addclock(&pp->io) ) {
357
351
                close ( fd ) ;
358
 
                free ( (void*) up ) ;
 
352
                pp->io.fd = -1 ;
 
353
                free ( up ) ;
 
354
                pp->unitptr = NULL ;
359
355
                return RC_START_ERROR ;
360
356
        }
361
357
 
384
380
 
385
381
        pp = peer->procptr ;
386
382
        up = (struct jjyunit *) pp->unitptr ;
387
 
        io_closeclock ( &pp->io ) ;
388
 
        free ( (void*) up ) ;
 
383
        if ( -1 != pp->io.fd )
 
384
                io_closeclock ( &pp->io ) ;
 
385
        if ( NULL != up )
 
386
                free ( up ) ;
389
387
 
390
388
}
391
389
 
546
544
         * timecode timestamp.
547
545
         */
548
546
 
549
 
        sprintf ( sLogText, "%04d/%02d/%02d %02d:%02d:%02d.%1d JST",
550
 
                  up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond/100 ) ;
 
547
        snprintf ( sLogText, sizeof(sLogText),
 
548
                   "%04d/%02d/%02d %02d:%02d:%02d.%1d JST",
 
549
                   up->year, up->month, up->day,
 
550
                   up->hour, up->minute, up->second, up->msecond/100 ) ;
551
551
        record_clock_stats ( &peer->srcadr, sLogText ) ;
552
552
 
553
553
        if ( ! refclock_process ( pp ) ) {