/* ************************************************************************* * * コマンド分岐関数 * ************************************************************************* */ void exec_command (char command, char *parameter, char *str) { switch (command) { case 'Q': command_quit(parameter); break; case 'C': command_check(parameter); break; case 'P': command_print(profile_data, atoi(parameter), str); break; case 'R': command_read(profile_data, parameter); break; case 'W': command_write(profile_data, parameter); break; case 'F': command_find(profile_data, parameter, str); break; case 'S': command_sort(profile_data, atoi(parameter), str); break; default: printf("Invalid command '%c' was found.\n", command); break; } }
void command_kill(t_serv *server, t_token *req) { t_fd *tmp; tmp = server->fd_lst; while (tmp) { command_quit(server, tmp); tmp = server->fd_lst; } free(req->content); free(req); close_server(server); return ; }
void ServerUI::processCommand() { ptCommand = szCommand; //trim whitespace trimWhitespace(); int nLen = strlen(ptCommand); if (nLen > 4 && strncmp(ptCommand, "quit", 4)) { ptCommand+=4; command_quit(); } else { printf("unknown command\n"); } }
static int do_run(t_env *env, char **splitted) { if (!ft_strcmp(splitted[0], "ls")) command_ls(env, splitted); else if (!ft_strcmp(splitted[0], "cd")) command_cd(env, splitted); else if (!ft_strcmp(splitted[0], "get")) command_get(env, splitted); else if (!ft_strcmp(splitted[0], "put")) command_put(env, splitted); else if (!ft_strcmp(splitted[0], "pwd")) command_pwd(env, splitted); else if (!ft_strcmp(splitted[0], "quit") || !ft_strcmp(splitted[0], "exit")) command_quit(env, splitted); else if (!ft_strcmp(splitted[0], "touch")) command_touch(env, splitted); else if (!ft_strcmp(splitted[0], "unlink")) command_unlink(env, splitted); else return (0); return (1); }
/*------------------------------------------------------------------------ * MAIN PROGRAM *------------------------------------------------------------------------*/ int main(int argc, const char *argv[]) { command_t command; /* the current command being processed */ //char command_text[MAX_COMMAND_LENGTH]; /* the raw text of the command */ char *command_text; ttp_session_t *session = NULL; ttp_parameter_t parameter; int argc_curr = 1; /* command line argument currently to be processed */ char *ptr_command_text = &command_text[0]; /* reset the client */ memset(¶meter, 0, sizeof(parameter)); reset_client(¶meter); /* show version / build information */ #ifdef VSIB_REALTIME fprintf(stderr, "Tsunami Realtime Client for protocol rev %X\nRevision: %s\nCompiled: %s %s\n" " /dev/vsib VSIB accesses mode is %d, gigabit=%d, 1pps embed=%d, sample skip=%d\n", PROTOCOL_REVISION, TSUNAMI_CVS_BUILDNR, __DATE__ , __TIME__, vsib_mode, vsib_mode_gigabit, vsib_mode_embed_1pps_markers, vsib_mode_skip_samples); #else fprintf(stderr, "Tsunami Client for protocol rev %X\nRevision: %s\nCompiled: %s %s\n", PROTOCOL_REVISION, TSUNAMI_CVS_BUILDNR, __DATE__ , __TIME__); #endif /* while the command loop is still running */ while (1) { /* retrieve the user's commands */ if (argc<=1 || argc_curr>=argc) { /* present the prompt */ fprintf(stdout, "tsunami> "); fflush(stdout); /* read next command */ if (fgets(command_text, MAX_COMMAND_LENGTH, stdin) == NULL) { error("Could not read command input"); } } else { // severe TODO: check that command_text appends do not over flow MAX_COMMAND_LENGTH... /* assemble next command from command line arguments */ for ( ; argc_curr<argc; argc_curr++) { // zero argument commands if (!strcasecmp(argv[argc_curr], "close") || !strcasecmp(argv[argc_curr], "quit") || !strcasecmp(argv[argc_curr], "exit") || !strcasecmp(argv[argc_curr], "bye") || !strcasecmp(argv[argc_curr], "help") || !strcasecmp(argv[argc_curr], "dir")) { strcpy(command_text, argv[argc_curr]); argc_curr += 1; break; } // single argument commands if (!strcasecmp(argv[argc_curr], "connect")) { if (argc_curr+1 < argc) { strcpy(ptr_command_text, argv[argc_curr]); strcat(command_text, " "); strcat(command_text, argv[argc_curr+1]); } else { fprintf(stderr, "Connect: no host specified\n"); exit(1); } argc_curr += 2; break; } /*__FINAL_PROJECT_START__ if (!strcasecmp(argv[argc_curr], "connect6")) { if (argc_curr+1 < argc) { strcpy(ptr_command_text, argv[argc_curr]); strcat(command_text, " "); strcat(command_text, argv[argc_curr+1]); } else { fprintf(stderr, "Connect: no host specified\n"); exit(1); } argc_curr += 2; break; } __FINAL_PROJECT_END __*/ if (!strcasecmp(argv[argc_curr], "get")) { if (argc_curr+1 < argc) { strcpy(ptr_command_text, argv[argc_curr]); strcat(command_text, " "); strcat(command_text, argv[argc_curr+1]); } else { fprintf(stderr, "Get: no file specified\n"); exit(1); } argc_curr += 2; break; } // double argument commands if (!strcasecmp(argv[argc_curr], "set")) { if (argc_curr+2 < argc) { strcpy(ptr_command_text, argv[argc_curr]); strcat(command_text, " "); strcat(command_text, argv[argc_curr+1]); strcat(command_text, " "); strcat(command_text, argv[argc_curr+2]); } else { fprintf(stderr, "Connect: no host specified\n"); exit(1); } argc_curr += 3; break; } // unknown commands, skip fprintf(stderr, "Unsupported command console command: %s\n", argv[argc_curr]); } } /* parse the command */ parse_command(&command, command_text); /* make sure we have at least one word */ if (command.count == 0) continue; /* dispatch on the command type */ if (!strcasecmp(command.text[0], "close")) command_close (&command, session); else if (!strcasecmp(command.text[0], "connect")) session = command_connect(&command, ¶meter); //else if (!strcasecmp(command.text[0], "connect6")) session = command_connect6(&command, ¶meter); else if (!strcasecmp(command.text[0], "get")) command_get (&command, session); else if (!strcasecmp(command.text[0], "dir")) command_dir (&command, session); else if (!strcasecmp(command.text[0], "help")) command_help (&command, session); else if (!strcasecmp(command.text[0], "quit")) command_quit (&command, session); else if (!strcasecmp(command.text[0], "exit")) command_quit (&command, session); else if (!strcasecmp(command.text[0], "bye")) command_quit (&command, session); else if (!strcasecmp(command.text[0], "set")) command_set (&command, ¶meter); else fprintf(stderr, "Unrecognized command: '%s'. Use 'HELP' for help.\n\n", command.text[0]); } /* if we're here, we shouldn't be */ return 1; }
bool VMGahpServer::cleanup(void) { bool result = true; if( m_is_cleanuped ) { return true; } m_is_cleanuped = true; dprintf(D_FULLDEBUG,"Inside VM_GAHP_SERVER::cleanup()\n"); // Remove all pending requests int currentkey = 0; VMGahpRequest *req = NULL; m_request_table.startIterations(); while( m_request_table.iterate(currentkey, req) != 0) { if( req ) { req->detachVMGahpServer(); } } m_request_table.clear(); // Stop poll timer if(m_poll_tid != -1) { if( daemonCore ) { daemonCore->Cancel_Timer(m_poll_tid); } m_poll_tid = -1; } if(m_poll_real_soon_tid != -1) { if( daemonCore ) { daemonCore->Cancel_Timer(m_poll_real_soon_tid); } m_poll_real_soon_tid = -1; } // Stop stderr timer if( m_stderr_tid != -1 ) { if( daemonCore ) { daemonCore->Cancel_Timer(m_stderr_tid); } m_stderr_tid = -1; } if( m_is_initialized && (m_vmgahp_pid > 0 )) { result = command_quit(); } // print last messages from vmgahp before closing pipes printSystemErrorMsg(); // Close pipes if( m_vmgahp_readfd != -1 ) { if( daemonCore ) { daemonCore->Close_Pipe(m_vmgahp_readfd); } m_vmgahp_readfd = -1; } if( m_vmgahp_writefd != -1 ) { if( daemonCore ) { daemonCore->Close_Pipe(m_vmgahp_writefd); } m_vmgahp_writefd = -1; } if( m_vmgahp_errorfd != -1 ) { if( daemonCore ) { daemonCore->Close_Pipe(m_vmgahp_errorfd); } m_vmgahp_errorfd = -1; } m_vmgahp_error_buffer = ""; // Make sure Virtual machine exits. if( m_vm_id > 0 ) { killVM(); m_vm_id = 0; } m_is_initialized = false; m_is_async_mode = false; m_vmgahp_pid = -1; m_rotated_reqids = false; m_commands_supported.clearAll(); m_vms_supported.clearAll(); dprintf(D_FULLDEBUG,"End of VM_GAHP_SERVER::cleanup\n"); sleep(1); return result; }
void Mixer::cb_menu(Fl_Widget* o) { Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o; /* const Fl_Menu_Item *mi = &menu->menu()[menu->value()]; */ char picked[256]; // const char *picked = menu->text(); menu->item_pathname( picked, sizeof( picked ) ); if (! strcmp( picked, "&Project/&New") ) { DMESSAGE( "New project" ); const char *templates[] = { "Default", NULL }; char *default_path; char *selected_template; read_line( user_config_dir, "default_path", &default_path ); char *path = new_project_chooser( templates, &default_path, &selected_template ); if ( path ) { if ( ! Project::create( path, selected_template ) ) fl_alert( "Error creating project!" ); free( path ); free( selected_template ); } update_menu(); if ( default_path ) { write_line( user_config_dir, "default_path", default_path ); free( default_path ); } } else if (! strcmp( picked, "&Project/&Open" ) ) { char *path = NULL; // read_line( user_config_dir, "default_path", &path ); const char *name = fl_dir_chooser( "Open Project", path ); free( path ); mixer->hide(); if ( int err = Project::open( name ) ) { fl_alert( "Error opening project: %s", Project::errstr( err ) ); } update_menu(); mixer->show(); } else if (! strcmp( picked, "&Project/&Save" ) ) { command_save(); } else if (! strcmp( picked, "&Project/&Quit") ) { command_quit(); } else if ( !strcmp( picked, "&Mixer/&Add Strip" ) ) { command_add_strip(); } else if ( !strcmp( picked, "&Mixer/Add &N Strips" ) ) { const char *s = fl_input( "Enter number of strips to add" ); if ( s ) { for ( int i = atoi( s ); i > 0; i-- ) command_add_strip(); } } else if ( !strcmp( picked, "&Mixer/&Import Strip" ) ) { const char *s = fl_file_chooser( "Export strip to filename:", "*.strip", NULL, 0 ); if ( s ) { if (! Mixer_Strip::import_strip( s ) ) fl_alert( "%s", "Failed to import strip!" ); } } else if (! strcmp( picked, "&Mixer/&Rows/One") ) { rows( 1 ); } else if (! strcmp( picked, "&Mixer/&Rows/Two") ) { rows( 2 ); } else if (! strcmp( picked, "&Mixer/&Rows/Three") ) { rows( 3 ); } else if (! strcmp( picked, "&View/&Theme") ) { fl_theme_chooser(); } else if (! strcmp( picked, "&Options/&Display/&Knobs/&Burnished") ) { Fl_Dial::default_style( Fl_Dial::BURNISHED_DIAL ); redraw_windows(); } else if (! strcmp( picked, "&Options/&Display/&Knobs/&Arc") ) { Fl_Dial::default_style( Fl_Dial::ARC_DIAL ); redraw_windows(); } else if (! strcmp( picked, "&Options/&Display/&Knobs/&Plastic") ) { Fl_Dial::default_style( Fl_Dial::PLASTIC_DIAL ); redraw_windows(); } else if (! strcmp( picked, "&Options/&Display/&Sliders/&Nice") ) { Fl_Value_SliderX::default_style( Fl_Value_SliderX::NICE_SLIDER ); redraw_windows(); } else if (! strcmp( picked, "&Options/&Display/&Sliders/&Fill") ) { Fl_Value_SliderX::default_style( Fl_Value_SliderX::FILL_SLIDER ); redraw_windows(); } else if (! strcmp( picked, "&Options/&Display/&Sliders/&Simple") ) { Fl_Value_SliderX::default_style( Fl_Value_SliderX::SIMPLE_SLIDER ); redraw_windows(); } else if ( ! strcmp( picked, "&Help/&About" ) ) { About_Dialog ab( PIXMAP_PATH "/non-mixer/icon-256x256.png" ); ab.logo_box->label( VERSION ); ab.title->label( "The Non Mixer" ); ab.copyright->label( "Copyright (C) 2008-2010 Jonathan Moore Liles" ); ab.credits->label( "Non-Mixer was written from scratch by\n" "Jonathan Moore Liles for his own use\n" "(see the manual).\n" "\n" "Nobody planned. Nobody helped.\n" "You can help now by donating time, money,\n" "and/or replacing the rest of Linux Audio\n" "with fast, light, reliable alternatives.\n" ); ab.website_url->label( "http://non-mixer.tuxfamily.org" ); ab.run(); } else if ( !strcmp( picked, "&Help/&Manual" )) { char *pat; asprintf( &pat, "file://%s.html", DOCUMENT_PATH "/non-mixer/MANUAL" ); open_url( pat ); free( pat ); } }