diff --git a/src/bin/ubistry/Makefile b/src/bin/ubistry/Makefile index b073991..5c6f764 100644 --- a/src/bin/ubistry/Makefile +++ b/src/bin/ubistry/Makefile @@ -26,6 +26,7 @@ # Link The Binary $(BINARY) : $(OBJS) $(CC) -nostdlib -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + strip $(BINARY) # Compile the source files .cc.o: diff --git a/src/bin/ubistry/include/ubistry.h b/src/bin/ubistry/include/ubistry.h new file mode 100644 index 0000000..ce40f4e --- /dev/null +++ b/src/bin/ubistry/include/ubistry.h @@ -0,0 +1,11 @@ +#include + +struct ubistryKey { + struct ubistryKey *prev; + struct ubistryKey *next; + char name[128]; + char value[512]; + }; + +struct ubistryKey * ubistryFindKey(char *); +int ubistryAddKey(char *,char *); diff --git a/src/bin/ubistry/main.c b/src/bin/ubistry/main.c index 0e32eb9..025cb1f 100644 --- a/src/bin/ubistry/main.c +++ b/src/bin/ubistry/main.c @@ -30,11 +30,16 @@ #include #include #include +#include #include +#include "./include/ubistry.h" + +struct ubistryKey *keys = 0x0; int main(int argc,char **argv) { - mpiMessage_t msg; + mpiMessage_t msg; + struct ubistryKey *tmpKey = 0x0; if (fork() != 0x0) { exit(0x0); @@ -45,17 +50,68 @@ exit(-1); } + keys = (struct ubistryKey *)malloc(sizeof(struct ubistryKey)); + + ubistryAddKey("ubu","is a god"); + ubistryAddKey("TCA","is a cry baby"); + while (1) { if (mpiFetchMessage("ubistry",&msg) == 0x0) { - printf("\nReceived Message: ubistry, %i:%s\n",msg.type,msg.data); + switch (msg.type) { + case 50: + tmpKey = ubistryFindKey(msg.data); + if (tmpKey == 0x0) + printf("ubistry: Key (%s) Not Found\n",msg.data); + else + printf("ubistry: key (%s) Found Has Value (%s)\n",tmpKey->name,tmpKey->value); + break; + default: + printf("ubistry: Command (%i) With Data (%s) Not Valid\n",msg.type,msg.data); + break; + } } } exit(0x0); } +struct ubistryKey * ubistryFindKey(char *name) { + struct ubistryKey *tmpKey = keys; + + for (;tmpKey;tmpKey=tmpKey->next) { + if (!strcmp(name,tmpKey->name)) { + return(tmpKey); + } + } + return(0x0); + } + +int ubistryAddKey(char *name,char *value) { + struct ubistryKey *tmpKey = (struct ubistryKey *)malloc(sizeof(struct ubistryKey)); + + sprintf(tmpKey->name,name); + sprintf(tmpKey->value,value); + + if (keys == 0x0) { + keys = tmpKey; + keys->prev = 0x0; + keys->next = 0x0; + } + else { + tmpKey->next = keys; + tmpKey->prev = 0x0; + keys->prev = tmpKey; + keys = tmpKey; + } + + return(0x0); + } + /*** $Log$ + Revision 1.2 2004/05/26 12:16:02 reddawg + ubistry: now runs as a deamon + Revision 1.1 2004/05/26 12:09:12 reddawg ubistry: this is the frame work for the ubix registry system more to come over the next few days