main(int argc,char *argv[]) { if (argc<2) { puts("\nPouziti: MGFSOUND film.mgf zvuk.wav [i]"); puts("\nnebo: MGFSOUND script.scr"); puts("\nKde _i_ je komprimacni krivka (viz SNDPACK) (default:4)"); exit(0); } if (argc>3) { sscanf(argv[3],"%d",&difftype); } Create_table_16(); if (argc==2) call_script(argv[1]); else { open_wav(argv[2]); open_files(argv[1]); ozvuceni(); } close_files(); }
int main() { char name[IFNAMSIZ]; name[0] = 0; int fd = create_tun(name); // Setting up IP-tables routes char script_call[strlen(setup_script) + 1 + IFNAMSIZ]; strncpy(script_call, setup_script, strlen(setup_script) + 1); strncpy(script_call + strlen(setup_script), " ", 1); strncpy(script_call + strlen(setup_script) + 1, name, IFNAMSIZ); printf("Calling script with %s\n", script_call); fflush(stdout); call_script(script_call, "Created iptable entries\n", "An error occured during creaton of iptable entries", 0); for(;;){ int wrote = write_tun_write(fd); printf("wrote %d bytes on the tun device, now check iptables log\n", wrote); usleep(500000); } /* char buf[strlen(msg) + 1]; */ // read is blocking here // read_from(fd, buf, strlen(msg)); printf("reading from the device string\n"); return 0; }
static int route_adddel(struct main_server_st* s, proc_st *proc, const char* pattern, const char* route, const char* dev) { int ret; char *cmd = NULL; if (pattern == 0) { mslog(s, NULL, LOG_WARNING, "route-add-cmd or route-del-cmd are not set."); return 0; } ret = replace_cmd(s, proc, &cmd, pattern, route, dev); if (ret < 0) return ret; ret = call_script(s, proc, cmd); if (ret < 0) { int e = errno; mslog(s, NULL, LOG_INFO, "failed to spawn cmd: %s: %s", cmd, strerror(e)); ret = ERR_EXEC; goto fail; } ret = 0; fail: talloc_free(cmd); return ret; }
void decay_worldzone( unsigned wx, unsigned wy, Realms::Realm* realm ) { Zone& zone = realm->zone[wx][wy]; gameclock_t now = read_gameclock(); bool statistics = Plib::systemstate.config.thread_decay_statistics; for ( ZoneItems::size_type idx = 0; idx < zone.items.size(); ++idx ) { Items::Item* item = zone.items[idx]; if (statistics) { if (item->can_decay()) { const Items::ItemDesc& descriptor = item->itemdesc(); if (!descriptor.decays_on_multis) { Multi::UMulti* multi = realm->find_supporting_multi( item->x, item->y, item->z ); if (multi == NULL) stateManager.decay_statistics.temp_count_active++; } else stateManager.decay_statistics.temp_count_active++; } } if ( item->should_decay( now ) ) { // check the CanDecay syshook first if it returns 1 go over to other checks if ( gamestate.system_hooks.can_decay ) { if ( !gamestate.system_hooks.can_decay->call( new Module::EItemRefObjImp( item ) ) ) continue; } const Items::ItemDesc& descriptor = item->itemdesc(); Multi::UMulti* multi = realm->find_supporting_multi( item->x, item->y, item->z ); // some things don't decay on multis: if ( multi != NULL && !descriptor.decays_on_multis ) continue; if (statistics) stateManager.decay_statistics.temp_count_decayed++; if ( !descriptor.destroy_script.empty() && !item->inuse() ) { bool decayok = call_script( descriptor.destroy_script, item->make_ref() ); if ( !decayok ) continue; } item->spill_contents( multi ); destroy_item( item ); --idx; } } }
int user_connected(main_server_st *s, struct proc_st* proc) { int ret; add_utmp_entry(s, proc); ret = call_script(s, proc, 1); if (ret < 0) return ret; return 0; }
void user_disconnected(main_server_st *s, struct proc_st* proc) { remove_utmp_entry(s, proc); call_script(s, proc, 0); }
void stop_trace() { call_script("trace_stop.sh", NULL); }
void start_trace() { call_script("trace_start.sh", NULL); }
/** * Setting up the routing table, which need iproute2 to work!! * * @param tun_name The human-readable name of the tun device, e.g. tun0 */ void setup_routes(char const* const tun_name) { char script_cmd[80] = "bash route_setup.sh "; strcat(script_cmd, tun_name); call_script(script_cmd, "tunnel succesfully set up", "routing setting up", 1); }
/** * repository_ipod_init: * * Ask for the iPod model and mountpoint and then create the directory * structure on the iPod. * * @itdb: itdb from where to extract the mountpoint. After * initialisation the model number is set. */ gboolean repository_ipod_init(iTunesDB *itdb) { IpodInit *ii; gint response; gboolean result = FALSE; gchar *mountpoint, *new_mount, *name, *model; GError *error = NULL; gchar buf[PATH_MAX]; GtkComboBox *cb; const IpodInfo *info; GtkTreeIter iter; g_return_val_if_fail (itdb, FALSE); /* Create window */ ii = g_new0 (IpodInit, 1); ii->itdb = itdb; ii->builder = init_repository_builder(); ii->window = gtkpod_builder_xml_get_widget(ii->builder, "ipod_init_dialog"); g_return_val_if_fail (ii->window, FALSE); /* Set mountpoint */ mountpoint = get_itdb_prefs_string(itdb, KEY_MOUNTPOINT); if (mountpoint) { gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(GET_WIDGET (ii->builder, IID_MOUNTPOINT_CHOOSER)), mountpoint); } /* Setup model number combo */ cb = GTK_COMBO_BOX (GET_WIDGET (ii->builder, IID_MODEL_COMBO)); repository_init_model_number_combo(cb); /* If available set current model number, otherwise indicate that none is available */ info = itdb_device_get_ipod_info(itdb->device); if (info && (info->ipod_generation != ITDB_IPOD_GENERATION_UNKNOWN)) { g_snprintf(buf, PATH_MAX, "x%s", info->model_number); } else { model = get_itdb_prefs_string(itdb, KEY_IPOD_MODEL); if (model && (strlen(g_strstrip (model)) != 0)) { g_snprintf(buf, PATH_MAX, "%s", model); g_free(model); } else { g_snprintf(buf, PATH_MAX, "%s", gettext (SELECT_OR_ENTER_YOUR_MODEL)); } } /* Try and set buf as the active selection in the combo box */ _model_combo_set_active_iter(cb, buf); gtk_window_set_transient_for(GTK_WINDOW (ii->window), GTK_WINDOW (gtkpod_app)); response = gtk_dialog_run(GTK_DIALOG (ii->window)); switch (response) { case GTK_RESPONSE_OK: new_mount = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(GET_WIDGET (ii->builder, IID_MOUNTPOINT_CHOOSER)))); if (!new_mount || (strlen(new_mount) == 0)) { gtkpod_statusbar_message("No mount point has been selected"); return FALSE; } if (!gtk_combo_box_get_has_entry(cb)) { gtkpod_statusbar_message("No model has been selected"); return FALSE; } /* remove trailing '/' in case it's present. */ if (mountpoint && (strlen(mountpoint) > 0)) { if (G_IS_DIR_SEPARATOR(mountpoint[strlen(mountpoint) - 1])) { mountpoint[strlen(mountpoint) - 1] = 0; } } if (new_mount && (strlen(new_mount) > 0)) { if (G_IS_DIR_SEPARATOR(new_mount[strlen(new_mount) - 1])) { new_mount[strlen(new_mount) - 1] = 0; } } if (!(mountpoint && new_mount && (strcmp(mountpoint, new_mount) == 0))) { /* mountpoint has changed */ g_free(mountpoint); mountpoint = new_mount; new_mount = NULL; set_itdb_prefs_string(itdb, KEY_MOUNTPOINT, mountpoint); call_script("gtkpod.load", mountpoint, NULL); itdb_set_mountpoint(itdb, mountpoint); } else { g_free(new_mount); new_mount = NULL; } g_return_val_if_fail(gtk_combo_box_get_active_iter(cb, &iter), FALSE); gtk_tree_model_get(gtk_combo_box_get_model(cb), &iter, COL_STRING, &model, -1); g_return_val_if_fail(model, FALSE); if ((strcmp(model, gettext(SELECT_OR_ENTER_YOUR_MODEL)) == 0) || (strlen(model) == 0)) { /* User didn't choose a model */ g_free(model); model = NULL; } /* Set model in the prefs system */ set_itdb_prefs_string(itdb, KEY_IPOD_MODEL, model); name = get_itdb_prefs_string(itdb, "name"); result = itdb_init_ipod(mountpoint, model, name, &error); /* Set the model in the sysinfo of the itdb */ itdb_device_set_sysinfo(itdb->device, "ModelNumStr", model); if (!result) { if (error) { gtkpod_warning(_("Error initialising iPod: %s\n"), error->message); g_error_free(error); error = NULL; } else { gtkpod_warning(_("Error initialising iPod, unknown error\n")); } } else { /* Should write the extended info file */ result = gp_create_extended_info(itdb); } g_free(name); g_free(model); break; default: /* canceled -- do nothing */ break; } gtk_widget_destroy(ii->window); g_free(mountpoint); g_free(ii); return result; }