void pile::push(generic_file *f, const string & label, bool extend_mode) { face to_add; if(is_terminated()) throw SRC_BUG; if(f == NULL) throw SRC_BUG; if(look_for_label(label) != stack.end()) throw Erange("pile::push", "Label already used while pushing a generic_file on a stack"); if(stack.empty()) set_mode(f->get_mode()); if(f->get_mode() != get_mode() && (!extend_mode || f->get_mode() != gf_read_write)) throw Erange("pile::push", "Adding to the stack of generic_file an object using an incompatible read/write mode"); if(extend_mode) set_mode(f->get_mode()); to_add.ptr = f; to_add.labels.clear(); if(label != "") to_add.labels.push_back(label); stack.push_back(to_add); }
static CommandDescriptor * find_active_mode(CommandDescriptor descriptors[], gint *argc, char **argv, GString *cmdname_accumulator) { const gchar *mode_string = get_mode(argc, &argv); if (!mode_string) { print_usage(cmdname_accumulator->str, descriptors); exit(1); } for (gint mode = 0; descriptors[mode].mode; mode++) if (strcmp(descriptors[mode].mode, mode_string) == 0) { if (descriptors[mode].main) return &descriptors[mode]; g_assert(descriptors[mode].subcommands); g_string_append_printf(cmdname_accumulator, " %s", mode_string); return find_active_mode(descriptors[mode].subcommands, argc, argv, cmdname_accumulator); } return NULL; }
int main(int argc, char ** argv) { check_help_arg(argc, argv); check_args_count(argc, argv, 4); bool mode_make = get_mode(argv, "make", "test"); mpz_t hash; mpz_init(hash); mpz_set_file_hash(hash, argv[2]); if (mode_make) { write_signature_file(argv[3], hash); } else { test_signature_file(argv[3], hash); } mpz_clear(hash); return EXIT_SUCCESS; }
static int set_codec_options(const struct PluginCodec_Definition * defn, void * context, const char * name, void * parm, unsigned * parmLen) { const char * const * option; if (context == NULL || parm == NULL || parmLen == NULL || *parmLen != sizeof(const char **)) return 0; for (option = (const char * const *)parm; *option != NULL; option += 2) { if (STRCMPI(option[0], PreferredModeStr) == 0) { unsigned mode = get_mode(option[1]); if (defn->destFormat[0] == 'L') initDecode(context, mode, 0); else initEncode(context, mode); } } return 1; }
static int bool_cmd(int argc, char **argv, struct mpd_connection *conn, bool (*get_mode)(const struct mpd_status *status), bool (*run_set_mode)(struct mpd_connection *conn, bool mode)) { bool mode; if (argc == 1) { mode = get_boolean(argv[0]); if (mode < 0) return -1; } else { struct mpd_status *status; status = getStatus(conn); mode = !get_mode(status); mpd_status_free(status); } if (!run_set_mode(conn, mode)) printErrorAndExit(conn); return 1; }
static void exit_predictions(PRED_AT what) { int i; if (gl_nsim > 1 && gl_lhs) lhs(get_gstat_data(), get_n_vars(), get_mode() == STRATIFY); switch (what) { case AT_POINTS: write_points(NULL, NULL, NULL, NULL, 0); if (gl_nsim > 1) save_simulations_to_ascii(o_filename); break; case AT_GRIDMAP: if (gl_nsim > 1) { if (DEBUG_DUMP) printlog("\nWriting results to files..."); save_simulations_to_maps(masks[0]); if (DEBUG_DUMP) printlog("done"); } else { for (i = 0; i < get_n_outfile(); i++) { if (get_outfile_namei(i)) { map_sign(outmap[i], what_is_outfile(i)); (outmap[i])->write(outmap[i]); map_free(outmap[i]); } } } for (i = 0; i < get_n_masks(); i++) map_free(masks[i]); efree(masks); efree(outmap); break; } print_orvc(); efree(est); } /* exit_predictions() */
int headers_to_stat(GList *headers, struct stat *stbuf) { GList *head = NULL, *next = NULL; head = g_list_first(headers); while(head != NULL) { next = head->next; HTTP_HEADER *header = head->data; // TODO: clean this up. if(strcmp(header->key, "x-amz-meta-uid") == 0) stbuf->st_uid = get_uid(header->value); else if(strcmp(header->key, "x-amz-meta-gid") == 0) stbuf->st_gid = get_gid(header->value); else if(strcmp(header->key, "x-amz-meta-ctime") == 0) stbuf->st_ctime = get_ctime(header->value); else if(strcmp(header->key, "x-amz-meta-mtime") == 0) stbuf->st_mtime = get_mtime(header->value); else if(strcmp(header->key, "x-amz-meta-rdev") == 0) stbuf->st_rdev = get_rdev(header->value); else if(strcmp(header->key, "Last-Modified") == 0 && stbuf->st_mtime == 0) stbuf->st_mtime = get_mtime(header->value); else if(strcmp(header->key, "x-amz-meta-mode") == 0) stbuf->st_mode = get_mode(header->value); else if(strcmp(header->key, "Content-Length") == 0) stbuf->st_size = get_size(header->value); else if(strcmp(header->key, "Content-Type") == 0) if(strstr(header->value, "x-directory")) stbuf->st_mode |= S_IFDIR; head = next; } return 0; }
int main() { get_mode(); create_connect(); create_full(); set_servo_position(BAR_SERVO, BAR_CLOSED_POSITION); set_servo_position(CLAW_SERVO, CLAW_OPEN_POSITION); set_servo_position(GYRO_SERVO, GYRO_SETTING_POSITION); enable_servos(); msleep(3000); // operate_winch(WINCH_START_POSITION); // set_servo_position(GYRO_SERVO, GYRO_START_POSITION); // press_a_to_continue(); // set_servo_position(GYRO_SERVO, GYRO_SETTING_POSITION); // msleep(2000); drop_three_hangers(); //pick_up_first_doubler(); pick_up_cube(); create_disconnect(); return 0; }
void mode_and_toggle_test(){ SERIAL_OUT.println(); SERIAL_OUT.println(); SERIAL_OUT.println("this function will determine the switch and toggle positions"); SERIAL_OUT.println("perform hard reset to exit function"); //determines the current state and waits for it to change to start the race int toggle_state = digitalRead(TOGGLE); int mode_state = mode; SERIAL_OUT.println("switch state = "); SERIAL_OUT.println(toggle_state); SERIAL_OUT.println("mode state = "); SERIAL_OUT.println(mode_state); while(1){ if((toggle_state == digitalRead(TOGGLE)) && (mode == mode_state)) SERIAL_OUT.println("switch or mode has not changed"); else SERIAL_OUT.println("something changed"); get_mode(); //waits until the switch is flipped to start the race delay(250); } return; }
static void wpa_setband_scan_freqs_list(struct wpa_supplicant *wpa_s, enum hostapd_hw_mode band, struct wpa_driver_scan_params *params) { /* Include only supported channels for the specified band */ struct hostapd_hw_modes *mode; int count, i; mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, band); if (mode == NULL) { /* No channels supported in this band - use empty list */ params->freqs = os_zalloc(sizeof(int)); return; } params->freqs = os_calloc(mode->num_channels + 1, sizeof(int)); if (params->freqs == NULL) return; for (count = 0, i = 0; i < mode->num_channels; i++) { if (mode->channels[i].flag & HOSTAPD_CHAN_DISABLED) continue; params->freqs[count++] = mode->channels[i].freq; } }
int do_chmod(int nargs, char **args) { char tmp[64]; char *target; int n; target = args[2]; if (!strncmp(target, "mtd@", 4)) { n = mtd_name_to_number(target + 4); if (n < 0) { return -1; } sprintf(tmp, "/dev/mtd/mtd%d", n); target = tmp; } //ERROR("do_chmod debug: target:%s\n",target); mode_t mode = get_mode(args[1]); if (chmod(target, mode) < 0) { return -errno; } return 0; }
// update mount position - should be called periodically void AP_Mount_SToRM32::update() { // exit immediately if not initialised if (!_initialised) { return; } // flag to trigger sending target angles to gimbal bool resend_now = false; // update based on mount mode switch(get_mode()) { // move mount to a "retracted" position. To-Do: remove support and replace with a relaxed mode? case MAV_MOUNT_MODE_RETRACT: { const Vector3f &target = _state._retract_angles.get(); _angle_ef_target_rad.x = ToRad(target.x); _angle_ef_target_rad.y = ToRad(target.y); _angle_ef_target_rad.z = ToRad(target.z); } break; // move mount to a neutral position, typically pointing forward case MAV_MOUNT_MODE_NEUTRAL: { const Vector3f &target = _state._neutral_angles.get(); _angle_ef_target_rad.x = ToRad(target.x); _angle_ef_target_rad.y = ToRad(target.y); _angle_ef_target_rad.z = ToRad(target.z); } break; // point to the angles given by a mavlink message case MAV_MOUNT_MODE_MAVLINK_TARGETING: // do nothing because earth-frame angle targets (i.e. _angle_ef_target_rad) should have already been set by a MOUNT_CONTROL message from GCS break; // RC radio manual angle control, but with stabilization from the AHRS case MAV_MOUNT_MODE_RC_TARGETING: // update targets using pilot's rc inputs update_targets_from_rc(); resend_now = true; break; // point mount to a GPS point given by the mission planner case MAV_MOUNT_MODE_GPS_POINT: if(_frontend._ahrs.get_gps().status() >= AP_GPS::GPS_OK_FIX_2D) { calc_angle_to_location(_state._roi_target, _angle_ef_target_rad, true, true); resend_now = true; } break; default: // we do not know this mode so do nothing break; } // resend target angles at least once per second if (resend_now || ((hal.scheduler->millis() - _last_send) > AP_MOUNT_STORM32_RESEND_MS)) { send_do_mount_control(ToDeg(_angle_ef_target_rad.y), ToDeg(_angle_ef_target_rad.x), ToDeg(_angle_ef_target_rad.z), MAV_MOUNT_MODE_MAVLINK_TARGETING); } }
static int queue_diff(struct diff_options *o, const char *name1, const char *name2) { int mode1 = 0, mode2 = 0; if (get_mode(name1, &mode1) || get_mode(name2, &mode2)) return -1; if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) return error("file/directory conflict: %s, %s", name1, name2); if (S_ISDIR(mode1) || S_ISDIR(mode2)) { char buffer1[PATH_MAX], buffer2[PATH_MAX]; struct string_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1}; int len1 = 0, len2 = 0, i1, i2, ret = 0; if (name1 && read_directory(name1, &p1)) return -1; if (name2 && read_directory(name2, &p2)) { string_list_clear(&p1, 0); return -1; } if (name1) { len1 = strlen(name1); if (len1 > 0 && name1[len1 - 1] == '/') len1--; memcpy(buffer1, name1, len1); buffer1[len1++] = '/'; } if (name2) { len2 = strlen(name2); if (len2 > 0 && name2[len2 - 1] == '/') len2--; memcpy(buffer2, name2, len2); buffer2[len2++] = '/'; } for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) { const char *n1, *n2; int comp; if (i1 == p1.nr) comp = 1; else if (i2 == p2.nr) comp = -1; else comp = strcmp(p1.items[i1].string, p2.items[i2].string); if (comp > 0) n1 = NULL; else { n1 = buffer1; strncpy(buffer1 + len1, p1.items[i1++].string, PATH_MAX - len1); } if (comp < 0) n2 = NULL; else { n2 = buffer2; strncpy(buffer2 + len2, p2.items[i2++].string, PATH_MAX - len2); } ret = queue_diff(o, n1, n2); } string_list_clear(&p1, 0); string_list_clear(&p2, 0); return ret; } else { struct diff_filespec *d1, *d2; if (DIFF_OPT_TST(o, REVERSE_DIFF)) { unsigned tmp; const char *tmp_c; tmp = mode1; mode1 = mode2; mode2 = tmp; tmp_c = name1; name1 = name2; name2 = tmp_c; } if (!name1) name1 = "/dev/null"; if (!name2) name2 = "/dev/null"; d1 = alloc_filespec(name1); d2 = alloc_filespec(name2); fill_filespec(d1, null_sha1, mode1); fill_filespec(d2, null_sha1, mode2); diff_queue(&diff_queued_diff, d1, d2); return 0; } }
/*We have found a file so write to disk*/ int write_to_disk(f_state *s, s_spec *needle, u_int64_t len, unsigned char *buf, u_int64_t t_offset) { char fn[MAX_STRING_LENGTH]; FILE *f; FILE *test; long byteswritten = 0; char temp[32]; u_int64_t block = ((t_offset) / s->block_size); int i = 1; //Name files based on their block offset needle->written = TRUE; if (get_mode(s, mode_write_audit)) { if (needle->comment == NULL) strcpy(needle->comment, " "); audit_msg(s, "%d:\t%10llu.%s \t %10s \t %10llu \t %s", // http://sourceforge.net/p/foremost/bugs/2/ s->fileswritten, block, needle->suffix, human_readable(len, temp), t_offset, needle->comment); s->fileswritten++; needle->found++; return TRUE; } snprintf(fn, MAX_STRING_LENGTH, "%s/%s/%0*llu.%s", s->output_directory, needle->suffix, 8, block, needle->suffix); test = fopen(fn, "r"); while (test) /*Test the files to make sure we have unique file names, some headers could be within the same block*/ { memset(fn, 0, MAX_STRING_LENGTH - 1); snprintf(fn, MAX_STRING_LENGTH - 1, "%s/%s/%0*llu_%d.%s", s->output_directory, needle->suffix, 8, block, i, needle->suffix); i++; fclose(test); test = fopen(fn, "r"); } if (!(f = fopen(fn, "w"))) { printf("fn = %s failed\n", fn); fatal_error(s, "Can't open file for writing \n"); } if ((byteswritten = fwrite(buf, sizeof(char), len, f)) != len) { fprintf(stderr, "fn=%s bytes=%lu\n", fn, byteswritten); fatal_error(s, "Error writing file\n"); } if (fclose(f)) { fatal_error(s, "Error closing file\n"); } if (needle->comment == NULL) strcpy(needle->comment, " "); if (i == 1) { audit_msg(s,"%d:\t%08llu.%s \t %10s \t %10llu \t %s", s->fileswritten, block, needle->suffix, human_readable(len, temp), t_offset, needle->comment); } else { audit_msg(s,"%d:\t%08llu_%d.%s \t %10s \t %10llu \t %s", s->fileswritten, block, i - 1, needle->suffix, human_readable(len, temp), t_offset, needle->comment); } /* audit_msg(s,"%d:\t%10llu.%s \t %10s \t %10llu \t %s", s->fileswritten, block, needle->suffix, human_readable(len, temp), t_offset, needle->comment); */ s->fileswritten++; needle->found++; return TRUE; }
uint8_t sportswatch_process(uint8_t event, uint16_t lparam, void* rparam) { UNUSED_VAR(lparam); switch(event) { case EVENT_WINDOW_CREATED: { if (rparam == (void*)0) { //running sports_type = SPORTS_DATA_FLAG_RUN; set_mode(DATA_MODE_RUNNING); //ant_init(MODE_HRM); } else { //cycling sports_type = SPORTS_DATA_FLAG_BIKE; set_mode(DATA_MODE_BIKING); //ant_init(MODE_CBSC); } rtc_enablechange(SECOND_CHANGE); cleanUpSportsWatchData(); ui_config* config = window_readconfig(); sportnum = config->sports_grid + 4; add_watch_status(WS_SPORTS); ble_start_sync(2, get_mode()); return 0x80; // disable status } case EVENT_SPORT_DATA: { //printf("got a sport data \n"); updateData(lparam, (uint32_t)rparam); break; } case EVENT_TIME_CHANGED: { workout_time++; updateData(SPORTS_TIME, workout_time); if (upload_data_interval > 0 && workout_time % upload_data_interval == 0) { ui_config* config = window_readconfig(); sportnum = config->sports_grid + 4; //STLV over RFCOMM send_sports_data(0, sports_type | SPORTS_DATA_FLAG_START, config->sports_grid_data, grid_data, sportnum); //BLE ble_send_sports_data(grid_data, 5); } if (workout_time % save_data_interval == 0 && (get_mode() & DATA_MODE_PAUSED) != 0) { saveSportsData(); } break; } case EVENT_WINDOW_PAINT: { tContext *pContext = (tContext*)rparam; GrContextForegroundSet(pContext, ClrBlack); GrRectFill(pContext, &fullscreen_clip); GrContextForegroundSet(pContext, ClrWhite); onDraw(pContext); break; } case EVENT_WINDOW_CLOSING: { rtc_enablechange(0); #if PRODUCT_W001 ant_shutdown(); #endif uint8_t dummy_stlv_meta = 0; uint32_t dummy_stlv_data = 0; send_sports_data(0, sports_type | SPORTS_DATA_FLAG_STOP, &dummy_stlv_meta, &dummy_stlv_data, 1); saveSportsData(); ble_stop_sync(); set_mode(DATA_MODE_NORMAL); del_watch_status(WS_SPORTS); break; } default: return 0; } return 1; }
DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands) { out2 = &out; *out2 << "TWBT: version " << TWBT_VER << std::endl; int mode = get_mode(); if (!mode) { *out2 << COLOR_RED << "TWBT: set PRINT_MODE to TWBT in data/init/init.txt to activate the plugin" << std::endl; *out2 << COLOR_RESET; return CR_OK; } if (mode == 1) { #ifdef LEGACY_MODE_ONLY *out2 << COLOR_RED << "TWBT: falling back to legacy mode with this version of DF" << std::endl; *out2 << COLOR_RESET; mode = -1; #else #ifdef NO_RENDERING_PATCH *out2 << "TWBT: no rendering patch (not an error)" << std::endl; #endif #ifdef NO_DISPLAY_PATCH *out2 << "TWBT: no display patch (not an error)" << std::endl; #endif #endif } legacy_mode = (mode == -1); #ifdef WIN32 _load_multi_pdim = (LOAD_MULTI_PDIM) (A_LOAD_MULTI_PDIM + Core::getInstance().vinfo->getRebaseDelta()); _render_map = (RENDER_MAP) (A_RENDER_MAP + Core::getInstance().vinfo->getRebaseDelta()); _render_updown = (RENDER_UPDOWN) (A_RENDER_UPDOWN + Core::getInstance().vinfo->getRebaseDelta()); #elif defined(__APPLE__) _load_multi_pdim = (LOAD_MULTI_PDIM) A_LOAD_MULTI_PDIM; _render_map = (RENDER_MAP) A_RENDER_MAP; _render_updown = (RENDER_UPDOWN) A_RENDER_UPDOWN; #else _load_multi_pdim = (LOAD_MULTI_PDIM) dlsym(RTLD_DEFAULT, "_ZN8textures15load_multi_pdimERKSsPlllbS2_S2_"); _render_map = (RENDER_MAP) A_RENDER_MAP; _render_updown = (RENDER_UPDOWN) A_RENDER_UPDOWN; #endif bad_item_flags.whole = 0; bad_item_flags.bits.in_building = true; bad_item_flags.bits.garbage_collect = true; bad_item_flags.bits.removed = true; bad_item_flags.bits.dead_dwarf = true; bad_item_flags.bits.murder = true; bad_item_flags.bits.construction = true; bad_item_flags.bits.in_inventory = true; bad_item_flags.bits.in_chest = true; // Used only if rendering patch is not available skytile = d_init->sky_tile; chasmtile = d_init->chasm_tile; struct stat buf; if (stat("data/art/white1px.png", &buf) == 0) { long dx, dy; load_tileset("data/art/white1px.png", &white_texpos, 1, 1, &dx, &dy); } else { *out2 << COLOR_RED << "TWBT: data/art/white1px.png not found, can not continue" << std::endl; *out2 << COLOR_RESET; return CR_FAILURE; } if (stat("data/art/transparent1px.png", &buf) == 0) { long dx, dy; load_tileset("data/art/transparent1px.png", &transparent_texpos, 1, 1, &dx, &dy); } else { *out2 << COLOR_RED << "TWBT: data/art/transparent1px.png not found, can not continue" << std::endl; *out2 << COLOR_RESET; return CR_FAILURE; } if (init->display.flag.is_set(init_display_flags::USE_GRAPHICS)) { // Graphics is enabled. Map tileset is already loaded, so use it. Then load text tileset. // Existing map tileset - accessible at index 0 struct tileset ts; memcpy(ts.small_texpos, init->font.small_font_texpos, sizeof(ts.small_texpos)); tilesets.push_back(ts); // We will replace init->font with text font, so let's save graphics tile size small_map_dispx = init->font.small_font_dispx, small_map_dispy = init->font.small_font_dispy; has_textfont = load_text_font(); if (!has_textfont) tilesets.push_back(tilesets[0]); } else { // Graphics is disabled. Text tileset is already loaded. Load map tileset. has_textfont = load_map_font(); // Existing text tileset - accessible at index 1 if (has_textfont) { struct tileset ts; memcpy(ts.small_texpos, init->font.small_font_texpos, sizeof(ts.small_texpos)); tilesets.push_back(ts); } else tilesets.push_back(tilesets[0]); } init_text_tileset_layers(); if (!has_textfont) { *out2 << COLOR_YELLOW << "TWBT: FONT and GRAPHICS_FONT are the same" << std::endl; *out2 << COLOR_RESET; } has_overrides = load_overrides(); // Load shadows if (stat("data/art/shadows.png", &buf) == 0) { long dx, dy; load_tileset("data/art/shadows.png", shadow_texpos, 8, 1, &dx, &dy); shadowsloaded = true; } else { *out2 << COLOR_RED << "TWBT: data/art/shadows.png not found, shadows will not be rendered" << std::endl; *out2 << COLOR_RESET; } map_texpos = tilesets[0].small_texpos; text_texpos = tilesets[1].small_texpos; commands.push_back(PluginCommand( "mapshot", "Mapshot!", mapshot_cmd, true, "" )); commands.push_back(PluginCommand( "multilevel", "Multi-level rendering", multilevel_cmd, false, "" )); commands.push_back(PluginCommand( "colormap", "Colomap manipulation", colormap_cmd, false, "" )); commands.push_back(PluginCommand( "twbt", "Text Will Be Text", twbt_cmd, false, "" )); if (!legacy_mode) { replace_renderer(); INTERPOSE_HOOK(dwarfmode_hook, render).apply(true); INTERPOSE_HOOK(dwarfmode_hook, logic).apply(true); INTERPOSE_HOOK(dwarfmode_hook, feed).apply(true); INTERPOSE_HOOK(viewscreen_unitlistst_zoomfix, feed).apply(true); INTERPOSE_HOOK(viewscreen_buildinglistst_zoomfix, feed).apply(true); INTERPOSE_HOOK(viewscreen_layer_unit_relationshipst_zoomfix, feed).apply(true); INTERPOSE_HOOK(dungeonmode_hook, render).apply(true); INTERPOSE_HOOK(dungeonmode_hook, logic).apply(true); INTERPOSE_HOOK(dungeonmode_hook, feed).apply(true); enable_building_hooks(); enable_item_hooks(); enable_unit_hooks(); } else { hook_legacy(); INTERPOSE_HOOK(dwarfmode_hook_legacy, render).apply(true); } return CR_OK; }
/*Create file type sub dirs, can get tricky when multiple types use one extraction algorithm (OLE)*/ int create_sub_dirs(f_state *s) { int i = 0; int j = 0; char dir_name[MAX_STRING_LENGTH]; char ole_types[7][4] = { "ppt", "doc", "xls", "sdw", "mbd", "vis", "ole" }; char riff_types[2][4] = { "avi", "wav" }; char zip_types[8][5] = { "sxc", "sxw", "sxi", "sx", "jar","docx","pptx","xlsx" }; for (i = 0; i < s->num_builtin; i++) { memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, search_spec[i].suffix); make_new_directory(s, dir_name); if (search_spec[i].type == OLE) { for (j = 0; j < 7; j++) { if (strstr(ole_types[j], search_spec[i].suffix)) continue; memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, ole_types[j]); make_new_directory(s, dir_name); } } else if (get_mode(s, mode_write_all)) { for (j = 0; j < 7; j++) { if (strstr(search_spec[i].suffix, ole_types[j])) { for (j = 0; j < 7; j++) { if (strstr(ole_types[j], search_spec[i].suffix)) continue; memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, ole_types[j]); make_new_directory(s, dir_name); } break; } } } if (search_spec[i].type == EXE) { memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, "dll"); make_new_directory(s, dir_name); } if (search_spec[i].type == RIFF) { for (j = 0; j < 2; j++) { if (strstr(ole_types[j], search_spec[i].suffix)) continue; memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, riff_types[j]); make_new_directory(s, dir_name); } } else if (get_mode(s, mode_write_all)) { for (j = 0; j < 2; j++) { if (strstr(search_spec[i].suffix, riff_types[j])) { for (j = 0; j < 2; j++) { if (strstr(ole_types[j], search_spec[i].suffix)) continue; memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, riff_types[j]); make_new_directory(s, dir_name); } break; } } } if (search_spec[i].type == ZIP) { for (j = 0; j < 8; j++) { if (strstr(ole_types[j], search_spec[i].suffix)) continue; memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, zip_types[j]); make_new_directory(s, dir_name); } } else if (get_mode(s, mode_write_all)) { for (j = 0; j < 8; j++) { if (strstr(search_spec[i].suffix, zip_types[j])) { for (j = 0; j < 5; j++) { if (strstr(ole_types[j], search_spec[i].suffix)) continue; memset(dir_name, 0, MAX_STRING_LENGTH - 1); strcpy(dir_name, get_output_directory(s)); strcat(dir_name, "/"); strcat(dir_name, zip_types[j]); make_new_directory(s, dir_name); } break; } } } } return TRUE; }
static int queue_diff(struct diff_options *o, const char *name1, const char *name2) { int mode1 = 0, mode2 = 0; if (get_mode(name1, &mode1) || get_mode(name2, &mode2)) return -1; if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) return error("file/directory conflict: %s, %s", name1, name2); if (S_ISDIR(mode1) || S_ISDIR(mode2)) { struct strbuf buffer1 = STRBUF_INIT; struct strbuf buffer2 = STRBUF_INIT; struct string_list p1 = STRING_LIST_INIT_DUP; struct string_list p2 = STRING_LIST_INIT_DUP; int i1, i2, ret = 0; size_t len1 = 0, len2 = 0; if (name1 && read_directory_contents(name1, &p1)) return -1; if (name2 && read_directory_contents(name2, &p2)) { string_list_clear(&p1, 0); return -1; } if (name1) { strbuf_addstr(&buffer1, name1); if (buffer1.len && buffer1.buf[buffer1.len - 1] != '/') strbuf_addch(&buffer1, '/'); len1 = buffer1.len; } if (name2) { strbuf_addstr(&buffer2, name2); if (buffer2.len && buffer2.buf[buffer2.len - 1] != '/') strbuf_addch(&buffer2, '/'); len2 = buffer2.len; } for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) { const char *n1, *n2; int comp; strbuf_setlen(&buffer1, len1); strbuf_setlen(&buffer2, len2); if (i1 == p1.nr) comp = 1; else if (i2 == p2.nr) comp = -1; else comp = strcmp(p1.items[i1].string, p2.items[i2].string); if (comp > 0) n1 = NULL; else { strbuf_addstr(&buffer1, p1.items[i1++].string); n1 = buffer1.buf; } if (comp < 0) n2 = NULL; else { strbuf_addstr(&buffer2, p2.items[i2++].string); n2 = buffer2.buf; } ret = queue_diff(o, n1, n2); } string_list_clear(&p1, 0); string_list_clear(&p2, 0); strbuf_release(&buffer1); strbuf_release(&buffer2); return ret; } else { struct diff_filespec *d1, *d2; if (DIFF_OPT_TST(o, REVERSE_DIFF)) { unsigned tmp; const char *tmp_c; tmp = mode1; mode1 = mode2; mode2 = tmp; tmp_c = name1; name1 = name2; name2 = tmp_c; } d1 = noindex_filespec(name1, mode1); d2 = noindex_filespec(name2, mode2); diff_queue(&diff_queued_diff, d1, d2); return 0; } }
IDL4_INLINE CORBA_long file_open_implementation(CORBA_Object _caller, CORBA_long objID, CORBA_long mode, idl4_server_environment *_env) { int inactive_fcb=0; int fcbNummer=0; int temp =0; int inode_type; if (!mounted) return ESUPP; // test objID (directory or regular file) temp = get_mode(objID); inode_type = temp & 0x3f000; //Mask last 4 Octals if (inode_type==0x04000){ inode_type=DIRECTORY; } else{ if (inode_type==0x08000){ inode_type=FILE; } else{ return ESUPP; } } // printf("Finding inactive FCB \n"); // finding inactive while(fcbNummer<(MAXFCB-1)){ if (fcbTable[fcbNummer].active==0){ inactive_fcb=1; break; } else fcbNummer++; } // if exist inactive fcb - set fcb if (inactive_fcb==1){ // printf("the inactive fcbnumber is : %X\n", fcbNummer); int file_length = get_length(objID); // length of the file fcbTable[fcbNummer].taskID=_caller; fcbTable[fcbNummer].objID=(int)objID; fcbTable[fcbNummer].position=0; fcbTable[fcbNummer].mode=(int)mode; fcbTable[fcbNummer].inode_type=inode_type; fcbTable[fcbNummer].active=1; fcbTable[fcbNummer].file_length=file_length; if (inode_type==DIRECTORY){ char *buffer; read(objID,0,file_length,&buffer); // parsing buffer ext2_dir_entry *parse; parse = (ext2_dir_entry*)buffer; int count = 0; char *dirptr = &fcbTable[fcbNummer].dir_buffer[0]; int count_length=0; while (count <file_length){ strncpy(dirptr,parse->name,parse->name_length&0xFF); count_length += (parse->name_length&0xFF)+1; count += (int)parse->rec_length; dirptr+=(parse->name_length&0xFF)+1; parse=(ext2_dir_entry*)(((char*)parse)+parse->rec_length); // really fine pointer arithmetic } fcbTable[fcbNummer].file_length=count_length-1; //setting the parsed size minus one zero } } else return EAGAIN; return ESUCCESS; // file is open }
void daemonize(void) { int v_ret; pid_t v_pid; char v_name[128]; char v_buf[512]; struct inotify_event iev; struct sigaction actions; v_pid = fork(); if(v_pid > 0) { exit(0); } sprintf(v_buf,"emw820w_tool (%s) daemonizing ...\n", g_vers); logging(ANDROID_LOG_ERROR, v_buf); g_loop=1; close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); memset(&actions, 0, sizeof(actions)); sigemptyset(&actions.sa_mask); actions.sa_flags = 0; actions.sa_handler = sighdl; sigaction(SIGTERM,& actions, NULL); g_ifd = inotify_init(); if(g_ifd < 0) { sprintf(v_buf,"inotify_init() error %d\n", errno); logging(ANDROID_LOG_ERROR, v_buf); exit(1); } logging(ANDROID_LOG_DEBUG, "entering watchdog mode ...\n"); if(get_mode() != 1404) { set_1404(); sleep(2); } read_val("/sys/bus/usb/devices/1-1/power/autosuspend", g_curval); while(g_loop == 1) { getport(v_name); g_wfd = inotify_add_watch(g_ifd, v_name, IN_DELETE_SELF); if(g_wfd < 0) { sprintf(v_buf,"watchdog: inotify_add_watch() error %d\n", errno); logging(ANDROID_LOG_ERROR, v_buf); sleep(2); } else { sprintf(v_buf,"watchdog for %s initialized\n", v_name); logging(ANDROID_LOG_DEBUG, v_buf); iev.mask = 0; while(iev.mask != IN_DELETE_SELF) { v_ret=read(g_ifd, &iev, sizeof(iev)); if(g_loop == 0) { break; } } v_ret = inotify_rm_watch(g_ifd, g_wfd); if(g_loop == 1) { sleep(5); if((v_ret = get_mode()) != 1404) { logging(ANDROID_LOG_DEBUG,"3G crash detected!\n"); logging(ANDROID_LOG_DEBUG,"activating wakelock\n"); v_ret = write_val("/sys/power/wake_lock", "em820w_tool\n"); while (v_ret != 1404) { set_1404(); sleep(10); v_ret = get_mode(); } logging(ANDROID_LOG_DEBUG,"deactivating wakelock\n"); v_ret = write_val("/sys/power/wake_unlock", "em820w_tool\n"); } sleep(2); } } } logging(ANDROID_LOG_DEBUG,"exiting...\n"); close(g_wfd); close(g_ifd); exit(0); }
void fichier_local::open(const string & chemin, gf_mode m, U_I permission, bool fail_if_exists, bool erase, bool furtive_mode) { U_I o_mode = O_BINARY; const char *name = chemin.c_str(); adv = advise_normal; switch(m) { case gf_read_only : o_mode |= O_RDONLY; break; case gf_write_only : o_mode |= O_WRONLY; break; case gf_read_write : o_mode |= O_RDWR; break; default: throw SRC_BUG; } if(m != gf_read_only) { o_mode |= O_CREAT; if(fail_if_exists) o_mode |= O_EXCL; if(erase) o_mode |= O_TRUNC; } #if FURTIVE_READ_MODE_AVAILABLE if(furtive_mode) // only used for read-only, but available for write-only and read-write modes o_mode |= O_NOATIME; #else if(furtive_mode) throw Ecompilation(gettext("Furtive read mode")); #endif try { do { if(m != gf_read_only) filedesc = ::open(name, o_mode, permission); else filedesc = ::open(name, o_mode); if(filedesc < 0) { switch(errno) { case ENOSPC: if(get_mode() == gf_read_only) throw SRC_BUG; // in read_only mode we do not need to create a new inode !!! get_ui().pause(gettext("No space left for inode, you have the opportunity to make some room now. When done : can we continue ?")); break; case EEXIST: throw Esystem("fichier_local::open", tools_strerror_r(errno), Esystem::io_exist); case ENOENT: throw Esystem("fichier_local::open", tools_strerror_r(errno), Esystem::io_absent); default: throw Erange("fichier_local::open", string(gettext("Cannot open file : ")) + tools_strerror_r(errno)); } } } while(filedesc < 0 && errno == ENOSPC); } catch(...) { if(filedesc >= 0) { ::close(filedesc); filedesc = -1; } throw; } }
static void read_all_data(DATA **data, DATA *valdata, int n_vars) { int i; DATA *area; init_data_minmax(); area = get_data_area(); for (i = 0; i < n_vars; i++) { if (get_mode() == STRATIFY) printlog("stratum # %d:\n", i + strata_min); printlog("data(%s): ", name_identifier(i)); if (data[i]->id < 0) { message("data(%s) was not specified\n", name_identifier(i)); ErrMsg(ER_SYNTAX, "data specification error"); } read_gstat_data(data[i]); report_data(data[i]); } /* for i */ /* * what to do when area is specified, but no masks or data()? * default prediction to `area'. Create a valdata with one point at * centre of area (for select()); and centre area at (0,0,0) */ if (area && get_n_masks() <= 0 && valdata->id == -1) { valdata->id = ID_OF_VALDATA; valdata->centre = area->centre = 1; } /* * read data() data: */ if (valdata->id > -1) { setup_valdata_X(valdata); if (! valdata->centre) valdata = read_gstat_data(valdata); } /* * read area, if existed */ if (area != NULL && get_method() != POLY) { read_gstat_data(area); /* now, before centring area: */ if (valdata->centre) valdata = get_area_centre(area, valdata); if (area->centre) centre_area(area); printlog("area:%s\n", area->centre ? " (centred around 0)" : ""); report_data(area); if (DEBUG_DATA) print_data_list(area); } /* * read edges, if existed */ if (get_n_edges() > 0) { read_edges(); report_edges(); /* setup_visibility_graph(); */ /*setup_planar_subdivisions();*/ } /* * setup and report data */ if (valdata->id > -1) { printlog("data():%s ", valdata->centre ? " [at area centre]" : ""); report_data(valdata); } for (i = 0; i < n_vars; i++) setup_data_minmax(data[i]); if (valdata->id > -1) setup_data_minmax(valdata); for (i = 0; i < n_vars; i++) calc_polynomials(data[i]); if (valdata->id > -1) calc_polynomials(valdata); if (DEBUG_DATA) { for (i = 0; i < n_vars; i++) print_data_list(data[i]); if (valdata->id > -1) print_data_list(valdata); } }
void set_1404(void) { char v_rilsvc[] = "ril-daemon"; char *p_rilsvc = v_rilsvc; char p_name[64]; char v_buf[1024]; int v_ret; int v_max = 0; if(get_mode() == 1404) { logging(ANDROID_LOG_DEBUG, "modem already has USB-PID 1404!\n"); return; } if(g_svc != '\0') { p_rilsvc = g_svc; } logging(ANDROID_LOG_WARN, "setting modem to USB-PID 1404 ...\n"); // v_ret = write_val("/sys/bus/usb/devices/usb1/power/control", "on\n"); if(g_kill == 0) { sprintf(v_buf, "stopping service %s ...\n", p_rilsvc); logging(ANDROID_LOG_DEBUG, v_buf); property_set("ctl.stop", p_rilsvc); } v_ret = write_val("/sys/EcControl/ThreeGPower", "0\n"); v_max = 10; getport(p_name); while(p_name != NULL && v_max > 0) { getport(p_name); v_max--; sleep(1); } v_ret = write_val("/sys/EcControl/ThreeGPower", "1\n"); v_max = 10; getport(p_name); while(p_name == NULL && v_max > 0) { getport(p_name); v_max--; sleep(1); } v_max=0; while(get_mode() != 1404 && v_max < 5) { v_ret = write_val("/sys/bus/usb/devices/usb1/power/control", "on\n"); sleep(1 + v_max); v_max++; } v_ret = write_val("/sys/bus/usb/devices/1-1/power/autosuspend", "2\n"); v_ret = write_val("/sys/bus/usb/devices/1-1/power/control", "on\n"); v_ret = write_val("/sys/bus/usb/devices/1-1/power/wakeup", "enabled\n"); v_ret = write_val("/sys/bus/usb/devices/usb1/power/control", "auto\n"); if(strlen(g_curval) > 0) { v_ret = write_val("/sys/bus/usb/devices/1-1/power/autosuspend", g_curval); } else { v_ret = write_val("/sys/bus/usb/devices/1-1/power/autosuspend", "2\n"); } /* sleep(5); v_max=0; while(get_mode() != 1404 && v_max < 5) { v_ret = write_val("/sys/bus/usb/devices/usb1/power/control", "on\n"); sleep(1 + v_max); v_max++; } */ if(g_kill == 0) { sprintf(v_buf, "starting service %s ...\n", p_rilsvc); logging(ANDROID_LOG_DEBUG, v_buf); property_set("ctl.start", p_rilsvc); } else { logging(ANDROID_LOG_DEBUG, "killing rild...\n"); system("killall rild"); } if(get_mode() == 1404) { logging(ANDROID_LOG_WARN, "Modem was set to USB-PID 1404 successfuly\n"); } else { logging(ANDROID_LOG_ERROR, "ERROR! Modem was not set to USB-PID 1404\n"); } }
pstring::~pstring() { if ( get_mode(PERSISTENT) == false && NULL != v_str_ptr.p ) delete v_str_ptr.p; }
int main(void) { int result; int done, op; result = SusiDllInit(); if (result == FALSE) { printf("SusiDllInit() failed\n"); return 1; } result = SusiCoreAvailable(); if (result == 0) { printf("SusiCoreAvailable() failed\n"); SusiDllUnInit(); return 1; } show_platform_info(); result = SusiPlusSpeedSetActive(); if (result != 0) { printf("SusiPlusSpeedSetActive() failed\n"); printf("CPU or OS does not support speedstep!!\n"); SusiDllUnInit(); return 1; } done = 0; while (! done) { show_menu(); if (scanf("%i", &op) <= 0) op = -1; switch (op) { case 0: done = 1; continue; case 1: result = get_mode(); break; case 2: result = set_mode(); break; default: printf("\nUnknown choice!\n\n"); continue; } if (result != 0) { SusiDllUnInit(); return 1; } } result = SusiPlusSpeedSetInactive(); if (result != 0) { printf("SusiPlusSpeedSetInactive() failed\n"); SusiDllUnInit(); return 1; } result = SusiDllUnInit(); if (result == FALSE) { printf("SusiDllUnInit() failed\n"); return 1; } return 0; }
int main(int argc, char *argv[]) { /* options */ char *section = NULL; int nfragments = GFARM_FILE_DONTCARE; /* -1, actually */ char *hostname = NULL; char *hostfile = NULL; char *domainname = NULL; char *e, *gfarm_url, *file_mode_arg; gfarm_mode_t file_mode = DEFAULT_FILE_MODE; int c, i, is_dir, index; struct gfs_stat gs; e = gfarm_initialize(&argc, &argv); if (e != NULL) { fprintf(stderr, "%s: %s\n", program_name, e); exit(EXIT_FAILURE); } /* Command options */ while ((c = getopt(argc, argv, "a:fh:D:I:N:?")) != -1) { switch (c) { case 'I': case 'a': section = optarg; break; case 'N': nfragments = strtol(optarg, NULL, 0); break; case 'h': hostname = optarg; break; case 'D': domainname = optarg; break; case 'f': opt_force = 1; break; case '?': default: usage(); } } argc -= optind; argv += optind; if (argc == 0) { fprintf(stderr, "%s: missing a local filename\n", program_name); usage(); } if (argc == 1) { fprintf(stderr, "%s: missing a Gfarm URL\n", program_name); usage(); } gfarm_url = argv[argc - 1]; --argc; if (!gfarm_is_url(gfarm_url)) { fprintf(stderr, "%s: %s: %s\n", program_name, gfarm_url, GFARM_ERR_GFARM_URL_PREFIX_IS_MISSING); exit(EXIT_FAILURE); } c = 0; if (hostname != NULL) c++; if (hostfile != NULL) c++; if (domainname != NULL) c++; if (c > 1) { fprintf(stderr, "%s: more than one options are specified " "from -h, -H and -D\n", program_name); usage(); } /* * distinguish which mode is specified: * 1. program mode: * gfreg [-h <hostname>] [-a <architecture>] \ * <local-program>... <gfarm-URL> * 2. auto index mode: * gfreg [-h <hostname>] [-H <hostfile>] [-D <domainname>] \ * <local-file>... <gfarm-URL> * 3. fragment mode: * gfreg [-h <hostname>] [-N <nfragments>] -I <index> \ * <local-file>... <gfarm-URL> */ e = gfs_stat(gfarm_url, &gs); if (e == GFARM_ERR_NO_SUCH_OBJECT) { is_dir = 0; file_mode_arg = NULL; } else if (e != NULL) { fprintf(stderr, "%s: %s: %s\n", program_name, gfarm_url, e); exit(EXIT_FAILURE); } else { if (GFARM_S_ISREG(gs.st_mode)) { is_dir = 0; file_mode_arg = gfarm_url; file_mode = gs.st_mode; } else if (GFARM_S_ISDIR(gs.st_mode)) { is_dir = 1; file_mode_arg = NULL; } else { /* defensive programming. this shouldn't happen. */ fprintf(stderr, "%s: %s: unknown file type\n", program_name, gfarm_url); exit(EXIT_FAILURE); } gfs_stat_free(&gs); } c = 0; /* count of "-" in the arguments */ if (hostfile != NULL && strcmp(hostfile, STDIN_FILENAME) == 0) ++c; for (i = 0; i < argc; i++) { int fd, fd_needs_close; gfarm_mode_t m; if (!open_file(argv[i], &fd, &fd_needs_close)) exit(EXIT_FAILURE); if (!get_mode(fd, argv[i], &m)) exit(EXIT_FAILURE); if (S_ISREG(m)) { if (file_mode_arg == NULL) { /* * NOTE: this mode may be used for the mode * to create the gfarm file. */ file_mode_arg = argv[i]; file_mode = m & FILE_MODE_MASK; } if (((m & 0111) != 0) != ((file_mode & 0111) != 0)) { fprintf(stderr, "%s: program and non-program are mixed in " "%s and %s\n", program_name, file_mode_arg, argv[i]); exit(EXIT_FAILURE); } } else if (fd_needs_close) { /* if it's "-", allow non-file (e.g. pipe) */ fprintf(stderr, "%s: %s: not a regular file\n", program_name, argv[i]); exit(EXIT_FAILURE); } if (fd_needs_close) { close(fd); } else if (++c > 1) { fprintf(stderr, "%s: `-' (stdin) is specified " "multiple times\n", program_name); exit(EXIT_FAILURE); } } if ((file_mode & 0111) != 0) { /* * program mode */ int section_alloced = 0; if (!is_dir && argc != 1) { fprintf(stderr, "%s: only one file can be specified to" " register the gfarm program `%s'\n", program_name, gfarm_url); exit(EXIT_FAILURE); } if (hostfile != NULL || domainname != NULL) { fprintf(stderr, "%s: cannot use -%c to register programs\n", program_name, hostfile != NULL ? 'H' : 'D'); exit(EXIT_FAILURE); } if (nfragments != GFARM_FILE_DONTCARE) { /* * XXX - call gfarm_url_replicate() to replicate * `nfragments' copies of gfarm_url:section? */ fprintf(stderr, "%s: warning: option -N is currently ignored\n", program_name); } if (section != NULL) { ; } else if (hostname != NULL) { char *canonical; e = gfarm_host_get_canonical_name(hostname, &canonical); if (e != NULL) { if (e == GFARM_ERR_NO_SUCH_OBJECT) e = "not a filesystem node"; fprintf(stderr, "%s: host %s: %s\n", program_name, hostname, e); exit(EXIT_FAILURE); } section_alloced = 1; section = gfarm_host_info_get_architecture_by_host( canonical); free(canonical); if (section == NULL) { fprintf(stderr, "%s: %s\n", program_name, GFARM_ERR_NO_MEMORY); exit(EXIT_FAILURE); } } else if (gfarm_host_get_self_architecture(§ion) != NULL){ fprintf(stderr, "%s: missing -a option\n", program_name); exit(EXIT_FAILURE); } for (i = 0; i < argc; i++) { register_program(is_dir, gfarm_url, section, hostname, argv[i], file_mode_arg == gfarm_url || file_mode_arg == argv[i], file_mode); } if (section_alloced) free(section); } else if (section != NULL || gfs_pio_get_node_rank(&index) == NULL) { /* * fragment mode */ if (section != NULL) index = strtol(section, NULL, 0); else if (nfragments == GFARM_FILE_DONTCARE) gfs_pio_get_node_size(&nfragments); if (!is_dir && argc != 1) { fprintf(stderr, "%s: only one file can be specified to" " register a fragment %s of the gfarm file `%s'\n", program_name, section, gfarm_url); exit(EXIT_FAILURE); } if (hostfile != NULL || domainname != NULL) { fprintf(stderr, "%s: cannot use -%c with -I\n", program_name, hostfile != NULL ? 'H' : 'D'); exit(EXIT_FAILURE); } for (i = 0; i < argc; i++) { register_fragment(is_dir, gfarm_url, index, nfragments, hostname, argv[i], file_mode_arg == gfarm_url || file_mode_arg == argv[i], file_mode); } } else { /* * auto index mode */ char **hosts = NULL; if (nfragments == GFARM_FILE_DONTCARE) nfragments = argc; if (nfragments != argc) { fprintf(stderr, "%s: local file number %d " "doesn't match with -N %d\n", program_name, argc, nfragments); exit(EXIT_FAILURE); } if (is_dir && nfragments > 1) { fprintf(stderr, "%s: cannot determine the file name " "under the directory %s, " "because multiple local file names are specifed\n", program_name, gfarm_url); exit(EXIT_FAILURE); } if (hostname != NULL) { ; } else if (hostfile != NULL) { int nhosts, error_line; e = gfarm_hostlist_read(hostfile, &nhosts, &hosts, &error_line); if (e != NULL) { if (error_line != -1) fprintf(stderr, "%s: %s line %d: %s\n", program_name, hostfile, error_line, e); else fprintf(stderr, "%s: %s: %s\n", program_name, hostfile, e); exit(EXIT_FAILURE); } } else { hosts = malloc(sizeof(*hosts) * nfragments); if (hosts == NULL) { fprintf(stderr, "%s: %s\n", program_name, GFARM_ERR_NO_MEMORY); exit(EXIT_FAILURE); } if (domainname != NULL) e = gfarm_schedule_search_idle_by_domainname( domainname, nfragments, hosts); else e = gfarm_schedule_search_idle_by_all( nfragments, hosts); if (e != NULL) { fprintf(stderr, "%s: selecting filesystem nodes: %s\n", program_name, e); exit(EXIT_FAILURE); } } /* XXX - need to register in parallel? */ for (i = 0; i < argc; i++) { register_fragment(is_dir, gfarm_url, i, nfragments, hostname != NULL ? hostname : hosts[i], argv[i], 1, file_mode); } if (hostname == NULL) gfarm_strings_free_deeply(nfragments, hosts); } e = gfarm_terminate(); if (e != NULL) { fprintf(stderr, "%s: %s\n", program_name, e); exit(EXIT_FAILURE); } exit(error_happened); }
static void wpa_obss_scan_freqs_list(struct wpa_supplicant *wpa_s, struct wpa_driver_scan_params *params) { /* Include only affected channels */ struct hostapd_hw_modes *mode; int count, i; int start, end; mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, HOSTAPD_MODE_IEEE80211G); if (mode == NULL) { /* No channels supported in this band - use empty list */ params->freqs = os_zalloc(sizeof(int)); return; } if (wpa_s->sme.ht_sec_chan == HT_SEC_CHAN_UNKNOWN && wpa_s->current_bss) { const u8 *ie; ie = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_HT_OPERATION); if (ie && ie[1] >= 2) { u8 o; o = ie[3] & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK; if (o == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE) wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_ABOVE; else if (o == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW) wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_BELOW; } } start = wpa_s->assoc_freq - 10; end = wpa_s->assoc_freq + 10; switch (wpa_s->sme.ht_sec_chan) { case HT_SEC_CHAN_UNKNOWN: /* HT40+ possible on channels 1..9 */ if (wpa_s->assoc_freq <= 2452) start -= 20; /* HT40- possible on channels 5-13 */ if (wpa_s->assoc_freq >= 2432) end += 20; break; case HT_SEC_CHAN_ABOVE: end += 20; break; case HT_SEC_CHAN_BELOW: start -= 20; break; } wpa_printf(MSG_DEBUG, "OBSS: assoc_freq %d possible affected range %d-%d", wpa_s->assoc_freq, start, end); params->freqs = os_calloc(mode->num_channels + 1, sizeof(int)); if (params->freqs == NULL) return; for (count = 0, i = 0; i < mode->num_channels; i++) { int freq; if (mode->channels[i].flag & HOSTAPD_CHAN_DISABLED) continue; freq = mode->channels[i].freq; if (freq - 10 >= end || freq + 10 <= start) continue; /* not affected */ params->freqs[count++] = freq; } }
void chown_advanced_cmd (void) { /* Number of files at startup */ int files_on_begin; files_on_begin = MAX (1, current_panel->marked); do { /* do while any files remaining */ int file_idx; char buffer[BUF_MEDIUM]; vfs_path_t *vpath; int result; init_chown_advanced (); if (current_panel->marked) fname = next_file (); /* next marked file */ else fname = selection (current_panel)->fname; /* single file */ vpath = vfs_path_from_str (fname); if (mc_stat (vpath, sf_stat) != 0) { /* get status of file */ dlg_destroy (ch_dlg); vfs_path_free (vpath); break; } ch_cmode = sf_stat->st_mode; file_idx = files_on_begin == 1 ? 1 : (files_on_begin - current_panel->marked + 1); g_snprintf (buffer, sizeof (buffer), "%s (%d/%d)", str_fit_to_term (fname, WIDGET (ch_dlg)->cols - 20, J_LEFT_FIT), file_idx, files_on_begin); label_set_text (l_filename, buffer); chown_refresh (); update_ownership (); result = dlg_run (ch_dlg); switch (result) { case B_CANCEL: end_chown = TRUE; break; case B_ENTER: need_update = TRUE; if (mc_chmod (vpath, get_mode ()) == -1) message (D_ERROR, MSG_ERROR, _("Cannot chmod \"%s\"\n%s"), fname, unix_error_string (errno)); /* call mc_chown only, if mc_chmod didn't fail */ else if (mc_chown (vpath, (ch_flags[9] == '+') ? sf_stat->st_uid : (uid_t) (-1), (ch_flags[10] == '+') ? sf_stat->st_gid : (gid_t) (-1)) == -1) message (D_ERROR, MSG_ERROR, _("Cannot chown \"%s\"\n%s"), fname, unix_error_string (errno)); break; case B_SETALL: apply_advanced_chowns (sf_stat); break; case B_SKIP: default: break; } if (current_panel->marked && result != B_CANCEL) { do_file_mark (current_panel, current_file, 0); need_update = TRUE; } dlg_destroy (ch_dlg); vfs_path_free (vpath); } while (current_panel->marked && !end_chown); chown_advanced_done (); }
void show_mode(void) { printf("current mode >%d<\n", get_mode()); }
int toc_readtoc( WINDOW * win ) { struct _toc_data * data; struct idao_stream * in; const static char * type[] = { "Audio", "Data mode 1", "Data mode 2", "Data" }; long beg, end; int m, s, f; int i, entry, mode; data = DataSearch( win, TW_MAGIC ); if( data == NULL ) { data = new_toc_data( ); if( !data ) return -1; } busybee(); if( toc_popup.selected == 0 ) in = idao_open_file( toc_info.toc_file ); else in = idao_open_cd( toc_popup.item[toc_popup.selected].info ); if( !in ) goto readerr; data->toc = in->toc; /* Analyse de la toc */ entry = get_toc_entry( &data->toc, 0xa1, data->toc.head.last_track ); data->n_tracks = desc( data->toc, entry ).pmin; if( toc_gen_tree( data ) ) goto readerr2; for( i=0; i<data->n_tracks; i++ ) { sprintf( data->f[i].tno, "%2d", i + 1 ); beg = get_track_offset( &data->toc, i + 1, &end ); msf( beg, &m, &s, &f ); sprintf( data->f[i].beg_time, "%02d%02d%02d", m, s, f ); msf( end - 1, &m, &s, &f ); mode = get_mode( &data->toc, i + 1 ); if( mode < 0 ) mode = 3; objc_enable( data->tree, i*data->n_obj + 1 + TF_CK, mode == 0 /*mode != 3*/ ); data->tree[ i*data->n_obj + 1 + TF_TYPE ].ob_spec.free_string = type[ mode ]; sprintf( data->f[i].end_time, "%02d%02d%02d", m, s, f ); data->tree[ i*data->n_obj + 1 + TF_TNO ].ob_spec.free_string = data->f[i].tno; } idao_close( in ); FormAttach( win, data->tree, form_mgr ); DataAttach( win, TW_MAGIC, data ); EvntAttach( win, WM_DESTROY, toc_destroy ); wind_center( win, -1, data->tree->ob_height ); objc_redraw( data->tree, 0 ); arrow(); return 0; readerr2: idao_close( in ); readerr: free( data ); arrow(); alert_msg( "AL_CANTREAD", 1 ); return -1; }