#include #include #include "emotion.h" #define TOPICS 10 int main(int argc, char** argv) { if(argc < 2) { printf("usage: %s topic message\n", argv[0]); return 0; } char *topic = argv[1]; printf("load topic %s\n", topic); const char* topics[TOPICS] = { "emotion" }; void (*handlers[])() = { handle_emotion, }; for(int i = 0; i < TOPICS; i++) { const char* cur_topic = topics[i]; if(strcmp(topic, cur_topic) == 0) { void (*fun_ptr)() = handlers[i]; fun_ptr(); return 0; } } printf("topic %s not found\n", topic); return 0; }