~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to gnulib-tests/setsockopt.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- buffer-read-only: t -*- vi: set ro: */
2
 
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3
1
/* setsockopt.c --- wrappers for Windows setsockopt function
4
2
 
5
 
   Copyright (C) 2008-2011 Free Software Foundation, Inc.
 
3
   Copyright (C) 2008-2012 Free Software Foundation, Inc.
6
4
 
7
5
   This program is free software: you can redistribute it and/or modify
8
6
   it under the terms of the GNU General Public License as published by
36
34
int
37
35
rpl_setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen)
38
36
{
 
37
  SOCKET sock = FD_TO_SOCKET (fd);
39
38
  int r;
40
 
  SOCKET sock = FD_TO_SOCKET (fd);
41
39
 
42
 
  if (level == SOL_SOCKET && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
 
40
  if (sock == INVALID_SOCKET)
43
41
    {
44
 
      const struct timeval *tv = optval;
45
 
      int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000;
46
 
      optval = &milliseconds;
47
 
      r = setsockopt (sock, level, optname, optval, sizeof (int));
 
42
      errno = EBADF;
 
43
      return -1;
48
44
    }
49
45
  else
50
46
    {
51
 
      r = setsockopt (sock, level, optname, optval, optlen);
 
47
      if (level == SOL_SOCKET
 
48
          && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
 
49
        {
 
50
          const struct timeval *tv = optval;
 
51
          int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000;
 
52
          optval = &milliseconds;
 
53
          r = setsockopt (sock, level, optname, optval, sizeof (int));
 
54
        }
 
55
      else
 
56
        {
 
57
          r = setsockopt (sock, level, optname, optval, optlen);
 
58
        }
 
59
 
 
60
      if (r < 0)
 
61
        set_winsock_errno ();
 
62
 
 
63
      return r;
52
64
    }
53
 
 
54
 
  if (r < 0)
55
 
    set_winsock_errno ();
56
 
 
57
 
  return r;
58
65
}