99 |
#define BIND_ADDRESS_INCREMENT 16 |
#define BIND_ADDRESS_INCREMENT 16 |
100 |
#define BIND_INITIAL_ADDRESS 5000 |
#define BIND_INITIAL_ADDRESS 5000 |
101 |
#define BIND_LAST_ADDRESS 65534 |
#define BIND_LAST_ADDRESS 65534 |
102 |
static iLastAddressUsed = BIND_INITIAL_ADDRESS; |
static unsigned int iLastAddressUsed = BIND_INITIAL_ADDRESS; |
103 |
|
|
104 |
DEFUN("OPEN-NAMED-SOCKET",object,fSopen_named_socket,SI,1,1,NONE,OI,OO,OO,OO, |
DEFUN("OPEN-NAMED-SOCKET",object,fSopen_named_socket,SI,1,1,NONE,OI,OO,OO,OO, |
105 |
"Open a socket on PORT and return (cons fd portname) where file \ |
"Open a socket on PORT and return (cons fd portname) where file \ |
248 |
|
|
249 |
|
|
250 |
DEFUN("HOSTNAME-TO-HOSTID",object,fShostname_to_hostid,SI,1,1, |
DEFUN("HOSTNAME-TO-HOSTID",object,fShostname_to_hostid,SI,1,1, |
251 |
NONE,OO,OO,OO,OO,"")(host) |
NONE,OO,OO,OO,OO,"")(object host) |
252 |
{ |
{ |
253 |
struct hostent *h; |
struct hostent *h; |
254 |
char buf[300]; |
char buf[300]; |
308 |
#include "comm.c" |
#include "comm.c" |
309 |
|
|
310 |
|
|
311 |
DEFUN("CONNECTION-STATE-FD",int,fSconnection_state_fd,SI,1,1,NONE,IO,OO,OO,OO,"") (sfd) |
DEFUN("CONNECTION-STATE-FD",object,fSconnection_state_fd,SI,1,1,NONE,OO,OO,OO,OO,"") (sfd) |
312 |
object sfd; |
object sfd; |
313 |
{ return OBJ_TO_CONNECTION_STATE(sfd)->fd; |
{ return make_fixnum(OBJ_TO_CONNECTION_STATE(sfd)->fd); |
314 |
} |
} |
315 |
|
|
316 |
DEFUN("OUR-WRITE",int,fSour_write,SI,3,3,NONE,IO,OI,OO,OO,"") |
DEFUN("OUR-WRITE",object,fSour_write,SI,3,3,NONE,OO,OI,OO,OO,"") |
317 |
(sfd,buffer,nbytes) |
(sfd,buffer,nbytes) |
318 |
object buffer; |
object buffer; |
319 |
object sfd; |
object sfd; |
320 |
int nbytes; |
int nbytes; |
321 |
{ return write1(OBJ_TO_CONNECTION_STATE(sfd),buffer->ust.ust_self,nbytes); |
{ return make_fixnum(write1(OBJ_TO_CONNECTION_STATE(sfd),buffer->ust.ust_self,nbytes)); |
322 |
} |
} |
323 |
|
|
324 |
DEFUN("OUR-READ-WITH-OFFSET",int,fSour_read_with_offset,SI,5,5,NONE, |
DEFUN("OUR-READ-WITH-OFFSET",object,fSour_read_with_offset,SI,5,5,NONE, |
325 |
IO,OI,II,OO, |
OO,OI,II,OO, |
326 |
"Read from STATE-FD into string BUFFER putting data at OFFSET and reading NBYTES, waiting for TIMEOUT before failing") |
"Read from STATE-FD into string BUFFER putting data at OFFSET and reading NBYTES, waiting for TIMEOUT before failing") |
327 |
(fd,buffer,offset,nbytes,timeout) |
(fd,buffer,offset,nbytes,timeout) |
328 |
int offset,nbytes,timeout; |
int offset,nbytes,timeout; |
329 |
object buffer,fd; |
object buffer,fd; |
330 |
{ return read1(OBJ_TO_CONNECTION_STATE(fd),&((buffer)->ust.ust_self[offset]),nbytes,timeout); |
{ return make_fixnum(read1(OBJ_TO_CONNECTION_STATE(fd),&((buffer)->ust.ust_self[offset]),nbytes,timeout)); |
331 |
} |
} |
332 |
|
|
333 |
|
|
355 |
#define BEGIN_QUOTE '"' |
#define BEGIN_QUOTE '"' |
356 |
#define END_QUOTE '"' |
#define END_QUOTE '"' |
357 |
|
|
358 |
static needs_quoting[256]; |
static int needs_quoting[256]; |
359 |
|
|
360 |
DEFUN("PRINT-TO-STRING1",object,fSprint_to_string1,SI,3,3,NONE,OO,OO,OO,OO, |
DEFUN("PRINT-TO-STRING1",object,fSprint_to_string1,SI,3,3,NONE,OO,OO,OO,OO, |
361 |
"Print to STRING the object X according to CODE. The string must have \ |
"Print to STRING the object X according to CODE. The string must have \ |
438 |
while (--len>=0) |
while (--len>=0) |
439 |
{ char c = *p++; |
{ char c = *p++; |
440 |
c=tolower(c); |
c=tolower(c); |
441 |
if(needs_quoting[c]) |
if(needs_quoting[(unsigned char)c]) |
442 |
PUSH('\\'); |
PUSH('\\'); |
443 |
PUSH(c);} |
PUSH(c);} |
444 |
else |
else |
445 |
while (--len>=0) |
while (--len>=0) |
446 |
{ char c = *p++; |
{ char c = *p++; |
447 |
if(needs_quoting[c]) |
if(needs_quoting[(unsigned char)c]) |
448 |
PUSH('\\'); |
PUSH('\\'); |
449 |
PUSH(c);}} |
PUSH(c);}} |
450 |
break; |
break; |
451 |
case t_fixnum: |
case t_fixnum: |
452 |
sprintf(buf,"%d",fix(x)); |
sprintf(buf,"%ld",fix(x)); |
453 |
p = buf; |
p = buf; |
454 |
while(*p) {PUSH(*p);p++;} |
while(*p) {PUSH(*p);p++;} |
455 |
break; |
break; |
488 |
DEFUN("SET-SIGIO-FOR-FD",object,fSset_sigio_for_fd,SI,1,1,NONE,OI,OO,OO,OO,"") |
DEFUN("SET-SIGIO-FOR-FD",object,fSset_sigio_for_fd,SI,1,1,NONE,OI,OO,OO,OO,"") |
489 |
(fd) |
(fd) |
490 |
int fd; |
int fd; |
491 |
{ int flags; |
{ |
492 |
/* for the moment we will use SIGUSR1 to notify, instead of depending on SIGIO, |
/* for the moment we will use SIGUSR1 to notify, instead of depending on SIGIO, |
493 |
since LINUX does not support the latter yet... |
since LINUX does not support the latter yet... |
494 |
So right now this does nothing... |
So right now this does nothing... |
527 |
return strm; |
return strm; |
528 |
} |
} |
529 |
|
|
530 |
DEFUN("CHECK-STATE-INPUT",int ,fScheck_state_input,SI,2,2,NONE,IO,IO,OO,OO, |
DEFUN("CHECK-STATE-INPUT",object,fScheck_state_input,SI,2,2,NONE,OO,IO,OO,OO, |
531 |
"") (osfd,timeout) |
"") (osfd,timeout) |
532 |
object osfd; |
object osfd; |
533 |
int timeout; |
int timeout; |
536 |
|
|
537 |
} |
} |
538 |
|
|
539 |
DEFUN("CLEAR-CONNECTION-STATE",int,fSclear_connection_state, |
DEFUN("CLEAR-CONNECTION-STATE",object,fSclear_connection_state, |
540 |
SI,1,1,NONE,IO,OO,OO,OO, |
SI,1,1,NONE,OO,OO,OO,OO, |
541 |
"Read on FD until nothing left to read. Return number of bytes read") |
"Read on FD until nothing left to read. Return number of bytes read") |
542 |
(osfd) |
(osfd) |
543 |
object osfd; |
object osfd; |
544 |
{ |
{ |
545 |
struct connection_state *sfd = OBJ_TO_CONNECTION_STATE(osfd); |
struct connection_state *sfd = OBJ_TO_CONNECTION_STATE(osfd); |
546 |
int n=fSclear_connection(sfd->fd);; |
int n=fix(fSclear_connection(sfd->fd)); |
547 |
|
|
548 |
sfd->valid_data = sfd->read_buffer; |
sfd->valid_data = sfd->read_buffer; |
549 |
sfd->valid_data_size = 0; |
sfd->valid_data_size = 0; |
550 |
sfd->bytes_received_not_confirmed += n; |
sfd->bytes_received_not_confirmed += n; |
551 |
return n; |
return make_fixnum(n); |
552 |
} |
} |
553 |
|
|
554 |
#endif |
#endif |