2 * Automatically generated from ../../../sntp/libevent/test/regress.rpc
3 * by event_rpcgen.py/0.1. DO NOT EDIT THIS FILE.
9 #include <event2/event-config.h>
10 #include <event2/event.h>
11 #include <event2/buffer.h>
12 #include <event2/tag.h>
14 #ifdef EVENT____func__
15 #define __func__ EVENT____func__
19 #include "regress.gen.h"
21 void event_warn(const char *fmt, ...);
22 void event_warnx(const char *fmt, ...);
26 * Implementation of msg
29 static struct msg_access_ msg_base__ = {
44 return msg_new_with_arg(NULL);
48 msg_new_with_arg(void *unused)
51 if ((tmp = malloc(sizeof(struct msg))) == NULL) {
52 event_warn("%s: malloc", __func__);
55 tmp->base = &msg_base__;
57 tmp->from_name_data = NULL;
58 tmp->from_name_set = 0;
60 tmp->to_name_data = NULL;
63 tmp->attack_data = NULL;
68 tmp->run_num_allocated = 0;
78 msg_run_expand_to_hold_more(struct msg *msg)
80 int tobe_allocated = msg->run_num_allocated;
81 struct run** new_data = NULL;
82 tobe_allocated = !tobe_allocated ? 1 : tobe_allocated << 1;
83 new_data = (struct run**) realloc(msg->run_data,
84 tobe_allocated * sizeof(struct run*));
87 msg->run_data = new_data;
88 msg->run_num_allocated = tobe_allocated;
92 msg_run_add(struct msg *msg)
94 if (++msg->run_length >= msg->run_num_allocated) {
95 if (msg_run_expand_to_hold_more(msg)<0)
98 msg->run_data[msg->run_length - 1] = run_new();
99 if (msg->run_data[msg->run_length - 1] == NULL)
102 return (msg->run_data[msg->run_length - 1]);
109 msg_from_name_assign(struct msg *msg,
112 if (msg->from_name_data != NULL)
113 free(msg->from_name_data);
114 if ((msg->from_name_data = strdup(value)) == NULL)
116 msg->from_name_set = 1;
121 msg_to_name_assign(struct msg *msg,
124 if (msg->to_name_data != NULL)
125 free(msg->to_name_data);
126 if ((msg->to_name_data = strdup(value)) == NULL)
128 msg->to_name_set = 1;
133 msg_attack_assign(struct msg *msg,
134 const struct kill* value)
136 struct evbuffer *tmp = NULL;
137 if (msg->attack_set) {
138 kill_clear(msg->attack_data);
141 msg->attack_data = kill_new();
142 if (msg->attack_data == NULL) {
143 event_warn("%s: kill_new()", __func__);
147 if ((tmp = evbuffer_new()) == NULL) {
148 event_warn("%s: evbuffer_new()", __func__);
151 kill_marshal(tmp, value);
152 if (kill_unmarshal(msg->attack_data, tmp) == -1) {
153 event_warnx("%s: kill_unmarshal", __func__);
162 if (msg->attack_data != NULL) {
163 kill_free(msg->attack_data);
164 msg->attack_data = NULL;
170 msg_run_assign(struct msg *msg, int off,
171 const struct run* value)
173 if (!msg->run_set || off < 0 || off >= msg->run_length)
178 struct evbuffer *tmp = NULL;
179 run_clear(msg->run_data[off]);
180 if ((tmp = evbuffer_new()) == NULL) {
181 event_warn("%s: evbuffer_new()", __func__);
185 run_marshal(tmp, value);
186 if (run_unmarshal(msg->run_data[off], tmp) == -1) {
187 event_warnx("%s: run_unmarshal", __func__);
191 done:if (tmp != NULL)
194 run_clear(msg->run_data[off]);
202 msg_from_name_get(struct msg *msg, char * *value)
204 if (msg->from_name_set != 1)
206 *value = msg->from_name_data;
211 msg_to_name_get(struct msg *msg, char * *value)
213 if (msg->to_name_set != 1)
215 *value = msg->to_name_data;
220 msg_attack_get(struct msg *msg, struct kill* *value)
222 if (msg->attack_set != 1) {
223 msg->attack_data = kill_new();
224 if (msg->attack_data == NULL)
228 *value = msg->attack_data;
233 msg_run_get(struct msg *msg, int offset,
236 if (!msg->run_set || offset < 0 || offset >= msg->run_length)
238 *value = msg->run_data[offset];
243 msg_clear(struct msg *tmp)
245 if (tmp->from_name_set == 1) {
246 free(tmp->from_name_data);
247 tmp->from_name_data = NULL;
248 tmp->from_name_set = 0;
250 if (tmp->to_name_set == 1) {
251 free(tmp->to_name_data);
252 tmp->to_name_data = NULL;
253 tmp->to_name_set = 0;
255 if (tmp->attack_set == 1) {
256 kill_free(tmp->attack_data);
257 tmp->attack_data = NULL;
260 if (tmp->run_set == 1) {
262 for (i = 0; i < tmp->run_length; ++i) {
263 run_free(tmp->run_data[i]);
266 tmp->run_data = NULL;
269 tmp->run_num_allocated = 0;
274 msg_free(struct msg *tmp)
276 if (tmp->from_name_data != NULL)
277 free (tmp->from_name_data);
278 if (tmp->to_name_data != NULL)
279 free (tmp->to_name_data);
280 if (tmp->attack_data != NULL)
281 kill_free(tmp->attack_data);
282 if (tmp->run_set == 1) {
284 for (i = 0; i < tmp->run_length; ++i) {
285 run_free(tmp->run_data[i]);
288 tmp->run_data = NULL;
291 tmp->run_num_allocated = 0;
298 msg_marshal(struct evbuffer *evbuf, const struct msg *tmp){
299 evtag_marshal_string(evbuf, MSG_FROM_NAME, tmp->from_name_data);
300 evtag_marshal_string(evbuf, MSG_TO_NAME, tmp->to_name_data);
301 if (tmp->attack_set) {
302 evtag_marshal_kill(evbuf, MSG_ATTACK, tmp->attack_data);
307 for (i = 0; i < tmp->run_length; ++i) {
308 evtag_marshal_run(evbuf, MSG_RUN, tmp->run_data[i]);
315 msg_unmarshal(struct msg *tmp, struct evbuffer *evbuf)
318 while (evbuffer_get_length(evbuf) > 0) {
319 if (evtag_peek(evbuf, &tag) == -1)
325 if (tmp->from_name_set)
327 if (evtag_unmarshal_string(evbuf, MSG_FROM_NAME, &tmp->from_name_data) == -1) {
328 event_warnx("%s: failed to unmarshal from_name", __func__);
331 tmp->from_name_set = 1;
336 if (tmp->to_name_set)
338 if (evtag_unmarshal_string(evbuf, MSG_TO_NAME, &tmp->to_name_data) == -1) {
339 event_warnx("%s: failed to unmarshal to_name", __func__);
342 tmp->to_name_set = 1;
349 tmp->attack_data = kill_new();
350 if (tmp->attack_data == NULL)
352 if (evtag_unmarshal_kill(evbuf, MSG_ATTACK, tmp->attack_data) == -1) {
353 event_warnx("%s: failed to unmarshal attack", __func__);
361 if (tmp->run_length >= tmp->run_num_allocated &&
362 msg_run_expand_to_hold_more(tmp) < 0) {
366 tmp->run_data[tmp->run_length] = run_new();
367 if (tmp->run_data[tmp->run_length] == NULL)
369 if (evtag_unmarshal_run(evbuf, MSG_RUN, tmp->run_data[tmp->run_length]) == -1) {
370 event_warnx("%s: failed to unmarshal run", __func__);
382 if (msg_complete(tmp) == -1)
388 msg_complete(struct msg *msg)
390 if (!msg->from_name_set)
392 if (!msg->to_name_set)
394 if (msg->attack_set && kill_complete(msg->attack_data) == -1)
398 for (i = 0; i < msg->run_length; ++i) {
399 if (msg->run_set && run_complete(msg->run_data[i]) == -1)
407 evtag_unmarshal_msg(struct evbuffer *evbuf, ev_uint32_t need_tag, struct msg *msg)
412 struct evbuffer *tmp = evbuffer_new();
414 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
417 if (msg_unmarshal(msg, tmp) == -1)
428 evtag_marshal_msg(struct evbuffer *evbuf, ev_uint32_t tag, const struct msg *msg)
430 struct evbuffer *buf_ = evbuffer_new();
431 assert(buf_ != NULL);
432 msg_marshal(buf_, msg);
433 evtag_marshal_buffer(evbuf, tag, buf_);
438 * Implementation of kill
441 static struct kill_access_ kill_base__ = {
446 kill_how_often_assign,
454 return kill_new_with_arg(NULL);
458 kill_new_with_arg(void *unused)
461 if ((tmp = malloc(sizeof(struct kill))) == NULL) {
462 event_warn("%s: malloc", __func__);
465 tmp->base = &kill_base__;
467 tmp->weapon_data = NULL;
470 tmp->action_data = NULL;
473 tmp->how_often_data = NULL;
474 tmp->how_often_length = 0;
475 tmp->how_often_num_allocated = 0;
476 tmp->how_often_set = 0;
484 kill_how_often_expand_to_hold_more(struct kill *msg)
486 int tobe_allocated = msg->how_often_num_allocated;
487 ev_uint32_t* new_data = NULL;
488 tobe_allocated = !tobe_allocated ? 1 : tobe_allocated << 1;
489 new_data = (ev_uint32_t*) realloc(msg->how_often_data,
490 tobe_allocated * sizeof(ev_uint32_t));
491 if (new_data == NULL)
493 msg->how_often_data = new_data;
494 msg->how_often_num_allocated = tobe_allocated;
498 kill_how_often_add(struct kill *msg, const ev_uint32_t value)
500 if (++msg->how_often_length >= msg->how_often_num_allocated) {
501 if (kill_how_often_expand_to_hold_more(msg)<0)
504 msg->how_often_data[msg->how_often_length - 1] = value;
505 msg->how_often_set = 1;
506 return &(msg->how_often_data[msg->how_often_length - 1]);
508 --msg->how_often_length;
513 kill_weapon_assign(struct kill *msg,
516 if (msg->weapon_data != NULL)
517 free(msg->weapon_data);
518 if ((msg->weapon_data = strdup(value)) == NULL)
525 kill_action_assign(struct kill *msg,
528 if (msg->action_data != NULL)
529 free(msg->action_data);
530 if ((msg->action_data = strdup(value)) == NULL)
537 kill_how_often_assign(struct kill *msg, int off,
538 const ev_uint32_t value)
540 if (!msg->how_often_set || off < 0 || off >= msg->how_often_length)
544 msg->how_often_data[off] = value;
550 kill_weapon_get(struct kill *msg, char * *value)
552 if (msg->weapon_set != 1)
554 *value = msg->weapon_data;
559 kill_action_get(struct kill *msg, char * *value)
561 if (msg->action_set != 1)
563 *value = msg->action_data;
568 kill_how_often_get(struct kill *msg, int offset,
571 if (!msg->how_often_set || offset < 0 || offset >= msg->how_often_length)
573 *value = msg->how_often_data[offset];
578 kill_clear(struct kill *tmp)
580 if (tmp->weapon_set == 1) {
581 free(tmp->weapon_data);
582 tmp->weapon_data = NULL;
585 if (tmp->action_set == 1) {
586 free(tmp->action_data);
587 tmp->action_data = NULL;
590 if (tmp->how_often_set == 1) {
591 free(tmp->how_often_data);
592 tmp->how_often_data = NULL;
593 tmp->how_often_set = 0;
594 tmp->how_often_length = 0;
595 tmp->how_often_num_allocated = 0;
600 kill_free(struct kill *tmp)
602 if (tmp->weapon_data != NULL)
603 free (tmp->weapon_data);
604 if (tmp->action_data != NULL)
605 free (tmp->action_data);
606 if (tmp->how_often_set == 1) {
607 free(tmp->how_often_data);
608 tmp->how_often_data = NULL;
609 tmp->how_often_set = 0;
610 tmp->how_often_length = 0;
611 tmp->how_often_num_allocated = 0;
613 free(tmp->how_often_data);
618 kill_marshal(struct evbuffer *evbuf, const struct kill *tmp){
619 evtag_marshal_string(evbuf, KILL_WEAPON, tmp->weapon_data);
620 evtag_marshal_string(evbuf, KILL_ACTION, tmp->action_data);
621 if (tmp->how_often_set) {
624 for (i = 0; i < tmp->how_often_length; ++i) {
625 evtag_marshal_int(evbuf, KILL_HOW_OFTEN, tmp->how_often_data[i]);
632 kill_unmarshal(struct kill *tmp, struct evbuffer *evbuf)
635 while (evbuffer_get_length(evbuf) > 0) {
636 if (evtag_peek(evbuf, &tag) == -1)
644 if (evtag_unmarshal_string(evbuf, KILL_WEAPON, &tmp->weapon_data) == -1) {
645 event_warnx("%s: failed to unmarshal weapon", __func__);
655 if (evtag_unmarshal_string(evbuf, KILL_ACTION, &tmp->action_data) == -1) {
656 event_warnx("%s: failed to unmarshal action", __func__);
664 if (tmp->how_often_length >= tmp->how_often_num_allocated &&
665 kill_how_often_expand_to_hold_more(tmp) < 0) {
669 if (evtag_unmarshal_int(evbuf, KILL_HOW_OFTEN, &tmp->how_often_data[tmp->how_often_length]) == -1) {
670 event_warnx("%s: failed to unmarshal how_often", __func__);
673 ++tmp->how_often_length;
674 tmp->how_often_set = 1;
682 if (kill_complete(tmp) == -1)
688 kill_complete(struct kill *msg)
690 if (!msg->weapon_set)
692 if (!msg->action_set)
698 evtag_unmarshal_kill(struct evbuffer *evbuf, ev_uint32_t need_tag, struct kill *msg)
703 struct evbuffer *tmp = evbuffer_new();
705 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
708 if (kill_unmarshal(msg, tmp) == -1)
719 evtag_marshal_kill(struct evbuffer *evbuf, ev_uint32_t tag, const struct kill *msg)
721 struct evbuffer *buf_ = evbuffer_new();
722 assert(buf_ != NULL);
723 kill_marshal(buf_, msg);
724 evtag_marshal_buffer(evbuf, tag, buf_);
729 * Implementation of run
732 static struct run_access_ run_base__ = {
735 run_some_bytes_assign,
737 run_fixed_bytes_assign,
742 run_large_number_assign,
743 run_large_number_get,
744 run_other_numbers_assign,
745 run_other_numbers_get,
746 run_other_numbers_add,
752 return run_new_with_arg(NULL);
756 run_new_with_arg(void *unused)
759 if ((tmp = malloc(sizeof(struct run))) == NULL) {
760 event_warn("%s: malloc", __func__);
763 tmp->base = &run_base__;
765 tmp->how_data = NULL;
768 tmp->some_bytes_data = NULL;
769 tmp->some_bytes_length = 0;
770 tmp->some_bytes_set = 0;
772 memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
773 tmp->fixed_bytes_set = 0;
775 tmp->notes_data = NULL;
776 tmp->notes_length = 0;
777 tmp->notes_num_allocated = 0;
780 tmp->large_number_data = 0;
781 tmp->large_number_set = 0;
783 tmp->other_numbers_data = NULL;
784 tmp->other_numbers_length = 0;
785 tmp->other_numbers_num_allocated = 0;
786 tmp->other_numbers_set = 0;
795 run_notes_expand_to_hold_more(struct run *msg)
797 int tobe_allocated = msg->notes_num_allocated;
798 char ** new_data = NULL;
799 tobe_allocated = !tobe_allocated ? 1 : tobe_allocated << 1;
800 new_data = (char **) realloc(msg->notes_data,
801 tobe_allocated * sizeof(char *));
802 if (new_data == NULL)
804 msg->notes_data = new_data;
805 msg->notes_num_allocated = tobe_allocated;
809 run_notes_add(struct run *msg, const char * value)
811 if (++msg->notes_length >= msg->notes_num_allocated) {
812 if (run_notes_expand_to_hold_more(msg)<0)
816 msg->notes_data[msg->notes_length - 1] = strdup(value);
817 if (msg->notes_data[msg->notes_length - 1] == NULL) {
821 msg->notes_data[msg->notes_length - 1] = NULL;
824 return &(msg->notes_data[msg->notes_length - 1]);
832 run_other_numbers_expand_to_hold_more(struct run *msg)
834 int tobe_allocated = msg->other_numbers_num_allocated;
835 ev_uint32_t* new_data = NULL;
836 tobe_allocated = !tobe_allocated ? 1 : tobe_allocated << 1;
837 new_data = (ev_uint32_t*) realloc(msg->other_numbers_data,
838 tobe_allocated * sizeof(ev_uint32_t));
839 if (new_data == NULL)
841 msg->other_numbers_data = new_data;
842 msg->other_numbers_num_allocated = tobe_allocated;
846 run_other_numbers_add(struct run *msg, const ev_uint32_t value)
848 if (++msg->other_numbers_length >= msg->other_numbers_num_allocated) {
849 if (run_other_numbers_expand_to_hold_more(msg)<0)
852 msg->other_numbers_data[msg->other_numbers_length - 1] = value;
853 msg->other_numbers_set = 1;
854 return &(msg->other_numbers_data[msg->other_numbers_length - 1]);
856 --msg->other_numbers_length;
861 run_how_assign(struct run *msg,
864 if (msg->how_data != NULL)
866 if ((msg->how_data = strdup(value)) == NULL)
873 run_some_bytes_assign(struct run *msg, const ev_uint8_t * value, ev_uint32_t len)
875 if (msg->some_bytes_data != NULL)
876 free (msg->some_bytes_data);
877 msg->some_bytes_data = malloc(len);
878 if (msg->some_bytes_data == NULL)
880 msg->some_bytes_set = 1;
881 msg->some_bytes_length = len;
882 memcpy(msg->some_bytes_data, value, len);
887 run_fixed_bytes_assign(struct run *msg, const ev_uint8_t *value)
889 msg->fixed_bytes_set = 1;
890 memcpy(msg->fixed_bytes_data, value, 24);
895 run_notes_assign(struct run *msg, int off,
898 if (!msg->notes_set || off < 0 || off >= msg->notes_length)
902 if (msg->notes_data[off] != NULL)
903 free(msg->notes_data[off]);
904 msg->notes_data[off] = strdup(value);
905 if (msg->notes_data[off] == NULL) {
906 event_warnx("%s: strdup", __func__);
914 run_large_number_assign(struct run *msg, const ev_uint64_t value)
916 msg->large_number_set = 1;
917 msg->large_number_data = value;
922 run_other_numbers_assign(struct run *msg, int off,
923 const ev_uint32_t value)
925 if (!msg->other_numbers_set || off < 0 || off >= msg->other_numbers_length)
929 msg->other_numbers_data[off] = value;
935 run_how_get(struct run *msg, char * *value)
937 if (msg->how_set != 1)
939 *value = msg->how_data;
944 run_some_bytes_get(struct run *msg, ev_uint8_t * *value, ev_uint32_t *plen)
946 if (msg->some_bytes_set != 1)
948 *value = msg->some_bytes_data;
949 *plen = msg->some_bytes_length;
954 run_fixed_bytes_get(struct run *msg, ev_uint8_t **value)
956 if (msg->fixed_bytes_set != 1)
958 *value = msg->fixed_bytes_data;
963 run_notes_get(struct run *msg, int offset,
966 if (!msg->notes_set || offset < 0 || offset >= msg->notes_length)
968 *value = msg->notes_data[offset];
973 run_large_number_get(struct run *msg, ev_uint64_t *value)
975 if (msg->large_number_set != 1)
977 *value = msg->large_number_data;
982 run_other_numbers_get(struct run *msg, int offset,
985 if (!msg->other_numbers_set || offset < 0 || offset >= msg->other_numbers_length)
987 *value = msg->other_numbers_data[offset];
992 run_clear(struct run *tmp)
994 if (tmp->how_set == 1) {
996 tmp->how_data = NULL;
999 if (tmp->some_bytes_set == 1) {
1000 free (tmp->some_bytes_data);
1001 tmp->some_bytes_data = NULL;
1002 tmp->some_bytes_length = 0;
1003 tmp->some_bytes_set = 0;
1005 tmp->fixed_bytes_set = 0;
1006 memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
1007 if (tmp->notes_set == 1) {
1009 for (i = 0; i < tmp->notes_length; ++i) {
1010 if (tmp->notes_data[i] != NULL) free(tmp->notes_data[i]);
1012 free(tmp->notes_data);
1013 tmp->notes_data = NULL;
1015 tmp->notes_length = 0;
1016 tmp->notes_num_allocated = 0;
1018 tmp->large_number_set = 0;
1019 if (tmp->other_numbers_set == 1) {
1020 free(tmp->other_numbers_data);
1021 tmp->other_numbers_data = NULL;
1022 tmp->other_numbers_set = 0;
1023 tmp->other_numbers_length = 0;
1024 tmp->other_numbers_num_allocated = 0;
1029 run_free(struct run *tmp)
1031 if (tmp->how_data != NULL)
1032 free (tmp->how_data);
1033 if (tmp->some_bytes_data != NULL)
1034 free(tmp->some_bytes_data);
1035 if (tmp->notes_set == 1) {
1037 for (i = 0; i < tmp->notes_length; ++i) {
1038 if (tmp->notes_data[i] != NULL) free(tmp->notes_data[i]);
1040 free(tmp->notes_data);
1041 tmp->notes_data = NULL;
1043 tmp->notes_length = 0;
1044 tmp->notes_num_allocated = 0;
1046 free(tmp->notes_data);
1047 if (tmp->other_numbers_set == 1) {
1048 free(tmp->other_numbers_data);
1049 tmp->other_numbers_data = NULL;
1050 tmp->other_numbers_set = 0;
1051 tmp->other_numbers_length = 0;
1052 tmp->other_numbers_num_allocated = 0;
1054 free(tmp->other_numbers_data);
1059 run_marshal(struct evbuffer *evbuf, const struct run *tmp){
1060 evtag_marshal_string(evbuf, RUN_HOW, tmp->how_data);
1061 if (tmp->some_bytes_set) {
1062 evtag_marshal(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length);
1064 evtag_marshal(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, (24));
1065 if (tmp->notes_set) {
1068 for (i = 0; i < tmp->notes_length; ++i) {
1069 evtag_marshal_string(evbuf, RUN_NOTES, tmp->notes_data[i]);
1073 if (tmp->large_number_set) {
1074 evtag_marshal_int64(evbuf, RUN_LARGE_NUMBER, tmp->large_number_data);
1076 if (tmp->other_numbers_set) {
1079 for (i = 0; i < tmp->other_numbers_length; ++i) {
1080 evtag_marshal_int(evbuf, RUN_OTHER_NUMBERS, tmp->other_numbers_data[i]);
1087 run_unmarshal(struct run *tmp, struct evbuffer *evbuf)
1090 while (evbuffer_get_length(evbuf) > 0) {
1091 if (evtag_peek(evbuf, &tag) == -1)
1099 if (evtag_unmarshal_string(evbuf, RUN_HOW, &tmp->how_data) == -1) {
1100 event_warnx("%s: failed to unmarshal how", __func__);
1106 case RUN_SOME_BYTES:
1108 if (tmp->some_bytes_set)
1110 if (evtag_payload_length(evbuf, &tmp->some_bytes_length) == -1)
1112 if (tmp->some_bytes_length > evbuffer_get_length(evbuf))
1114 if ((tmp->some_bytes_data = malloc(tmp->some_bytes_length)) == NULL)
1116 if (evtag_unmarshal_fixed(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length) == -1) {
1117 event_warnx("%s: failed to unmarshal some_bytes", __func__);
1120 tmp->some_bytes_set = 1;
1123 case RUN_FIXED_BYTES:
1125 if (tmp->fixed_bytes_set)
1127 if (evtag_unmarshal_fixed(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, (24)) == -1) {
1128 event_warnx("%s: failed to unmarshal fixed_bytes", __func__);
1131 tmp->fixed_bytes_set = 1;
1136 if (tmp->notes_length >= tmp->notes_num_allocated &&
1137 run_notes_expand_to_hold_more(tmp) < 0) {
1141 if (evtag_unmarshal_string(evbuf, RUN_NOTES, &tmp->notes_data[tmp->notes_length]) == -1) {
1142 event_warnx("%s: failed to unmarshal notes", __func__);
1145 ++tmp->notes_length;
1149 case RUN_LARGE_NUMBER:
1151 if (tmp->large_number_set)
1153 if (evtag_unmarshal_int64(evbuf, RUN_LARGE_NUMBER, &tmp->large_number_data) == -1) {
1154 event_warnx("%s: failed to unmarshal large_number", __func__);
1157 tmp->large_number_set = 1;
1160 case RUN_OTHER_NUMBERS:
1162 if (tmp->other_numbers_length >= tmp->other_numbers_num_allocated &&
1163 run_other_numbers_expand_to_hold_more(tmp) < 0) {
1167 if (evtag_unmarshal_int(evbuf, RUN_OTHER_NUMBERS, &tmp->other_numbers_data[tmp->other_numbers_length]) == -1) {
1168 event_warnx("%s: failed to unmarshal other_numbers", __func__);
1171 ++tmp->other_numbers_length;
1172 tmp->other_numbers_set = 1;
1180 if (run_complete(tmp) == -1)
1186 run_complete(struct run *msg)
1190 if (!msg->fixed_bytes_set)
1196 evtag_unmarshal_run(struct evbuffer *evbuf, ev_uint32_t need_tag, struct run *msg)
1201 struct evbuffer *tmp = evbuffer_new();
1203 if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
1206 if (run_unmarshal(msg, tmp) == -1)
1217 evtag_marshal_run(struct evbuffer *evbuf, ev_uint32_t tag, const struct run *msg)
1219 struct evbuffer *buf_ = evbuffer_new();
1220 assert(buf_ != NULL);
1221 run_marshal(buf_, msg);
1222 evtag_marshal_buffer(evbuf, tag, buf_);
1223 evbuffer_free(buf_);