diff options
author | Nathan Straz <nstraz@redhat.com> | 2013-08-12 11:45:09 -0400 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2013-09-11 17:39:57 -0400 |
commit | 2faad967427b001262712523a7ffbf3e9b28d32a (patch) | |
tree | a3770d78dc451541ac4dc21834689c3406e71813 /qarsh_packet.c | |
parent | 38e9c4f1b856b74d72b62437b36333146ad83ee6 (diff) | |
download | qarsh-2faad967427b001262712523a7ffbf3e9b28d32a.tar.gz qarsh-2faad967427b001262712523a7ffbf3e9b28d32a.tar.xz qarsh-2faad967427b001262712523a7ffbf3e9b28d32a.zip |
Send all server side error messages to stderr
This should get sent to the journal or syslog
Diffstat (limited to 'qarsh_packet.c')
-rw-r--r-- | qarsh_packet.c | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/qarsh_packet.c b/qarsh_packet.c index ffaf35a..6617362 100644 --- a/qarsh_packet.c +++ b/qarsh_packet.c @@ -186,7 +186,7 @@ fetch_int(char *buf, int *buflen, int *out) { int i; if (*buflen < sizeof i) { - printf("Not enough data to unpack a uint32_t, %d\n", *buflen); + fprintf(stderr, "Not enough data to unpack a uint32_t, %d\n", *buflen); return buf; } memcpy(&i, buf, sizeof i); @@ -200,13 +200,13 @@ fetch_string(char *buf, int *buflen, char **out) { int slen; if (*buflen < sizeof slen) { - printf("Not enough data to unpack string length, %d\n", *buflen); + fprintf(stderr, "Not enough data to unpack string length, %d\n", *buflen); *out = NULL; return buf; } buf = fetch_int(buf, buflen, &slen); if (slen > *buflen) { - printf("String is more than available data, %d > %d\n", slen, *buflen); + fprintf(stderr, "String is more than available data, %d > %d\n", slen, *buflen); *out = NULL; return buf; } @@ -223,7 +223,7 @@ fetch_off_t(char *buf, int *buflen, off_t *out) { off_t i; if (*buflen < sizeof i) { - printf("Not enough data to unpack a off_t, %d\n", *buflen); + fprintf(stderr, "Not enough data to unpack a off_t, %d\n", *buflen); return buf; } memcpy(&i, buf, sizeof i); @@ -326,11 +326,11 @@ parse_packet(char *buf, int buflen) if (qa_pi[qp->qp_type].pi_parse) qa_pi[qp->qp_type].pi_parse(buf, &buflen, qp); else { - printf("Packet type %d not implemented yet\n", qp->qp_type); + fprintf(stderr, "Packet type %d not implemented yet\n", qp->qp_type); free(qp); qp = NULL; } - if (buflen) { printf("%d remaining bytes of data in packet\n", buflen); } + if (buflen) { fprintf(stderr, "%d remaining bytes of data in packet\n", buflen); } return qp; } @@ -695,77 +695,76 @@ qpfree(struct qa_packet *qp) void dump_qp_ack(struct qa_packet *qp) { - printf("\t%s #%d\n", QP_NAME(qp->qp_ack.qp_ack_type), + fprintf(stderr, "\t%s #%d\n", QP_NAME(qp->qp_ack.qp_ack_type), qp->qp_ack.qp_ack_seq); } void dump_qp_runcmd(struct qa_packet *qp) { - printf("\tcmdline: %s\n", qp->qp_runcmd.qp_cmdline); + fprintf(stderr, "\tcmdline: %s\n", qp->qp_runcmd.qp_cmdline); } void dump_qp_returncode(struct qa_packet *qp) { - printf("\trc: %d\n", qp->qp_returncode.qp_rc); + fprintf(stderr, "\trc: %d\n", qp->qp_returncode.qp_rc); } void dump_qp_cmdexit(struct qa_packet *qp) { if (WIFEXITED(qp->qp_cmdexit.qp_status)) { - printf("\texited: %d\n", WEXITSTATUS(qp->qp_cmdexit.qp_status)); + fprintf(stderr, "\texited: %d\n", WEXITSTATUS(qp->qp_cmdexit.qp_status)); } else if (WIFSIGNALED(qp->qp_cmdexit.qp_status)) { - printf("\tsignaled: %d\n", WTERMSIG(qp->qp_cmdexit.qp_status)); + fprintf(stderr, "\tsignaled: %d\n", WTERMSIG(qp->qp_cmdexit.qp_status)); } else { - printf("\tstatus: %d\n", qp->qp_cmdexit.qp_status); + fprintf(stderr, "\tstatus: %d\n", qp->qp_cmdexit.qp_status); } } void dump_qp_setuser(struct qa_packet *qp) { - printf("\tuser: %s\n", qp->qp_setuser.qp_user); - printf("\tgroup: %s\n", qp->qp_setuser.qp_group); + fprintf(stderr, "\tuser: %s\n", qp->qp_setuser.qp_user); + fprintf(stderr, "\tgroup: %s\n", qp->qp_setuser.qp_group); } void dump_qp_kill(struct qa_packet *qp) { - printf("\tsig: %d\n", qp->qp_kill.qp_sig); + fprintf(stderr, "\tsig: %d\n", qp->qp_kill.qp_sig); } void dump_qp_recvfile(struct qa_packet *qp) { - printf("\tpath: %s\n", qp->qp_recvfile.qp_path); - printf("\tif_port: %d\n", qp->qp_recvfile.qp_if_port); - printf("\tcount: %lld\n", (long long int)qp->qp_recvfile.qp_count); - printf("\tmode: %o\n", qp->qp_recvfile.qp_mode); + fprintf(stderr, "\tpath: %s\n", qp->qp_recvfile.qp_path); + fprintf(stderr, "\tmode: %o\n", qp->qp_recvfile.qp_mode); + fprintf(stderr, "\tcount: %lld\n", (long long int)qp->qp_recvfile.qp_count); } void dump_qp_sendfile(struct qa_packet *qp) { - printf("\tpath: %s\n", qp->qp_sendfile.qp_path); - printf("\tof_port: %d\n", qp->qp_sendfile.qp_of_port); + fprintf(stderr, "\tpath: %s\n", qp->qp_sendfile.qp_path); + fprintf(stderr, "\tremfd: %d\n", qp->qp_sendfile.qp_remfd); } void dump_qp_rstat(struct qa_packet *qp) { - printf("\tpath: %s\n", qp->qp_rstat.qp_path); - printf("\tst_mode: %o\n", qp->qp_rstat.qp_st_mode); - printf("\tst_uid: %d\n", qp->qp_rstat.qp_st_uid); - printf("\tst_gid: %d\n", qp->qp_rstat.qp_st_gid); - printf("\tst_size: %lld\n", (long long int)qp->qp_rstat.qp_st_size); + fprintf(stderr, "\tpath: %s\n", qp->qp_rstat.qp_path); + fprintf(stderr, "\tst_mode: %o\n", qp->qp_rstat.qp_st_mode); + fprintf(stderr, "\tst_uid: %d\n", qp->qp_rstat.qp_st_uid); + fprintf(stderr, "\tst_gid: %d\n", qp->qp_rstat.qp_st_gid); + fprintf(stderr, "\tst_size: %lld\n", (long long int)qp->qp_rstat.qp_st_size); } void dump_qp(struct qa_packet *qp) { - printf("%s #%d\n", QP_NAME(qp->qp_type), qp->qp_seq); + fprintf(stderr, "%s #%d\n", QP_NAME(qp->qp_type), qp->qp_seq); if (qa_pi[qp->qp_type].pi_dump) { qa_pi[qp->qp_type].pi_dump(qp); } |