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

« back to all changes in this revision

Viewing changes to ports/winnt/ntpd/win32_io.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:
6
6
#include "ntp_machine.h"
7
7
#include "ntp_stdlib.h"
8
8
#include "ntp_syslog.h"
 
9
#include "ntp_assert.h"
9
10
#include "ntp_debug.h"
10
11
#include "ntp_fp.h"
11
12
#include "ntp.h"
158
159
 * refclock_open - open serial port for reference clock
159
160
 *
160
161
 * This routine opens a serial port for I/O and sets default options. It
161
 
 * returns the file descriptor or -1 indicating failure.
 
162
 * returns the file descriptor or 0 indicating failure.
162
163
 */
163
164
int refclock_open(
164
165
        char *  dev,            /* device name pointer */
170
171
        HANDLE          h;
171
172
        COMMTIMEOUTS    timeouts;
172
173
        DCB             dcb;
 
174
        int             fd;
173
175
 
174
176
        /*
175
177
         * open communication port handle
180
182
 
181
183
        if (INVALID_HANDLE_VALUE == h) {  
182
184
                msyslog(LOG_ERR, "Device %s CreateFile error: %m", windev);
183
 
                return -1;
 
185
                return 0;
184
186
        }
185
187
 
186
188
        /* Change the input/output buffers to be large. */
187
189
        if (!SetupComm(h, 1024, 1024)) {
188
190
                msyslog(LOG_ERR, "Device %s SetupComm error: %m", windev);
189
 
                return -1;
 
191
                return 0;
190
192
        }
191
193
 
192
194
        dcb.DCBlength = sizeof(dcb);
194
196
        if (!GetCommState(h, &dcb)) {
195
197
                msyslog(LOG_ERR, "Device %s GetCommState error: %m",
196
198
                                 windev);
197
 
                return -1;
 
199
                return 0;
198
200
        }
199
201
 
200
202
        switch (speed) {
238
240
        default:
239
241
                msyslog(LOG_ERR, "Device %s unsupported baud rate "
240
242
                                 "code %u", windev, speed);
241
 
                return -1;
 
243
                return 0;
242
244
        }
243
245
 
244
246
 
264
266
 
265
267
        if (!SetCommState(h, &dcb)) {
266
268
                msyslog(LOG_ERR, "Device %s SetCommState error: %m", windev);
267
 
                return -1;
 
269
                return 0;
268
270
        }
269
271
 
270
272
        /* watch out for CR (dcb.EvtChar) as well as the CD line */
271
273
        if (!SetCommMask(h, EV_RXFLAG | EV_RLSD)) {
272
274
                msyslog(LOG_ERR, "Device %s SetCommMask error: %m", windev);
273
 
                return -1;
 
275
                return 0;
274
276
        }
275
277
 
276
278
        /* configure the handle to never block */
282
284
 
283
285
        if (!SetCommTimeouts(h, &timeouts)) {
284
286
                msyslog(LOG_ERR, "Device %s SetCommTimeouts error: %m", windev);
285
 
                return -1;
 
287
                return 0;
286
288
        }
287
289
 
288
 
        return (int)_open_osfhandle((int)h, _O_TEXT);
 
290
        fd = _open_osfhandle((int)h, _O_TEXT);
 
291
        if (fd < 0)
 
292
                return 0;
 
293
        NTP_INSIST(fd != 0);
 
294
        return fd;
289
295
}
290
296
 
291
297