summaryrefslogtreecommitdiff
path: root/print/pips800/files/extra-patch-2.6.2-src-lpr
blob: 056f7f5e0e60e8ae2af7c0d33800ae8e6c9a8649 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Index: src/ekpcom.c
diff -u -p src/ekpcom.c.orig src/ekpcom.c
--- src/ekpcom.c.orig	Sat Oct 19 16:56:12 2002
+++ src/ekpcom.c	Wed Aug 25 18:40:11 2004
@@ -51,15 +51,25 @@ sock_open (void)
 {
   int sockfd, len;
   struct sockaddr_in address;
+#ifndef MSG_NOSIGNAL
+  const int on = 1;
+#endif
 
   if (server_sock_fd >= 0)
     return 0;
 
   /* �����åȥ����ץ� */
   sockfd = socket (AF_INET, SOCK_STREAM, 0);
+#if !defined(MSG_NOSIGNAL) && defined(SO_NOSIGPIPE)
+  setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
+#endif
+  memset(&address, 0, sizeof(address));
   address.sin_family = AF_INET;
   address.sin_addr.s_addr = htonl (INADDR_ANY);
   address.sin_port = htons (35586);
+#ifdef __FreeBSD__
+  address.sin_len = sizeof(address);
+#endif
   len = sizeof (address);
   if (connect (sockfd, (struct sockaddr *)&address, len))
     {
@@ -101,7 +111,11 @@ sock_write (char* buf, int* lp_wsize)
   packet[4] = size % 0xFF;
   memcpy (packet + Header_Size, buf, size);
 
+#ifndef MSG_NOSIGNAL
+  size = send (server_sock_fd, packet, size + Header_Size, 0);
+#else
   size = send (server_sock_fd, packet, size + Header_Size, MSG_NOSIGNAL);
+#endif
 
   if (size < 0)
     return -1;
@@ -125,7 +139,11 @@ sock_read (char* buf, int* lp_rsize)
   if (size <= 0)
     return 0;
 
+#ifndef MSG_NOSIGNAL
+  dsize = recv (server_sock_fd, packet, size, 0);
+#else
   dsize = recv (server_sock_fd, packet, size, MSG_NOSIGNAL);
+#endif
 
   if (dsize < 0)
     return -1;