diff options
Diffstat (limited to 'qarsh/qarsh_packet.c')
-rw-r--r-- | qarsh/qarsh_packet.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/qarsh/qarsh_packet.c b/qarsh/qarsh_packet.c index cc4f082..bad614f 100644 --- a/qarsh/qarsh_packet.c +++ b/qarsh/qarsh_packet.c @@ -17,6 +17,7 @@ int parse_qp_ack(xmlXPathContextPtr ctxt, struct qa_packet *qp); int parse_qp_runcmd(xmlXPathContextPtr ctxt, struct qa_packet *qp); int parse_qp_cmdexit(xmlXPathContextPtr ctxt, struct qa_packet *qp); int parse_qp_setuser(xmlXPathContextPtr ctxt, struct qa_packet *qp); +int parse_qp_kill(xmlXPathContextPtr ctxt, struct qa_packet *qp); void string_qp_hello(xmlNodePtr node, struct qa_packet *qp); void string_qp_returncode(xmlNodePtr node, struct qa_packet *qp); @@ -24,6 +25,7 @@ void string_qp_runcmd(xmlNodePtr node, struct qa_packet *qp); void string_qp_ack(xmlNodePtr node, struct qa_packet *qp); void string_qp_cmdexit(xmlNodePtr node, struct qa_packet *qp); void string_qp_setuser(xmlNodePtr node, struct qa_packet *qp); +void string_qp_kill(xmlNodePtr node, struct qa_packet *qp); void free_qp_hello(struct qa_packet *qp); void free_qp_returncode(struct qa_packet *qp); @@ -35,6 +37,7 @@ void dump_qp_runcmd(struct qa_packet *qp); void dump_qp_returncode(struct qa_packet *qp); void dump_qp_cmdexit(struct qa_packet *qp); void dump_qp_setuser(struct qa_packet *qp); +void dump_qp_kill(struct qa_packet *qp); struct packet_internals { @@ -86,6 +89,12 @@ struct packet_internals { .pi_string = string_qp_setuser, .pi_free = free_qp_setuser, .pi_dump = dump_qp_setuser + }, { + .pi_name = "kill", + .pi_parse = parse_qp_kill, + .pi_string = string_qp_kill, + .pi_free = NULL, + .pi_dump = dump_qp_kill } }; @@ -196,6 +205,17 @@ parse_qp_setuser(xmlXPathContextPtr ctxt, struct qa_packet *qp) return 0; } +int +parse_qp_kill(xmlXPathContextPtr ctxt, struct qa_packet *qp) +{ + char *s; + + s = get_xpath_string(ctxt, "param[@name='signal']"); + qp->qp_kill.qp_sig = atoi(s); + free(s); + return 0; +} + struct qa_packet * parse_packet(xmlXPathContextPtr ctxt) { @@ -349,6 +369,14 @@ void string_qp_setuser(xmlNodePtr node, struct qa_packet *qp) } } +void string_qp_kill(xmlNodePtr node, struct qa_packet *qp) +{ + char tmpstr[32]; + + snprintf(tmpstr, 32, "%d", qp->qp_kill.qp_sig); + xmlAddChild(node, make_param("signal", tmpstr)); +} + /* Must pass in a pointer, but not a malloc'ed pointer */ char * qptostr(struct qa_packet *qp, char **qpstr, int *qpsize) @@ -476,6 +504,20 @@ make_qp_setuser(char *user, char *group) return qp; } +struct qa_packet * +make_qp_kill(int sig) +{ + struct qa_packet *qp; + qp = malloc(sizeof *qp); + assert(qp); + memset(qp, 0, sizeof *qp); + + qp->qp_type = QP_KILL; + qp->qp_kill.qp_sig = sig; + + return qp; +} + /* * Packet deallocation functions */ @@ -560,6 +602,12 @@ dump_qp_setuser(struct qa_packet *qp) } void +dump_qp_kill(struct qa_packet *qp) +{ + printf("\tsig: %d\n", qp->qp_kill.qp_sig); +} + +void dump_qp(struct qa_packet *qp) { printf("%s #%d\n", QP_NAME(qp->qp_type), qp->qp_seq); |