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

« back to all changes in this revision

Viewing changes to ntpd/refclock_dumbclock.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#include <config.h>
13
13
#endif
14
14
 
 
15
#if defined(SYS_WINNT)
 
16
#undef close
 
17
#define close closesocket
 
18
#endif
 
19
 
15
20
#if defined(REFCLOCK) && defined(CLOCK_DUMBCLOCK)
16
21
 
17
22
#include "ntpd.h"
114
119
        if (debug)
115
120
                printf ("starting Dumbclock with device %s\n",device);
116
121
#endif
117
 
        if (!(fd = refclock_open(device, SPEED232, 0)))
 
122
        fd = refclock_open(device, SPEED232, 0);
 
123
        if (fd < 0)
118
124
                return (0);
119
125
 
120
126
        /*
121
127
         * Allocate and initialize unit structure
122
128
         */
123
 
        if (!(up = (struct dumbclock_unit *)
124
 
              emalloc(sizeof(struct dumbclock_unit)))) {
 
129
        up = (struct dumbclock_unit *)emalloc(sizeof(struct dumbclock_unit));
 
130
        if (up == NULL) {
125
131
                (void) close(fd);
126
132
                return (0);
127
133
        }
218
224
                    up->tcswitch = 0;
219
225
                return;
220
226
        }
221
 
        pp->lencode = temp;
 
227
        pp->lencode = (u_short)temp;
222
228
        pp->lastrec = up->laststamp;
223
229
        up->laststamp = trtmp;
224
230
        up->tcswitch = 1;
232
238
        /*
233
239
         * We get down to business. Check the timecode format...
234
240
         */
235
 
        pp->msec = 0;
236
241
        got_good=0;
237
242
        if (sscanf(pp->a_lastcode,"%02d:%02d:%02d",
238
243
                   &hours,&minutes,&seconds) == 3)
330
335
                refclock_report(peer, CEVNT_BADTIME);
331
336
                return;
332
337
        }
 
338
        pp->lastref = pp->lastrec;
 
339
        refclock_receive(peer);
333
340
        record_clock_stats(&peer->srcadr, pp->a_lastcode);
334
 
        refclock_receive(peer);
335
 
        up->lasthour = pp->hour;
 
341
        up->lasthour = (u_char)pp->hour;
336
342
}
337
343
 
338
344
#if 0