int main(int argc, char ** argv) { SECTREE_MANAGER sectree_manager; DESC_MANAGER desc_manager; CHARACTER_MANAGER char_manager; quest::CQuestManager quest_manager; // CHARACTER::Intiailize에서 필요함 CArenaManager arena_manager; CPVPManager pvp_manager; LZOManager lzo; if (!start(argc, argv)) return 0; signal_timer_disable(); char buf[256]; char last_cmd[256]; char * p; bool bEnd = false; while (!bEnd && fgets(buf, 256, stdin)) { while ((p = strrchr(buf, '\r'))) *p = '\0'; while ((p = strrchr(buf, '\n'))) *p = '\0'; if (buf[0] == '!') strlcpy(buf, last_cmd, sizeof(buf)); strlcpy(last_cmd, buf, sizeof(last_cmd)); char arg1[64], arg2[64];//, arg3[64], arg4[64]; const char * line = one_argument(buf, arg1, sizeof(arg1)); switch (arg1[0]) { case 'a': { two_arguments(line, arg1, sizeof(arg1), arg2, sizeof(arg2)); if (!*arg1 || !*arg2) { printf("Syntax: a <collision data filename> <map directory>\n"); break; } ConvertAttribute(arg1, arg2); puts("build server_attr done"); } break; case 'c': { one_argument(line, arg1, sizeof(arg1)); if (!*arg1) { printf("Syntax: c <filename>\n"); break; } ConvertAttribute2(arg1); } //ReadColorMapRecursive(line); break; case 'b': { // Buffer overflow test (must use with valgrind or gdb at least) LPCHARACTER ch = CHARACTER_MANAGER::instance().CreateCharacter("test"); // 스택에 할당하면 valgrind가 제대로 오류를 잡지 못함 size_t bufsize = 512 + 1; size_t linesize = 1024 + 1; if (bufsize > 0 && linesize > 0) { char *buf = (char *) malloc(bufsize); char *line = (char *) malloc(linesize); memset(buf, 0, bufsize); memset(line, 0, linesize); for (size_t i = 0; i < bufsize - 1; ++i) { buf[i] = '$'; int linelen = snprintf(line, linesize, "pvp %s", buf); if (linelen < 0 || linelen >= (int) linesize) linelen = linesize - 1; printf("%d %s\n", i, line); interpret_command(ch, line, linelen); } free(buf); free(line); } else { printf("size error!\n"); abort(); } printf("Buffer overflow test finished\n"); } break; case 'q': bEnd = true; break; } } thecore_destroy(); event_destroy(); return 0; }
void DocumentConverter::startElement(const XMLCh* const name, AttributeList & attrs) { XMLChToVXIchar elementName(name); // (1) Convert name string to enum. int elemType; if (!ConvertElement(elementName.c_str(), elemType)) { vxistring temp(L"unrecognized element - "); temp += elementName.c_str(); ParseException(temp.c_str()); } // (2) Check for ignored nodes and do version number processing. // (2.1) Catch illegal nodes and do version number processing. switch (elemType) { case DEFAULTS_ROOT: version = 2.0f; break; case NODE_VXML: { for (unsigned int index = 0; index < attrs.getLength(); ++index) { if (!Compare(attrs.getName(index), L"version")) continue; const XMLCh * attributeValue = attrs.getValue(index); if (Compare(attributeValue, L"1.0")) version = 1.0f; else if (Compare(attributeValue, L"2.0")) version = 2.0f; else ParseException(L"illegal version"); break; } break; } case PRIV_ELEM_DIV: case PRIV_ELEM_EMP: case PRIV_ELEM_PROS: case PRIV_ELEM_SAYAS: if (version != 1.0f) { vxistring temp(L"support for element '"); temp += elementName.c_str(); temp += L"' was dropped after VXML 1.0"; ParseException(temp.c_str()); } break; default: break; } // (2.2) Should we just ignore this node? if (IsIgnorable(elemType)) return; // (2.3) Convert nodes as necessary. switch (elemType) { case PRIV_ELEM_DIV: // Convert <div> into either <p> or <s>. if (attrs.getLength() == 1 && Compare(attrs.getName(0), L"paragraph")) elemType = NODE_PARAGRAPH; else elemType = NODE_SENTENCE; break; case PRIV_ELEM_EMP: elemType = NODE_EMPHASIS; break; case PRIV_ELEM_SAYAS: { elemType = NODE_SAYAS; for (unsigned int index = 0; index < attrs.getLength(); ++index) if (Compare(attrs.getName(index), L"phon")) { elemType = NODE_PHONEME; break; } break; } default: break; } // (3) Create new element. if (elemType > PRIV_ELEM_RangeStart) { vxistring temp(L"internal error for element - "); temp += elementName.c_str(); ParseException(temp.c_str()); } try { doc->StartElement(VXMLElementType(elemType)); } catch (const VXMLDocumentModel::OutOfMemory &) { ParseException(L"unable to allocate memory for element"); } catch (const VXMLDocumentModel::InternalError &) { ParseException(L"corrupted document tree; unable to add element"); } // (4) Add attributes to element. for (unsigned int index = 0; index < attrs.getLength(); ++index) { int attrType; // (4.1) Convert string to integer. XMLChToVXIchar attributeName(attrs.getName(index)); if (!ConvertAttribute(attributeName.c_str(), attrType)) { vxistring temp(L"unrecognized attribute - "); temp += attributeName.c_str(); ParseException(temp.c_str()); } // (4.2) Handle a few global settings. switch (attrType) { case PRIV_ATTRIB_CACHING: if (version != 1.0f) ParseException(L"the caching attribute was replaced by maxage and " L"maxstale after VXML 1.0"); if (Compare(attrs.getValue(index), L"safe")) { vxistring attr; if (!doc->GetAttribute(ATTRIBUTE_MAXAGE, attr)) doc->AddAttribute(ATTRIBUTE_MAXAGE, L"0"); } continue; default: break; } // (4.3) Handle internal values. XMLChToVXIchar attributeValue(attrs.getValue(index)); ProcessNodeAttribute(VXMLElementType(elemType), attrType, attributeValue.c_str()); } // (5) Verify the node. ProcessNodeFinal(VXMLElementType(elemType)); }