void NyqBench::OnGo(wxCommandEvent & e) { // No need to delete...EffectManager will do it mEffect = new NyquistEffect(wxT("Nyquist Effect Workbench")); const PluginID & ID = EffectManager::Get().RegisterEffect(mEffect); mEffect->SetCommand(mScript->GetValue()); mEffect->RedirectOutput(); AudacityProject *p = GetActiveProject(); wxASSERT(p != NULL); if (p) { wxWindowDisabler disable(this); NyqRedirector redir((NyqTextCtrl *)mOutput); mRunning = true; UpdateWindowUI(); p->DoEffect(ID, CommandContext(*p), 0); mRunning = false; UpdateWindowUI(); } Raise(); EffectManager::Get().UnregisterEffect(ID); }
static char *try_directory(QSP_ARG_DECL const char *dir,const char* progname) { FILE *fp; static char filename[MAXPATHLEN]; if( *dir ){ strcpy(filename,dir); strcat(filename,DIR_DELIM); } else strcpy(filename,""); strcat(filename,progname); strcat(filename,".scr"); fp=fopen(filename,"r"); if( fp!=NULL ) { redir(QSP_ARG fp, filename ); if( *dir ){ //sprintf(ERROR_STRING,"Setting %s to %s",STARTUP_DIRNAME,dir); //advise(ERROR_STRING); // We should only set the variable here if // it doesn't already exist - vars defined // in the environment are reserved! Variable *vp; vp = VAR_OF(STARTUP_DIRNAME); if( vp == NO_VARIABLE ){ assign_var(QSP_ARG STARTUP_DIRNAME,dir); } } return(filename); } else { return(NULL); } }
bool CoreEngine::dissassemble(ULONG64 offset, unsigned long beforeLines, unsigned long afterLines, QString *target, QString *errorMessage) { const ULONG flags = DEBUG_DISASM_MATCHING_SYMBOLS|DEBUG_DISASM_SOURCE_LINE_NUMBER|DEBUG_DISASM_SOURCE_FILE_NAME; // Catch the output by temporarily setting another handler. // We use the method that outputs to the output handler as it // conveniently provides the 'beforeLines' context (stepping back // in assembler code). We build a complete string first as line breaks // may occur in-between messages. QSharedPointer<StringOutputHandler> outputHandler(new StringOutputHandler); OutputRedirector redir(this, outputHandler); // For some reason, we need to output to "all clients" const HRESULT hr = m_cif.debugControl->OutputDisassemblyLines(DEBUG_OUTCTL_ALL_CLIENTS, beforeLines, beforeLines + afterLines, offset, flags, 0, 0, 0, 0); if (FAILED(hr)) { *errorMessage= QString::fromLatin1("Unable to dissamble at 0x%1: %2"). arg(offset, 0, 16).arg(msgComFailed("OutputDisassemblyLines", hr)); return false; } *target = outputHandler->result(); return true; }
static char *_try_directory(QSP_ARG_DECL const char *dir,const char* progname) { FILE *fp; static char filename[MAXPATHLEN]; if( *dir ){ strcpy(filename,dir); strcat(filename,DIR_DELIM); } else strcpy(filename,""); strcat(filename,progname); strcat(filename,".scr"); fp=fopen(filename,"r"); if( fp!=NULL ) { redir(fp, filename ); if( *dir ){ // We should only set the variable here if // it doesn't already exist - vars defined // in the environment are reserved! Variable *vp; vp = var_of(STARTUP_DIRNAME); if( vp == NULL ){ assign_var(STARTUP_DIRNAME,dir); } } return(filename); } else { return(NULL); } }
static int root(fshv_env *env) { // public zone if (fshv_m(env, "/mirror")) return fshv_mirror(env, 1); if (fshv_m(env, "/hello/:name")) return hello(env); if (fshv_m(env, "/redir")) return redir(env); if (fshv_m(env, "/files/**")) return fshv_serve_files(env, "../spec/www"); // 'private' zone and friends //if ( ! fshv_basic_auth(env, "tst_realm", bauth)) return 1; //if (fshv_m(env, "GET /secret")) return secret(env); // OR //fshv_basic_auth(env, "tst_realm", bauth); if (fshv_m(env, "POST /login")) return login(env); //if ( ! fshv_session_auth_filter(env)) return fshv_status(env, 401); fshv_session_auth(env, SESSION_PUSH, SESSION_COOKIE); if (fshv_m(env, "GET /secret")) return secret(env); return 0; // which will //return fshv_status(env, 404); }
bool CoreEngine::allocDebuggeeMemory(int size, ULONG64 *addressPtr, QString *errorMessage) { *addressPtr = 0; const QString allocCmd = QLatin1String(".dvalloc ") + QString::number(size); QSharedPointer<StringOutputHandler> outputHandler(new StringOutputHandler); OutputRedirector redir(this, outputHandler); Q_UNUSED(redir) if (!executeDebuggerCommand(allocCmd, errorMessage)) return false; // "Allocated 1000 bytes starting at 003a0000" or // "Allocated 1000 bytes starting at 00000000'000023ab" (64bit) / hopefully never localized const QString output = outputHandler->result().trimmed(); const int lastBlank = output.lastIndexOf(QLatin1Char(' ')); if (lastBlank != -1) { const QString hexNumberS = QLatin1String("0x") + output.mid(lastBlank + 1); quint64 address; if (SymbolGroupContext::getUnsignedHexValue(hexNumberS, &address)) { *addressPtr = address; return true; } } // blank *errorMessage = QString::fromLatin1("Failed to parse output '%1'").arg(output); return false; }
static void bgRun(char *args) { prepThread(); redir(args); free(args); }
static void cmd_redir(const char *cmd, const char *args) { if (toupper(cmd[0]) == 'B') // Run in background thread. CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)bgRun, (LPVOID)_strdup(args), 0, NULL); else redir(args); }
int main() { std::srand(std::time(NULL)); allegro_init(); install_timer(); install_keyboard(); // install_mouse(); install_joystick(JOY_TYPE_AUTODETECT); override_config_file(redir("defnot.ini").c_str()); gfx_widescreen = get_config_int("Game", "Widescreen", gfx_widescreen); gfx_fullscreen = get_config_int("Game", "Fullscreen", gfx_fullscreen); if (!setup_gfx() != 0) { allegro_message("Unable to setup the graphics mode\n"); return 1; } // if (gfx_capabilities & GFX_HW_CURSOR) { // enable_hardware_cursor(); // select_mouse_cursor(MOUSE_CURSOR_ARROW); // show_mouse(screen); // } if (!load_media()) { allegro_message("Unable to load data files to play the game\n"); return 1; } // install the timer to control the game speed LOCK_VARIABLE(beats); LOCK_FUNCTION(timer_control); beats = 0; install_int_ex(timer_control, BPS_TO_TIMER(BPS)); // insert the callback routine for the close-button LOCK_VARIABLE(continuing); LOCK_FUNCTION(close_button); set_close_button_callback(close_button); // play the game game_loop(); set_config_int("Game", "Widescreen", gfx_widescreen); set_config_int("Game", "Fullscreen", gfx_fullscreen); remove_int(timer_control); allegro_exit(); return 0; }
static int read_global_startup(SINGLE_QSP_ARG_DECL) { #ifdef BUILD_FOR_OBJC #ifdef BUILD_FOR_IOS // this is called from the main thread at startup... return ios_read_global_startup(SINGLE_QSP_ARG); // in .m file #endif // BUILD_FOR_IOS #ifdef BUILD_FOR_MACOS // this is called from the main thread at startup... return macos_read_global_startup(SINGLE_QSP_ARG); #endif // BUILD_FOR_MACOS #else /* ! BUILD_FOR_OBJC */ char *home; char filename[MAXPATHLEN]; FILE *fp; home=getenv("HOME"); if( home == NULL ){ WARN("read_global_startup: no HOME in environment"); return -1; } // In the IOS simulator, HOME expands to a very long and strange path... // There is an install script to copy the file, but this fails when // we copy the file to the device... sprintf(filename,"%s/.coqrc",home); // BUG possible buffer overrun fp=fopen(filename,"r"); if( fp!=NULL ) { // int lvl; /* We might like to interpret commands here, * but no menus have been pushed, so we can't!? * Could perhaps use builtin menu only? */ redir(QSP_ARG fp, filename ); // If the startup file contains widget creation commands, // they can't run before the appDelegate has started (ios). // Therefore, we defer execution of the startup commands // until later. return 0; } return -1; #endif /* ! BUILD_FOR_OBJC */ }
int main(void) { char ***l1 = NULL, *fv[3] ,dir[50] ,c; int vc, bg, id, p[2], d; signal(SIGINT, SIG_IGN); signal(SIGQUIT,SIG_IGN); while (1) { getcwd(dir,50); write(1,dir,strlen(dir)); write(1," $ ",d = bg = 3); for (;bg; fv[bg] = NULL) realloc(fv[--bg],0); size(l1,4,0,NULL); for (vc = p[0] = 0; read(0,&c,1) && (c != '\n');) switch(c) { case '<': d = 0; break; case '>': d = 1; break; case '|': if (l2) {vc++; p[0] = 0;} d = 3; break; case '&': if (d < 3) d++; else bg = 1; break; case ' ': if (d < 3) {if (fv[d]) d = 3;} else if (l2 && l3) p[0]++; break; default: if (d < 3) {if (!fv[d]) size(fv[d],1,0,'\0'); size(fv[d],(id=strlen(fv[d]))+2,id,c); fv[d][id+1]='\0';} else { if (!l2) {size(l1,vc*4+8,vc+1,NULL); size(l2,4,0,NULL);} if (!l3) {size(l2,p[0]*4+8,p[0]+1,NULL); size(l3,1,0,'\0');} size(l3,(id=strlen(l3))+2,id,c); l3[id+1] = '\0';}} for (vc = 0; l2;) { if (!vc) d = dup(0); if (l1[vc+1]) chkerr(pipe(p),"pipe"); if (!strcmp(l2[0],"exit")) exit(0); if (!strcmp(l2[0],"cd")) {if (chdir(l2[1]) < 0) chdir(getenv("HOME"));} else {if (!(id = fork())) { if (fv[0] && !vc) redir(0,O_RDONLY) else mvdesc(0,d); if (fv[1]) redir(1,O_CREAT|O_WRONLY|O_TRUNC); if (fv[2]) redir(2,O_CREAT|O_WRONLY|O_TRUNC); if (l1[vc+1]) {mvdesc(1,p[1]); close(p[0]);} if (!bg) {signal(SIGINT,SIG_DFL); signal(SIGQUIT,SIG_DFL);} chkerr(execvp(l2[0],l2),"exec");} if (!l1[vc+1] && !bg) while (wait(NULL) != id);} for (id = 0; l2[id]; realloc(l2[id++],0)); realloc(l2,0); close(d); if (l1[++vc]) {d = dup(p[0]); close(p[0]); close(p[1]);}}}}
static void rdprms(QSP_ARG_DECL Param *p,FILE* fp, const char *filename) { int level; const char *s; redir(QSP_ARG fp, filename); level=QLEVEL; do { s=NAMEOF("name of parameter"); if( get_pval(QSP_ARG s,p) == -1 ) WARN("error getting parameter value"); /* lookahead word should decrement qlevel at EOF */ lookahead(SINGLE_QSP_ARG); } while( level == QLEVEL ); }
void make_screenshot(BITMAP *bmp) { std::string filename; char buf[1024]; for (int c=0; c<10000; ++c) { sprintf(buf, "shot%04d.bmp", c); filename = redir(buf); if (!exists(filename.c_str())) { PALETTE pal; get_palette(pal); save_bitmap(filename.c_str(), bmp, pal); break; } } }
/* ** Init the toyos values according to the specified redirection operator */ int init_toyos(char **instrucs, int i, int *toyos, int *old) { int (*redir)(); int ret_val; ret_val = 1; redir = NULL; if (instrucs[i + 1] && (redir = get_redirec(instrucs[i + 1]))) ret_val = redir(old, toyos, instrucs[i]); else { toyos[1] = old[1]; toyos[0] = old[0]; } return (ret_val); }
// everything happens in this constructor. Ttt::Ttt(Writer* wr, std::string str, int unicode , std::string ttfont ) : my_writer(wr) { self = this; // so that static methods work.. int error; int linescale = 0; previous = false; // no previous char, for kerning previous_glyph_index = 0; // no index, for kerning error = FT_Init_FreeType(&library); if(error) handle_ft_error("FT_Init_FreeType" , error, __LINE__); error = FT_New_Face(library, ttfont.data() , 0, &face); if(error) handle_ft_error("FT_New_Face", error, __LINE__); #define MYFSIZE 64 error = FT_Set_Pixel_Sizes(face, 0, MYFSIZE); if (error) handle_ft_error("FT_Set_Pixel_Sizes", error, __LINE__); if (unicode) setlocale(LC_CTYPE, ""); // this redirects to the buffer cout_redirect redir( buffer.rdbuf() ); int l = str.length(); my_writer->preamble(); line_extents.reset(); long int offset = 0; const char* s = str.data(); while(*s ) { // loop through characters wchar_t wc; int r = mbtowc(&wc, s, l); // convert multibyte s, store in wc. return number of converted bytes if(r==-1) { s++; continue; } my_writer->start_glyph(s,wc, offset); // comment at start of glyph glyph_extents.reset(); offset += render_char(face, wc, offset, linescale); // the glyph line_extents.add_extents(glyph_extents); s += r; l -= r; my_writer->end_glyph(glyph_extents, advance); // comment at end of glyph } my_writer->set_extents(line_extents); my_writer->postamble(offset, line_extents); }
static int read_traditional_startup(QSP_ARG_DECL const char *progname) { char *home; char filename[MAXPATHLEN]; FILE *fp; home=getenv("HOME"); if( home == NULL ){ warn("read_traditional_startup: no HOME in environment"); return -1; } // In the IOS simulator, HOME expands to a very long and strange path... // There is an install script to copy the file, but this fails when // we copy the file to the device... // BUG possible buffer overrun sprintf(filename,"%s/.%src",home,progname); // e.g. .quiprc fp=fopen(filename,"r"); if( fp!=NULL ) { if( verbose ){ sprintf(ERROR_STRING, "Interpreting global startup file %s",filename); advise(ERROR_STRING); } /* We might like to interpret commands here, * but no menus have been pushed, so we can't!? * Could perhaps use builtin menu only? */ redir(fp, filename ); // If the startup file contains widget creation commands, // they can't run before the appDelegate has started (ios). // Therefore, we defer execution of the startup commands // until later. return 0; } return -1; }
void NyqBench::OnGo(wxCommandEvent & e) { mEffect->SetCommand(mScript->GetValue()); AudacityProject *p = GetActiveProject(); wxASSERT(p != NULL); if (p) { wxWindowDisabler disable(this); NyqRedirector redir((NyqTextCtrl *)mOutput); mRunning = true; UpdateWindowUI(); p->OnEffect(ALL_EFFECTS, mEffect->GetID()); mRunning = false; UpdateWindowUI(); } Raise(); }
void NyqBench::OnGo(wxCommandEvent & e) { mEffect->SetCommand(mScript->GetValue()); mEffect->RedirectOutput(); AudacityProject *p = GetActiveProject(); wxASSERT(p != NULL); if (p) { wxWindowDisabler disable(this); NyqRedirector redir((NyqTextCtrl *)mOutput); mRunning = true; UpdateWindowUI(); const PluginID & id = EffectManager::Get().GetEffectByIdentifier(mEffect->GetSymbol()); p->OnEffect(id); mRunning = false; UpdateWindowUI(); } Raise(); }
int main(){ char ligne[MaxLigne]; char pathname[MaxPathLength]; char * mot[MaxMot]; char * dirs[MaxDirs]; char * wd; int i, tmp; short plsr; plsr=0; //cette commande comporte-elle plusieurs instructions? /* Decouper UNE COPIE de PATH en repertoires */ decouper(strdup(getenv("PATH")), ":", dirs, MaxDirs); /* Lire et traiter chaque ligne de commande */ for(wd=getcwd(NULL,0),printf("%s%s",wd,PROMPT); fgets(ligne, sizeof ligne, stdin) != NULL; wd=getcwd(NULL,0),printf("%s%s",wd,PROMPT)){ free(wd); /* Traitement des ^C et ^Z */ if (signal(SIGINT,SIG_IGN) == SIG_ERR) perror("signal"); if (signal(SIGTSTP,ctrl) == SIG_ERR) perror("signal"); if (signal(SIGQUIT,ctrl) == SIG_ERR) perror("signal"); /* Traitement des "&" et des ";" */ plsr=plusieurs(ligne); decouper(ligne, " \t\n", mot, MaxMot); if (mot[0] == NULL){ // ligne vide if(!plsr) continue; exit(0); } /*Traitement de la commande cd*/ if (!strcmp(mot[0],"cd")){ cd(mot,plsr); continue; } /*Traitement des commandes fg et bg*/ if (!strcmp(mot[0],"fg")){ fg(); if(!plsr) continue; exit(0); } if (!strcmp(mot[0],"bg")){ bg(); if(!plsr) continue; exit(0); } if(!plsr){ tmp = fork(); // lancer le processus enfant uniquement si ce n'est pas déjà un enfant à cause d'une multiplicité de commande if (tmp < 0){ perror("fork"); continue; } if (tmp != 0){ // parent : attendre la fin de l'enfant enfant=tmp; waitpid(tmp,NULL,WUNTRACED); enfant=0; continue; } } // enfant : exec du programme /* Traitement des "<", ">" ">>" et "2>" */ redir(mot); /* Traitement des "|" */ transfert(mot); for(i = 0; dirs[i] != NULL; i++){ snprintf(pathname, sizeof pathname, "%s/%s", dirs[i], mot[0]); execv(pathname, mot); } // aucun exec n'a fonctionne fprintf(stderr, "%s: not found\n", mot[0]); exit(1); } printf("Bye\n"); return 0; }
int redir(char **tokenv, int *tokenc) { int fd[2]; int pid1; int pid2; int status; (*tokenc)=0; while(tokenv[(*tokenc)]!=NULL) { (*tokenc)++; if(!strcmp(tokenv[(*tokenc)-1],">")) { if(tokenv[(*tokenc)]==NULL) { /* return(0); */ } else { free(tokenv[(*tokenc)-1]); tokenv[(*tokenc)-1]=NULL; close(1); dup(open(tokenv[(*tokenc)],O_WRONLY | O_CREAT,PERMISSIONS)); return(0); } } if(!strcmp(tokenv[(*tokenc)-1],"<")) { if(tokenv[(*tokenc)]==NULL) { /* return(0); */ } else { free(tokenv[(*tokenc)-1]); tokenv[(*tokenc)-1]=NULL; close(0); dup(open(tokenv[(*tokenc)],O_RDONLY)); return(0); } } if(!strcmp(tokenv[(*tokenc)-1],"|")) { free(tokenv[(*tokenc)-1]); tokenv[(*tokenc)-1]=NULL; if(tokenv[(*tokenc)]==NULL) { execvp(tokenv[0],tokenv); } else { if (pipe(fd)) { perror("What is this business..."); exit(0); } pid2=fork(); /*fprintf(stderr,"pid: %d\n",pid2); */ switch(pid2) { case 0: tokenv=tokenv+(*tokenc); fprintf(stderr,"case 0 executing %s...\n",tokenv[0]); close(0); dup(fd[1]); /* (*tokenc) = (*tokenc)*/ /* you set tokenc to 0 at top of this function*/ /*check for another pipe and recursively call this function if necessary!!*/ redir(tokenv,tokenc); fprintf(stderr,"No redirection."); execvp(tokenv[0],tokenv); break; default: close(1); dup(fd[0]); fprintf(stderr,"default executing %s...\n",tokenv[0]); fprintf(stdout,"%s is talking through stdout...\n",tokenv[0]); execvp(tokenv[0],tokenv); break; } } } } return(0); }
void CfdMeshScreen::CallBack( Fl_Widget* w ) { bool update_flag = true; if ( w == m_CfdMeshUI->rigorLimitButton ) { if ( m_CfdMeshUI->rigorLimitButton->value() ) { CfdMeshMgr.GetGridDensityPtr()->SetRigorLimit( true ); } else { CfdMeshMgr.GetGridDensityPtr()->SetRigorLimit( false ); } } else if ( w == m_CfdMeshUI->farMeshButton ) { if ( m_CfdMeshUI->farMeshButton->value() ) { CfdMeshMgr.GetCfdSettingsPtr()->SetFarMeshFlag( true ); } else { CfdMeshMgr.GetCfdSettingsPtr()->SetFarMeshFlag( false ); } } else if ( w == m_CfdMeshUI->halfMeshButton ) { if ( m_CfdMeshUI->halfMeshButton->value() ) { CfdMeshMgr.GetCfdSettingsPtr()->SetHalfMeshFlag( true ); } else { CfdMeshMgr.GetCfdSettingsPtr()->SetHalfMeshFlag( false ); } } else if ( w == m_CfdMeshUI->finalMeshButton ) { redirecter redir( std::cout, CfdMeshMgr.m_OutStream ); CfdMeshMgr.GenerateMesh(); // Hide all geoms. Vehicle* veh = m_ScreenMgr->GetVehiclePtr(); veh->HideAll(); } else if ( w == m_CfdMeshUI->addDefaultsButton ) { CfdMeshMgr.AddDefaultSourcesCurrGeom(); } // else if ( m_FarXScaleSlider->GuiChanged( w ) ) // { // double val = m_FarXScaleSlider->GetVal(); // bool change = false; // // if ( CfdMeshMgr.GetFarAbsSizeFlag() ) // { // CfdMeshMgr.SetFarAbsSizeFlag( false ); // change = true; // } // // CfdMeshMgr.SetFarXScale( val ); // CfdMeshMgr.UpdateDomain(); // char xstr[255]; // sprintf( xstr, "%0.4f", CfdMeshMgr.GetFarLength() ); // cfdMeshUI->farXScaleAbsInput->value(xstr); // // if ( change ) // CfdMeshMgr.SetFarAbsSizeFlag( true ); // // update_flag = false; // } // else if ( m_FarYScaleSlider->GuiChanged( w ) ) // { // double val = m_FarYScaleSlider->GetVal(); // bool change = false; // // if ( CfdMeshMgr.GetFarAbsSizeFlag() ) // { // CfdMeshMgr.SetFarAbsSizeFlag( false ); // change = true; // } // // CfdMeshMgr.SetFarYScale( val ); // CfdMeshMgr.UpdateDomain(); // char ystr[255]; // sprintf( ystr, "%0.4f", CfdMeshMgr.GetFarWidth() ); // cfdMeshUI->farYScaleAbsInput->value(ystr); // // if ( change ) // CfdMeshMgr.SetFarAbsSizeFlag( true ); // // update_flag = false; // } // else if ( m_FarZScaleSlider->GuiChanged( w ) ) // { // double val = m_FarZScaleSlider->GetVal(); // bool change = false; // // if ( CfdMeshMgr.GetFarAbsSizeFlag() ) // { // CfdMeshMgr.SetFarAbsSizeFlag( false ); // change = true; // } // // CfdMeshMgr.SetFarZScale( val ); // CfdMeshMgr.UpdateDomain(); // char zstr[255]; // sprintf( zstr, "%0.4f", CfdMeshMgr.GetFarHeight() ); // cfdMeshUI->farZScaleAbsInput->value(zstr); // // if ( change ) // CfdMeshMgr.SetFarAbsSizeFlag( true ); // // update_flag = false; // } // else if ( w == cfdMeshUI->SourceNameInput ) // { // CfdMeshMgr.GUI_Val( "SourceName", cfdMeshUI->SourceNameInput->value() ); // } else if ( w == m_CfdMeshUI->compChoice ) { //==== Load List of Parts for Comp ====// int id = m_CfdMeshUI->compChoice->value(); CfdMeshMgr.SetCurrSourceGeomID( m_GeomVec[ id ] ); CfdMeshMgr.SetCurrMainSurfIndx( 0 ); } else if ( w == m_CfdMeshUI->surfChoice ) { int id = m_CfdMeshUI->surfChoice->value(); CfdMeshMgr.SetCurrMainSurfIndx( id ); } else if ( w == m_CfdMeshUI->wakeCompChoice ) { //==== Load List of Parts for Comp ====// int id = m_CfdMeshUI->wakeCompChoice->value(); CfdMeshMgr.SetWakeGeomID( m_WingGeomVec[ id ] ); } else if ( w == m_CfdMeshUI->farCompChoice ) { //==== Load List of Parts for Comp ====// int id = m_CfdMeshUI->farCompChoice->value(); CfdMeshMgr.GetCfdSettingsPtr()->SetFarGeomID( m_GeomVec[ id ] ); } else if ( w == m_CfdMeshUI->sourceBrowser ) { CfdMeshMgr.GUI_Val( "SourceID", m_CfdMeshUI->sourceBrowser->value() - 1 ); } else if ( w == m_CfdMeshUI->setChoice ) { CfdMeshMgr.GetCfdSettingsPtr()->m_SelectedSetIndex = m_CfdMeshUI->setChoice->value(); } else if ( w == m_CfdMeshUI->addSourceButton ) { int type = m_CfdMeshUI->sourceTypeChoice->value(); if ( type >= 0 && type < vsp::NUM_SOURCE_TYPES ) { CfdMeshMgr.AddSource( type ); } } else if ( w == m_CfdMeshUI->deleteSourceButton ) { CfdMeshMgr.DeleteCurrSource(); } else if ( w == m_CfdMeshUI->adjLenDownButton ) { CfdMeshMgr.AdjustAllSourceLen( 1.0 / 1.1 ); } else if ( w == m_CfdMeshUI->adjLenUpButton ) { CfdMeshMgr.AdjustAllSourceLen( 1.1 ); } else if ( w == m_CfdMeshUI->adjLenDownDownButton ) { CfdMeshMgr.AdjustAllSourceLen( 1.0 / 1.5 ); } else if ( w == m_CfdMeshUI->adjLenUpUpButton ) { CfdMeshMgr.AdjustAllSourceLen( 1.5 ); } else if ( w == m_CfdMeshUI->adjRadDownButton ) { CfdMeshMgr.AdjustAllSourceRad( 1.0 / 1.1 ); } else if ( w == m_CfdMeshUI->adjRadUpButton ) { CfdMeshMgr.AdjustAllSourceRad( 1.1 ); } else if ( w == m_CfdMeshUI->adjRadDownDownButton ) { CfdMeshMgr.AdjustAllSourceRad( 1.0 / 1.5 ); } else if ( w == m_CfdMeshUI->adjRadUpUpButton ) { CfdMeshMgr.AdjustAllSourceRad( 1.5 ); } else if ( w == m_CfdMeshUI->datButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select NASCART .dat file.", "*.dat" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_DAT_FILE_NAME ); } } else if ( w == m_CfdMeshUI->keyButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select NASCART .key file.", "*.key" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_KEY_FILE_NAME ); } } else if ( w == m_CfdMeshUI->objButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select .obj file.", "*.obj" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_OBJ_FILE_NAME ); } } else if ( w == m_CfdMeshUI->polyButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select .poly file.", "*.poly" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_POLY_FILE_NAME ); } } else if ( w == m_CfdMeshUI->stlButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select .stl file.", "*.stl" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_STL_FILE_NAME ); } } else if ( w == m_CfdMeshUI->triButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select .tri file.", "*.tri" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_TRI_FILE_NAME ); } } else if ( w == m_CfdMeshUI->gmshButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select .msh file.", "*.msh" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_GMSH_FILE_NAME ); } } else if ( w == m_CfdMeshUI->srfButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select .srf file.", "*.srf" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_SRF_FILE_NAME ); } } else if ( w == m_CfdMeshUI->tkeyButton ) { string newfile = m_ScreenMgr->GetSelectFileScreen()->FileChooser( "Select .tkey file.", "*.tkey" ); if ( newfile.compare( "" ) != 0 ) { CfdMeshMgr.GetCfdSettingsPtr()->SetExportFileName( newfile, vsp::CFD_TKEY_FILE_NAME ); } } else if ( w == m_CfdMeshUI->addWakeButton ) { bool flag = !!( m_CfdMeshUI->addWakeButton->value() ); vector<string> geomVec = m_Vehicle->GetGeomVec(); string wakeGeomID = CfdMeshMgr.GetWakeGeomID(); Geom* g = m_Vehicle->FindGeom( wakeGeomID ); if ( g ) { g->SetWakeActiveFlag( flag ); } } else if ( w == m_CfdMeshUI->farBoxGenButton ) { CfdMeshMgr.GetCfdSettingsPtr()->SetFarCompFlag( false ); } else if ( w == m_CfdMeshUI->farComponentGenButton ) { CfdMeshMgr.GetCfdSettingsPtr()->SetFarCompFlag( true ); } else if ( w == m_CfdMeshUI->farCenLocButton ) { CfdMeshMgr.GetCfdSettingsPtr()->SetFarManLocFlag( false ); } else if ( w == m_CfdMeshUI->farManLocButton ) { CfdMeshMgr.GetCfdSettingsPtr()->SetFarManLocFlag( true ); } else if ( w == m_CfdMeshUI->farRelSizeButton ) { CfdMeshMgr.GetCfdSettingsPtr()->SetFarAbsSizeFlag( false ); } else if ( w == m_CfdMeshUI->farAbsSizeButton ) { CfdMeshMgr.GetCfdSettingsPtr()->SetFarAbsSizeFlag( true ); } // else if ( w == m_CfdMeshUI->farXScaleAbsInput ) // { // bool change = false; // // if ( !CfdMeshMgr.GetFarAbsSizeFlag() ) // { // CfdMeshMgr.SetFarAbsSizeFlag( true ); // change = true; // } // // double val = atof( m_CfdMeshUI->farXScaleAbsInput->value() ); // CfdMeshMgr.SetFarLength( val ); // CfdMeshMgr.UpdateDomain(); // double scale = CfdMeshMgr.GetFarXScale(); // m_FarXScaleSlider.SetVal( scale ); // m_FarXScaleSlider.UpdateGui(); // // update_flag = false; // // if ( change ) // CfdMeshMgr.SetFarAbsSizeFlag( false ); // } // // else if ( w == m_CfdMeshUI->farYScaleAbsInput ) // { // bool change = false; // // if ( !CfdMeshMgr.GetFarAbsSizeFlag() ) // { // CfdMeshMgr.SetFarAbsSizeFlag( true ); // change = true; // } // // double val = atof( m_CfdMeshUI->farYScaleAbsInput->value() ); // CfdMeshMgr.SetFarWidth( val ); // CfdMeshMgr.UpdateDomain(); // double scale = CfdMeshMgr.GetFarYScale(); // m_FarYScaleSlider.SetVal( scale ); // m_FarYScaleSlider.UpdateGui(); // // update_flag = false; // // if ( change ) // CfdMeshMgr.SetFarAbsSizeFlag( false ); // } // // else if ( w == m_CfdMeshUI->farZScaleAbsInput ) // { // bool change = false; // // if ( !CfdMeshMgr.GetFarAbsSizeFlag() ) // { // CfdMeshMgr.SetFarAbsSizeFlag( true ); // change = true; // } // // double val = atof( m_CfdMeshUI->farZScaleAbsInput->value() ); // CfdMeshMgr.SetFarHeight( val ); // CfdMeshMgr.UpdateDomain(); // double scale = CfdMeshMgr.GetFarZScale(); // m_FarZScaleSlider.SetVal( scale ); // m_FarZScaleSlider.UpdateGui(); // // update_flag = false; // // if ( change ) // CfdMeshMgr.SetFarAbsSizeFlag( false ); // } if ( update_flag ) { Update(); } m_ScreenMgr->SetUpdateFlag( true ); }
void PakProtocol::listDir(const KURL &url) { kdDebug(PAK_DEBUG_ID) << "Entering listDir()" << endl; QString path; KIO::Error errorNum; if ( !checkNewFile( url, path, errorNum ) ) { if ( errorNum == KIO::ERR_CANNOT_OPEN_FOR_READING ) { // If we cannot open, it might be a problem with the archive header (e.g. unsupported format) // Therefore give a more specific error message error( KIO::ERR_SLAVE_DEFINED, i18n( "Could not open the file, probably due to an unsupported file format.\n%1") .arg( url.prettyURL() ) ); return; } else if ( errorNum != KIO::ERR_IS_DIRECTORY ) { // We have any other error error( errorNum, url.prettyURL() ); return; } // It's a real dir -> redirect KURL redir; redir.setPath( url.path() ); kdDebug( PAK_DEBUG_ID ) << "Ok, redirection to " << redir.url() << endl; redirection( redir ); finished(); // And let go of the tar file - for people who want to unmount a cdrom after that delete _pakFile; _pakFile = 0L; return; } if ( path.isEmpty() ) { KURL redir( url.protocol() + QString::fromLatin1( ":/") ); kdDebug( PAK_DEBUG_ID ) << "url.path()==" << url.path() << endl; redir.setPath( url.path() + QString::fromLatin1("/") ); kdDebug( PAK_DEBUG_ID ) << "ArchiveProtocol::listDir: redirection " << redir.url() << endl; redirection( redir ); finished(); return; } path = QString::fromLocal8Bit(remoteEncoding()->encode(path)); kdDebug( PAK_DEBUG_ID ) << "checkNewFile done" << endl; const KArchiveDirectory* root = _pakFile->directory(); const KArchiveDirectory* dir; if (!path.isEmpty() && path != "/") { kdDebug(PAK_DEBUG_ID) << QString("Looking for entry %1").arg(path) << endl; const KArchiveEntry* e = root->entry( path ); if ( !e ) { error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() ); return; } if ( ! e->isDirectory() ) { error( KIO::ERR_IS_FILE, url.prettyURL() ); return; } dir = (KArchiveDirectory*)e; } else { dir = root; } QStringList l = dir->entries(); totalSize( l.count() ); KIO::UDSEntry entry; QStringList::Iterator it = l.begin(); for( ; it != l.end(); ++it ) { kdDebug(PAK_DEBUG_ID) << (*it) << endl; const KArchiveEntry* archiveEntry = dir->entry( (*it) ); createUDSEntry( archiveEntry, entry ); listEntry( entry, false ); } listEntry( entry, true ); // ready finished(); kdDebug( PAK_DEBUG_ID ) << "ArchiveProtocol::listDir done" << endl; /*kdDebug(PAK_DEBUG_ID) << "Entering listDir()" << endl; totalSize(1); // ONE file (Magic!!) KIO::UDSEntry entry; createUDSEntry(NULL, entry); kdDebug(PAK_DEBUG_ID) << "Giving file away" << endl; listEntry(entry, false); listEntry(entry, true); // End finished(); kdDebug(PAK_DEBUG_ID) << "-<> Exiting listDir()" << endl;*/ }
int process(char *argu){ char *trail; trail = argu; int trailingOp = -1; //0 for bg, 1 for routing, -1 for neither while (trail != NULL){ if (strcmp(trail, "&") == 0){ //anything after the & is summarily ignored //run in background trailingOp = 0; break; } if (strcmp(trail, ">") == 0){ trailingOp = 1; //routing break; } args[argSize] = trail; //printf("Trail = %s. Arg = %s.\n", trail, args[argSize]); argSize++; trail = strtok(NULL, " \n\t\r"); } args[argSize] = '\0'; //sets end of argument array to \0 because execvp likes that argSize++; if (trailingOp == 0){ //implementation to run jobs in the backgrounds if (executeProgram(argu, 0) == 0){ return 0; } } else if (trailingOp == 1){ //implementation to redirect job output trail = strtok(NULL, " \n\t\r"); char outPath[512]; memset(outPath, '\0', 512); strcpy(outPath, trail); //outpath now holds the name/path of the output file that the user has specified int i; for (i = 0; i < 512; i++){ if ((outPath[i] == ' ') || (outPath[i] == '>')){ fprintf(stderr, "Error: Invalid file name.\n"); return -1; } } if (redir(outPath, argu) == 0){ return 0; } else return -1; } //checks the first word in the user input //exit if (strcmp(argu, "exit") == 0){ exit(0); } //returns current pid, good for testing if (strcmp(argu, "pid") == 0){ int pid = getpid(); printf("PID: %d\n", pid); return 0; } //wait if (strcmp(argu, "wait") == 0){ //wont return until all background jobs are completed wait(); return(0); } if (strcmp(argu, "pwd") == 0){ char buffer[255]; //all ex file systems have a maximum file name size of 255 bytes getcwd(buffer, 256); printf("%s\n", buffer); return(0); } if (strcmp(argu, "cd") == 0){ char *argu; char path[512]; if (args[1] == NULL){ strcpy(path, getenv("HOME")); } else { strcpy(path, args[1]); } chdir(path); return 0; } if (python(argu) == 0){ char *pyArg[512]; char path[128]; strcpy(path, "python"); pyArg[0] = argu; int i; for(i = 1; i < argSize + 1; i++){ pyArg[i] = args[i - 1]; } int childID = fork(); if (childID == 0){ execvp(path, pyArg); } return 0; } if (executeProgram(argu, 1) == 0) return 0; else return -1; }