/** @brief Implement the class-specific methods. @param ctx Pointer to the method context. @return Zero if successful, or -1 if not. Branch on the method type: create, retrieve, update, delete, search, or id_list. The method parameters and the type of value returned to the client depend on the method type. */ int dispatchCRUDMethod( osrfMethodContext* ctx ) { // Get the method type, then can branch on it osrfHash* method_meta = (osrfHash*) ctx->method->userData; const char* methodtype = osrfHashGet( method_meta, "methodtype" ); if( !strcmp( methodtype, "create" )) return doCreate( ctx ); else if( !strcmp(methodtype, "retrieve" )) return doRetrieve( ctx ); else if( !strcmp(methodtype, "update" )) return doUpdate( ctx ); else if( !strcmp(methodtype, "delete" )) return doDelete( ctx ); else if( !strcmp(methodtype, "search" )) return doSearch( ctx ); else if( !strcmp(methodtype, "id_list" )) return doIdList( ctx ); else { osrfAppRespondComplete( ctx, NULL ); // should be unreachable... return 0; } }
int main (int argc, char **argv) { int dbug=0; char *input; int ch; list *l = lst_create(); if(argc ==2){ if(argv[1][0] == '-' && argv[1][1] == 'd'){ dbug = 1; // ./a.out -d printf("\nDebug mode activated\n"); } } printf ("Starting Restaurant Wait List Program\n\n"); printf ("Enter command: "); while ((ch = getNextNWSChar ()) != EOF) { /* check for the various commands */ if ('q' == ch) { printf ("Quitting Program\n"); return (0); } else if ('?' == ch) { printCommands(); } else if('a' == ch) { doAdd(l,dbug); } else if('c' == ch) { doCallAhead(l,dbug); } else if('w' == ch) { doWaiting(l,dbug); } else if('r' == ch) { doRetrieve(l,dbug); } else if('l' == ch) { doList(l,dbug); } else if('d' == ch) { doDisplay(l,dbug); } else { printf ("%c - in not a valid command\n", ch); printf ("For a list of valid commands, type ?\n"); clearToEoln(); } printf ("\nEnter command: "); } printf ("Quiting Program - EOF reached\n"); lst_free(l,dbug); return 1; }