int main(int argc, char* argv[]) { if (argc < 3) { printf("\nUsage: swfvartool.exe filename_source filename_target "); return 0; } // Read in the SWF file. // This will show the brief information of it. printf("------------------------------------------------\n"); printf("Reading '%s'...\n", (char*) argv[1]); printf("------------------------------------------------\n"); SWFFile *swf = new SWFFile((char*) argv[1]); // deletion is done within this function. printf("------------------------------------------------\n"); // // Get commands from the console. // char szCmdline[256]; char *sz = 0; do { printf("> "); sz = gets(szCmdline); if (0 != sz) { if( 0==TranslateCommand(swf, szCmdline) ){ break; } } } while (0 != sz); printf("------------------------------------------------\n"); printf("Now saving to '%s'...\n", (char*) argv[2]); printf("------------------------------------------------\n"); // Now save it.. swf->SaveTo((char*) argv[2]); printf("Press any key to finish..."); getchar(); delete swf; }
void ConvertAllttString(char *s) /****************************************************************************** purpose : converts string in TeX-format to Rtf-format according to the alltt environment, which is like verbatim environment except that \, {, and } have their usual meanings ******************************************************************************/ { char cThis; if (s==NULL) return; diagnostics(4, "Entering Convert() from StringAllttConvert()"); if(PushSource(NULL, s)==0) { while (StillSource()) { cThis = getRawTexChar(); /* it is a verbatim like environment */ switch (cThis) { case '\\': PushLevels(); TranslateCommand(); CleanStack(); break; case '{': PushBrace(); fprintRTF("{"); break; case '}': ret = RecursionLevel - PopBrace(); fprintRTF("}"); break; default: putRtfChar(cThis); break; } } PopSource(); } diagnostics(4, "Exiting Convert() from StringAllttConvert()"); }
EFI_STATUS MMCSendCommand ( IN EFI_MMC_HOST_PROTOCOL *This, IN MMC_CMD MmcCmd, IN UINT32 Argument ) { UINTN MmcStatus; UINTN RetryCount = 0; if (IgnoreCommand(MmcCmd)) return EFI_SUCCESS; MmcCmd = TranslateCommand(MmcCmd); //DEBUG ((EFI_D_ERROR, "MMCSendCommand(%d)\n", MmcCmd)); // Check if command line is in use or not. Poll till command line is available. while ((MmioRead32 (MMCHS_PSTATE) & DATI_MASK) == DATI_NOT_ALLOWED); // Provide the block size. MmioWrite32 (MMCHS_BLK, BLEN_512BYTES); // Setting Data timeout counter value to max value. MmioAndThenOr32 (MMCHS_SYSCTL, ~DTO_MASK, DTO_VAL); // Clear Status register. MmioWrite32 (MMCHS_STAT, 0xFFFFFFFF); // Set command argument register MmioWrite32 (MMCHS_ARG, Argument); //TODO: fix this //Enable interrupt enable events to occur //MmioWrite32 (MMCHS_IE, CmdInterruptEnableVal); // Send a command MmioWrite32 (MMCHS_CMD, MmcCmd); // Check for the command status. while (RetryCount < MAX_RETRY_COUNT) { do { MmcStatus = MmioRead32 (MMCHS_STAT); } while (MmcStatus == 0); // Read status of command response if ((MmcStatus & ERRI) != 0) { // Perform soft-reset for mmci_cmd line. MmioOr32 (MMCHS_SYSCTL, SRC); while ((MmioRead32 (MMCHS_SYSCTL) & SRC)); //DEBUG ((EFI_D_INFO, "MmcStatus: 0x%x\n", MmcStatus)); return EFI_DEVICE_ERROR; } // Check if command is completed. if ((MmcStatus & CC) == CC) { MmioWrite32 (MMCHS_STAT, CC); break; } RetryCount++; } if (RetryCount == MAX_RETRY_COUNT) { DEBUG ((DEBUG_BLKIO, "MMCSendCommand: Timeout\n")); return EFI_TIMEOUT; } return EFI_SUCCESS; }
void Convert() /**************************************************************************** purpose: converts inputfile and writes result to outputfile globals: fTex, fRtf and all global flags for convert (see above) ****************************************************************************/ { char cThis = '\n'; char cLast = '\0'; char cNext; int mode, count,pending_new_paragraph; diagnostics(3, "Entering Convert ret = %d", ret); RecursionLevel++; PushLevels(); while ((cThis = getTexChar()) && cThis != '\0') { if (cThis == '\n') diagnostics(5, "Current character is '\\n' mode = %d ret = %d level = %d", GetTexMode(), ret, RecursionLevel); else diagnostics(5, "Current character is '%c' mode = %d ret = %d level = %d", cThis, GetTexMode(), ret, RecursionLevel); mode = GetTexMode(); pending_new_paragraph--; switch (cThis) { case '\\': PushLevels(); TranslateCommand(); CleanStack(); if (ret > 0) { diagnostics(5, "Exiting Convert via TranslateCommand ret = %d level = %d", ret, RecursionLevel); ret--; RecursionLevel--; return; } break; case '{': if (mode==MODE_VERTICAL) SetTexMode(MODE_HORIZONTAL); CleanStack(); PushBrace(); fprintRTF("{"); break; case '}': CleanStack(); ret = RecursionLevel - PopBrace(); fprintRTF("}"); if (ret > 0) { diagnostics(5, "Exiting Convert via '}' ret = %d level = %d", ret, RecursionLevel); ret--; RecursionLevel--; return; } break; case ' ': if (mode==MODE_VERTICAL || mode==MODE_MATH || mode==MODE_DISPLAYMATH) cThis = cLast; else if ( cLast != ' ' && cLast != '\n' ) { if (GetTexMode()==MODE_RESTRICTED_HORIZONTAL) fprintRTF("\\~"); else fprintRTF(" "); } break; case '\n': tabcounter = 0; if (mode==MODE_MATH || mode==MODE_DISPLAYMATH) { cNext = getNonBlank(); ungetTexChar(cNext); } else { cNext = getNonSpace(); if (cNext == '\n') { /* new paragraph ... skip all ' ' and '\n' */ pending_new_paragraph=2; CmdEndParagraph(0); cNext = getNonBlank(); ungetTexChar(cNext); } else { /* add a space if needed */ ungetTexChar(cNext); if (mode != MODE_VERTICAL && cLast != ' ') fprintRTF(" "); } } break; case '$': cNext = getTexChar(); diagnostics(5,"Processing $, next char <%c>",cNext); if (cNext == '$' && GetTexMode() != MODE_MATH) CmdEquation(EQN_DOLLAR_DOLLAR | ON); else { ungetTexChar(cNext); CmdEquation(EQN_DOLLAR | ON); } /* Formulas need to close all Convert() operations when they end This works for \begin{equation} but not $$ since the BraceLevel and environments don't get pushed properly. We do it explicitly here. */ /* if (GetTexMode() == MODE_MATH || GetTexMode() == MODE_DISPLAYMATH) PushBrace(); else { ret = RecursionLevel - PopBrace(); if (ret > 0) { ret--; RecursionLevel--; diagnostics(5, "Exiting Convert via Math ret = %d", ret); return; } } */ break; case '&': if (g_processing_arrays) { fprintRTF("%c",g_field_separator); break; } if (GetTexMode() == MODE_MATH || GetTexMode() == MODE_DISPLAYMATH) { /* in eqnarray */ fprintRTF("\\tab "); g_equation_column++; break; } if (g_processing_tabular) { /* in tabular */ actCol++; fprintRTF("\\cell\\pard\\intbl\\q%c ", colFmt[actCol]); break; } fprintRTF("&"); break; case '~': fprintRTF("\\~"); break; case '^': CmdSuperscript(0); break; case '_': CmdSubscript(0); break; case '-': if (mode == MODE_MATH || mode == MODE_DISPLAYMATH) fprintRTF("-"); else { SetTexMode(MODE_HORIZONTAL); count = getSameChar('-')+1; if (count == 1) fprintRTF("-"); else if (count == 2) fprintRTF("\\endash "); else if (count == 3) fprintRTF("\\emdash "); else while (count--) fprintRTF("-"); } break; case '|': if (mode == MODE_MATH || mode == MODE_DISPLAYMATH) fprintRTF("|"); else fprintRTF("\\emdash "); break; case '\'': if (mode == MODE_MATH || mode == MODE_DISPLAYMATH) fprintRTF("'"); else { SetTexMode(MODE_HORIZONTAL); count = getSameChar('\'')+1; if (count == 2) fprintRTF("\\rdblquote "); else while (count--) fprintRTF("\\rquote "); } break; case '`': SetTexMode(MODE_HORIZONTAL); count = getSameChar('`')+1; if (count == 2) fprintRTF("\\ldblquote "); else while (count--) fprintRTF("\\lquote "); break; case '\"': SetTexMode(MODE_HORIZONTAL); if (GermanMode) TranslateGerman(); else fprintRTF("\""); break; case '<': if (mode == MODE_VERTICAL) SetTexMode(MODE_HORIZONTAL); if (GetTexMode() == MODE_HORIZONTAL){ cNext = getTexChar(); if (cNext == '<') { if (FrenchMode) { /* not quite right */ skipSpaces(); cNext = getTexChar(); if (cNext == '~') skipSpaces(); else ungetTexChar(cNext); fprintRTF("\\'ab\\~"); } else fprintRTF("\\'ab"); } else { ungetTexChar(cNext); fprintRTF("<"); } } else fprintRTF("<"); break; case '>': if (mode == MODE_VERTICAL) SetTexMode(MODE_HORIZONTAL); if (GetTexMode() == MODE_HORIZONTAL){ cNext = getTexChar(); if (cNext == '>') fprintRTF("\\'bb"); else { ungetTexChar(cNext); fprintRTF(">"); } } else fprintRTF(">"); break; case '!': if (mode == MODE_MATH || mode == MODE_DISPLAYMATH) fprintRTF("!"); else { SetTexMode(MODE_HORIZONTAL); if ((cNext = getTexChar()) && cNext == '`') { fprintRTF("\\'a1 "); } else { fprintRTF("! "); ungetTexChar(cNext); } } break; case '?': SetTexMode(MODE_HORIZONTAL); if ((cNext = getTexChar()) && cNext == '`') { fprintRTF("\\'bf "); } else { fprintRTF("? "); ungetTexChar(cNext); } break; case ':': if (mode == MODE_MATH || mode == MODE_DISPLAYMATH) fprintRTF(":"); else { SetTexMode(MODE_HORIZONTAL); if (FrenchMode) fprintRTF("\\~:"); else fprintRTF(":"); } break; case '.': if (mode == MODE_MATH || mode == MODE_DISPLAYMATH) fprintRTF("."); else { SetTexMode(MODE_HORIZONTAL); fprintRTF("."); /* try to simulate double spaces after sentences */ cNext = getTexChar(); if (0 && cNext == ' ' && (isalpha((int)cLast) && !isupper((int) cLast))) fprintRTF(" "); ungetTexChar(cNext); } break; case '\t': diagnostics(WARNING, "This should not happen, ignoring \\t"); cThis = ' '; break; case '\r': diagnostics(WARNING, "This should not happen, ignoring \\r"); cThis = ' '; break; case '%': diagnostics(WARNING, "This should not happen, ignoring %%"); cThis = ' '; break; case '(': if (g_processing_fields&&g_escape_parent) fprintRTF("\\\\("); else fprintRTF("("); break; case ')': if (g_processing_fields&&g_escape_parent) fprintRTF("\\\\)"); else fprintRTF(")"); break; case ';': if (g_field_separator == ';' && g_processing_fields) fprintRTF("\\\\;"); else if (FrenchMode) fprintRTF("\\~;"); else fprintRTF(";"); break; case ',': if (g_field_separator == ',' && g_processing_fields) fprintRTF("\\\\,"); else fprintRTF(","); break; default: if (mode == MODE_MATH || mode == MODE_DISPLAYMATH) { if (('a' <= cThis && cThis <= 'z') || ('A' <= cThis && cThis <= 'Z')) fprintRTF("{\\i %c}", cThis); else fprintRTF("%c", cThis); } else { SetTexMode(MODE_HORIZONTAL); fprintRTF("%c", cThis); } break; } tabcounter++; cLast = cThis; } RecursionLevel--; diagnostics(5, "Exiting Convert via exhaustion ret = %d", ret); }
int PushConsoleManager::OnCommand(const HashedString& command, const strutil::strvec& parameter_vector) { int result = Parent::OnCommand(command, parameter_vector); if (result < 0) { result = 0; CommandClient _command = (CommandClient)TranslateCommand(command); switch ((int)_command) { case kCommandSetAvatar: { if (parameter_vector.size() == 1) { ((PushManager*)GetGameManager())->SelectAvatar(parameter_vector[0]); } else { log_.Warningf("usage: %s <avatar>", command.c_str()); result = 1; } } break; case kCommandSetAvatarEnginePower: { if (parameter_vector.size() == 2) { log_debug("Setting avatar engine power."); int aspect = 0; strutil::StringToInt(parameter_vector[0], aspect); double power; strutil::StringToDouble(parameter_vector[1], power); if (!((PushManager*)GetGameManager())->SetAvatarEnginePower(aspect, (float)power)) { log_.Error("Could not set avatar engine power!"); result = 1; } } else { log_.Warningf("usage: %s <aspect> <power>", command.c_str()); result = 1; } } break; #if defined(LEPRA_DEBUG) && defined(LEPRA_WINDOWS) case kCommandBuildData: { const cure::GameObjectId avatar_id = ((PushManager*)GetGameManager())->GetAvatarInstanceId(); if (!avatar_id) { break; } const str avatar_type = GetGameManager()->GetContext()->GetObject(avatar_id)->GetClassId(); ((PushManager*)GetGameManager())->Logout(); Thread::Sleep(0.5); GetResourceManager()->ForceFreeCache(); const str current_dir = SystemManager::GetCurrentDirectory(); ::SetCurrentDirectoryA(astrutil::Encode(Path::GetParentDirectory(current_dir)).c_str()); ::system("c:/Program/Python31/python.exe -B Tools/build/rgo.py builddata"); ::SetCurrentDirectoryA(astrutil::Encode(current_dir).c_str()); const str user_name = v_slowget(GetVariableScope(), kRtvarLoginUsername, EmptyString); const str server = v_slowget(GetVariableScope(), kRtvarNetworkServeraddress, EmptyString); wstr pw(L"CarPassword"); const cure::LoginId login_id(wstrutil::Encode(user_name), cure::MangledPassword(pw)); ((PushManager*)GetGameManager())->RequestLogin(server, login_id); ((PushManager*)GetGameManager())->ToggleConsole(); ExecuteCommand("wait-login"); ((PushManager*)GetGameManager())->SelectAvatar(avatar_type); } break; #endif // Debug & Windows default: { result = -1; } break; } } return (result); }