int hitbuffer_inc(hitbuffer *hb, Z32 *hit) { hb->freq += 1LLU; //LLU for 64-bit. OSX 10.5 is VERY finicky about this. int result; if (hb->freq < PHILO_INDEX_CUTOFF) { add_to_dir(hb, hit, 1); // fprintf(stderr, "added hit for %s...\n", hb->word); } else if (hb->freq == PHILO_INDEX_CUTOFF) { //when the frequency reaches 10, we start using a block-header layout. //each "hit" in the directory corresponds to a large, compressed block of hits. //by comparing the directory headers to the query, the search engine skips blocks if possible. result = add_to_block(hb,&(hb->dir[1*hb->db->dbspec->fields]),PHILO_INDEX_CUTOFF - 2); if (result == PHILO_BLOCK_FULL) { fprintf(stderr, "you can't fit PHILO_INDEX_CUTOFF hits into a block! adjust your block size, or your index cutoff.\n"); } hb->dir_length = 1LLU; hb->type = 1; result = add_to_block(hb,hit,1); // fprintf(stderr, "clearing dir. started new block for %s...\n", hb->word); } if (hb->freq > PHILO_INDEX_CUTOFF) { result = add_to_block(hb,hit,1); if (result == PHILO_BLOCK_FULL) { // IF the block add failed, write_blk(hb); //write the full block out, start a new one, add_to_dir(hb,hit,1); //then push the current hit onto the directory. // fprintf(stderr, "started new block for %s...\n", hb->word); } } return 0; }
static int fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { int domain, title, res; /* Make sure dvd is open */ if ((res = inc_refcnt(&mi)) < 0) return res; /* Standard directory entries */ filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); if (strcmp(path, "/") == 0) { /* Dummy file for volume id */ if(mi.vol_id_info.len>0) { filler(buf, ".volume_id", NULL ,0); } filler(buf, "VIDEO_TS", NULL, 0); } else if (strcmp(path, "/VIDEO_TS") == 0) { for (title = 0; title <= mi.num_title; ++title) { for (domain = MIN_DOMAIN; domain <= MAX_DOMAIN; ++domain) { char name[15]; if (title > 0) { sprintf(name, "VTS_%02d_0.VOB", title); } else { if (domain == DVD_READ_TITLE_VOBS) continue; strcpy(name, "VIDEO_TS.VOB"); } if (domain == DVD_READ_TITLE_VOBS) { int partnum; for (partnum = 1; partnum < 10; ++partnum) { name[7] = partnum + '0'; if (!add_to_dir(buf, filler, name)) break; } } else { switch(domain) { case DVD_READ_INFO_BACKUP_FILE: strcpy(name+9, "BUP"); break; case DVD_READ_INFO_FILE: strcpy(name+9, "IFO"); break; } (void) add_to_dir(buf, filler, name); } } } } /* Release our reference to dvd */ dec_refcnt(&mi); return 0; }