cvsuser 04/05/26 03:27:04
Modified: io io_unix.c io_win32.c
Added: library .cvsignore
Log:
io whitespace, warnings, string_make fixes
Revision Changes Path
1.3 +0 -0 parrot/library/.cvsignore
1.53 +96 -54 parrot/io/io_unix.c
Index: io_unix.c
===================================================================
RCS file: /cvs/public/parrot/io/io_unix.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -w -r1.52 -r1.53
--- io_unix.c 24 May 2004 13:46:44 -0000 1.52
+++ io_unix.c 26 May 2004 10:27:04 -0000 1.53
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: io_unix.c,v 1.52 2004/05/24 13:46:44 leo Exp $
+$Id: io_unix.c,v 1.53 2004/05/26 10:27:04 leo Exp $
=head1 NAME
@@ -647,7 +647,8 @@
sa.sin_port = htons(port);
fprintf(stderr, "sockaddr_in: port %d\n", port);
- return string_make(interpreter, &sa, sizeof(struct sockaddr), "iso-8859-1", 0);
+ return string_make(interpreter, &sa, sizeof(struct sockaddr),
+ "iso-8859-1", 0);
}
@@ -670,6 +671,8 @@
{
int sock;
ParrotIO * io;
+
+ UNUSED(layer);
if((sock = socket(fam, type, proto)) >= 0) {
io = PIO_new(interpreter, PIO_F_SOCKET, 0, PIO_F_READ|PIO_F_WRITE);
io->fd = sock;
@@ -695,6 +698,8 @@
static INTVAL
PIO_unix_connect(theINTERP, ParrotIOLayer *layer, ParrotIO *io, STRING *r)
{
+ UNUSED(layer);
+
if(r) {
struct sockaddr_in sa;
memcpy(&sa, PObj_bufstart(r), sizeof(struct sockaddr));
@@ -702,21 +707,28 @@
io->remote.sin_port = sa.sin_port;
}
AGAIN:
- PIO_eprintf(interpreter, "connect: fd = %d port = %d\n", io->fd,
ntohs(io->remote.sin_port));
+ PIO_eprintf(interpreter,
+ "connect: fd = %d port = %d\n",
+ io->fd, ntohs(io->remote.sin_port));
if((connect(io->fd, (struct sockaddr*)&io->remote,
sizeof(struct sockaddr))) != 0) {
switch(errno) {
- case EINTR: goto AGAIN;
- case EINPROGRESS: goto AGAIN;
- case EISCONN: return 0;
+ case EINTR:
+ goto AGAIN;
+ case EINPROGRESS:
+ goto AGAIN;
+ case EISCONN:
+ return 0;
case ECONNREFUSED:
#if PIO_TRACE
- PIO_eprintf(interpreter, "PIO_unix_connect: connect
refused\n");
+ PIO_eprintf(interpreter,
+ "PIO_unix_connect: connect refused\n");
#endif
case EINVAL:
default:
#if PIO_TRACE
- PIO_eprintf(interpreter, "PIO_unix_connect: errno =
%d\n", errno);
+ PIO_eprintf(interpreter,
+ "PIO_unix_connect: errno = %d\n", errno);
#endif
return -1;
}
@@ -740,16 +752,20 @@
PIO_unix_bind(theINTERP, ParrotIOLayer *layer, ParrotIO *io, STRING *l)
{
struct sockaddr_in sa;
- if(!l) return -1;
+
+ UNUSED(layer);
+ UNUSED(interpreter);
+ if (!l)
+ return -1;
memcpy(&sa, PObj_bufstart(l), sizeof(struct sockaddr));
io->local.sin_addr.s_addr = sa.sin_addr.s_addr;
io->local.sin_port = sa.sin_port;
- if((bind(io->fd, (struct sockaddr *)&io->local, sizeof(struct sockaddr))) == -1)
- {
+ if ((bind(io->fd, (struct sockaddr *)&io->local,
+ sizeof(struct sockaddr))) == -1) {
fprintf(stderr, "bind: errno= ret=%d fd = %d port = %d\n",
- errno, io->fd, ntohs(io->local.sin_port));
+ errno, (int)io->fd, (int)ntohs(io->local.sin_port));
return -1;
}
@@ -771,9 +787,11 @@
static INTVAL
PIO_unix_listen(theINTERP, ParrotIOLayer *layer, ParrotIO *io, INTVAL sec)
{
+ UNUSED(layer);
+ UNUSED(interpreter);
if((listen(io->fd, sec)) == -1) {
fprintf(stderr, "listen: errno= ret=%d fd = %d port = %d\n",
- errno, io->fd, ntohs(io->local.sin_port));
+ errno, (int)io->fd, (int)ntohs(io->local.sin_port));
return -1;
}
return 0;
@@ -796,6 +814,8 @@
int newsock;
int newsize;
ParrotIO *newio;
+
+ UNUSED(layer);
newio = PIO_new(interpreter, PIO_F_SOCKET, 0, PIO_F_READ|PIO_F_WRITE);
if((newsock = accept(io->fd, (struct sockaddr *)&newio->remote,
@@ -834,15 +854,18 @@
PIO_unix_send(theINTERP, ParrotIOLayer *layer, ParrotIO * io, STRING *s)
{
int error, bytes, byteswrote, maxwrite;
- bytes = string_length(s);
+
+ UNUSED(layer);
+ UNUSED(interpreter);
+ bytes = s->bufused;
byteswrote = 0;
maxwrite = 2048;
AGAIN:
/*
* Ignore encoding issues for now.
*/
- if((error = send(io->fd, (char *)PObj_bufstart(s) + byteswrote,
- PObj_buflen(s), 0)) >= 0) {
+ if ((error = send(io->fd, (char *)s->strstart + byteswrote,
+ s->bufused, 0)) >= 0) {
byteswrote += error;
if(byteswrote >= bytes) {
return byteswrote;
@@ -854,15 +877,20 @@
}
else {
switch(errno) {
- case EINTR: goto AGAIN;
+ case EINTR:
+ goto AGAIN;
#ifdef EWOULDBLOCK
- case EWOULDBLOCK: goto AGAIN;
+ case EWOULDBLOCK:
+ goto AGAIN;
#else
- case EAGAIN: goto AGAIN;
+ case EAGAIN:
+ goto AGAIN;
#endif
- case EPIPE: close(io->fd);
+ case EPIPE:
+ close(io->fd);
+ return -1;
+ default:
return -1;
- default: return -1;
}
}
}
@@ -883,7 +911,9 @@
{
int error;
unsigned int bytesread = 0;
- char buf[2048+1];
+ char buf[2048];
+
+ UNUSED(layer);
AGAIN:
if((error = recv(io->fd, buf, 2048, 0)) >= 0) {
if(error > 0)
@@ -891,7 +921,7 @@
else {
close(io->fd);
}
- *s = string_make(interpreter, buf, bytesread + 1, NULL, 0, NULL);
+ *s = string_make(interpreter, buf, bytesread, "iso-8859-1", 0);
if(!*s) {
PANIC("PIO_recv: Failed to allocate string");
}
@@ -901,18 +931,23 @@
return bytesread;
} else {
switch(errno) {
- case EINTR: goto AGAIN;
+ case EINTR:
+ goto AGAIN;
#ifdef EWOULDBLOCK
- case EWOULDBLOCK: goto AGAIN;
+ case EWOULDBLOCK:
+ goto AGAIN;
#else
- case EGAIN: goto AGAIN;
+ case EGAIN:
+ goto AGAIN;
#endif
- case ECONNRESET: close(io->fd);
+ case ECONNRESET:
+ close(io->fd);
#if PIO_TRACE
PIO_eprintf(interpreter, "recv: Connection reset by peer\n");
#endif
return -1;
- default: close(io->fd);
+ default:
+ close(io->fd);
#if PIO_TRACE
PIO_eprintf(interpreter, "recv: errno = %d\n", errno);
#endif
@@ -948,6 +983,9 @@
int n;
fd_set r, w, e;
struct timeval t;
+
+ UNUSED(l);
+ UNUSED(interpreter);
t.tv_sec = sec;
t.tv_usec = usec;
FD_ZERO(&r); FD_ZERO(&w); FD_ZERO(&e);
@@ -989,8 +1027,11 @@
#if defined (linux) || defined (solaris)
ParrotIO *io;
int pid, err, fds[2];
- char *ccmd = string_to_cstring(interpreter, cmd);
- /* FIXME mem leak here */
+ char *ccmd;
+
+ UNUSED(interpreter);
+ UNUSED(l);
+ UNUSED(flags);
if((err = pipe(fds)) < 0) {
perror("pipe:");
@@ -1015,6 +1056,7 @@
{
exit(0);
}
+ ccmd = string_to_cstring(interpreter, cmd);
execl(ccmd, ccmd, (char*)0);
/* Will never reach this unless exec fails. */
1.46 +6 -6 parrot/io/io_win32.c
Index: io_win32.c
===================================================================
RCS file: /cvs/public/parrot/io/io_win32.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -w -r1.45 -r1.46
--- io_win32.c 26 May 2004 09:15:05 -0000 1.45
+++ io_win32.c 26 May 2004 10:27:04 -0000 1.46
@@ -1,6 +1,6 @@
/*
Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-$Id: io_win32.c,v 1.45 2004/05/26 09:15:05 jrieks Exp $
+$Id: io_win32.c,v 1.46 2004/05/26 10:27:04 leo Exp $
=head1 NAME
@@ -683,7 +683,7 @@
else {
close((int)io->fd);
}
- *s = string_make(interpreter, buf, bytesread, "iso-8859-1", 0, NULL);
+ *s = string_make(interpreter, buf, bytesread, "iso-8859-1", 0);
if(!*s) {
PANIC("PIO_recv: Failed to allocate string");
}