// rtl_init - initialise rtl controller bool Copter::ModeRTL::init(bool ignore_checks) { // initialise waypoint and spline controller wp_nav->wp_and_spline_init(); build_path(!copter.failsafe.terrain); climb_start(); return true; }
std::string AppDirs::get_dirs_config_file(const std::string& dirs_config_file) const { if(!dirs_config_file.empty()) return dirs_config_file; const gchar * conf_file_env = g_getenv("STARDICT_DIRS_CONFIG_FILE"); if(conf_file_env) return conf_file_env; return build_path(get_default_user_config_dir(), "stardict-dirs.cfg"); }
// re-start RTL with terrain following disabled void Copter::ModeRTL::restart_without_terrain() { AP::logger().Write_Error(LogErrorSubsystem::NAVIGATION, LogErrorCode::RESTARTED_RTL); if (rtl_path.terrain_used) { build_path(false); climb_start(); gcs().send_text(MAV_SEVERITY_CRITICAL,"Restarting RTL - Terrain data missing"); } }
/*---------------------------------------------------------------------- Check to see if user is allowed to read or write this folder. Args: s -- the name to check Result: Returns 1 if OK Returns 0 and posts an error message if access is denied ----*/ int context_allowed(char *s) { struct variable *vars = ps_global ? ps_global->vars : NULL; int retval = 1; MAILSTREAM stream; /* fake stream for error message in mm_notify */ if(ps_global && ps_global->restricted && (strindex("./~", s[0]) || srchstr(s, "/../"))){ stream.mailbox = s; mm_notify(&stream, "Restricted mode doesn't allow operation", WARN); retval = 0; } else if(vars && VAR_OPER_DIR && s[0] != '{' && !(s[0] == '*' && s[1] == '{') && strucmp(s,ps_global->inbox_name) != 0 && strcmp(s, ps_global->VAR_INBOX_PATH) != 0){ char *p, *free_this = NULL; p = s; if(strindex(s, '~')){ p = strindex(s, '~'); free_this = (char *)fs_get(strlen(p) + 200); strncpy(free_this, p, strlen(p)+200); fnexpand(free_this, strlen(p)+200); p = free_this; } else if(p[0] != '/'){ /* add home dir to relative paths */ free_this = p = (char *)fs_get(strlen(s) + strlen(ps_global->home_dir) + 2); build_path(p, ps_global->home_dir, s, strlen(s)+strlen(ps_global->home_dir)+2); } if(!in_dir(VAR_OPER_DIR, p)){ char err[200]; /* TRANSLATORS: User is restricted to operating within a certain directory */ snprintf(err, sizeof(err), _("Not allowed outside of %.150s"), VAR_OPER_DIR); stream.mailbox = p; mm_notify(&stream, err, WARN); retval = 0; } else if(srchstr(p, "/../")){ /* check for .. in path */ stream.mailbox = p; mm_notify(&stream, "\"..\" not allowed in name", WARN); retval = 0; } if(free_this) fs_give((void **)&free_this); } return retval; }
// re-start RTL with terrain following disabled void Copter::ModeRTL::restart_without_terrain() { // log an error copter.Log_Write_Error(ERROR_SUBSYSTEM_NAVIGATION, ERROR_CODE_RESTARTED_RTL); if (rtl_path.terrain_used) { build_path(false); climb_start(); gcs().send_text(MAV_SEVERITY_CRITICAL,"Restarting RTL - Terrain data missing"); } }
/* fills buff with the path to the adb vendor id file. returns 0 if success */ int get_adb_usb_ini(char* buff, size_t len) { #ifdef _WIN32 const char* home = getenv("ANDROID_SDK_HOME"); if (home != NULL) { return build_path(buff, len, "%s\\%s\\%s", home); } else { char path[MAX_PATH]; SHGetFolderPath( NULL, CSIDL_PROFILE, NULL, 0, path); return build_path(buff, len, "%s\\%s\\%s", path); } #else const char* home = getenv("HOME"); if (home == NULL) home = "/tmp"; return build_path(buff, len, "%s/%s/%s", home); #endif }
int initialize_pwm(void) { if (!BBB_G(pwm_initialized) && load_device_tree("am33xx_pwm")) { build_path("/sys/devices", "ocp", BBB_G(ocp_dir), sizeof(BBB_G(ocp_dir))); BBB_G(pwm_initialized) = 1; return 1; } return 0; }
static Cube * _cube_new(Evas_Coord w, Evas_Coord h, Evas_Coord d) { Cube *c; int i; w -= (w / 2); h -= (h / 2); d -= (d / 2); c = calloc(1, sizeof(Cube)); for (i = 0; i < 6; i++) { Evas_Object *o; char buf[256]; o = evas_object_image_add(evas); c->side[i].o = o; snprintf(buf, sizeof(buf), "im%i.png", (i % 2) + 1); evas_object_image_file_set(o, build_path(buf), NULL); evas_object_image_fill_set(o, 0, 0, 720, 420); evas_object_resize(o, 720, 420); evas_object_image_smooth_scale_set(o, 0); evas_object_show(o); } POINT(0, 0, -w, -h, -d, 0, 0); POINT(0, 1, w, -h, -d, 720, 0); POINT(0, 2, w, h, -d, 720, 420); POINT(0, 3, -w, h, -d, 0, 420); POINT(1, 0, w, -h, -d, 0, 0); POINT(1, 1, w, -h, d, 720, 0); POINT(1, 2, w, h, d, 720, 420); POINT(1, 3, w, h, -d, 0, 420); POINT(2, 0, w, -h, d, 0, 0); POINT(2, 1, -w, -h, d, 720, 0); POINT(2, 2, -w, h, d, 720, 420); POINT(2, 3, w, h, d, 0, 420); POINT(3, 0, -w, -h, d, 0, 0); POINT(3, 1, -w, -h, -d, 720, 0); POINT(3, 2, -w, h, -d, 720, 420); POINT(3, 3, -w, h, d, 0, 420); POINT(4, 0, -w, -h, d, 0, 0); POINT(4, 1, w, -h, d, 720, 0); POINT(4, 2, w, -h, -d, 720, 420); POINT(4, 3, -w, -h, -d, 0, 420); POINT(5, 0, -w, h, -d, 0, 0); POINT(5, 1, w, h, -d, 720, 0); POINT(5, 2, w, h, d, 720, 420); POINT(5, 3, -w, h, d, 0, 420); return c; }
// Initializes values for a file // @param file a pointer to the file variable // @param client a pointer to the client variable // @param p a linked list node with the file static void initialize_file(file_info *file, client_info *client, csv_record *p) { file->path = build_path(p, client->dir); file->file_length = get_file_length(file->path); file->transfer_threshold = file->file_length * TRANSFER_THRESHOLD_PERCENT; file->file_count = 0; file->packets_in_buffer = 0; file->bytes_sent = 0; file->file_buffer_size = 0; } //end initialize_file
/* Look for existing cgroups and set up the group_dir array. Not MT-safe: call before thread setup. */ void init_cgroups(void) { cgroup_t group; DENTER(TOP_LAYER, "init_cgroups"); for (group = (cgroup_t)0; group < cg_num; group++) { group_dir[group][0] = 0; if (find_cgroup_dir(group, group_dir[group], SGE_PATH_MAX)) /* special treatment for cpuset */ if (cg_cpuset == group) { char path[SGE_PATH_MAX], shortbuf[10]; size_t l = sizeof shortbuf; build_path(path, group_dir[group], "cpuset.mems"); cpuset_prefix = file_exists(path); if (!cpuset_prefix) build_path(path, group_dir[group], "mems"); dev_file2string(path, shortbuf, &l); if (l <= 1) { /* get a newline when it's empty */ WARNING((SGE_EVENT, "Populating "SFN" in " SFN " so cpusets will work", cpuset_prefix ? "cpuset.mems" : "mems", group_dir[group])); copy_from_parent (group_dir[group], "mems"); } build_path(path, group_dir[group], cpuset_prefix ? "cpuset.cpus" : "cpus"); l = sizeof shortbuf; dev_file2string(path, shortbuf, &l); if (l <= 1) { WARNING((SGE_EVENT, "Populating "SFN" in " SFN " so cpusets will work", cpuset_prefix ? "cpuset.mems" : "mems", group_dir[group])); copy_from_parent (group_dir[group], "cpus"); } } } initialized = true; DRETURN_VOID; }
SignViewGump::SignViewGump(Configuration *cfg) : DraggableView(cfg) { font = new BMPFont(); std::string datadir = GUI::get_gui()->get_data_dir(); std::string imagefile; std::string path; build_path(datadir, "images", path); datadir = path; build_path(datadir, "gumps", path); datadir = path; build_path(datadir, "sign", path); datadir = path; build_path(datadir, "sign_font", imagefile); ((BMPFont *)font)->init(imagefile, true); sign_text = NULL; }
std::string AppConf::get_default_export_filename() { std::string exportname; #ifdef _WIN32 exportname = build_path(conf_dirs->get_data_dir(), "dic.txt"); exportname = rel_path_to_data_dir(exportname); #else exportname = g_get_home_dir(); exportname+= G_DIR_SEPARATOR_S "dic.txt"; #endif return exportname; }
static void build_paths(MCExecPoint& ep) { ep . clear(); MCU_path2std(*sg_chosen_folder); if (**sg_chosen_files == '"') { Meta::itemised_string t_items(sg_chosen_files, ' ', true); for(unsigned int t_index = 0; t_index < t_items . count(); ++t_index) { if (t_index != 0) ep.appendnewline(); build_path(ep, *sg_chosen_folder, t_items[t_index]); } } else build_path(ep, *sg_chosen_folder, *sg_chosen_files); sg_chosen_files . clear(); sg_chosen_folder . clear(); }
/* Put PROC (string version of pid) into the controller DIR */ static bool reparent_proc(const char *proc, char *dir) { char path[SGE_PATH_MAX]; pid_t pid = atoi(proc); if (!pid) return false; /* Don't fail if the process no longer exists. */ build_path(path, "/proc", proc); if (!sge_is_directory(path)) return true; return set_pid_cgroup(pid, dir); }
void parcours_rep (const char *chemin) { struct dirent *e; char path[PATH_MAX]; DIR *d = opendir(chemin); if (d == NULL) fail(); while ((e = readdir(d))) { build_path(chemin, e->d_name, path); liens_symboliques(path); } if (errno != 0) fail(); if (closedir(d) == -1) fail(); }
static IplImage* splat(int *coeffs, CvSize size, int *plane_coeffs) { IplImage *g = cvCreateImage(size, IPL_DEPTH_16S, 1); IplImage *b = cvCreateImage(size, IPL_DEPTH_16S, 1); IplImage *r = cvCreateImage(size, IPL_DEPTH_16S, 1); IplImage *rgb = cvCreateImage(size, IPL_DEPTH_16S, 3); IplImage *img = cvCreateImage(size, IPL_DEPTH_8U, 3); IplImage *trans = cvCreateImage(size, IPL_DEPTH_16S, 1); int dim = plane_coeffs[0] + plane_coeffs[1] + plane_coeffs[2]; unsigned *order_p0 = build_path(plane_coeffs[0], KERNS); unsigned *order_p1 = build_path(plane_coeffs[1], KERNS); unsigned *order_p2 = build_path(plane_coeffs[2], KERNS); memset(trans->imageData, 0, trans->imageSize); dequantize(trans, plane_coeffs[0], order_p0, KERNS, coeffs, dim); iwht2d(trans, g); memset(trans->imageData, 0, trans->imageSize); dequantize(trans, plane_coeffs[1], order_p1, KERNS, coeffs+plane_coeffs[0], dim); iwht2d(trans, b); memset(trans->imageData, 0, trans->imageSize); dequantize(trans, plane_coeffs[2], order_p2, KERNS, coeffs+plane_coeffs[0]+plane_coeffs[1], dim); iwht2d(trans, r); cvMerge(g, b, r, NULL, rgb); cvConvertScale(rgb, img, 1, 0); cvReleaseImage(&g); cvReleaseImage(&b); cvReleaseImage(&r); cvReleaseImage(&rgb); cvReleaseImage(&trans); free(order_p0); free(order_p1); free(order_p2); return img; }
/* setup */ static void _setup(void) { int i; Evas_Object *o; for (i = 0; i < OBNUM; i++) { o = evas_object_image_add(evas); o_images[i] = o; evas_object_image_file_set(o, build_path("image.png"), NULL); evas_object_image_smooth_scale_set(o, 0); evas_object_show(o); } done = 0; }
/* setup */ static void _setup(void) { int i; Evas_Object *o; for (i = 0; i < OBNUM; i++) { o = evas_object_image_add(evas); o_images[i] = o; evas_object_image_file_set(o, build_path("bar.png"), NULL); evas_object_image_border_set(o, 6, 6, 6, 6); evas_object_show(o); } done = 0; }
bool disjunctive_polynomial_accelerationt::find_path(patht &path) { scratch_programt program(symbol_table); program.append(fixed); program.append(fixed); // Let's make sure that we get a path we have not seen before. for (std::list<distinguish_valuest>::iterator it = accelerated_paths.begin(); it != accelerated_paths.end(); ++it) { exprt new_path = false_exprt(); for (distinguish_valuest::iterator jt = it->begin(); jt != it->end(); ++jt) { exprt distinguisher = jt->first; bool taken = jt->second; if (taken) { not_exprt negated(distinguisher); distinguisher.swap(negated); } or_exprt disjunct(new_path, distinguisher); new_path.swap(disjunct); } program.assume(new_path); } program.add_instruction(ASSERT)->guard = false_exprt(); try { if (program.check_sat()) { #ifdef DEBUG std::cout << "Found a path" << std::endl; #endif build_path(program, path); record_path(program); return true; } } catch (std::string s) { std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; } catch (const char *s) { std::cout << "Error in fitting polynomial SAT check: " << s << std::endl; } return false; }
static int restore_file_or_get_meta(struct asfd *asfd, BFILE *bfd, struct sbuf *sb, const char *fname, enum action act, char **metadata, size_t *metalen, int vss_restore, struct cntr *cntr, const char *encyption_password) { int ret=0; char *rpath=NULL; if(act==ACTION_VERIFY) { cntr_add(cntr, sb->path.cmd, 1); goto end; } if(build_path(fname, "", &rpath, NULL)) { char msg[256]=""; // failed - do a warning snprintf(msg, sizeof(msg), "build path failed: %s", fname); if(restore_interrupt(asfd, sb, msg, cntr, PROTO_1)) ret=-1; goto end; } #ifndef HAVE_WIN32 // We always want to open the file if it is on Windows. Otherwise, // only open it if we are not doing metadata. if(!metadata) { #endif switch(open_for_restore(asfd, bfd, rpath, sb, vss_restore, cntr, PROTO_1)) { case OFR_OK: break; case OFR_CONTINUE: goto end; default: ret=-1; goto end; } #ifndef HAVE_WIN32 } #endif if(!(ret=do_restore_file_or_get_meta(asfd, bfd, sb, fname, metadata, metalen, cntr, rpath, encyption_password))) cntr_add(cntr, sb->path.cmd, 1); end: free_w(&rpath); if(ret) logp("restore_file error\n"); return ret; }
static int ypfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { char* full_path; struct stat real_stat; size_t real_size; #ifdef DEBUG if(1){ FILE *f2 = fopen("/opfs/log2.txt", "a"); fprintf(f2, "READ: %s\n", path); fclose(f2); } #endif #ifdef DEBUG if(!strcmp(path,"/debug")){ size_t len; char* debugstr=NULL; len = asprintf(&debugstr, "%010u\n", CURRENT->uid); if (len == (size_t)-1) return 0; if (offset < len) { if (offset + size > len) size = len - offset; memcpy(buf, debugstr + offset, size); }else size = 0; free(debugstr); return size; } #endif full_path = build_path(path); stat(full_path, &real_stat); real_size = real_stat.st_size; if (offset < real_size) { if (offset + size > real_size) size = real_size - offset; pread(fi->fh, buf, size, offset); } else { size = 0; } free(full_path); return size; }
std::string AppDirs::get_default_locale_dir(void) const { #ifdef _WIN32 return build_path(data_dir, "locale"); #elif defined(CONFIG_DARWIN) const gchar* dir = g_getenv("STARDICT_LOCALE_DIR"); if (dir) { return dir; } else { return STARDICT_LOCALE_DIR; } #else return STARDICT_LOCALE_DIR; #endif }
void build_path(multimap<string,string> father,string start,string end,vector<string> &CurrPath,vector<vector<string>> &Path){ CurrPath.push_back(end); if(start==end){ Path.push_back(CurrPath); reverse(Path.back().begin(),Path.back().end()); CurrPath.pop_back(); return; } pair<multimap<string,string>::iterator,multimap<string,string>::iterator> pos=father.equal_range(end); while(pos.first!=pos.second){ build_path(father,start,pos.first->second,CurrPath,Path); pos.first++; } CurrPath.pop_back(); }
/* setup */ static void _setup(void) { int i; Evas_Object *o; for (i = 0; i < (OBNUM / 2); i++) { o = evas_object_image_add(evas); o_images[i] = o; evas_object_image_file_set(o, build_path("logo.png"), NULL); evas_object_image_fill_set(o, 0, 0, 120, 160); evas_object_resize(o, 120, 160); evas_object_show(o); } done = 0; }
void ContainerViewGump::init_chest(std::string datadir) { std::string imagefile, path; uint8 check_y = 56; gump_button = loadButton(datadir, "gump", CHECK_X, check_y); build_path(datadir, "container", path); datadir = path; up_arrow_button = loadButton(datadir, "cont_up", 85, 31); down_arrow_button = loadButton(datadir, "cont_down", 85, 47); build_path(datadir, "chest_bg.bmp", imagefile); bg_image = SDL_LoadBMP(imagefile.c_str()); SetRect(area.x, area.y, bg_image->w, bg_image->h + 16); //111, 101); container_widget = new ContainerWidgetGump(config, this); container_widget_y_offset = CONTAINER_WIDGET_OFFSET - 1; container_widget->init(actor, 21, container_widget_y_offset, 4, 2, tile_manager, obj_manager, font, CHECK_X, check_y); AddWidget(container_widget); }
void ContainerViewGump::init_barrel(std::string datadir) { std::string imagefile, path; uint8 check_y = 55; gump_button = loadButton(datadir, "gump", CHECK_X, check_y); build_path(datadir, "container", path); datadir = path; up_arrow_button = loadButton(datadir, "cont_up", 102, 28); down_arrow_button = loadButton(datadir, "cont_down", 102, 42); build_path(datadir, "barrel_bg.bmp", imagefile); bg_image = SDL_LoadBMP(imagefile.c_str()); SetRect(area.x, area.y, bg_image->w, bg_image->h); container_widget = new ContainerWidgetGump(config, this); container_widget_y_offset = 24; container_widget->init(actor, 38, container_widget_y_offset, 4, 2, tile_manager, obj_manager, font, CHECK_X, check_y); AddWidget(container_widget); }
void ContainerViewGump::init_corpse(std::string datadir, std::string bg_filename) { std::string imagefile, path; uint8 check_y = 25; gump_button = loadButton(datadir, "gump", CHECK_X, check_y); build_path(datadir, "container", path); datadir = path; up_arrow_button = loadButton(datadir, "cont_up", 67, 28); down_arrow_button = loadButton(datadir, "cont_down", 67, 78); build_path(datadir, bg_filename, imagefile); bg_image = SDL_LoadBMP(imagefile.c_str()); SetRect(area.x, area.y, bg_image->w, bg_image->h); container_widget = new ContainerWidgetGump(config, this); container_widget_y_offset = 26; container_widget->init(actor, 20, container_widget_y_offset, 3, 4, tile_manager, obj_manager, font, CHECK_X, check_y); AddWidget(container_widget); }
static void build_paths(MCStringRef &r_path) { MCAutoStringRef t_path; /* UNCHECKED */ MCStringCreateMutable(0, &t_path); MCAutoStringRef t_std_path; MCAutoStringRef t_native_path; /* UNCHECKED */ MCStringCreateWithChars(s_chosen_folder.Ptr(), s_chosen_folder.Size()-1, &t_native_path); /* UNCHECKED */ MCS_pathfromnative(*t_native_path, &t_std_path); if (MCStringGetCharAtIndex(*t_std_path, 0) == '"') { // Does this ever actually receive a quoted path? /*Meta::itemised_string t_items(sg_chosen_files, ' ', true); for(unsigned int t_index = 0; t_index < t_items . count(); ++t_index) { if (t_index != 0) /* UNCHECKED * / MCStringAppendChar(*t_path, '\n'); build_path(*t_std_path, t_items[t_index], *t_path); }*/ MCAutoStringRef t_item; /* UNCHECKED */ MCStringCreateWithChars(s_chosen_files.Ptr(), s_chosen_files.Size()-1, &t_item); build_path(*t_std_path, *t_item, *t_path); } else { MCAutoStringRef t_files; /* UNCHECKED */ MCStringCreateWithChars(s_chosen_files.Ptr(), s_chosen_files.Size()-1, &t_files); build_path(*t_std_path, *t_files, *t_path); } s_chosen_files.Delete(); s_chosen_folder.Delete(); MCStringCopy(*t_path, r_path); }
static int* block_coeffs(IplImage *img, int* plane_coeffs) { CvSize size = cvGetSize(img); IplImage *b = cvCreateImage(size, IPL_DEPTH_8U, 1); IplImage *g = cvCreateImage(size, IPL_DEPTH_8U, 1); IplImage *r = cvCreateImage(size, IPL_DEPTH_8U, 1); IplImage *trans = cvCreateImage(size, IPL_DEPTH_16S, 1); int dim = plane_coeffs[0] + plane_coeffs[1] + plane_coeffs[2]; int sz = size.width*size.height/64*dim; int *buf = malloc(sizeof(int)*sz); unsigned *order_p0 = build_path(plane_coeffs[0], KERNS); unsigned *order_p1 = build_path(plane_coeffs[1], KERNS); unsigned *order_p2 = build_path(plane_coeffs[2], KERNS); cvSplit(img, b, g, r, NULL); wht2d(b, trans); quantize(trans, plane_coeffs[0], KERNS, order_p0, buf, dim); wht2d(g, trans); quantize(trans, plane_coeffs[1], KERNS, order_p1, buf+plane_coeffs[0], dim); wht2d(r, trans); quantize(trans, plane_coeffs[2], KERNS, order_p2, buf+plane_coeffs[0]+plane_coeffs[1], dim); cvReleaseImage(&trans); cvReleaseImage(&b); cvReleaseImage(&g); cvReleaseImage(&r); free(order_p0); free(order_p1); free(order_p2); return buf; }
bool ActorManager::loadCustomTiles(nuvie_game_t game_type) { if(obj_manager->use_custom_actor_tiles() == false) { return false; } std::string datadir = GUI::get_gui()->get_data_dir(); std::string path; build_path(datadir, "images", path); datadir = path; build_path(datadir, "actors", path); datadir = path; build_path(datadir, get_game_tag(game_type), path); datadir = path; tile_manager->freeCustomTiles(); //FIXME this might need to change if we start using custom tiles outside of ActorManager. eg custom map/object tilesets loadAvatarTiles(datadir); loadNPCTiles(datadir); return true; }