ReactOS 0.4.15-dev-8219-ge8b88cf
USendtoByName.c
Go to the documentation of this file.
1#include "syshdrs.h"
2
3#if !defined(NO_UNIX_DOMAIN_SOCKETS) && !defined(NO_SIGNALS)
4
5extern volatile Sjmp_buf gNetTimeoutJmp;
6extern volatile Sjmp_buf gPipeJmp;
7
8int
9USendtoByName(int sfd, const char *const buf, size_t size, int fl, const char *const toAddrStr, int tlen)
10{
11 int nwrote, tleft;
12 vsio_sigproc_t sigalrm, sigpipe;
13 time_t done, now;
14 struct sockaddr_un toAddr;
15 int ualen;
16
17 ualen = MakeSockAddrUn(&toAddr, toAddrStr);
18
19 if (SSetjmp(gNetTimeoutJmp) != 0) {
20 alarm(0);
21 (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
22 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
24 return (kTimeoutErr);
25 }
26
27 if (SSetjmp(gPipeJmp) != 0) {
28 alarm(0);
29 (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
30 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
31 errno = EPIPE;
32 return (kBrokenPipeErr);
33 }
34
35 sigalrm = (vsio_sigproc_t) SSignal(SIGALRM, SIOHandler);
37
38 time(&now);
39 done = now + tlen;
40 tleft = (int) (done - now);
41 forever {
42 (void) alarm((unsigned int) tleft);
43 nwrote = sendto(sfd, buf, size, fl,
44 (struct sockaddr *) &toAddr, ualen);
45 (void) alarm(0);
46 if (nwrote >= 0)
47 break;
48 if (errno != EINTR)
49 break; /* Fatal error. */
50 errno = 0;
51 time(&now);
52 tleft = (int) (done - now);
53 if (tleft < 1) {
54 nwrote = kTimeoutErr;
56 break;
57 }
58 }
59
60 (void) SSignal(SIGALRM, (sio_sigproc_t) sigalrm);
61 (void) SSignal(SIGPIPE, (sio_sigproc_t) sigpipe);
62
63 return (nwrote);
64} /* USendtoByName */
65
66#endif
#define EINTR
Definition: acclib.h:80
#define EPIPE
Definition: acclib.h:91
#define SIGPIPE
Definition: signal.h:35
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
#define ETIMEDOUT
Definition: errno.h:121
__kernel_time_t time_t
Definition: linux.h:252
time_t now
Definition: finger.c:65
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__u16 time
Definition: mkdosfs.c:8
#define kBrokenPipeErr
Definition: sio.h:59
void SIOHandler(int)
#define SSetjmp(a)
Definition: sio.h:39
volatile sio_sigproc_t vsio_sigproc_t
Definition: sio.h:124
void(*)(int) SSignal(int signum, void(*handler)(int))
Definition: sio.h:237
#define Sjmp_buf
Definition: sio.h:41
#define kTimeoutErr
Definition: sio.h:58
void(* sio_sigproc_t)(int)
Definition: sio.h:123
#define forever
Definition: ncftp.h:73
#define errno
Definition: errno.h:18
int MakeSockAddrUn(struct sockaddr_un *, const char *const)
int USendtoByName(int, const char *const, size_t, int, const char *const, int)
_In_ FLONG fl
Definition: winddi.h:1279