int Menu::how_much_is( Sentence& mSentence, ServerHandler* mh ) { int result =0; RestaurantOrder tmpOrder; if (mSentence.are_found_in_sentence("how much")) { result = Parse_Menu( mSentence, mh, tmpOrder); if (tmpOrder.m_order.size()==0) mh->form_response("I could not find that on the menu."); else { SuperString tmp = "Okay, "; tmpOrder.read_back_items( tmp ); tmp += " costs $"; float total = tmpOrder.get_total(); tmp.append_float ( total ); mh->form_response( tmp.c_str() ); } return 1; } return 0; }
int Parse_Ctlfile(char *ctlname) { FILE *ctlfile; char p[MAX_LINE]; /* First word on line */ char temp[MAX_LINE]; char *bufr; int x; linenum=1; strcpy(ctl_name, fancy_fn(ctlname)); fixPathMove(ctl_name); printf("\nParsing `%s':",ctl_name); if ((ctlfile=fopen(ctlname,"r"))==NULL) { printf(" \aFatal error opening `%s' for read!\n",ctlname); exit(1); } if ((bufr=malloc(MAX_BUFR)) != NULL) setvbuf(ctlfile, bufr, _IOFBF, MAX_BUFR); while (fgets(line, MAX_LINE, ctlfile)) { Strip_Comment(line); if (*line) { getword(line, p, ctl_delim, 1); if (! *p) linenum++; else if (eqstri(p,"system")) { Compiling(LAST_SECTION,cc_section,"System"); Parse_System(ctlfile); done_sys=TRUE; } else if (eqstri(p,"access")) { strcpy(p,fchar(line,ctl_delim,2)); Compiling(LAST_ACCESS,cc_accs,p); ParseAccess(ctlfile,p); done_access=TRUE; } else if (eqstri(p,"equipment")) { Compiling(LAST_SECTION,cc_section,"Equipment"); Parse_Equipment(ctlfile); done_equip=TRUE; } else if (eqstri(p,"matrix")) { Compiling(LAST_SECTION,cc_section,"Matrix"); Parse_Matrix(ctlfile); done_matrix=TRUE; } else if (eqstri(p,"colour") || eqstri(p,"color") || eqstri(p,"colours") || eqstri(p,"colors")) { Compiling(LAST_SECTION,cc_section,"Colors"); Parse_Colours(ctlfile); done_colours=TRUE; } else if (eqstri(p,"session")) { Compiling(LAST_SECTION,cc_section,"Session"); Parse_Session(ctlfile); done_session=TRUE; } else if (eqstri(p,"language")) { Compiling(LAST_SECTION,cc_section,"Language"); Parse_Language(ctlfile); done_language=TRUE; } else if (eqstri(p,"reader")) { Compiling(LAST_SECTION,cc_section,"Reader"); Parse_Reader(ctlfile); } else if (eqstri(p, "msgdivisionbegin")) { char acs[PATHLEN]; char displayfile[PATHLEN]; linenum++; /* MsgDivisionBegin comp sysop/1234 misc\msgname The InterNet comp.* hierarchy */ getword(line, p, ctl_delim, 2); getword(line, acs, ctl_delim, 3); getword(line, displayfile, ctl_delim, 4); ParseMsgDivisionBegin(p, acs, displayfile, fchar(line, ctl_delim, 5)); } else if (eqstri(p, "filedivisionbegin")) { char acs[PATHLEN]; char displayfile[PATHLEN]; linenum++; /* FileDivisionBegin comp sysop/1234 misc\filename The InterNet comp.* hierarchy */ getword(line, p, ctl_delim, 2); getword(line, acs, ctl_delim, 3); getword(line, displayfile, ctl_delim, 4); ParseFileDivisionBegin(p, acs, displayfile, fchar(line, ctl_delim, 5)); } else if (eqstri(p, "msgdivisionend")) { linenum++; ParseMsgDivisionEnd(); } else if (eqstri(p, "filedivisionend")) { linenum++; ParseFileDivisionEnd(); } else if (eqstri(p,"msgarea")) { linenum++; getword(line,p,ctl_delim,2); Compiling(LAST_AREA,cc_area,p); ParseMsgArea(ctlfile, p); } else if (eqstri(p,"filearea")) { linenum++; getword(line,p,ctl_delim,2); Compiling(LAST_AREA,cc_area,p); ParseFileArea(ctlfile, p); } else if (eqstri(p,"protocol")) { strcpy(p, fchar(line, ctl_delim, 2)); Compiling(LAST_SECTION, cc_section, p); Parse_Protocol(ctlfile, p); } else if (eqstri(p,"menu")) { strcpy(p,fchar(line,ctl_delim,2)); Compiling(LAST_MENU,cc_menu,p); Parse_Menu(ctlfile,p); } else if (eqstri(p,"section")) { linenum++; while (fgets(line,MAX_LINE,ctlfile) != NULL) { linenum++; getword(line,p," \t\n",1); if (eqstri(p,"end")) break; } } else if (eqstri(p,"include")) { getword(line,p,ctl_delim,2); linenum++; x=linenum; last=LAST_NONE; Parse_Ctlfile(p); strcpy(ctl_name,ctlname); linenum=x; } else if (eqstri(p, "max20area")) { getword(line, p, ctl_delim, 2); if (p[1] != ':' && p[0] != '\\' && p[0] != '/') { strcpy(temp, strings + prm.sys_path); strcat(temp, p); strcpy(p, temp); } strcpy(max20area, p); strcpy(temp, p); strcat(temp, ".dat"); Make_String(prm.adat_name, temp); strcpy(temp, p); strcat(temp, ".idx"); Make_String(prm.aidx_name, temp); } else if (eqstri(p,"version14")) ; else if (eqstri(p,"version17")) ; else if (eqstri(p, "app") || eqstri(p, "application")) ; else Unknown_Ctl(linenum++,p); } else linenum++; } fclose(ctlfile); if (bufr) free(bufr); return 0; }