Lines Matching refs:tmp
47 struct msg *tmp;
48 if ((tmp = malloc(sizeof(struct msg))) == NULL) {
52 tmp->base = &__msg_base;
54 tmp->from_name_data = NULL;
55 tmp->from_name_set = 0;
57 tmp->to_name_data = NULL;
58 tmp->to_name_set = 0;
60 tmp->attack_data = NULL;
61 tmp->attack_set = 0;
63 tmp->run_data = NULL;
64 tmp->run_length = 0;
65 tmp->run_num_allocated = 0;
66 tmp->run_set = 0;
68 return (tmp);
127 struct evbuffer *tmp = NULL;
138 if ((tmp = evbuffer_new()) == NULL) {
142 kill_marshal(tmp, value);
143 if (kill_unmarshal(msg->attack_data, tmp) == -1) {
148 evbuffer_free(tmp);
151 if (tmp != NULL)
152 evbuffer_free(tmp);
164 struct evbuffer *tmp = NULL;
168 if ((tmp = evbuffer_new()) == NULL) {
172 run_marshal(tmp, value);
173 if (run_unmarshal(msg->run_data[off], tmp) == -1) {
177 evbuffer_free(tmp);
180 if (tmp != NULL)
181 evbuffer_free(tmp);
228 msg_clear(struct msg *tmp)
230 if (tmp->from_name_set == 1) {
231 free (tmp->from_name_data);
232 tmp->from_name_data = NULL;
233 tmp->from_name_set = 0;
235 if (tmp->to_name_set == 1) {
236 free (tmp->to_name_data);
237 tmp->to_name_data = NULL;
238 tmp->to_name_set = 0;
240 if (tmp->attack_set == 1) {
241 kill_free(tmp->attack_data);
242 tmp->attack_data = NULL;
243 tmp->attack_set = 0;
245 if (tmp->run_set == 1) {
247 for (i = 0; i < tmp->run_length; ++i) {
248 run_free(tmp->run_data[i]);
250 free(tmp->run_data);
251 tmp->run_data = NULL;
252 tmp->run_set = 0;
253 tmp->run_length = 0;
254 tmp->run_num_allocated = 0;
259 msg_free(struct msg *tmp)
261 if (tmp->from_name_data != NULL)
262 free (tmp->from_name_data);
263 if (tmp->to_name_data != NULL)
264 free (tmp->to_name_data);
265 if (tmp->attack_data != NULL)
266 kill_free(tmp->attack_data);
267 if (tmp->run_data != NULL) {
269 for (i = 0; i < tmp->run_length; ++i) {
270 run_free(tmp->run_data[i]);
271 tmp->run_data[i] = NULL;
273 free(tmp->run_data);
274 tmp->run_data = NULL;
275 tmp->run_length = 0;
276 tmp->run_num_allocated = 0;
278 free(tmp);
282 msg_marshal(struct evbuffer *evbuf, const struct msg *tmp){
283 evtag_marshal_string(evbuf, MSG_FROM_NAME, tmp->from_name_data);
284 evtag_marshal_string(evbuf, MSG_TO_NAME, tmp->to_name_data);
285 if (tmp->attack_set) {
286 evtag_marshal_kill(evbuf, MSG_ATTACK, tmp->attack_data);
290 for (i = 0; i < tmp->run_length; ++i) {
291 evtag_marshal_run(evbuf, MSG_RUN, tmp->run_data[i]);
297 msg_unmarshal(struct msg *tmp, struct evbuffer *evbuf)
307 if (tmp->from_name_set)
309 if (evtag_unmarshal_string(evbuf, MSG_FROM_NAME, &tmp->from_name_data) == -1) {
313 tmp->from_name_set = 1;
318 if (tmp->to_name_set)
320 if (evtag_unmarshal_string(evbuf, MSG_TO_NAME, &tmp->to_name_data) == -1) {
324 tmp->to_name_set = 1;
329 if (tmp->attack_set)
331 tmp->attack_data = kill_new();
332 if (tmp->attack_data == NULL)
334 if (evtag_unmarshal_kill(evbuf, MSG_ATTACK, tmp->attack_data) == -1) {
338 tmp->attack_set = 1;
343 if (msg_run_add(tmp) == NULL)
346 tmp->run_data[tmp->run_length - 1]) == -1) {
347 --tmp->run_length;
351 tmp->run_set = 1;
359 if (msg_complete(tmp) == -1)
389 struct evbuffer *tmp = evbuffer_new();
391 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
394 if (msg_unmarshal(msg, tmp) == -1)
400 evbuffer_free(tmp);
431 struct kill *tmp;
432 if ((tmp = malloc(sizeof(struct kill))) == NULL) {
436 tmp->base = &__kill_base;
438 tmp->weapon_data = NULL;
439 tmp->weapon_set = 0;
441 tmp->action_data = NULL;
442 tmp->action_set = 0;
444 tmp->how_often_data = 0;
445 tmp->how_often_set = 0;
447 return (tmp);
513 kill_clear(struct kill *tmp)
515 if (tmp->weapon_set == 1) {
516 free (tmp->weapon_data);
517 tmp->weapon_data = NULL;
518 tmp->weapon_set = 0;
520 if (tmp->action_set == 1) {
521 free (tmp->action_data);
522 tmp->action_data = NULL;
523 tmp->action_set = 0;
525 tmp->how_often_set = 0;
529 kill_free(struct kill *tmp)
531 if (tmp->weapon_data != NULL)
532 free (tmp->weapon_data);
533 if (tmp->action_data != NULL)
534 free (tmp->action_data);
535 free(tmp);
539 kill_marshal(struct evbuffer *evbuf, const struct kill *tmp){
540 evtag_marshal_string(evbuf, KILL_WEAPON, tmp->weapon_data);
541 evtag_marshal_string(evbuf, KILL_ACTION, tmp->action_data);
542 if (tmp->how_often_set) {
543 evtag_marshal_int(evbuf, KILL_HOW_OFTEN, tmp->how_often_data);
548 kill_unmarshal(struct kill *tmp, struct evbuffer *evbuf)
558 if (tmp->weapon_set)
560 if (evtag_unmarshal_string(evbuf, KILL_WEAPON, &tmp->weapon_data) == -1) {
564 tmp->weapon_set = 1;
569 if (tmp->action_set)
571 if (evtag_unmarshal_string(evbuf, KILL_ACTION, &tmp->action_data) == -1) {
575 tmp->action_set = 1;
580 if (tmp->how_often_set)
582 if (evtag_unmarshal_int(evbuf, KILL_HOW_OFTEN, &tmp->how_often_data) == -1) {
586 tmp->how_often_set = 1;
594 if (kill_complete(tmp) == -1)
615 struct evbuffer *tmp = evbuffer_new();
617 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
620 if (kill_unmarshal(msg, tmp) == -1)
626 evbuffer_free(tmp);
657 struct run *tmp;
658 if ((tmp = malloc(sizeof(struct run))) == NULL) {
662 tmp->base = &__run_base;
664 tmp->how_data = NULL;
665 tmp->how_set = 0;
667 tmp->some_bytes_data = NULL;
668 tmp->some_bytes_length = 0;
669 tmp->some_bytes_set = 0;
671 memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
672 tmp->fixed_bytes_set = 0;
674 return (tmp);
743 run_clear(struct run *tmp)
745 if (tmp->how_set == 1) {
746 free (tmp->how_data);
747 tmp->how_data = NULL;
748 tmp->how_set = 0;
750 if (tmp->some_bytes_set == 1) {
751 free (tmp->some_bytes_data);
752 tmp->some_bytes_data = NULL;
753 tmp->some_bytes_length = 0;
754 tmp->some_bytes_set = 0;
756 tmp->fixed_bytes_set = 0;
757 memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
761 run_free(struct run *tmp)
763 if (tmp->how_data != NULL)
764 free (tmp->how_data);
765 if (tmp->some_bytes_data != NULL)
766 free (tmp->some_bytes_data);
767 free(tmp);
771 run_marshal(struct evbuffer *evbuf, const struct run *tmp){
772 evtag_marshal_string(evbuf, RUN_HOW, tmp->how_data);
773 if (tmp->some_bytes_set) {
774 evtag_marshal(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length);
776 evtag_marshal(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, sizeof(tmp->fixed_bytes_data));
780 run_unmarshal(struct run *tmp, struct evbuffer *evbuf)
790 if (tmp->how_set)
792 if (evtag_unmarshal_string(evbuf, RUN_HOW, &tmp->how_data) == -1) {
796 tmp->how_set = 1;
801 if (tmp->some_bytes_set)
803 if (evtag_payload_length(evbuf, &tmp->some_bytes_length) == -1)
805 if (tmp->some_bytes_length > EVBUFFER_LENGTH(evbuf))
807 if ((tmp->some_bytes_data = malloc(tmp->some_bytes_length)) == NULL)
809 if (evtag_unmarshal_fixed(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length) == -1) {
813 tmp->some_bytes_set = 1;
818 if (tmp->fixed_bytes_set)
820 if (evtag_unmarshal_fixed(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, sizeof(tmp->fixed_bytes_data)) == -1) {
824 tmp->fixed_bytes_set = 1;
832 if (run_complete(tmp) == -1)
853 struct evbuffer *tmp = evbuffer_new();
855 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
858 if (run_unmarshal(msg, tmp) == -1)
864 evbuffer_free(tmp);