add basic emotion topic
This commit is contained in:
parent
193103a981
commit
c0cfeaa333
4 changed files with 44 additions and 5 deletions
8
Makefile
8
Makefile
|
@ -22,9 +22,11 @@ uninstall:
|
|||
rm $(DESTDIR)$(PREFIX)/bin/journal
|
||||
|
||||
# currently we only have one journal util, others may come later
|
||||
journal: src/journal/main.o
|
||||
$(CC) $(LDFLAGS) -o bin/journal src/journal/main.o $(LDLIBS)
|
||||
journal: src/journal/main.o src/journal/emotion.o
|
||||
$(CC) $(LDFLAGS) -o bin/journal \
|
||||
src/journal/main.o src/journal/emotion.o $(LDLIBS)
|
||||
|
||||
src/journal/emotion.o: src/journal/emotion.c
|
||||
src/journal/main.o: src/journal/main.c
|
||||
|
||||
clean:
|
||||
|
@ -32,6 +34,4 @@ clean:
|
|||
|
||||
.SUFFIXES: .c .o
|
||||
.c.o:
|
||||
# $< mean the prereqs
|
||||
# $@ means the target
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
|
7
src/journal/emotion.c
Normal file
7
src/journal/emotion.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void handle_emotion()
|
||||
{
|
||||
printf("test\n");
|
||||
return;
|
||||
}
|
6
src/journal/emotion.h
Normal file
6
src/journal/emotion.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef __EMOTION_H__
|
||||
#define __EMOTION_H__
|
||||
|
||||
void handle_emotion();
|
||||
|
||||
#endif
|
|
@ -1,4 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "emotion.h"
|
||||
|
||||
#define TOPICS 10
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -9,7 +14,28 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
char *topic = argv[1];
|
||||
printf("%s\n", topic);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue