python/dbus-python: rename package to normalize it
[oi-userland.git] / components / library / libevent / patches / del-dam-py2.patch
blob998aca140ee242a00b4cfc61ec398c940f5fe7fc
1 --- libevent-release-1.4.15-stable/test/Makefile.am.orig 2015-01-05 15:34:32.000000000 +0100
2 +++ libevent-release-1.4.15-stable/test/Makefile.am 2023-02-23 15:17:46.911780258 +0100
3 @@ -6,7 +6,6 @@
5 noinst_PROGRAMS = test-init test-eof test-weof test-time regress bench
7 -BUILT_SOURCES = regress.gen.c regress.gen.h
8 test_init_SOURCES = test-init.c
9 test_init_LDADD = ../libevent_core.la
10 test_eof_SOURCES = test-eof.c
11 @@ -22,9 +21,6 @@
12 bench_SOURCES = bench.c
13 bench_LDADD = ../libevent.la
15 -regress.gen.c regress.gen.h: regress.rpc $(top_srcdir)/event_rpcgen.py
16 - $(top_srcdir)/event_rpcgen.py $(srcdir)/regress.rpc || echo "No Python installed"
18 DISTCLEANFILES = *~
20 test: test-init test-eof test-weof test-time regress
21 --- /dev/null 2023-02-23 16:05:07.000000000 +0100
22 +++ libevent-release-1.4.15-stable/test/regress.gen.c 2023-02-23 16:03:40.223708383 +0100
23 @@ -0,0 +1,878 @@
24 +/*
25 + * Automatically generated from ../libevent-release-1.4.15-stable/test/regress.rpc
26 + * by event_rpcgen.py/0.1. DO NOT EDIT THIS FILE.
27 + */
29 +#include <sys/types.h>
30 +#ifdef _EVENT_HAVE_SYS_TIME_H
31 +#include <sys/time.h>
32 +#endif
33 +#include <stdlib.h>
34 +#include <string.h>
35 +#include <assert.h>
36 +#define EVENT_NO_STRUCT
37 +#include <event.h>
39 +#ifdef _EVENT___func__
40 +#define __func__ _EVENT___func__
41 +#endif
43 +#include "regress.gen.h"
45 +void event_err(int eval, const char *fmt, ...);
46 +void event_warn(const char *fmt, ...);
47 +void event_errx(int eval, const char *fmt, ...);
48 +void event_warnx(const char *fmt, ...);
51 +/*
52 + * Implementation of msg
53 + */
55 +static struct msg_access_ __msg_base = {
56 + msg_from_name_assign,
57 + msg_from_name_get,
58 + msg_to_name_assign,
59 + msg_to_name_get,
60 + msg_attack_assign,
61 + msg_attack_get,
62 + msg_run_assign,
63 + msg_run_get,
64 + msg_run_add,
65 +};
67 +struct msg *
68 +msg_new(void)
70 + struct msg *tmp;
71 + if ((tmp = malloc(sizeof(struct msg))) == NULL) {
72 + event_warn("%s: malloc", __func__);
73 + return (NULL);
74 + }
75 + tmp->base = &__msg_base;
77 + tmp->from_name_data = NULL;
78 + tmp->from_name_set = 0;
80 + tmp->to_name_data = NULL;
81 + tmp->to_name_set = 0;
83 + tmp->attack_data = NULL;
84 + tmp->attack_set = 0;
86 + tmp->run_data = NULL;
87 + tmp->run_length = 0;
88 + tmp->run_num_allocated = 0;
89 + tmp->run_set = 0;
91 + return (tmp);
97 +struct run *
98 +msg_run_add(struct msg *msg)
100 + if (++msg->run_length >= msg->run_num_allocated) {
101 + int tobe_allocated = msg->run_num_allocated;
102 + struct run ** new_data = NULL;
103 + tobe_allocated = !tobe_allocated ? 1 : tobe_allocated << 1;
104 + new_data = (struct run **) realloc(msg->run_data,
105 + tobe_allocated * sizeof(struct run *));
106 + if (new_data == NULL)
107 + goto error;
108 + msg->run_data = new_data;
109 + msg->run_num_allocated = tobe_allocated;
111 + msg->run_data[msg->run_length - 1] = run_new();
112 + if (msg->run_data[msg->run_length - 1] == NULL)
113 + goto error;
114 + msg->run_set = 1;
115 + return (msg->run_data[msg->run_length - 1]);
116 +error:
117 + --msg->run_length;
118 + return (NULL);
122 +int
123 +msg_from_name_assign(struct msg *msg,
124 + const char * value)
126 + if (msg->from_name_data != NULL)
127 + free(msg->from_name_data);
128 + if ((msg->from_name_data = strdup(value)) == NULL)
129 + return (-1);
130 + msg->from_name_set = 1;
131 + return (0);
134 +int
135 +msg_to_name_assign(struct msg *msg,
136 + const char * value)
138 + if (msg->to_name_data != NULL)
139 + free(msg->to_name_data);
140 + if ((msg->to_name_data = strdup(value)) == NULL)
141 + return (-1);
142 + msg->to_name_set = 1;
143 + return (0);
146 +int
147 +msg_attack_assign(struct msg *msg,
148 + const struct kill* value)
150 + struct evbuffer *tmp = NULL;
151 + if (msg->attack_set) {
152 + kill_clear(msg->attack_data);
153 + msg->attack_set = 0;
154 + } else {
155 + msg->attack_data = kill_new();
156 + if (msg->attack_data == NULL) {
157 + event_warn("%s: kill_new()", __func__);
158 + goto error;
161 + if ((tmp = evbuffer_new()) == NULL) {
162 + event_warn("%s: evbuffer_new()", __func__);
163 + goto error;
165 + kill_marshal(tmp, value);
166 + if (kill_unmarshal(msg->attack_data, tmp) == -1) {
167 + event_warnx("%s: kill_unmarshal", __func__);
168 + goto error;
170 + msg->attack_set = 1;
171 + evbuffer_free(tmp);
172 + return (0);
173 + error:
174 + if (tmp != NULL)
175 + evbuffer_free(tmp);
176 + if (msg->attack_data != NULL) {
177 + kill_free(msg->attack_data);
178 + msg->attack_data = NULL;
180 + return (-1);
183 +int
184 +msg_run_assign(struct msg *msg, int off,
185 + const struct run * value)
187 + struct evbuffer *tmp = NULL;
188 + if (!msg->run_set || off < 0 || off >= msg->run_length)
189 + return (-1);
190 + run_clear(msg->run_data[off]);
191 + if ((tmp = evbuffer_new()) == NULL) {
192 + event_warn("%s: evbuffer_new()", __func__);
193 + goto error;
195 + run_marshal(tmp, value);
196 + if (run_unmarshal(msg->run_data[off], tmp) == -1) {
197 + event_warnx("%s: run_unmarshal", __func__);
198 + goto error;
200 + evbuffer_free(tmp);
201 + return (0);
202 +error:
203 + if (tmp != NULL)
204 + evbuffer_free(tmp);
205 + run_clear(msg->run_data[off]);
206 + return (-1);
209 +int
210 +msg_from_name_get(struct msg *msg, char * *value)
212 + if (msg->from_name_set != 1)
213 + return (-1);
214 + *value = msg->from_name_data;
215 + return (0);
218 +int
219 +msg_to_name_get(struct msg *msg, char * *value)
221 + if (msg->to_name_set != 1)
222 + return (-1);
223 + *value = msg->to_name_data;
224 + return (0);
227 +int
228 +msg_attack_get(struct msg *msg, struct kill* *value)
230 + if (msg->attack_set != 1) {
231 + msg->attack_data = kill_new();
232 + if (msg->attack_data == NULL)
233 + return (-1);
234 + msg->attack_set = 1;
236 + *value = msg->attack_data;
237 + return (0);
240 +int
241 +msg_run_get(struct msg *msg, int offset,
242 + struct run * *value)
244 + if (!msg->run_set || offset < 0 || offset >= msg->run_length)
245 + return (-1);
246 + *value = msg->run_data[offset];
247 + return (0);
250 +void
251 +msg_clear(struct msg *tmp)
253 + if (tmp->from_name_set == 1) {
254 + free (tmp->from_name_data);
255 + tmp->from_name_data = NULL;
256 + tmp->from_name_set = 0;
258 + if (tmp->to_name_set == 1) {
259 + free (tmp->to_name_data);
260 + tmp->to_name_data = NULL;
261 + tmp->to_name_set = 0;
263 + if (tmp->attack_set == 1) {
264 + kill_free(tmp->attack_data);
265 + tmp->attack_data = NULL;
266 + tmp->attack_set = 0;
268 + if (tmp->run_set == 1) {
269 + int i;
270 + for (i = 0; i < tmp->run_length; ++i) {
271 + run_free(tmp->run_data[i]);
273 + free(tmp->run_data);
274 + tmp->run_data = NULL;
275 + tmp->run_set = 0;
276 + tmp->run_length = 0;
277 + tmp->run_num_allocated = 0;
281 +void
282 +msg_free(struct msg *tmp)
284 + if (tmp->from_name_data != NULL)
285 + free (tmp->from_name_data);
286 + if (tmp->to_name_data != NULL)
287 + free (tmp->to_name_data);
288 + if (tmp->attack_data != NULL)
289 + kill_free(tmp->attack_data);
290 + if (tmp->run_data != NULL) {
291 + int i;
292 + for (i = 0; i < tmp->run_length; ++i) {
293 + run_free(tmp->run_data[i]);
294 + tmp->run_data[i] = NULL;
296 + free(tmp->run_data);
297 + tmp->run_data = NULL;
298 + tmp->run_length = 0;
299 + tmp->run_num_allocated = 0;
301 + free(tmp);
304 +void
305 +msg_marshal(struct evbuffer *evbuf, const struct msg *tmp){
306 + evtag_marshal_string(evbuf, MSG_FROM_NAME, tmp->from_name_data);
307 + evtag_marshal_string(evbuf, MSG_TO_NAME, tmp->to_name_data);
308 + if (tmp->attack_set) {
309 + evtag_marshal_kill(evbuf, MSG_ATTACK, tmp->attack_data);
312 + int i;
313 + for (i = 0; i < tmp->run_length; ++i) {
314 + evtag_marshal_run(evbuf, MSG_RUN, tmp->run_data[i]);
319 +int
320 +msg_unmarshal(struct msg *tmp, struct evbuffer *evbuf)
322 + ev_uint32_t tag;
323 + while (EVBUFFER_LENGTH(evbuf) > 0) {
324 + if (evtag_peek(evbuf, &tag) == -1)
325 + return (-1);
326 + switch (tag) {
328 + case MSG_FROM_NAME:
330 + if (tmp->from_name_set)
331 + return (-1);
332 + if (evtag_unmarshal_string(evbuf, MSG_FROM_NAME, &tmp->from_name_data) == -1) {
333 + event_warnx("%s: failed to unmarshal from_name", __func__);
334 + return (-1);
336 + tmp->from_name_set = 1;
337 + break;
339 + case MSG_TO_NAME:
341 + if (tmp->to_name_set)
342 + return (-1);
343 + if (evtag_unmarshal_string(evbuf, MSG_TO_NAME, &tmp->to_name_data) == -1) {
344 + event_warnx("%s: failed to unmarshal to_name", __func__);
345 + return (-1);
347 + tmp->to_name_set = 1;
348 + break;
350 + case MSG_ATTACK:
352 + if (tmp->attack_set)
353 + return (-1);
354 + tmp->attack_data = kill_new();
355 + if (tmp->attack_data == NULL)
356 + return (-1);
357 + if (evtag_unmarshal_kill(evbuf, MSG_ATTACK, tmp->attack_data) == -1) {
358 + event_warnx("%s: failed to unmarshal attack", __func__);
359 + return (-1);
361 + tmp->attack_set = 1;
362 + break;
364 + case MSG_RUN:
366 + if (msg_run_add(tmp) == NULL)
367 + return (-1);
368 + if (evtag_unmarshal_run(evbuf, MSG_RUN,
369 + tmp->run_data[tmp->run_length - 1]) == -1) {
370 + --tmp->run_length;
371 + event_warnx("%s: failed to unmarshal run", __func__);
372 + return (-1);
374 + tmp->run_set = 1;
375 + break;
377 + default:
378 + return -1;
382 + if (msg_complete(tmp) == -1)
383 + return (-1);
384 + return (0);
387 +int
388 +msg_complete(struct msg *msg)
390 + if (!msg->from_name_set)
391 + return (-1);
392 + if (!msg->to_name_set)
393 + return (-1);
394 + if (msg->attack_set && kill_complete(msg->attack_data) == -1)
395 + return (-1);
397 + int i;
398 + for (i = 0; i < msg->run_length; ++i) {
399 + if (run_complete(msg->run_data[i]) == -1)
400 + return (-1);
403 + return (0);
406 +int
407 +evtag_unmarshal_msg(struct evbuffer *evbuf, ev_uint32_t need_tag, struct msg *msg)
409 + ev_uint32_t tag;
410 + int res = -1;
412 + struct evbuffer *tmp = evbuffer_new();
414 + if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
415 + goto error;
417 + if (msg_unmarshal(msg, tmp) == -1)
418 + goto error;
420 + res = 0;
422 + error:
423 + evbuffer_free(tmp);
424 + return (res);
427 +void
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 + evbuffer_drain(_buf, -1);
433 + msg_marshal(_buf, msg);
434 + evtag_marshal(evbuf, tag, EVBUFFER_DATA(_buf), EVBUFFER_LENGTH(_buf));
435 + evbuffer_free(_buf);
439 + * Implementation of kill
440 + */
442 +static struct kill_access_ __kill_base = {
443 + kill_weapon_assign,
444 + kill_weapon_get,
445 + kill_action_assign,
446 + kill_action_get,
447 + kill_how_often_assign,
448 + kill_how_often_get,
451 +struct kill *
452 +kill_new(void)
454 + struct kill *tmp;
455 + if ((tmp = malloc(sizeof(struct kill))) == NULL) {
456 + event_warn("%s: malloc", __func__);
457 + return (NULL);
459 + tmp->base = &__kill_base;
461 + tmp->weapon_data = NULL;
462 + tmp->weapon_set = 0;
464 + tmp->action_data = NULL;
465 + tmp->action_set = 0;
467 + tmp->how_often_data = 0;
468 + tmp->how_often_set = 0;
470 + return (tmp);
476 +int
477 +kill_weapon_assign(struct kill *msg,
478 + const char * value)
480 + if (msg->weapon_data != NULL)
481 + free(msg->weapon_data);
482 + if ((msg->weapon_data = strdup(value)) == NULL)
483 + return (-1);
484 + msg->weapon_set = 1;
485 + return (0);
488 +int
489 +kill_action_assign(struct kill *msg,
490 + const char * value)
492 + if (msg->action_data != NULL)
493 + free(msg->action_data);
494 + if ((msg->action_data = strdup(value)) == NULL)
495 + return (-1);
496 + msg->action_set = 1;
497 + return (0);
500 +int
501 +kill_how_often_assign(struct kill *msg, const ev_uint32_t value)
503 + msg->how_often_set = 1;
504 + msg->how_often_data = value;
505 + return (0);
508 +int
509 +kill_weapon_get(struct kill *msg, char * *value)
511 + if (msg->weapon_set != 1)
512 + return (-1);
513 + *value = msg->weapon_data;
514 + return (0);
517 +int
518 +kill_action_get(struct kill *msg, char * *value)
520 + if (msg->action_set != 1)
521 + return (-1);
522 + *value = msg->action_data;
523 + return (0);
526 +int
527 +kill_how_often_get(struct kill *msg, ev_uint32_t *value)
529 + if (msg->how_often_set != 1)
530 + return (-1);
531 + *value = msg->how_often_data;
532 + return (0);
535 +void
536 +kill_clear(struct kill *tmp)
538 + if (tmp->weapon_set == 1) {
539 + free (tmp->weapon_data);
540 + tmp->weapon_data = NULL;
541 + tmp->weapon_set = 0;
543 + if (tmp->action_set == 1) {
544 + free (tmp->action_data);
545 + tmp->action_data = NULL;
546 + tmp->action_set = 0;
548 + tmp->how_often_set = 0;
551 +void
552 +kill_free(struct kill *tmp)
554 + if (tmp->weapon_data != NULL)
555 + free (tmp->weapon_data);
556 + if (tmp->action_data != NULL)
557 + free (tmp->action_data);
558 + free(tmp);
561 +void
562 +kill_marshal(struct evbuffer *evbuf, const struct kill *tmp){
563 + evtag_marshal_string(evbuf, KILL_WEAPON, tmp->weapon_data);
564 + evtag_marshal_string(evbuf, KILL_ACTION, tmp->action_data);
565 + if (tmp->how_often_set) {
566 + evtag_marshal_int(evbuf, KILL_HOW_OFTEN, tmp->how_often_data);
570 +int
571 +kill_unmarshal(struct kill *tmp, struct evbuffer *evbuf)
573 + ev_uint32_t tag;
574 + while (EVBUFFER_LENGTH(evbuf) > 0) {
575 + if (evtag_peek(evbuf, &tag) == -1)
576 + return (-1);
577 + switch (tag) {
579 + case KILL_WEAPON:
581 + if (tmp->weapon_set)
582 + return (-1);
583 + if (evtag_unmarshal_string(evbuf, KILL_WEAPON, &tmp->weapon_data) == -1) {
584 + event_warnx("%s: failed to unmarshal weapon", __func__);
585 + return (-1);
587 + tmp->weapon_set = 1;
588 + break;
590 + case KILL_ACTION:
592 + if (tmp->action_set)
593 + return (-1);
594 + if (evtag_unmarshal_string(evbuf, KILL_ACTION, &tmp->action_data) == -1) {
595 + event_warnx("%s: failed to unmarshal action", __func__);
596 + return (-1);
598 + tmp->action_set = 1;
599 + break;
601 + case KILL_HOW_OFTEN:
603 + if (tmp->how_often_set)
604 + return (-1);
605 + if (evtag_unmarshal_int(evbuf, KILL_HOW_OFTEN, &tmp->how_often_data) == -1) {
606 + event_warnx("%s: failed to unmarshal how_often", __func__);
607 + return (-1);
609 + tmp->how_often_set = 1;
610 + break;
612 + default:
613 + return -1;
617 + if (kill_complete(tmp) == -1)
618 + return (-1);
619 + return (0);
622 +int
623 +kill_complete(struct kill *msg)
625 + if (!msg->weapon_set)
626 + return (-1);
627 + if (!msg->action_set)
628 + return (-1);
629 + return (0);
632 +int
633 +evtag_unmarshal_kill(struct evbuffer *evbuf, ev_uint32_t need_tag, struct kill *msg)
635 + ev_uint32_t tag;
636 + int res = -1;
638 + struct evbuffer *tmp = evbuffer_new();
640 + if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
641 + goto error;
643 + if (kill_unmarshal(msg, tmp) == -1)
644 + goto error;
646 + res = 0;
648 + error:
649 + evbuffer_free(tmp);
650 + return (res);
653 +void
654 +evtag_marshal_kill(struct evbuffer *evbuf, ev_uint32_t tag, const struct kill *msg)
656 + struct evbuffer *_buf = evbuffer_new();
657 + assert(_buf != NULL);
658 + evbuffer_drain(_buf, -1);
659 + kill_marshal(_buf, msg);
660 + evtag_marshal(evbuf, tag, EVBUFFER_DATA(_buf), EVBUFFER_LENGTH(_buf));
661 + evbuffer_free(_buf);
665 + * Implementation of run
666 + */
668 +static struct run_access_ __run_base = {
669 + run_how_assign,
670 + run_how_get,
671 + run_some_bytes_assign,
672 + run_some_bytes_get,
673 + run_fixed_bytes_assign,
674 + run_fixed_bytes_get,
677 +struct run *
678 +run_new(void)
680 + struct run *tmp;
681 + if ((tmp = malloc(sizeof(struct run))) == NULL) {
682 + event_warn("%s: malloc", __func__);
683 + return (NULL);
685 + tmp->base = &__run_base;
687 + tmp->how_data = NULL;
688 + tmp->how_set = 0;
690 + tmp->some_bytes_data = NULL;
691 + tmp->some_bytes_length = 0;
692 + tmp->some_bytes_set = 0;
694 + memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
695 + tmp->fixed_bytes_set = 0;
697 + return (tmp);
703 +int
704 +run_how_assign(struct run *msg,
705 + const char * value)
707 + if (msg->how_data != NULL)
708 + free(msg->how_data);
709 + if ((msg->how_data = strdup(value)) == NULL)
710 + return (-1);
711 + msg->how_set = 1;
712 + return (0);
715 +int
716 +run_some_bytes_assign(struct run *msg, const ev_uint8_t * value, ev_uint32_t len)
718 + if (msg->some_bytes_data != NULL)
719 + free (msg->some_bytes_data);
720 + msg->some_bytes_data = malloc(len);
721 + if (msg->some_bytes_data == NULL)
722 + return (-1);
723 + msg->some_bytes_set = 1;
724 + msg->some_bytes_length = len;
725 + memcpy(msg->some_bytes_data, value, len);
726 + return (0);
729 +int
730 +run_fixed_bytes_assign(struct run *msg, const ev_uint8_t *value)
732 + msg->fixed_bytes_set = 1;
733 + memcpy(msg->fixed_bytes_data, value, 24);
734 + return (0);
737 +int
738 +run_how_get(struct run *msg, char * *value)
740 + if (msg->how_set != 1)
741 + return (-1);
742 + *value = msg->how_data;
743 + return (0);
746 +int
747 +run_some_bytes_get(struct run *msg, ev_uint8_t * *value, ev_uint32_t *plen)
749 + if (msg->some_bytes_set != 1)
750 + return (-1);
751 + *value = msg->some_bytes_data;
752 + *plen = msg->some_bytes_length;
753 + return (0);
756 +int
757 +run_fixed_bytes_get(struct run *msg, ev_uint8_t **value)
759 + if (msg->fixed_bytes_set != 1)
760 + return (-1);
761 + *value = msg->fixed_bytes_data;
762 + return (0);
765 +void
766 +run_clear(struct run *tmp)
768 + if (tmp->how_set == 1) {
769 + free (tmp->how_data);
770 + tmp->how_data = NULL;
771 + tmp->how_set = 0;
773 + if (tmp->some_bytes_set == 1) {
774 + free (tmp->some_bytes_data);
775 + tmp->some_bytes_data = NULL;
776 + tmp->some_bytes_length = 0;
777 + tmp->some_bytes_set = 0;
779 + tmp->fixed_bytes_set = 0;
780 + memset(tmp->fixed_bytes_data, 0, sizeof(tmp->fixed_bytes_data));
783 +void
784 +run_free(struct run *tmp)
786 + if (tmp->how_data != NULL)
787 + free (tmp->how_data);
788 + if (tmp->some_bytes_data != NULL)
789 + free (tmp->some_bytes_data);
790 + free(tmp);
793 +void
794 +run_marshal(struct evbuffer *evbuf, const struct run *tmp){
795 + evtag_marshal_string(evbuf, RUN_HOW, tmp->how_data);
796 + if (tmp->some_bytes_set) {
797 + evtag_marshal(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length);
799 + evtag_marshal(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, sizeof(tmp->fixed_bytes_data));
802 +int
803 +run_unmarshal(struct run *tmp, struct evbuffer *evbuf)
805 + ev_uint32_t tag;
806 + while (EVBUFFER_LENGTH(evbuf) > 0) {
807 + if (evtag_peek(evbuf, &tag) == -1)
808 + return (-1);
809 + switch (tag) {
811 + case RUN_HOW:
813 + if (tmp->how_set)
814 + return (-1);
815 + if (evtag_unmarshal_string(evbuf, RUN_HOW, &tmp->how_data) == -1) {
816 + event_warnx("%s: failed to unmarshal how", __func__);
817 + return (-1);
819 + tmp->how_set = 1;
820 + break;
822 + case RUN_SOME_BYTES:
824 + if (tmp->some_bytes_set)
825 + return (-1);
826 + if (evtag_payload_length(evbuf, &tmp->some_bytes_length) == -1)
827 + return (-1);
828 + if (tmp->some_bytes_length > EVBUFFER_LENGTH(evbuf))
829 + return (-1);
830 + if ((tmp->some_bytes_data = malloc(tmp->some_bytes_length)) == NULL)
831 + return (-1);
832 + if (evtag_unmarshal_fixed(evbuf, RUN_SOME_BYTES, tmp->some_bytes_data, tmp->some_bytes_length) == -1) {
833 + event_warnx("%s: failed to unmarshal some_bytes", __func__);
834 + return (-1);
836 + tmp->some_bytes_set = 1;
837 + break;
839 + case RUN_FIXED_BYTES:
841 + if (tmp->fixed_bytes_set)
842 + return (-1);
843 + if (evtag_unmarshal_fixed(evbuf, RUN_FIXED_BYTES, tmp->fixed_bytes_data, sizeof(tmp->fixed_bytes_data)) == -1) {
844 + event_warnx("%s: failed to unmarshal fixed_bytes", __func__);
845 + return (-1);
847 + tmp->fixed_bytes_set = 1;
848 + break;
850 + default:
851 + return -1;
855 + if (run_complete(tmp) == -1)
856 + return (-1);
857 + return (0);
860 +int
861 +run_complete(struct run *msg)
863 + if (!msg->how_set)
864 + return (-1);
865 + if (!msg->fixed_bytes_set)
866 + return (-1);
867 + return (0);
870 +int
871 +evtag_unmarshal_run(struct evbuffer *evbuf, ev_uint32_t need_tag, struct run *msg)
873 + ev_uint32_t tag;
874 + int res = -1;
876 + struct evbuffer *tmp = evbuffer_new();
878 + if (evtag_unmarshal(evbuf, &tag, tmp) == -1 || tag != need_tag)
879 + goto error;
881 + if (run_unmarshal(msg, tmp) == -1)
882 + goto error;
884 + res = 0;
886 + error:
887 + evbuffer_free(tmp);
888 + return (res);
891 +void
892 +evtag_marshal_run(struct evbuffer *evbuf, ev_uint32_t tag, const struct run *msg)
894 + struct evbuffer *_buf = evbuffer_new();
895 + assert(_buf != NULL);
896 + evbuffer_drain(_buf, -1);
897 + run_marshal(_buf, msg);
898 + evtag_marshal(evbuf, tag, EVBUFFER_DATA(_buf), EVBUFFER_LENGTH(_buf));
899 + evbuffer_free(_buf);
902 --- /dev/null 2023-02-23 16:05:07.000000000 +0100
903 +++ libevent-release-1.4.15-stable/test/regress.gen.h 2023-02-23 16:04:15.669510682 +0100
904 @@ -0,0 +1,178 @@
906 + * Automatically generated from .../libevent-release-1.4.15-stable/test/regress.rpc
907 + */
909 +#include <event-config.h>
910 +#ifdef _EVENT_HAVE_STDINT_H
911 +#include <stdint.h>
912 +#endif
913 +#define EVTAG_HAS(msg, member) ((msg)->member##_set == 1)
914 +#ifdef __GNUC__
915 +#define EVTAG_ASSIGN(msg, member, args...) (*(msg)->base->member##_assign)(msg, ## args)
916 +#define EVTAG_GET(msg, member, args...) (*(msg)->base->member##_get)(msg, ## args)
917 +#else
918 +#define EVTAG_ASSIGN(msg, member, ...) (*(msg)->base->member##_assign)(msg, ## __VA_ARGS__)
919 +#define EVTAG_GET(msg, member, ...) (*(msg)->base->member##_get)(msg, ## __VA_ARGS__)
920 +#endif
921 +#define EVTAG_ADD(msg, member) (*(msg)->base->member##_add)(msg)
922 +#define EVTAG_LEN(msg, member) ((msg)->member##_length)
924 +struct msg;
925 +struct kill;
926 +struct run;
928 +/* Tag definition for msg */
929 +enum msg_ {
930 + MSG_FROM_NAME=1,
931 + MSG_TO_NAME=2,
932 + MSG_ATTACK=3,
933 + MSG_RUN=4,
934 + MSG_MAX_TAGS
937 +/* Structure declaration for msg */
938 +struct msg_access_ {
939 + int (*from_name_assign)(struct msg *, const char *);
940 + int (*from_name_get)(struct msg *, char * *);
941 + int (*to_name_assign)(struct msg *, const char *);
942 + int (*to_name_get)(struct msg *, char * *);
943 + int (*attack_assign)(struct msg *, const struct kill*);
944 + int (*attack_get)(struct msg *, struct kill* *);
945 + int (*run_assign)(struct msg *, int, const struct run *);
946 + int (*run_get)(struct msg *, int, struct run * *);
947 + struct run * (*run_add)(struct msg *);
950 +struct msg {
951 + struct msg_access_ *base;
953 + char *from_name_data;
954 + char *to_name_data;
955 + struct kill* attack_data;
956 + struct run **run_data;
957 + int run_length;
958 + int run_num_allocated;
960 + ev_uint8_t from_name_set;
961 + ev_uint8_t to_name_set;
962 + ev_uint8_t attack_set;
963 + ev_uint8_t run_set;
966 +struct msg *msg_new(void);
967 +void msg_free(struct msg *);
968 +void msg_clear(struct msg *);
969 +void msg_marshal(struct evbuffer *, const struct msg *);
970 +int msg_unmarshal(struct msg *, struct evbuffer *);
971 +int msg_complete(struct msg *);
972 +void evtag_marshal_msg(struct evbuffer *, ev_uint32_t,
973 + const struct msg *);
974 +int evtag_unmarshal_msg(struct evbuffer *, ev_uint32_t,
975 + struct msg *);
976 +int msg_from_name_assign(struct msg *, const char *);
977 +int msg_from_name_get(struct msg *, char * *);
978 +int msg_to_name_assign(struct msg *, const char *);
979 +int msg_to_name_get(struct msg *, char * *);
980 +int msg_attack_assign(struct msg *, const struct kill*);
981 +int msg_attack_get(struct msg *, struct kill* *);
982 +int msg_run_assign(struct msg *, int, const struct run *);
983 +int msg_run_get(struct msg *, int, struct run * *);
984 +struct run * msg_run_add(struct msg *);
985 +/* --- msg done --- */
987 +/* Tag definition for kill */
988 +enum kill_ {
989 + KILL_WEAPON=65825,
990 + KILL_ACTION=2,
991 + KILL_HOW_OFTEN=3,
992 + KILL_MAX_TAGS
995 +/* Structure declaration for kill */
996 +struct kill_access_ {
997 + int (*weapon_assign)(struct kill *, const char *);
998 + int (*weapon_get)(struct kill *, char * *);
999 + int (*action_assign)(struct kill *, const char *);
1000 + int (*action_get)(struct kill *, char * *);
1001 + int (*how_often_assign)(struct kill *, const ev_uint32_t);
1002 + int (*how_often_get)(struct kill *, ev_uint32_t *);
1005 +struct kill {
1006 + struct kill_access_ *base;
1008 + char *weapon_data;
1009 + char *action_data;
1010 + ev_uint32_t how_often_data;
1012 + ev_uint8_t weapon_set;
1013 + ev_uint8_t action_set;
1014 + ev_uint8_t how_often_set;
1017 +struct kill *kill_new(void);
1018 +void kill_free(struct kill *);
1019 +void kill_clear(struct kill *);
1020 +void kill_marshal(struct evbuffer *, const struct kill *);
1021 +int kill_unmarshal(struct kill *, struct evbuffer *);
1022 +int kill_complete(struct kill *);
1023 +void evtag_marshal_kill(struct evbuffer *, ev_uint32_t,
1024 + const struct kill *);
1025 +int evtag_unmarshal_kill(struct evbuffer *, ev_uint32_t,
1026 + struct kill *);
1027 +int kill_weapon_assign(struct kill *, const char *);
1028 +int kill_weapon_get(struct kill *, char * *);
1029 +int kill_action_assign(struct kill *, const char *);
1030 +int kill_action_get(struct kill *, char * *);
1031 +int kill_how_often_assign(struct kill *, const ev_uint32_t);
1032 +int kill_how_often_get(struct kill *, ev_uint32_t *);
1033 +/* --- kill done --- */
1035 +/* Tag definition for run */
1036 +enum run_ {
1037 + RUN_HOW=1,
1038 + RUN_SOME_BYTES=2,
1039 + RUN_FIXED_BYTES=3,
1040 + RUN_MAX_TAGS
1043 +/* Structure declaration for run */
1044 +struct run_access_ {
1045 + int (*how_assign)(struct run *, const char *);
1046 + int (*how_get)(struct run *, char * *);
1047 + int (*some_bytes_assign)(struct run *, const ev_uint8_t *, ev_uint32_t);
1048 + int (*some_bytes_get)(struct run *, ev_uint8_t * *, ev_uint32_t *);
1049 + int (*fixed_bytes_assign)(struct run *, const ev_uint8_t *);
1050 + int (*fixed_bytes_get)(struct run *, ev_uint8_t **);
1053 +struct run {
1054 + struct run_access_ *base;
1056 + char *how_data;
1057 + ev_uint8_t *some_bytes_data;
1058 + ev_uint32_t some_bytes_length;
1059 + ev_uint8_t fixed_bytes_data[24];
1061 + ev_uint8_t how_set;
1062 + ev_uint8_t some_bytes_set;
1063 + ev_uint8_t fixed_bytes_set;
1066 +struct run *run_new(void);
1067 +void run_free(struct run *);
1068 +void run_clear(struct run *);
1069 +void run_marshal(struct evbuffer *, const struct run *);
1070 +int run_unmarshal(struct run *, struct evbuffer *);
1071 +int run_complete(struct run *);
1072 +void evtag_marshal_run(struct evbuffer *, ev_uint32_t,
1073 + const struct run *);
1074 +int evtag_unmarshal_run(struct evbuffer *, ev_uint32_t,
1075 + struct run *);
1076 +int run_how_assign(struct run *, const char *);
1077 +int run_how_get(struct run *, char * *);
1078 +int run_some_bytes_assign(struct run *, const ev_uint8_t *, ev_uint32_t);
1079 +int run_some_bytes_get(struct run *, ev_uint8_t * *, ev_uint32_t *);
1080 +int run_fixed_bytes_assign(struct run *, const ev_uint8_t *);
1081 +int run_fixed_bytes_get(struct run *, ev_uint8_t **);
1082 +/* --- run done --- */