]> git.lizzy.rs Git - dragonnet.git/commitdiff
Support nested types
authorHimbeerserverDE <himbeerserverde@gmail.com>
Thu, 7 Oct 2021 17:47:08 +0000 (19:47 +0200)
committerHimbeerserverDE <himbeerserverde@gmail.com>
Thu, 7 Oct 2021 17:47:08 +0000 (19:47 +0200)
recv.c
recv.h
send.c
send.h
typegen/main.c

diff --git a/recv.c b/recv.c
index 5a67a74d227a8302cb72ab82d51423813cdb2b45..5bb20e8a71cf61c5010ee7448fb851703a4b715c 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -3,7 +3,7 @@
 
 #include <dragonnet/recv.h>
 
-void recv_raw(DragonnetPeer *p, void *buf, size_t n)
+void dragonnet_recv_raw(DragonnetPeer *p, void *buf, size_t n)
 {
        pthread_rwlock_rdlock(&p->mu);
        int sock = p->sock;
diff --git a/recv.h b/recv.h
index 01b24d74e4927fc008e52b7b0741a8f74e7ee04e..09f958699a0c7559d4a4398430f444b8f2311369 100644 (file)
--- a/recv.h
+++ b/recv.h
@@ -3,6 +3,6 @@
 
 #include <dragonnet/peer.h>
 
-void recv_raw(DragonnetPeer *p, void *buf, size_t n);
+void dragonnet_recv_raw(DragonnetPeer *p, void *buf, size_t n);
 
 #endif
diff --git a/send.c b/send.c
index 89408e49ba7cfe2f34439fdbfa9d5df1f1ec470e..1a2ca9dca3c3e806328452847f31b3d4bc5af12a 100644 (file)
--- a/send.c
+++ b/send.c
@@ -3,7 +3,7 @@
 
 #include <dragonnet/send.h>
 
-void send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n)
+void dragonnet_send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n)
 {
        pthread_rwlock_rdlock(&p->mu);
        int sock = p->sock;
diff --git a/send.h b/send.h
index 0a3a8b1446802666f78a85a93120780251caddd1..4988f0c8dea64ecc94f5ff1be4db4e599c80f318 100644 (file)
--- a/send.h
+++ b/send.h
@@ -5,6 +5,6 @@
 
 #include <dragonnet/peer.h>
 
-void send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n);
+void dragonnet_send_raw(DragonnetPeer *p, bool submit, const void *buf, size_t n);
 
 #endif
index cbaa11104136b6267964e02ab6e9afa9d19c3e53..e591a278ad98686dbd251734260fe1bdcf4c457e 100644 (file)
@@ -38,16 +38,13 @@ static void gen_serializers(FILE *c_fp, FILE *h_fp)
        fprintf(h_fp, "typedef struct {\n\tu32 siz;\n\tu8 *data;\n} Blob;\n\n");
 
        for (u8 bits = 8; bits <= 64; bits *= 2) {
-               char *fmt_u = "void send_u%d(DragonnetPeer *p, bool submit, u%d v)%s\n";
-               char *fmt_s = "void send_s%d(DragonnetPeer *p, bool submit, s%d v)%s\n";
+               char *fmt_u = "static void dragonnet_send_u%d(DragonnetPeer *p, bool submit, u%d v)\n";
+               char *fmt_s = "static void dragonnet_send_s%d(DragonnetPeer *p, bool submit, s%d v)\n";
 
-               fprintf(h_fp, fmt_u, bits, bits, ";");
-               fprintf(h_fp, fmt_s, bits, bits, ";");
-
-               fprintf(c_fp, fmt_u, bits, bits, "");
+               fprintf(c_fp, fmt_u, bits, bits);
                fprintf(c_fp, "{\n");
                fprintf(c_fp, "\tu%d be = htobe%d(v);\n", bits, bits);
-               fprintf(c_fp, "\tsend_raw(p, submit, &be, sizeof be);\n");
+               fprintf(c_fp, "\tdragonnet_send_raw(p, submit, &be, sizeof be);\n");
                fprintf(c_fp, "}\n\n");
 
                fprintf(c_fp, fmt_s, bits, bits, "");
@@ -56,181 +53,149 @@ static void gen_serializers(FILE *c_fp, FILE *h_fp)
                fprintf(c_fp, "}\n\n");
 
                if (bits >= 32) {
-                       char *fmt_f = "void send_f%d(DragonnetPeer *p, bool submit, f%d v)%s\n";
-                       fprintf(h_fp, fmt_f, bits, bits, ";");
+                       char *fmt_f = "static void dragonnet_send_f%d(DragonnetPeer *p, bool submit, f%d v)\n";
 
-                       fprintf(c_fp, fmt_f, bits, bits, "");
+                       fprintf(c_fp, fmt_f, bits, bits);
                        fprintf(c_fp, "{\n");
-                       fprintf(c_fp, "\tsend_u%d(p, submit, (u%d) v);\n", bits, bits);
+                       fprintf(c_fp, "\tdragonnet_send_u%d(p, submit, (u%d) v);\n", bits, bits);
                        fprintf(c_fp, "}\n\n");
                }
        }
 
