diff options
author | Nate Straz <nstraz@redhat.com> | 2005-08-24 21:46:50 +0000 |
---|---|---|
committer | Nate Straz <nstraz@redhat.com> | 2005-08-24 21:46:50 +0000 |
commit | 0c59da8a7310e1e3811f873fd0106ccebdb53c53 (patch) | |
tree | c2705f5e8e5db9c158686ae853136343c3027226 /qarsh/qarshd.c | |
parent | 5e1aaf26033163543a0758fe50e52b7b17a9e530 (diff) | |
download | qarsh-0c59da8a7310e1e3811f873fd0106ccebdb53c53.tar.gz qarsh-0c59da8a7310e1e3811f873fd0106ccebdb53c53.tar.xz qarsh-0c59da8a7310e1e3811f873fd0106ccebdb53c53.zip |
Move send_packet() and recv_packet() to sockutil.c so qarsh can use them too.
Diffstat (limited to 'qarsh/qarshd.c')
-rw-r--r-- | qarsh/qarshd.c | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/qarsh/qarshd.c b/qarsh/qarshd.c index 437645d..9a90782 100644 --- a/qarsh/qarshd.c +++ b/qarsh/qarshd.c @@ -83,57 +83,23 @@ run_cmd(const char *cmd, int p_in, int p_out, int p_err) return pid; } -struct qa_packet * -recv_packet(int fd) -{ - char *packetbuf; - int packetsize; - struct qa_packet *qp = NULL; - - packetbuf = malloc(QARSH_MAX_PACKET_SIZE); - memset(packetbuf, 0, QARSH_MAX_PACKET_SIZE); - - packetsize = read(fd, packetbuf, QARSH_MAX_PACKET_SIZE); - if (packetsize > 0) { - qp = parse_packets(packetbuf, packetsize); - } - free(packetbuf); - return qp; -} - -int -send_packet(int fd, struct qa_packet *qp) -{ - char *packetbuf; - int packetsize; - - packetbuf = malloc(1024); - memset(packetbuf, 0, 1024); - packetbuf = qptostr(qp, &packetbuf, &packetsize); - - return write(fd, packetbuf, packetsize); -} - void handle_packets(int infd) { fd_set rfds; - int highfd, nfd; + int nfd; struct timeval timeout; struct qa_packet *qp = NULL, *rp = NULL; pid_t child_pid = 0; int child_status; - /* set up the select structures */ - highfd = infd+1; - for (;;) { FD_SET(infd, &rfds); timeout.tv_sec = 5; timeout.tv_usec = 0; - nfd = select(highfd, &rfds, NULL, NULL, &timeout); + nfd = select(infd+1, &rfds, NULL, NULL, &timeout); if (nfd < 0) { syslog(LOG_ERR, "select errno %d, %s\n", errno, strerror(errno)); } else if (nfd > 0) { |