diff --git a/mailtest/.gitignore b/mailtest/.gitignore new file mode 100644 index 0000000..8d17d69 --- /dev/null +++ b/mailtest/.gitignore @@ -0,0 +1,6 @@ +*.o +*.json +docs/ +.cache/ +*.map +mailtest diff --git a/mailtest/Makefile b/mailtest/Makefile new file mode 100644 index 0000000..e55f26f --- /dev/null +++ b/mailtest/Makefile @@ -0,0 +1,11 @@ +include ../make/ufuncs.mk + +$(eval $(call add_lib,libprocess)) +$(eval $(call add_lib,libstring)) +$(eval $(call add_lib,libmalloc)) +$(eval $(call add_lib,libdebugconsole)) +$(eval $(call add_lib,libaux)) + +cflags += -DPRINTF_INCLUDE_CONFIG_H=1 + +include ../make/user.mk diff --git a/mailtest/app.mk b/mailtest/app.mk new file mode 100644 index 0000000..05cab5b --- /dev/null +++ b/mailtest/app.mk @@ -0,0 +1 @@ +app := mailtest diff --git a/mailtest/mailtest.c b/mailtest/mailtest.c new file mode 100644 index 0000000..42a67c3 --- /dev/null +++ b/mailtest/mailtest.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include + +void app_main (void) { + libprocess_self_init (); + + char commandbuf[32]; + memset (commandbuf, 0, sizeof (commandbuf)); + char payloadbuf[32]; + memset (payloadbuf, 0, sizeof (payloadbuf)); + char procgroupbuf[32]; + memset (procgroupbuf, 0, sizeof (procgroupbuf)); + + if (env_get (process_get_pgid (), "C", (void*)commandbuf, sizeof (commandbuf)) != ST_OK) { + return; + } + + if (strcmp (commandbuf, "recv") == 0) { + char recv_buffer[1024]; + + for (;;) { + memset (recv_buffer, 0, sizeof (recv_buffer)); + mail_receive (recv_buffer, sizeof (recv_buffer)); + + debug_printf ("%s\n", recv_buffer); + } + } else if (strcmp (commandbuf, "send") == 0) { + if (env_get (process_get_pgid (), "payload", (void*)payloadbuf, sizeof (payloadbuf)) != ST_OK) { + return; + } + + if (env_get (process_get_pgid (), "pg", (void*)procgroupbuf, sizeof (procgroupbuf)) != ST_OK) { + return; + } + + int pgid = str_to_uint32 (procgroupbuf); + + debug_printf ("sending %s to PG %s (%d)\n", payloadbuf, procgroupbuf, pgid); + + mail_send (pgid, payloadbuf, sizeof (payloadbuf)); + } +} diff --git a/mailtest/src.mk b/mailtest/src.mk new file mode 100644 index 0000000..7c9ce88 --- /dev/null +++ b/mailtest/src.mk @@ -0,0 +1,3 @@ +c += mailtest.c + +o += mailtest.o diff --git a/make/apps.mk b/make/apps.mk index b295126..5f84dbc 100644 --- a/make/apps.mk +++ b/make/apps.mk @@ -3,7 +3,8 @@ apps := \ spin \ ce \ sdutil \ - usb + usb \ + mailtest all_apps: @for d in $(apps); do make -C $$d platform=$(platform) all; done