-       fprintf(h_fp, "\n");
-
        for (u8 elems = 2; elems <= 4; ++elems) {
                for (u8 bits = 8; bits <= 64; bits *= 2) {
-                       char *fmt_u = "void send_v%du%d(DragonnetPeer *p, bool submit, v%du%d v)%s\n";
-                       char *fmt_s = "void send_v%ds%d(DragonnetPeer *p, bool submit, v%ds%d v)%s\n";
+                       char *fmt_u = "static void dragonnet_send_v%du%d(DragonnetPeer *p, bool submit, v%du%d v)\n";
+                       char *fmt_s = "static void dragonnet_send_v%ds%d(DragonnetPeer *p, bool submit, v%ds%d v)\n";
 
-                       fprintf(h_fp, fmt_u, elems, bits, elems, bits, ";");
-                       fprintf(h_fp, fmt_s, elems, bits, elems, bits, ";");
-
-                       fprintf(c_fp, fmt_u, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_u, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\tfor (u8 i = 0; i < %d; ++i) {\n", elems);
-                       fprintf(c_fp, "\t\tsend_u%d(p, (i == %d-1) ? submit : false, v[i]);\n", bits, elems);
+                       fprintf(c_fp, "\t\tdragonnet_send_u%d(p, (i == %d-1) ? submit : false, v[i]);\n", bits, elems);
                        fprintf(c_fp, "\t}\n");
                        fprintf(c_fp, "}\n\n");
 
-                       fprintf(c_fp, fmt_s, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_s, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\tfor (u8 i = 0; i < %d; ++i) {\n", elems);
-                       fprintf(c_fp, "\t\tsend_s%d(p, (i == %d-1) ? submit : false, v[i]);\n", bits, elems);
+                       fprintf(c_fp, "\t\tdragonnet_send_s%d(p, (i == %d-1) ? submit : false, v[i]);\n", bits, elems);
                        fprintf(c_fp, "\t}\n");
                        fprintf(c_fp, "}\n\n");
 
                        if (bits >= 32) {
-                               char *fmt_f = "void send_v%df%d(DragonnetPeer *p, bool submit, v%df%d v)%s\n";
-                               fprintf(h_fp, fmt_f, elems, bits, elems, bits, ";");
+                               char *fmt_f = "static void dragonnet_send_v%df%d(DragonnetPeer *p, bool submit, v%df%d v)\n";
 
-                               fprintf(c_fp, fmt_f, elems, bits, elems, bits, "");
+                               fprintf(c_fp, fmt_f, elems, bits, elems, bits);
                                fprintf(c_fp, "{\n");
                                fprintf(c_fp, "\tfor (u8 i = 0; i < %d; ++i) {\n", elems);
-                               fprintf(c_fp, "\t\tsend_s%d(p, (i == %d-1) ? submit : false, v[i]);\n", bits, elems);
+                               fprintf(c_fp, "\t\tdragonnet_send_s%d(p, (i == %d-1) ? submit : false, v[i]);\n", bits, elems);
                                fprintf(c_fp, "\t}\n");
                                fprintf(c_fp, "}\n\n");
                        }
                }
        }
 
-       fprintf(h_fp, "\n");
-
        for (u8 elems = 2; elems <= 4; ++elems) {
                for (u8 bits = 8; bits <= 64; bits *= 2) {
-                       char *fmt_u = "void send_aabb%du%d(DragonnetPeer *p, bool submit, aabb%du%d v)\n";
-                       char *fmt_s = "void send_aabb%ds%d(DragonnetPeer *p, bool submit, aabb%ds%d v)\n";
+                       char *fmt_u = "static void dragonnet_send_aabb%du%d(DragonnetPeer *p, bool submit, aabb%du%d v)\n";
+                       char *fmt_s = "static void dragonnet_send_aabb%ds%d(DragonnetPeer *p, bool submit, aabb%ds%d v)\n";
 
-                       fprintf(h_fp, fmt_u, elems, bits, elems, bits, ";");
-                       fprintf(h_fp, fmt_s, elems, bits, elems, bits, ";");
-
-                       fprintf(c_fp, fmt_u, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_u, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\tfor (u8 i = 0; i < 2; ++i) {\n");
-                       fprintf(c_fp, "\t\tsend_v%du%d(p, (i == 1) ? submit : false, v[i]);\n", elems, bits);
+                       fprintf(c_fp, "\t\tdragonnet_send_v%du%d(p, (i == 1) ? submit : false, v[i]);\n", elems, bits);
                        fprintf(c_fp, "\t}\n");
                        fprintf(c_fp, "}\n\n");
 
-                       fprintf(c_fp, fmt_s, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_s, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\tfor (u8 i = 0; i < 2; ++i) {\n");
-                       fprintf(c_fp, "\t\tsend_v%ds%d(p, (i == 1) ? submit : false, v[i]);\n", elems, bits);
+                       fprintf(c_fp, "\t\tdragonnet_send_v%ds%d(p, (i == 1) ? submit : false, v[i]);\n", elems, bits);
                        fprintf(c_fp, "\t}\n");
                        fprintf(c_fp, "}\n\n");
 
                        if (bits >= 32) {
-                               char *fmt_f = "void send_aabb%df%d(DragonnetPeer *p, bool submit, aabb%df%d v);\n";
-                               fprintf(h_fp, fmt_f, elems, bits, elems, bits, ";");
+                               char *fmt_f = "static void dragonnet_send_aabb%df%d(DragonnetPeer *p, bool submit, aabb%df%d v);\n";
 
-                               fprintf(c_fp, fmt_f, elems, bits, elems, bits, "");
+                               fprintf(c_fp, fmt_f, elems, bits, elems, bits);
                                fprintf(c_fp, "{\n");
                                fprintf(c_fp, "\tfor (u8 i = 0; i < 2; ++i) {\n");
-                               fprintf(c_fp, "\t\tsend_v%df%d(p, (i == 1) ? submit : false, v[i]);\n", elems, bits);
+                               fprintf(c_fp, "\t\tdragonnet_send_v%df%d(p, (i == 1) ? submit : false, v[i]);\n", elems, bits);
                                fprintf(c_fp, "\t}\n");
                                fprintf(c_fp, "}\n\n");
                        }
                }
        }
 
-       fprintf(h_fp, "\n");
-
-       char *fmt_str = "void send_string(DragonnetPeer *p, bool submit, string v)%s\n";
-       char *fmt_blob = "void send_Blob(DragonnetPeer *p, bool submit, Blob *v)%s\n\n";
-
-       fprintf(h_fp, fmt_str, ";");
-       fprintf(h_fp, fmt_blob, ";");
-
-       fprintf(c_fp, fmt_str, "");
+       fprintf(c_fp, "static void dragonnet_send_string(DragonnetPeer *p, bool submit, string v)\n");
        fprintf(c_fp, "{\n");
-       fprintf(c_fp, "\tsend_raw(p, submit, v, strlen(v));\n");
+       fprintf(c_fp, "\tdragonnet_send_raw(p, submit, v, strlen(v));\n");
        fprintf(c_fp, "}\n\n");
 
-       fprintf(c_fp, fmt_blob, "");
+       fprintf(c_fp, "static void dragonnet_send_Blob(DragonnetPeer *p, bool submit, Blob *v)\n\n");
        fprintf(c_fp, "{\n");
-       fprintf(c_fp, "\tsend_u32(p, false, v->siz);\n");
-       fprintf(c_fp, "\tsend_raw(p, submit, v->data, v->siz);\n");
+       fprintf(c_fp, "\tdragonnet_send_u32(p, false, v->siz);\n");
+       fprintf(c_fp, "\tdragonnet_send_raw(p, submit, v->data, v->siz);\n");
        fprintf(c_fp, "}\n\n");
 }
 
-static void gen_deserializers(FILE *c_fp, FILE *h_fp)
+static void gen_deserializers(FILE *c_fp)
 {
-       c_fp = c_fp;
        for (u8 bits = 8; bits <= 64; bits *= 2) {
-               char *fmt_u = "u%d recv_u%d(DragonnetPeer *p)%s\n";
-               char *fmt_s = "s%d recv_s%d(DragonnetPeer *p)%s\n";
+               char *fmt_u = "static u%d dragonnet_recv_u%d(DragonnetPeer *p)\n";
+               char *fmt_s = "static s%d dragonnet_recv_s%d(DragonnetPeer *p)\n";
 
-               fprintf(h_fp, fmt_u, bits, bits, ";");
-               fprintf(h_fp, fmt_s, bits, bits, ";");
-
-               fprintf(c_fp, fmt_u, bits, bits, "");
+               fprintf(c_fp, fmt_u, bits, bits);
                fprintf(c_fp, "{\n");
-               fprintf(c_fp, "\tu%d be = recv_raw(p, &be, sizeof be);\n", bits);
+               fprintf(c_fp, "\tu%d be = dragonnet_recv_raw(p, &be, sizeof be);\n", bits);
                fprintf(c_fp, "\treturn be%dtoh(be);\n", bits);
                fprintf(c_fp, "}\n\n");
 
-               fprintf(c_fp, fmt_s, bits, bits, "");
+               fprintf(c_fp, fmt_s, bits, bits);
                fprintf(c_fp, "{\n");
-               fprintf(c_fp, "\treturn (s%d) recv_u%d(p);\n", bits, bits);
+               fprintf(c_fp, "\treturn (s%d) dragonnet_recv_u%d(p);\n", bits, bits);
                fprintf(c_fp, "}\n\n");
 
                if (bits >= 32) {
-                       char *fmt_f = "f%d recv_f%d(DragonnetPeer *p)%s\n";
-                       fprintf(h_fp, fmt_f, bits, bits, ";");
+                       char *fmt_f = "static f%d dragonnet_recv_f%d(DragonnetPeer *p)\n";
 
-                       fprintf(c_fp, fmt_f, bits, bits, "");
+                       fprintf(c_fp, fmt_f, bits, bits);
                        fprintf(c_fp, "{\n");
-                       fprintf(c_fp, "\treturn (f%d) recv_u%d(p);\n", bits, bits);
+                       fprintf(c_fp, "\treturn (f%d) dragonnet_recv_u%d(p);\n", bits, bits);
                        fprintf(c_fp, "}\n\n");
                }
        }
 
-       fprintf(h_fp, "\n");
-
        for (u8 elems = 2; elems <= 4; ++elems) {
                for (u8 bits = 8; bits <= 64; bits *= 2) {
-                       char *fmt_u = "v%du%d recv_v%du%d(DragonnetPeer *p)%s\n";
-                       char *fmt_s = "v%ds%d recv_v%ds%d(DragonnetPeer *p)%s\n";
-
-                       fprintf(h_fp, fmt_u, elems, bits, elems, bits, ";");
-                       fprintf(h_fp, fmt_s, elems, bits, elems, bits, ";");
+                       char *fmt_u = "static v%du%d dragonnet_recv_v%du%d(DragonnetPeer *p)\n";
+                       char *fmt_s = "static v%ds%d dragonnet_recv_v%ds%d(DragonnetPeer *p)\n";
 
-                       fprintf(c_fp, fmt_u, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_u, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\tv%du%d v = {0};\n", elems, bits);
                        fprintf(c_fp, "\tfor (u8 i = 0; i < %d; ++i) {\n", elems);
-                       fprintf(c_fp, "\t\tv[i] = recv_u%d(p);\n", bits);
+                       fprintf(c_fp, "\t\tv[i] = dragonnet_recv_u%d(p);\n", bits);
                        fprintf(c_fp, "\t}\n\n");
                        fprintf(c_fp, "\treturn v;\n");
                        fprintf(c_fp, "}\n\n");
 
-                       fprintf(c_fp, fmt_s, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_s, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\tv%ds%d v = {0};\n", elems, bits);
                        fprintf(c_fp, "\tfor (u8 i = 0; i < %d; ++i) {\n", elems);
-                       fprintf(c_fp, "\t\tv[i] = recv_s%d(p);\n", bits);
+                       fprintf(c_fp, "\t\tv[i] = dragonnet_recv_s%d(p);\n", bits);
                        fprintf(c_fp, "\t}\n\n");
                        fprintf(c_fp, "\treturn v;\n");
                        fprintf(c_fp, "}\n\n");
 
                        if (bits >= 32) {
-                               char *fmt_f = "v%df%d recv_v%df%d(DragonnetPeer *p)%s\n";
-                               fprintf(h_fp, fmt_f, elems, bits, elems, bits, ";");
+                               char *fmt_f = "static v%df%d dragonnet_recv_v%df%d(DragonnetPeer *p)\n";
 
-                               fprintf(c_fp, fmt_f, elems, bits, elems, bits, "");
+                               fprintf(c_fp, fmt_f, elems, bits, elems, bits);
                                fprintf(c_fp, "{\n");
                                fprintf(c_fp, "\tv%df%d v = {0};\n", elems, bits);
                                fprintf(c_fp, "\tfor (u8 i = 0; i < %d; ++i) {\n", elems);
-                               fprintf(c_fp, "\t\tv[i] = recv_f%d(p);\n", bits);
+                               fprintf(c_fp, "\t\tv[i] = dragonnet_recv_f%d(p);\n", bits);
                                fprintf(c_fp, "\t}\n\n");
                                fprintf(c_fp, "\treturn v;\n");
                                fprintf(c_fp, "}\n\n");
@@ -238,43 +203,37 @@ static void gen_deserializers(FILE *c_fp, FILE *h_fp)
                }
        }
 
-       fprintf(h_fp, "\n");
-
        for (u8 elems = 2; elems <= 4; ++elems) {
                for (u8 bits = 8; bits <= 64; bits *= 2) {
-                       char *fmt_u = "aabb%du%d recv_aabb%du%d(DragonnetPeer *p)%s\n";
-                       char *fmt_s = "aabb%ds%d recv_aabb%ds%d(DragonnetPeer *p)%s\n";
-
-                       fprintf(h_fp, fmt_u, elems, bits, elems, bits, ";");
-                       fprintf(h_fp, fmt_s, elems, bits, elems, bits, ";");
+                       char *fmt_u = "static aabb%du%d dragonnet_recv_aabb%du%d(DragonnetPeer *p)\n";
+                       char *fmt_s = "static aabb%ds%d dragonnet_recv_aabb%ds%d(DragonnetPeer *p)\n";
 
-                       fprintf(c_fp, fmt_u, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_u, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\taabb%du%d v = {0};\n", elems, bits);
                        fprintf(c_fp, "\tfor (u8 i = 0; i < 2; ++i) {\n");
-                       fprintf(c_fp, "\t\tv[i] = recv_v%du%d(p);\n", elems, bits);
+                       fprintf(c_fp, "\t\tv[i] = dragonnet_recv_v%du%d(p);\n", elems, bits);
                        fprintf(c_fp, "\t}\n\n");
                        fprintf(c_fp, "\treturn v;\n");
                        fprintf(c_fp, "}\n\n");
 
-                       fprintf(c_fp, fmt_s, elems, bits, elems, bits, "");
+                       fprintf(c_fp, fmt_s, elems, bits, elems, bits);
                        fprintf(c_fp, "{\n");
                        fprintf(c_fp, "\taabb%ds%d v = {0};\n", elems, bits);
                        fprintf(c_fp, "\tfor (u8 i = 0; i < 2; ++i) {\n");
-                       fprintf(c_fp, "\t\tv[i] = recv_v%ds%d(p);\n", elems, bits);
+                       fprintf(c_fp, "\t\tv[i] = dragonnet_recv_v%ds%d(p);\n", elems, bits);
                        fprintf(c_fp, "\t}\n\n");
                        fprintf(c_fp, "\treturn v;\n");
                        fprintf(c_fp, "}\n\n");
 
                        if (bits >= 32) {
-                               char *fmt_f = "aabb%df%d recv_aabb%df%d(DragonnetPeer *p)%s\n";
-                               fprintf(h_fp, fmt_f, elems, bits, elems, bits, ";");
+                               char *fmt_f = "static aabb%df%d dragonnet_recv_aabb%df%d(DragonnetPeer *p)\n";
 
-                               fprintf(c_fp, fmt_f, elems, bits, elems, bits, "");
+                               fprintf(c_fp, fmt_f, elems, bits, elems, bits);
                                fprintf(c_fp, "{\n");
                                fprintf(c_fp, "\taabb%df%d v = {0};\n", elems, bits);
                                fprintf(c_fp, "\tfor (u8 i = 0; i < 2; ++i) {\n");
-                               fprintf(c_fp, "\t\tv[i] = recv_v%ds%d(p);\n", elems, bits);
+                               fprintf(c_fp, "\t\tv[i] = dragonnet_recv_v%ds%d(p);\n", elems, bits);
                                fprintf(c_fp, "\t}\n\n");
                                fprintf(c_fp, "\treturn v;\n");
                                fprintf(c_fp, "}\n\n");
@@ -282,32 +241,24 @@ static void gen_deserializers(FILE *c_fp, FILE *h_fp)
                }
        }
 
-       fprintf(h_fp, "\n");
-
-       char *fmt_str = "string recv_string(DragonnetPeer *p)%s\n";
-       char *fmt_blob = "Blob *recv_Blob(DragonnetPeer *p)%s\n\n";
-
-       fprintf(h_fp, fmt_str, ";");
-       fprintf(h_fp, fmt_blob, ";");
-
-       fprintf(c_fp, fmt_str, "");
+       fprintf(c_fp, "static string dragonnet_recv_string(DragonnetPeer *p)\n");
        fprintf(c_fp, "{\n");
        fprintf(c_fp, "\tstring v = malloc(sizeof(u16));\n\n");
        fprintf(c_fp, "\tchar ch;\n");
        fprintf(c_fp, "\tfor (u16 i = 0; ch != '\\0'; ++i) {\n");
-       fprintf(c_fp, "\t\tch = recv_s8(p);\n");
+       fprintf(c_fp, "\t\tch = dragonnet_recv_s8(p);\n");
        fprintf(c_fp, "\t\tv[i] = ch;\n");
        fprintf(c_fp, "\t}\n\n");
        fprintf(c_fp, "\tv = realloc(v, strlen(v));\n");
        fprintf(c_fp, "\treturn v;\n");
        fprintf(c_fp, "}\n\n");
 
-       fprintf(c_fp, fmt_blob, "");
+       fprintf(c_fp, "static Blob *dragonnet_recv_Blob(DragonnetPeer *p)\n\n");
        fprintf(c_fp, "{\n");
        fprintf(c_fp, "\tBlob *v = malloc(sizeof *v);\n");
-       fprintf(c_fp, "\tv->siz = recv_u32(p, false, v->siz);\n");
+       fprintf(c_fp, "\tv->siz = dragonnet_recv_u32(p, false, v->siz);\n");
        fprintf(c_fp, "\tv->data = malloc(v->siz);\n");
-       fprintf(c_fp, "\trecv_raw(p, v->data, v->siz);\n\n");
+       fprintf(c_fp, "\tdragonnet_recv_raw(p, v->data, v->siz);\n\n");
        fprintf(c_fp, "\treturn v;\n");
        fprintf(c_fp, "}\n\n");
 }
@@ -334,7 +285,7 @@ int main(__attribute((unused)) int argc, __attribute((unused)) char **argv)
        fprintf(h_fp, "#define be8toh(x) (x)\n\n");
 
        gen_serializers(c_fp, h_fp);
-       gen_deserializers(c_fp, h_fp);
+       gen_deserializers(c_fp);
 
        char **msgs;
        size_t msgs_len = split(&msgs, data, "\n");
@@ -368,15 +319,37 @@ int main(__attribute((unused)) int argc, __attribute((unused)) char **argv)
                                fprintf(c_fp, "}\n\n");
 
                        msg = msgs[i];
-                       fprintf(c_fp, "void dragonnet_send_%s(DragonnetPeer *p, %s type)\n{\n", msg, msg);
+                       fprintf(c_fp, "static void dragonnet_send_%s(DragonnetPeer *p, %s type)\n{\n", msg, msg);
+               } else {
+                       char **tokens;
+                       size_t tokens_len = split(&tokens, msgs[i], " ");
+
+                       fprintf(c_fp, "\tdragonnet_send_%s(p, false, type.%s);\n", &tokens[0][1], tokens[1]);
+
+                       free_split(tokens, tokens_len);
+                       tokens = NULL;
+               }
+       }
+
+       fprintf(c_fp, "}\n\n");
+       msg = NULL;
+
+       for (size_t i = 0; i < msgs_len; ++i) {
+               if (msgs[i][0] != '\t') {
+                       if (msg != NULL)
+                               fprintf(c_fp, "}\n\n");
+
+                       msg = msgs[i];
+                       fprintf(h_fp, "void dragonnet_peer_send_%s(DragonnetPeer *p, %s type);\n", msg, msg);
+                       fprintf(c_fp, "void dragonnet_peer_send_%s(DragonnetPeer *p, %s type)\n{\n", msg, msg);
                } else {
                        char **tokens;
                        size_t tokens_len = split(&tokens, msgs[i], " ");
 
                        if (i >= msgs_len-1 || msgs[1+i][0] != '\t')
-                               fprintf(c_fp, "\tsend_%s(p, true, type.%s);\n", &tokens[0][1], tokens[1]);
+                               fprintf(c_fp, "\tdragonnet_send_%s(p, true, type.%s);\n", &tokens[0][1], tokens[1]);
                        else
-                               fprintf(c_fp, "\tsend_%s(p, false, type.%s);\n", &tokens[0][1], tokens[1]);
+                               fprintf(c_fp, "\tdragonnet_send_%s(p, false, type.%s);\n", &tokens[0][1], tokens[1]);
 
                        free_split(tokens, tokens_len);
                        tokens = NULL;
@@ -394,18 +367,20 @@ int main(__attribute((unused)) int argc, __attribute((unused)) char **argv)
                        }
 
                        msg = msgs[i];
-                       fprintf(c_fp, "%s dragonnet_recv_%s(DragonnetPeer *p)\n{\n", msg, msg);
+                       fprintf(h_fp, "%s dragonnet_peer_recv_%s(DragonnetPeer *p);\n", msg, msg);
+                       fprintf(c_fp, "%s dragonnet_peer_recv_%s(DragonnetPeer *p)\n{\n", msg, msg);
                        fprintf(c_fp, "\t%s type = {0};\n", msg);
                } else {
                        char **tokens;
                        size_t tokens_len = split(&tokens, msgs[i], " ");
 
-                       fprintf(c_fp, "\ttype.%s = recv_%s(p);\n", tokens[1], &tokens[0][1]);
+                       fprintf(c_fp, "\ttype.%s = dragonnet_recv_%s(p);\n", tokens[1], &tokens[0][1]);
                        free_split(tokens, tokens_len);
                        tokens = NULL;
                }
        }
 
+       fprintf(h_fp, "\n");
        fprintf(c_fp, "\treturn type;\n");
        fprintf(c_fp, "}\n");
        msg = NULL;