"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "beos.c" between
links-1.03.tar.gz and links-1.04.tar.gz

About: Links is a Lynx-like text WWW browser (table support and pop-up dialog boxes).

beos.c  (links-1.03):beos.c  (links-1.04)
/* beos.c /* beos.c
* (c) 2002 Mikulas Patocka * (c) 2002 Mikulas Patocka
* This file is a part of the Links program, released under GPL * This file is a part of the Links program, released under GPL
*/ */
#if defined(__BEOS__) || defined(__HAIKU__) #if defined(__BEOS__) || defined(__HAIKU__)
#include "com-defs.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/time.h> #include <sys/time.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <be/kernel/OS.h> #include <be/kernel/OS.h>
#define SHS 128 #define SHS 128
#ifndef MAXINT #ifndef MAXINT
skipping to change at line 83 skipping to change at line 86
int be_accept(int s, struct sockaddr *sa, int *sal) int be_accept(int s, struct sockaddr *sa, int *sal)
{ {
int a = accept(s - SHS, sa, sal); int a = accept(s - SHS, sa, sal);
if (a < 0) return -1; if (a < 0) return -1;
return a + SHS; return a + SHS;
} }
int be_bind(int s, struct sockaddr *sa, int sal) int be_bind(int s, struct sockaddr *sa, int sal)
{ {
/*struct sockaddr_in *sin = (struct sockaddr_in *)sa; /*struct sockaddr_in *sin = (struct sockaddr_in *)sa;
if (!sin->sin_port) { if (!ntohs(sin->sin_port)) {
int i; int i;
for (i = 16384; i < 49152; i++) { for (i = 16384; i < 49152; i++) {
sin->sin_port = i; sin->sin_port = htons(i);
if (!be_bind(s, sa, sal)) return 0; if (!be_bind(s, sa, sal)) return 0;
} }
return -1; return -1;
}*/ }*/
if (bind(s - SHS, sa, sal)) return -1; if (bind(s - SHS, sa, sal)) return -1;
getsockname(s - SHS, sa, &sal); getsockname(s - SHS, sa, &sal);
return 0; return 0;
} }
#define PIPE_RETRIES 10 #define PIPE_RETRIES 10
skipping to change at line 115 skipping to change at line 118
/*perror("socket1");*/ /*perror("socket1");*/
goto fatal_retry; goto fatal_retry;
} }
if ((s2 = be_socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { if ((s2 = be_socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
/*perror("socket2");*/ /*perror("socket2");*/
be_close(s1); be_close(s1);
goto fatal_retry; goto fatal_retry;
} }
memset(&sa1, 0, sizeof(sa1)); memset(&sa1, 0, sizeof(sa1));
sa1.sin_family = AF_INET; sa1.sin_family = AF_INET;
sa1.sin_port = 0; sa1.sin_port = htons(0);
sa1.sin_addr.s_addr = INADDR_ANY; sa1.sin_addr.s_addr = INADDR_ANY;
if (be_bind(s1, (struct sockaddr *)&sa1, sizeof(sa1))) { if (be_bind(s1, (struct sockaddr *)&sa1, sizeof(sa1))) {
/*perror("bind");*/ /*perror("bind");*/
clo: clo:
be_close(s1); be_close(s1);
be_close(s2); be_close(s2);
goto fatal_retry; goto fatal_retry;
} }
if (be_listen(s1, 1)) { if (be_listen(s1, 1)) {
/*perror("listen");*/ /*perror("listen");*/
skipping to change at line 157 skipping to change at line 160
fatal_retry: fatal_retry:
if (++retry_count > PIPE_RETRIES) return -1; if (++retry_count > PIPE_RETRIES) return -1;
sleep(1); sleep(1);
goto again; goto again;
} }
int be_select(int n, struct fd_set *rd, struct fd_set *wr, struct fd_set *exc, s truct timeval *tm) int be_select(int n, struct fd_set *rd, struct fd_set *wr, struct fd_set *exc, s truct timeval *tm)
{ {
int i, s; int i, s;
struct fd_set d, rrd; struct fd_set d, rrd;
retry:
FD_ZERO(&d); FD_ZERO(&d);
if (!rd) rd = &d; if (!rd) rd = &d;
if (!wr) wr = &d; if (!wr) wr = &d;
if (!exc) exc = &d; if (!exc) exc = &d;
if (n >= FD_SETSIZE) n = FD_SETSIZE; if (n >= FD_SETSIZE) n = FD_SETSIZE;
FD_ZERO(exc); FD_ZERO(exc);
for (i = 0; i < n; i++) if ((i < SHS && FD_ISSET(i, rd)) || FD_ISSET(i, w r)) { for (i = 0; i < n; i++) if ((i < SHS && FD_ISSET(i, rd)) || FD_ISSET(i, w r)) {
for (i = SHS; i < n; i++) FD_CLR(i, rd); for (i = SHS; i < n; i++) FD_CLR(i, rd);
return MAXINT; return MAXINT;
} }
FD_ZERO(&rrd); FD_ZERO(&rrd);
for (i = SHS; i < n; i++) if (FD_ISSET(i, rd)) FD_SET(i - SHS, &rrd); for (i = SHS; i < n; i++) if (FD_ISSET(i, rd)) FD_SET(i - SHS, &rrd);
if ((s = select(FD_SETSIZE, &rrd, &d, &d, tm)) < 0) { if ((s = select(FD_SETSIZE, &rrd, &d, &d, tm)) < 0) {
if (errno == EINTR) goto retry;
FD_ZERO(rd); FD_ZERO(rd);
return 0; return 0;
} }
FD_ZERO(rd); FD_ZERO(rd);
for (i = SHS; i < n; i++) if (FD_ISSET(i - SHS, &rrd)) FD_SET(i, rd); for (i = SHS; i < n; i++) if (FD_ISSET(i - SHS, &rrd)) FD_SET(i, rd);
return s; return s;
} }
#ifndef SO_ERROR #ifndef SO_ERROR
#define SO_ERROR 10001 #define SO_ERROR 10001
skipping to change at line 198 skipping to change at line 203
} }
return -1; return -1;
} }
int start_thr(void (*)(void *), void *, unsigned char *); int start_thr(void (*)(void *), void *, unsigned char *);
int ihpipe[2]; int ihpipe[2];
int inth; int inth;
#include <errno.h>
void input_handle_th(void *p) void input_handle_th(void *p)
{ {
char c; char c;
int b = 0; int b = 0;
setsockopt(ihpipe[1], SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); setsockopt(ihpipe[1], SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
while (1) if (read(0, &c, 1) == 1) be_write(ihpipe[1], &c, 1); while (1) if (read(0, &c, 1) == 1) be_write(ihpipe[1], &c, 1);
} }
int get_input_handle() int get_input_handle()
{ {
 End of changes. 8 change blocks. 
5 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)