/*
* receive network spool from the remote system
*/
-void receive_spool(int sock, char *remote_nodename) {
+void receive_spool(int *sock, char *remote_nodename) {
size_t siz;
long download_len = 0L;
long bytes_received = 0L;
FILE *fp, *newfp;
CtdlMakeTempFileName(tempfilename, sizeof tempfilename);
- if (sock_puts(sock, "NDOP") < 0) return;
+ if (sock_puts(*sock, "NDOP") < 0) return;
if (sock_getln(sock, buf, sizeof buf) < 0) return;
CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
bytes_received,
((download_len - bytes_received > IGNET_PACKET_SIZE)
? IGNET_PACKET_SIZE : (download_len - bytes_received)));
- if (sock_puts(sock, buf) < 0) {
+ if (sock_puts(*sock, buf) < 0) {
fclose(fp);
unlink(tempfilename);
return;
unlink(tempfilename);
return;
}
- if (sock_puts(sock, "CLOS") < 0) {
+ if (sock_puts(*sock, "CLOS") < 0) {
unlink(tempfilename);
return;
}
/*
* transmit network spool to the remote system
*/
-void transmit_spool(int sock, char *remote_nodename)
+void transmit_spool(int *sock, char *remote_nodename)
{
char buf[SIZ];
char pbuf[4096];
int fd;
char sfname[128];
- if (sock_puts(sock, "NUOP") < 0) return;
+ if (sock_puts(*sock, "NUOP") < 0) return;
if (sock_getln(sock, buf, sizeof buf) < 0) return;
CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
if (buf[0] != '2') {
}
snprintf(buf, sizeof buf, "WRIT %ld", bytes_to_write);
- if (sock_puts(sock, buf) < 0) {
+ if (sock_puts(*sock, buf) < 0) {
close(fd);
return;
}
}
thisblock = atol(&buf[4]);
if (buf[0] == '7') {
- if (sock_write(sock, pbuf,
+ if (sock_write(*sock, pbuf,
(int) thisblock) < 0) {
close(fd);
return;
if(CtdlThreadCheckStop())
return;
- if (sock_puts(sock, "UCLS 1") < 0) return;
+ if (sock_puts(*sock, "UCLS 1") < 0) return;
/**
* From here on we must complete or messages will get lost
*/
CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
/* Read the server greeting */
- if (sock_getln(sock, buf, sizeof buf) < 0) goto bail;
+ if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
/* Check that the remote is who we think it is and warn the Aide if not */
snprintf(buf, sizeof buf, "NETP %s|%s", config.c_nodename, secret);
CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
if (sock_puts(sock, buf) <0) goto bail;
- if (sock_getln(sock, buf, sizeof buf) < 0) goto bail;
+ if (sock_getln(&sock, buf, sizeof buf) < 0) goto bail;
CtdlLogPrintf(CTDL_DEBUG, ">%s\n", buf);
if (buf[0] != '2') goto bail;
/* At this point we are authenticated. */
if (!CtdlThreadCheckStop())
- receive_spool(sock, node);
+ receive_spool(&sock, node);
if (!CtdlThreadCheckStop())
- transmit_spool(sock, node);
+ transmit_spool(&sock, node);
}
sock_puts(sock, "QUIT");