예제 #1
0
/*
 ****************************************************************
 *	Chamada ao sistema "stime"				*
 ****************************************************************
 */
int
stime (const time_t *tp)
{
	time_t		t;

	if ((t = gulong (tp)) == -1)
		{ u.u_error = EFAULT; return (-1); }

	if (superuser () == 0)
		{ time = t; sb_head.sb_forw->sb_sbmod = 1; }

	return (UNDEF);

}	/* end stime */
예제 #2
0
파일: storage.cpp 프로젝트: 2php/stardict-3
gulong offset_rindex::load_page(glong page_idx)
{
	g_assert(gulong(page_idx+1)<npages);
	gulong nentr=ENTR_PER_PAGE;
	if (page_idx==glong(npages-2))
		if ((nentr=filecount%ENTR_PER_PAGE)==0)
			nentr=ENTR_PER_PAGE;


	if (page_idx!=page.page_idx) {
		page_data.resize(oft_file.get_wordoffset(page_idx+1)-oft_file.get_wordoffset(page_idx));
		fseek(idxfile, oft_file.get_wordoffset(page_idx), SEEK_SET);
		size_t fread_size;
		size_t page_data_size = page_data.size();
		fread_size = fread(&page_data[0], 1, page_data_size, idxfile);
		if (fread_size != page_data_size) {
			g_print("fread error!\n");
		}
		page.fill(&page_data[0], nentr, page_idx);
	}

	return nentr;
}
예제 #3
0
bool load_index(const std::string& ridx_url, index_vect_t &index_vect, 
	gulong filesize, gulong filecount, index_type_t index_type)
{
	std::vector<char> buffer(filesize);
	if(index_type == itRidx) {
		FILE *f = fopen(ridx_url.c_str(), "rb");
		if(!f)
			return false;
		size_t the_size;
		the_size = fread(&buffer[0], 1, filesize, f);
		if (the_size != filesize) {
			g_print("fread error!\n");
		}
		fclose(f);
	} else if(index_type == itRidxGz) {
		gzFile f = gzopen(ridx_url.c_str(), "rb");
		if (f == NULL)
			return false;
		gulong len = gzread(f, &buffer[0], filesize);
		gzclose(f);
		if(len != filesize)
			return false;
	} else
		return false;
	index_vect.resize(filecount);
	char *p = &buffer[0];
	for(gulong i=0; i<filecount; ++i) {
		index_vect[i].key = p;
		p += strlen(p) + 1;
		index_vect[i].off = g_ntohl(get_uint32(p));
		p += sizeof(guint32);
		index_vect[i].size = g_ntohl(get_uint32(p));
		p += sizeof(guint32);
	}
	g_assert(gulong(p-&buffer[0]) == filesize);
	return true;
}