/* * load_alias: load alias value. * * [$HOME/.gozillarc] * +----------------------- * |a:http://www.gnu.org * |f = file:/usr/share/xxx.html * |www http://www.xxx.yyy/ */ static void load_alias(void) { FILE *ip; STRBUF *sb = strbuf_open(0); char *p; int flag = STRBUF_NOCRLF; struct sh_entry *ent; sh = strhash_open(10); if (!(p = get_home_directory())) goto end; if (!test("r", makepath(p, gozillarc, NULL))) #ifdef __DJGPP__ if (!test("r", makepath(p, dos_gozillarc, NULL))) #endif goto end; if (!(ip = fopen(makepath(p, gozillarc, NULL), "r"))) #ifdef __DJGPP__ if (!(ip = fopen(makepath(p, dos_gozillarc, NULL), "r"))) #endif goto end; while ((p = strbuf_fgets(sb, ip, flag)) != NULL) { char *name, *value; flag &= ~STRBUF_APPEND; if (*p == '#') continue; if (strbuf_unputc(sb, '\\')) { flag |= STRBUF_APPEND; continue; } while (*p && isblank(*p)) /* skip spaces */ p++; name = p; while (*p && isalnum(*p)) /* get name */ p++; *p++ = 0; while (*p && isblank(*p)) /* skip spaces */ p++; if (*p == '=' || *p == ':') { p++; while (*p && isblank(*p))/* skip spaces */ p++; } value = p; while (*p && !isblank(*p)) /* get value */ p++; *p = 0; ent = strhash_assign(sh, name, 1); if (ent->value) (void)free(ent->value); ent->value = check_strdup(value); } fclose(ip); end: strbuf_close(sb); }
static char * reqpath(char *file, char **idnumber) { char *path; char *cp; char *cp2; /* * /var/spool/lp/tmp/machine/123-0 * /var/spool/lp/temp/123-0 * /usr/spool/lp/temp/123-0 * /usr/spool/lp/tmp/machine/123-0 * 123-0 * machine/123-0 * * /var/spool/lp/tmp/machine/123-0 + 123 */ if (*file == '/') { /*CONSTCOND*/ if (STRNEQU(file, Lp_Spooldir, strlen(Lp_Spooldir))) cp = file + strlen(Lp_Spooldir) + 1; else { if (STRNEQU(file, "/usr/spool/lp", 13)) cp = file + strlen("/usr/spool/lp") + 1; else { *idnumber = NULL; return (NULL); } } if (STRNEQU(cp, "temp", 4)) { cp += 5; path = makepath(Local_System, cp, NULL); } else path = Strdup(cp); } else { if (strchr(file, '/')) path = makepath(file, NULL); else path = makepath(Local_System, file, NULL); } cp = strrchr(path, '/'); cp++; if ((cp2 = strrchr(cp, '-')) == NULL) *idnumber = Strdup(cp); else { *cp2 = '\0'; *idnumber = Strdup(cp); *cp2 = '-'; } return (path); }
Stream* FileSystem::open(const char* path, size_t streamMode, bool external) { bool useExternal = (streamMode & WRITE) != 0 || external; char modeStr[] = "rb"; if ((streamMode & WRITE) != 0) modeStr[0] = 'w'; #ifdef __ANDROID__ std::string fullPath(__resourcePath); fullPath += resolvePath(path); if (useExternal) { // Open a file on the SD card size_t index = fullPath.rfind('/'); if (index != std::string::npos) { std::string directoryPath = fullPath.substr(0, index); gp_stat_struct s; if (stat(directoryPath.c_str(), &s) != 0) makepath(directoryPath, 0777); } return FileStream::create(fullPath.c_str(), modeStr); } else { // First try the SD card Stream* stream = FileStream::create(fullPath.c_str(), modeStr); if (!stream) { // Otherwise fall-back to assets loaded via the AssetManager fullPath = __assetPath; fullPath += resolvePath(path); stream = FileStreamAndroid::create(fullPath.c_str(), modeStr); } return stream; } #else std::string fullPath; getFullPath(path, fullPath, useExternal); if(useExternal && __externalPath.compare(__resourcePath) != 0) { size_t index = fullPath.rfind('/'); if(index != std::string::npos) { std::string directoryPath = fullPath.substr(0, index); gp_stat_struct s; if(stat(directoryPath.c_str(), &s) != 0) makepath(directoryPath, 0777); } } GP_WARN("Opening file %s", fullPath.c_str()); if(useExternal) GP_WARN("External file"); FileStream* stream = FileStream::create(fullPath.c_str(), modeStr); return stream; #endif }
int main(int argc, char *argv[]) { char* person_output_file = makepath(argv[1], "person", "bin"); char* interest_output_file = makepath(argv[1], "interest", "bin"); char* knows_output_file = makepath(argv[1], "knows", "bin"); // this does not do anything yet. But it could... return 0; }
//Removes from the knows table all the relationship between people that lives in different cities and updates accordingly the person_map void reorg_location(char* path, char *knows_output_file, char * person_output_file) { //offsets in the person_map unsigned int person_offset, knows_pos; //offset in the knows_map unsigned long knows_offset; unsigned short count; //keeps track of the position where we are writing on the new knows file unsigned long total_count = 0; Person *person, *knows; FILE *knows_file = open_binout(makepath(path, knows_output_file, "bin")); FILE *person_file = open_binout(makepath(path, person_output_file, "bin")); Person person_copy; for (person_offset = 0; person_offset < person_length / sizeof(Person); person_offset++) { person = &person_map[person_offset]; person_copy = *person; person_copy.knows_first = total_count; count = 0; // check if friend lives in same city and likes artist for (knows_offset = person->knows_first; knows_offset < person->knows_first + person->knows_n; knows_offset++) { //this is person's friend, let's check if it's reciprocal knows_pos = knows_map[knows_offset]; if(location_map[person_offset] != location_map[knows_pos]) continue; count++; total_count++; fwrite(&knows_pos, sizeof(int), 1, knows_file); } person_copy.knows_n = count; fwrite(&person_copy, sizeof(Person), 1, person_file); } fclose(person_file); fclose(knows_file); munmap(person_map, person_length); munmap(knows_map, knows_length); //open the correct person and knows map person_map = (Person *) mmapr(makepath(path, person_output_file, "bin"), &person_length); knows_map = (unsigned int *) mmapr(makepath(path, knows_output_file, "bin"), &knows_length); free(location_map); return; }
/* * tagsearch: execute tag search * * i) pattern search pattern * i) cwd current directory * i) root root of source tree * i) dbpath database directory * i) db GTAGS,GRTAGS,GSYMS */ void tagsearch(const char *pattern, const char *cwd, const char *root, const char *dbpath, int db) { int count, total = 0; char libdbpath[MAXPATHLEN]; /* * search in current source tree. */ count = search(pattern, root, cwd, dbpath, db); total += count; /* * search in library path. */ if (db == GTAGS && getenv("GTAGSLIBPATH") && (count == 0 || Tflag) && !lflag) { STRBUF *sb = strbuf_open(0); char *libdir, *nextp = NULL; strbuf_puts(sb, getenv("GTAGSLIBPATH")); /* * search for each tree in the library path. */ for (libdir = strbuf_value(sb); libdir; libdir = nextp) { if ((nextp = locatestring(libdir, PATHSEP, MATCH_FIRST)) != NULL) *nextp++ = 0; if (!gtagsexist(libdir, libdbpath, sizeof(libdbpath), 0)) continue; if (!strcmp(dbpath, libdbpath)) continue; if (!test("f", makepath(libdbpath, dbname(db), NULL))) continue; /* * search again */ count = search(pattern, libdir, cwd, libdbpath, db); total += count; if (count > 0 && !Tflag) { /* for verbose message */ dbpath = libdbpath; break; } } strbuf_close(sb); } if (vflag) { print_count(total); if (!Tflag) fprintf(stderr, " (using '%s')", makepath(dbpath, dbname(db), NULL)); fputs(".\n", stderr); } }
/** * configpath: get path of configuration file. * * @param[in] rootdir Project root directory * @return path name of the configuration file or NULL */ static char * configpath(const char *rootdir) { STATIC_STRBUF(sb); const char *p; strbuf_clear(sb); /* * at first, check environment variable GTAGSCONF. */ if (getenv("GTAGSCONF") != NULL) strbuf_puts(sb, getenv("GTAGSCONF")); /* * if GTAGSCONF not set then check standard config files. */ else if (rootdir && *rootdir && test("r", makepath(rootdir, "gtags.conf", NULL))) strbuf_puts(sb, makepath(rootdir, "gtags.conf", NULL)); else if ((p = get_home_directory()) && test("r", makepath(p, GTAGSRC, NULL))) strbuf_puts(sb, makepath(p, GTAGSRC, NULL)); #ifdef __DJGPP__ else if ((p = get_home_directory()) && test("r", makepath(p, DOS_GTAGSRC, NULL))) strbuf_puts(sb, makepath(p, DOS_GTAGSRC, NULL)); #endif else if (test("r", GTAGSCONF)) strbuf_puts(sb, GTAGSCONF); else if (test("r", DEBIANCONF)) strbuf_puts(sb, DEBIANCONF); else if (test("r", makepath(SYSCONFDIR, "gtags.conf", NULL))) strbuf_puts(sb, makepath(SYSCONFDIR, "gtags.conf", NULL)); else return NULL; return strbuf_value(sb); }
/* canonize the path and make it absolute */ void canonize_absolute_path(char *buf, int buf_size, const char *path1) { char cwd[MAX_FILENAME_SIZE]; char path[MAX_FILENAME_SIZE]; char *homedir; if (!is_abs_path(path1)) { /* XXX: should call it again */ if (*path1 == '~' && (path1[1] == '\0' || path1[1] == '/')) { homedir = getenv("HOME"); if (homedir) { pstrcpy(path, sizeof(path), homedir); pstrcat(path, sizeof(path), path1 + 1); goto next; } } /* CG: not sufficient for windows drives */ getcwd(cwd, sizeof(cwd)); #ifdef WIN32 path_win_to_unix(cwd); #endif makepath(path, sizeof(path), cwd, path1); } else { pstrcpy(path, sizeof(path), path1); } next: canonize_path(buf, buf_size, path); }
int run_discs_detection(GList **config) { GList *drives=NULL; int i; int found = 0; char *ptr; umount_if_needed(SOURCEDIR); makepath(SOURCEDIR); drives = grep_drives("/proc/sys/dev/cdrom/info"); for (i = 0; i < g_list_length(drives); i++) { ptr = get_blkid((char*)g_list_nth_data(drives, i)); if(ptr && !strcmp(ptr, "Frugalware Install")) { LOG("install medium found in %s", (char*)g_list_nth_data(drives, i)); free(ptr); ptr = g_strdup_printf("mount -o ro -t iso9660 /dev/%s %s", (char*)g_list_nth_data(drives, i), SOURCEDIR); fw_system(ptr); free(ptr); if(!is_netinstall(SOURCEDIR)) { data_put(config, "srcdev", (char*)g_list_nth_data(drives, i)); found = 1; break; } } else { LOG("skipping non-install medium in %s", (char*)g_list_nth_data(drives, i)); } } return found; }
void WEXPORT WFileName::relativeTo( const char* f ) { int i; _splitpath( *this, _x.drive, _x.dir, _x.fname, _x.ext ); if( _x.dir[0] == PATHSEP_CHAR ) { FullName s; splitref( s, f, PATHSEP_STR ); if( s.dir[0] == PATHSEP_CHAR && strieq( s.drive, _x.drive ) ) { _x.drive[0] = '\0'; int b = 0; for( i=1; _x.dir[i] != '\0' && s.dir[i] != '\0'; i++ ) { if( tolower( (unsigned char)_x.dir[i] ) != tolower( (unsigned char)s.dir[i] ) ) break; if( s.dir[i] == PATHSEP_CHAR ) b = i; } if( b == 0 ) { strcpy( s.dir, _x.dir ); } else { int n = 0; for( ; s.dir[i] != '\0'; i++ ) { if( s.dir[i] == PATHSEP_CHAR ) n++; } s.dir[0] = '\0'; if( n > 0 ) { for( int j=0; j<n; j++ ) { strcpy( &s.dir[3 * j], PARENTSEP_STR ); } } strcpy( &s.dir[3 * n], &_x.dir[b + 1] ); } makepath( _x.path, _x.drive, s.dir, _x.fname, _x.ext ); *this = _x.path; } } }
int main(int argc, char const *argv[]) { unsigned long person_length; Person* person_map = (Person *) mmapr(makepath(argv[1], "person", "bin"), &person_length); int location_found[1000]; int last=0; int i,j; for(i=0; i<&person_length; ++i){ int found=0; for(j=0; j<1000 && !found; j++){ if( (person_map+i)->location == location_found[j]){ found=1; } } if(!found){ last++; if(last==1000){ printf("too many\n"); exit(1); } location_found[last]=(person_map+i)->location; } } printf("%s\n", last); return 0; }
bdd_ptr makepath(bdd_manager *bddm, int n, unsigned leaf_value, void (*update_bddpaths) (unsigned (*new_place) (unsigned node))) { bdd_ptr res, sub_res, default_state_ptr; unsigned index; while ((n < offsets_size) && (sorted_path[n] == 'X')) n++; if (n >= offsets_size) return (bdd_find_leaf_hashed(bddm, leaf_value, SEQUENTIAL_LIST(sub_results), update_bddpaths)); sub_res = makepath(bddm, n+1, leaf_value, update_bddpaths); PUSH_SEQUENTIAL_LIST(sub_results, unsigned, sub_res); default_state_ptr = bdd_find_leaf_hashed(bddm, default_state, SEQUENTIAL_LIST(sub_results), update_bddpaths); POP_SEQUENTIAL_LIST(sub_results, unsigned, sub_res); index = global_offsets[sorted_indices[n]]; if (sorted_path[n] == '0') res = bdd_find_node_hashed(bddm, sub_res, default_state_ptr, index, SEQUENTIAL_LIST(sub_results), update_bddpaths); else res = bdd_find_node_hashed(bddm, default_state_ptr, sub_res, index, SEQUENTIAL_LIST(sub_results), update_bddpaths); return res; }
anyrequests () #endif { long lastdir = -1; char * name; /* * This routine walks through the requests (secure) * directory looking for files, descending one level * into each sub-directory, if any. Finding at least * one file means that a request is queued. */ while ((name = next_dir(Lp_Requests, &lastdir))) { long lastfile = -1; char * subdir; if (!(subdir = makepath(Lp_Requests, name, (char *)0))) return (1); /* err on safe side */ if (next_file(subdir, &lastfile)) { Free (subdir); return (1); } Free (subdir); } return (0); }
/* * getdirs: get directory list * * i) dir directory * o) sb string buffer * r) -1: error, 0: normal * * format of directory list: * |ddir1\0ffile1\0llink\0| * means directory 'dir1', file 'file1' and symbolic link 'link'. */ static int getdirs(const char *dir, STRBUF *sb) { DIR *dirp; struct dirent *dp; struct stat st; if ((dirp = opendir(dir)) == NULL) return -1; while ((dp = readdir(dirp)) != NULL) { if (!strcmp(dp->d_name, ".")) continue; if (!strcmp(dp->d_name, "..")) continue; if (stat(makepath(dir, dp->d_name, NULL), &st) < 0) { warning("cannot stat '%s'. (Ignored)", dp->d_name); continue; } if (S_ISDIR(st.st_mode)) strbuf_putc(sb, 'd'); else if (S_ISREG(st.st_mode)) strbuf_putc(sb, 'f'); else strbuf_putc(sb, ' '); strbuf_puts(sb, dp->d_name); strbuf_putc(sb, '\0'); } (void)closedir(dirp); return 0; }
void logaddr(const char *subdir,const char *event, const char *addr,const char *comment) { char ch; int fd; stralloc_copyb(&line,num,fmt_ulong(num,(unsigned long) now())); stralloc_cats(&line," "); stralloc_cats(&line,event); stralloc_cats(&line," "); while ((ch = *addr++) != 0) { if ((ch < 33) || (ch > 126)) ch = '?'; stralloc_append(&line,ch); } if (comment && *comment) { stralloc_cats(&line," "); while ((ch = *comment++) != 0) { if (ch == '\t') ch = ' '; else if ((ch < 32) || (ch > 126)) ch = '?'; stralloc_append(&line,ch); } } stralloc_cats(&line,"\n"); makepath(&fn,subdir,"/Log",0); fd = open_append(fn.s); if (fd == -1) return; substdio_fdbuf(&ss,write,fd,NULL,0); substdio_putflush(&ss,line.s,line.len); close(fd); return; }
/** * makehtaccess: make ".htaccess" skeleton file. */ static void makehtaccess(const char *cgidir, const char *file, int perm) { FILE *op; const char *dst = makepath(distpath, file, NULL); op = fopen(dst, "w"); if (!op) die("cannot make .htaccess skeleton file."); fputs_nl("#", op); fputs_nl("# Skeleton file for .htaccess -- This file was generated by htags(1).", op); fputs_nl("#", op); fputs_nl("# To make this file effective, undermentioned description is necessary", op); fputs_nl("# in your system's configuration file.", op); fputs_nl("#", op); fputs_nl("# [/usr/local/apache/conf/http.conf]", op); fputs_nl("# +-------------------------------------", op); fputs_nl("# |...", op); fputs_nl("# |AllowOverride Options FileInfo", op); fputs_nl("#", op); fputs_nl("# Htags was invoked with the -f, or -D option.", op); fprintf(op, "# You should start http server so that %s/*.cgi is executed\n", cgidir); fputs_nl("# as a CGI script.", op); fputs_nl("#", op); fputs_nl("Options +ExecCGI", op); fputs_nl("AddHandler cgi-script .cgi", op); fclose(op); if (chmod(dst, perm) < 0) die("cannot chmod .htaccess skeleton."); }
int prerun(GList **config) { // fix gtk graphical bug : forward button is clicked in set_page_completed(); set_page_incompleted(); long long *compsize = (long long*)data_get(*config,"compsizepkg"); if(compsize != NULL) compressedsize = *compsize; makepath(TARGETDIR "/dev"); fw_system("mount /dev -o bind " TARGETDIR "/dev"); if(data_get(*config, "srcdev") != NULL) { if(install_pkgs_discs((GList*)data_get(*config, "packages"), (char*)data_get(*config, "srcdev")) == -1) { fwife_error(_("An error occurs during packages installation (see /var/log/fwife.log for more details)")); return -1; } } else { if(install_pkgs((GList*)data_get(*config, "packages")) == -1) { fwife_error(_("An error occurs during packages installation (see /var/log/fwife.log for more details)")); return -1; } } gtk_label_set_label(GTK_LABEL(labelpkg), _("Packages installation completed")); set_page_completed(); return 0; }
/** * makeindex: make index file * * @param[in] file file name * @param[in] title title of index file * @param[in] index common part */ static void makeindex(const char *file, const char *title, const char *index) { FILE *op; op = fopen(makepath(distpath, file, NULL), "w"); if (!op) die("cannot make file '%s'.", file); if (Fflag) { fputs_nl(gen_page_frameset_begin(title), op); fputs_nl(gen_frameset_begin("cols='200,*'"), op); if (fflag) { fputs_nl(gen_frameset_begin("rows='33%,33%,*'"), op); fputs_nl(gen_frame("search", makepath(NULL, "search", normal_suffix)), op); } else { fputs_nl(gen_frameset_begin("rows='50%,*'"), op); } /* * id='xxx' for XHTML * name='xxx' for HTML */ fputs_nl(gen_frame("defines", makepath(NULL, "defines", normal_suffix)), op); fputs_nl(gen_frame("files", makepath(NULL, "files", normal_suffix)), op); fputs_nl(gen_frameset_end(), op); fputs_nl(gen_frame("mains", makepath(NULL, "mains", normal_suffix)), op); fputs_nl(noframes_begin, op); fputs_nl(body_begin, op); fputs(index, op); fputs_nl(body_end, op); fputs_nl(noframes_end, op); fputs_nl(gen_frameset_end(), op); fputs_nl(gen_page_end(), op); } else { fputs_nl(gen_page_index_begin(title, jscode), op); fputs_nl(body_begin, op); if (insert_header) fputs(gen_insert_header(TOPDIR), op); fputs(index, op); if (insert_footer) fputs(gen_insert_footer(TOPDIR), op); fputs_nl(body_end, op); fputs_nl(gen_page_end(), op); } fclose(op); html_count++; }
static bool tcddbout(TCDDB *ddb, const void *kbuf, int ksiz){ if(!ddb->name) return false; bool err = false; char *path = makepath(ddb, kbuf, ksiz); if(unlink(path) != 0) err = true; tcfree(path); return !err; }
static void *tcddbget(TCDDB *ddb, const void *kbuf, int ksiz, int *sp){ if(!ddb->name) return false; void *vbuf; char *path = makepath(ddb, kbuf, ksiz); vbuf = tcreadfile(path, -1, sp); tcfree(path); return vbuf; }
static bool tcddbput(TCDDB *ddb, const void *kbuf, int ksiz, const void *vbuf, int vsiz){ if(!ddb->name) return false; bool err = false; char *path = makepath(ddb, kbuf, ksiz); if(!tcwritefile(path, vbuf, vsiz)) err = true; tcfree(path); return !err; }
int preaddir(Fid *f, uchar *data, int n, vlong offset) { int r = 0, m; Dir *d; DEBUG(DFD, "\tpreaddir n=%d wo=%lld fo=%lld\n", n, offset, f->offset); if(offset == 0 && f->offset != 0){ if(seek(f->fid, 0, 0) != 0) return -1; f->offset = f->cdir = f->ndir = 0; free(f->dir); f->dir = nil; }else if(offset != f->offset){ werrstr("can't seek dir %lld to %lld", f->offset, offset); return -1; } while(n > 0){ if(f->dir == nil){ f->ndir = dirread(f->fid, &f->dir); if(f->ndir < 0) return f->ndir; if(f->ndir == 0) return r; } d = &f->dir[f->cdir++]; if(exclude){ char *p = makepath(f->f, d->name); if(excludefile(p)){ free(p); goto skipentry; } free(p); } m = convD2M(d, data, n); DEBUG(DFD, "\t\tconvD2M %d\n", m); if(m <= BIT16SZ){ DEBUG(DFD, "\t\t\tneeded %d\n", GBIT16(data)); /* not enough room for full entry; leave for next time */ f->cdir--; return r; }else{ data += m; n -= m; r += m; f->offset += m; } skipentry: if(f->cdir >= f->ndir){ f->cdir = f->ndir = 0; free(f->dir); f->dir = nil; } } return r; }
int Skin::load(char *name, bool quiet) { char d[512]; setpath(name); makepath(d,"colors.conf"); if (!Colors.load(d)) { sprintf(d, "Skin[%s]: Cannot load colors.conf", name); if (!quiet) MessageBox(NULL,d,"Error",MB_ICONERROR | MB_OK); return 0; } SDL_Surface *s; pngLoad("toolbar.png"); bmToolbar = new Bitmap( s , true ); pngLoad("load.png"); bmLoad = new Bitmap( s , true ); pngLoad("save.png"); bmSave = new Bitmap( s , true ); pngLoad("buttons.png"); bmButtons = new Bitmap( s , true ); pngLoad("about.png"); bmAbout = new Bitmap( s , true ); if (640 != CONSOLE_WIDTH && 480 != CONSOLE_HEIGHT) { double xscale = (double)CONSOLE_WIDTH / 640; double yscale = (double)CONSOLE_HEIGHT / 480; Drawable ss( zoomSurface(bmAbout->surface, xscale, yscale ,SMOOTHING_ON) , false ); // S->copy(&ss,5,row(12)); SDL_FreeSurface( bmAbout->surface ); bmAbout->surface = ss.surface; } pngLoad("logo.png"); SDL_FreeSurface(s); bmLogo = NULL; makepath(d,"font.fnt"); if (font_load(d)) { sprintf(d, "Skin[%s]: Cannot load font.fnt", name); if (!quiet) MessageBox(NULL,d,"Error",MB_ICONERROR | MB_OK); return 0; } return 1; }
/* * makesearchpart: make search part * * @param[in] target $target * @return html */ static char * makesearchpart(const char *target) { STATIC_STRBUF(sb); strbuf_clear(sb); strbuf_puts(sb, header_begin); if (Fflag) strbuf_puts(sb, gen_href_begin(NULL, "search", normal_suffix, NULL)); strbuf_puts(sb, "SEARCH"); if (Fflag) strbuf_puts(sb, gen_href_end()); strbuf_puts_nl(sb, header_end); if (!target) { strbuf_puts(sb, "Please input object name and select [Search]. POSIX's regular expression is allowed."); strbuf_puts_nl(sb, br); } strbuf_puts_nl(sb, gen_form_begin(target)); strbuf_puts_nl(sb, gen_input("pattern", NULL, NULL)); strbuf_puts_nl(sb, gen_input(NULL, "Search", "submit")); strbuf_puts(sb, gen_input(NULL, "Reset", "reset")); strbuf_puts_nl(sb, br); strbuf_puts(sb, gen_input_radio("type", "definition", 1, "Retrieve the definition place of the specified symbol.")); strbuf_puts_nl(sb, target ? "Def" : "Definition"); strbuf_puts(sb, gen_input_radio("type", "reference", 0, "Retrieve the reference place of the specified symbol.")); strbuf_puts_nl(sb, target ? "Ref" : "Reference"); strbuf_puts(sb, gen_input_radio("type", "symbol", 0, "Retrieve the place of the specified symbol is used.")); strbuf_puts_nl(sb, target ? "Sym" : "Other symbol"); strbuf_puts(sb, gen_input_radio("type", "path", 0, "Look for path name which matches to the specified pattern.")); strbuf_puts_nl(sb, target ? "Path" : "Path name"); if (enable_grep) { strbuf_puts(sb, gen_input_radio("type", "grep", 0, "Retrieve lines which matches to the specified pattern.")); strbuf_puts_nl(sb, target ? "Grep" : "Grep pattern"); } if (enable_idutils && test("f", makepath(dbpath, "ID", NULL))) { strbuf_puts(sb, gen_input_radio("type", "idutils", 0, "Retrieve lines which matches to the specified pattern using idutils(1).")); strbuf_puts_nl(sb, target ? "Id" : "Id pattern"); } strbuf_puts_nl(sb, br); strbuf_puts(sb, gen_input_checkbox("icase", NULL, "Ignore case distinctions in the pattern.")); strbuf_puts_nl(sb, target ? "Icase" : "Ignore case"); if (other_files) { strbuf_puts(sb, gen_input_checkbox("other", NULL, "Files other than the source code are also retrieved.")); strbuf_puts_nl(sb, target ? "Other" : "Other files"); } if (other_files && !target) { strbuf_puts_nl(sb, br); strbuf_puts(sb, "('Other files' is effective only to 'Path name'"); if (enable_grep) strbuf_puts(sb, " and 'Grep pattern'"); strbuf_puts_nl(sb, ".)"); } strbuf_puts_nl(sb, gen_form_end()); return strbuf_value(sb); }
int main(int argc, char *argv[]) { if (argc < 4) { fprintf(stderr, "Usage: [datadir] [query file] [results file]\n"); exit(1); } /* memory-map files created by loader */ person_map = (Person *) mmapr(makepath(argv[1], "person3", "bin"), &person_length); interest_map = (unsigned short *) mmapr(makepath(argv[1], "interest", "bin"), &interest_length); knows_map = (unsigned int *) mmapr(makepath(argv[1], "knows3", "bin"), &knows_length); outfile = fopen(argv[3], "w"); if (outfile == NULL) { fprintf(stderr, "Can't write to output file at %s\n", argv[3]); exit(-1); } /* run through queries */ parse_csv(argv[2], &query_line_handler); return 0; }
/** * makehtaccess: make ".htaccess" skeleton file. */ static void makehtaccess(const char *file, int perm) { char src[MAXPATHLEN]; const char *dst = makepath(distpath, file, NULL); snprintf(src, sizeof(src), "%s/gtags/dot_htaccess", datadir); copyfile(src, dst); if (chmod(dst, perm) < 0) die("cannot chmod .htaccess skeleton."); }
void WEXPORT WFileName::path( WFileName& f, bool slash ) const { _splitpath( *this, _x.drive, _x.dir, NULL, NULL ); makepath( _x.path, _x.drive, _x.dir, NULL, NULL ); if( !slash ) { size_t len = strlen( _x.path ); if( len > 0 && _x.path[len - 1] == PATHSEP_CHAR ) { _x.path[len - 1] = '\0'; } } f = _x.path; }
gchar* details(GtkCalendar *calendar, guint year, guint month, guint day, gpointer user_data) { gchar *text; gchar *dir = makepath(year, month, day); gchar *path = g_strconcat(dir, "index.txt", NULL); g_free(dir); g_file_get_contents(path, &text, NULL, NULL); g_free(path); return text; }
/** * make directory in the dist (distpath) directory. * * @param[in] name name of directory to create. * * Creates a file called "index.html" in the new directory. * * mkdir() creates the directory in mode 0775, if doesn't exist. */ static void make_directory_in_distpath(const char *name) { char path[MAXPATHLEN]; FILE *op; strlimcpy(path, makepath(distpath, name, NULL), sizeof(path)); if (!test("d", path)) if (mkdir(path, 0775)) die("cannot make directory '%s'.", path); /* * Not to publish the directory list. */ op = fopen(makepath(path, "index.html", NULL), "w"); if (op == NULL) die("cannot make file '%s'.", makepath(path, "index.html", NULL)); fputs(html_begin, op); fputs(html_end, op); fputc('\n', op); fclose(op); }
/** * makeprogram: make CGI program */ static void makeprogram(const char *cgidir, const char *file, int perm) { char src[MAXPATHLEN]; const char *dst = makepath(cgidir, file, NULL); snprintf(src, sizeof(src), "%s/gtags/%s", datadir, file); copyfile(src, dst); if (chmod(dst, perm) < 0) die("cannot chmod CGI program (%s).", dst); html_count++; }