Esempio n. 1
0
int main()
{
	int N;
	scanf("%d",&N);
	int i;
	char s[100];
	getchar();
	for(i=1;i<=N;i++)
	{
		gets(s);
		printf("Case %d: ",i);
		int j=0;
		while(s[j]!='\0')
		{
			int t=0;
			char ts=s[j];
			j++;
			while(toi(s[j])<=9&&toi(s[j])>=0)
			{
				t=t*10+toi(s[j]);
				j++;
			}
			int k;
			for(k=1;k<=t;k++)
			{
				printf("%c",ts);
			}
		}
		printf("\n");
	}
    return 0;
}
Esempio n. 2
0
P getfarpoint(int y, int x, P map, int ly, int lx){
	P ret;
	P temp;
	ret = P(0, 0);
	if(atom(map)){}
	else{
		ret = getfarpoint2(y, x, fst(map), ly, lx);
		temp = getfarpoint(y + 1, x, snd(map), ly, lx);
		ret = P(toi(fst(ret)) + toi(fst(temp)), toi(snd(ret)) + toi(snd(temp)));
	}
	return ret;
}
Esempio n. 3
0
File: init.c Progetto: zhasni/Wolf3D
void	ft_texture_to_int(t_env *env)
{
	int				y;
	int				x;
	int				z;

	z = 0;
	while (z < 13)
	{
		y = 0;
		while (y < TEX_HEIGHT)
		{
			x = 0;
			while (x < TEX_WIDTH)
			{
				ft_get_color(env, x, y, z);
				env->texture[z][TEX_WIDTH * y + x] =
				toi(env->r, env->g, env->b);
				x++;
			}
			y++;
		}
		z++;
	}
}
Esempio n. 4
0
P getfarpoint2(int y, int x, P map, int ly, int lx){
	P ret;
	P temp;
	int point;

	ret = P(0, 0);
	if(atom(map)){}
	else{
		point = getPoint(y, x) / 10;
		//point = 0;
		ret = P(point * sign(y - ly), point * sign(x - lx));
		temp = getfarpoint2(y, x + 1, snd(map), ly, lx);
		ret = P(toi(fst(ret)) + toi(fst(temp)), toi(snd(ret)) + toi(snd(temp)));
	}
	return ret;
}
static unsigned int
toi(const void *p, int n)
{
	const unsigned char *v = (const unsigned char *)p;
	if (n > 1)
		return v[0] + 256 * toi(v + 1, n - 1);
	if (n == 1)
		return v[0];
	return (0);
}
Esempio n. 6
0
int getNumber2(int x, P map){
	int ret;
	if(x == 0){
		ret = toi(fst(map));
	}
	else{
		ret = getNumber2(x - 1, snd(map));
	}
	return ret;
}
static void
dump_isodirrec(FILE *out, const unsigned char *isodirrec)
{
	fprintf(out, " l %d,",
	    toi(isodirrec + DR_length_offset, DR_length_size));
	fprintf(out, " a %d,",
	    toi(isodirrec + DR_ext_attr_length_offset, DR_ext_attr_length_size));
	fprintf(out, " ext 0x%x,",
	    toi(isodirrec + DR_extent_offset, DR_extent_size));
	fprintf(out, " s %d,",
	    toi(isodirrec + DR_size_offset, DR_extent_size));
	fprintf(out, " f 0x%02x,",
	    toi(isodirrec + DR_flags_offset, DR_flags_size));
	fprintf(out, " u %d,",
	    toi(isodirrec + DR_file_unit_size_offset, DR_file_unit_size_size));
	fprintf(out, " ilv %d,",
	    toi(isodirrec + DR_interleave_offset, DR_interleave_size));
	fprintf(out, " seq %d,",
	    toi(isodirrec + DR_volume_sequence_number_offset, DR_volume_sequence_number_size));
	fprintf(out, " nl %d:",
	    toi(isodirrec + DR_name_len_offset, DR_name_len_size));
	fprintf(out, " `%.*s'",
	    toi(isodirrec + DR_name_len_offset, DR_name_len_size), isodirrec + DR_name_offset);
}
static int
isPVD(struct iso9660 *iso9660, const unsigned char *h)
{
	struct file_info *file;

	if (h[0] != 1)
		return (0);
	if (memcmp(h+1, "CD001", 5) != 0)
		return (0);

	iso9660->logical_block_size = toi(h + PVD_logical_block_size_offset, 2);

	/* Store the root directory in the pending list. */
	file = parse_file_info(iso9660, NULL, h + PVD_root_directory_record_offset);
	add_entry(iso9660, file);
	return (48);
}
Esempio n. 9
0
int check_serial(char *s){

	//check the length
	if (strlen(s) != 19){
		return 0;
	}
	
	//check format is xxxx-xxxx-xxxx-xxxx
	int i;
	for(i=4; i<20; i=i+5){
		if (i<15 && s[i] != '-'){
			return 0;
		}
		
		//check if it's numbers
		int j;
		for (j=i-4; j<i; j++){
			if (s[j] < 48 || s[j] > 57){
				return 0;
			}
		}
	}


	
	int first[4] = {toi(s[0]), toi(s[1]), toi(s[2]), toi(s[3])};
	int second[4] = {toi(s[5]), toi(s[6]), toi(s[7]), toi(s[8])};
	int third[4] = {toi(s[10]), toi(s[11]), toi(s[12]), toi(s[13])};
	int fourth[4] = {toi(s[15]), toi(s[16]), toi(s[17]), toi(s[18])};

	int sum_first = first[0]+first[1]+first[2]+first[3];
	int sum_second = second[0]+second[1]+second[2]+second[3];
	int sum_third = third[0]+third[1]+third[2]+third[3];
	int sum_fourth = fourth[0]+fourth[1]+fourth[2]+fourth[3];

	int avg_sums = (sum_first+sum_second+sum_third)/3;

	//constraint 2
	for(i=0; i<4; i++){
		if (fourth[i] < 3 || fourth[i] > 8){
			return 0;
		}
	}
	
	//constraint 3.1
	if(sum_fourth != avg_sums){
		return 0;
	}

	//constraint 3.2
	if(sum_first != sum_fourth/4){
		return 0;
	}
	
	//constraint 4
	if(sum_first == sum_second){
		return 0;
	}

	//constraints 5 and 6
	if(sameAtIndex(first, fourth) || sameAtIndex(second, third)){
		return 0;
	}

	return 1;

}
Esempio n. 10
0
// step
P step2(P ai, P game) {
	P map;

	P game2;

	P lambdaman;
	int vitality;
	P lambdaman2;
	P lambdalocation;
	int lambdax;
	int lambday;
	P lambdaman3;
	int lambdadirection;
	P lambdaman4;
	int lambdalive;
	int lambdascore;

	int ghostlength;

	P game3;
	P ghosts;

	P tempghost;
	int ghostvitality;
	P ghostlocation;
	int ghosty;
	int ghostx;
	int ghostdirection;

	int ghostdist;
	int ghostdist2;
	int ghostpoint;

	P fruits;

	int uppoint;
	int rightpoint;
	int downpoint;
	int leftpoint;

	int maxpoint;

	int retdirection;

	int ghostmul;

	int fruittime;

	P farpoint;

	turn = turn + 1;

	uppoint = 0;
	rightpoint = 0;
	downpoint = 0;
	leftpoint = 0;

	maxpoint = 0 - 99999999;
	retdirection = 0;

	map = fst(game);
	gmap = map;

	//list_to_tree(game);

	game2 = snd(game);
	lambdaman = fst(game2);
	game3 = snd(game2);
	ghosts = fst(game3);
	fruits = snd(game3);

	fruitbonus = 0;

	fruittime = toi(fruits);
	if(fruittime > 0){
		fruitbonus = 1000;
	}
	else{}

	//debug(fruittime);

	vitality = toi(fst(lambdaman));
	lambdaman2 = snd(lambdaman);
	lambdalocation = fst(lambdaman2);
	lambdax = toi(fst(lambdalocation));
	lambday = toi(snd(lambdalocation));
	lambdaman3 = snd(lambdaman2);
	lambdadirection = toi(fst(lambdaman3));
	lambdaman4 = snd(lambdaman3);
	lambdalive = toi(fst(lambdaman4));
	lambdascore = toi(snd(lambdaman4));

	uppoint = dfs(lambday - 1, lambdax, 10, 0) * 10;
	rightpoint = dfs(lambday, lambdax + 1, 10, 1) * 10;
	downpoint = dfs(lambday + 1, lambdax, 10, 2) * 10;
	leftpoint = dfs(lambday, lambdax - 1, 10, 3) * 10;

	if(getNumber(lambday - 1,lambdax, map) == 0){
		uppoint = 0 - 99999999;
	}
	else{}
	
	if(getNumber(lambday,lambdax + 1, map) == 0){
		rightpoint = 0 - 99999999;
	}
	else{}
	
	if(getNumber(lambday + 1,lambdax, map) == 0){
		downpoint = 0 - 99999999;
	}
	else{}
	
	if(getNumber(lambday,lambdax - 1, map) == 0){
		leftpoint = 0 - 99999999;
	}
	else{}

	//farpoint = P(0,0);
	//farpoint = getfarpoint(0, 0, map, lambday, lambdax);

	//uppoint = uppoint + toi(fst(farpoint));
	//rightpoint = rightpoint - toi(snd(farpoint));
	//downpoint = downpoint - toi(fst(farpoint));
	//leftpoint = leftpoint + toi(snd(farpoint));

	//ghostlength = 2 + mod(turn / 5, 13);
	ghostlength = 4;

	if(mod(myrand(), 30) == 0){
		randomv = mod(myrand(), 7);
	}

	if(randomv == 0){
		uppoint = uppoint + 1000;
	}
	else{}
	if(randomv == 1){
		rightpoint = rightpoint + 1000;
	}
	else{}
	if(randomv == 2){
		downpoint = downpoint + 1000;
	}
	else{}
	if(randomv == 3){
		leftpoint = leftpoint + 1000;
	}
	else{}


	while(1 - atom(ghosts)){
			tempghost = fst(ghosts);
		ghosts = snd(ghosts);
			ghostvitality = toi(fst(tempghost));
		tempghost = snd(tempghost);
			ghostlocation = fst(tempghost);
			ghostx = toi(fst(ghostlocation));
		ghosty = toi(snd(ghostlocation));
		ghostdirection = toi(snd(tempghost));
	
		ghostdist = abs(lambdax - ghostx) + abs(lambday - ghosty);

		if(ghostdist < (vitality / 127 - 3) * 2){
			if(ghostvitality == 2){
				ghostmul = 0;
			}
			else{
				ghostmul = -1;
			}
		}
		else{
			ghostmul = 1;
		}

		if(ghostdist < ghostlength){
			ghostpoint = 1000000 * ghostlength / pow2(ghostdist) * ghostmul;
		}
		else{
			ghostpoint = 0;
		}
	
		uppoint = uppoint - ghostpoint * sign(lambday - ghosty);
		rightpoint = rightpoint + ghostpoint * sign(lambdax - ghostx);
		downpoint = downpoint + ghostpoint * sign(lambday - ghosty);
		leftpoint = leftpoint - ghostpoint * sign(lambdax - ghostx);
	}

	if(maxpoint < uppoint){
		retdirection = 0;
		maxpoint = uppoint;
	}
	else{}
	if(maxpoint < rightpoint){
		retdirection = 1;
		maxpoint = rightpoint;
	}
	else{}
	if(maxpoint < downpoint){
		retdirection = 2;
		maxpoint = downpoint;
	}
	else{}
	if(maxpoint < leftpoint){
		retdirection = 3;
		maxpoint = leftpoint;
	}
	else{}



	return P(P(retdirection, 0), retdirection);
}
Esempio n. 11
0
void Invocation::loadParams() {
	int kk = cmdParams.size(), x = 0, intValue;
	string curParam, curValue;
	bool ok;
	while (x < kk) {
		curParam = cmdParams[x];
		if (curParam[0] != '-') {
			warningsQueue.pb("unreferenced value \"" + curParam + "\" found");
			goto rept;
		}
		if (curParam == "-nowarnings") goto rept;
		if (curParam == "-cfgfile") {
			++x;
			goto rept;
		}
		if (!flagsDict.count(curParam)) warningsQueue.pb("unknown parameter \"" + curParam + "\" is defined"); else {
			ok = !definedParams.count(curParam);
			if (!ok) warningsQueue.pb("parameter \"" + curParam + "\" redefinition. Last definition is accepted");
			if (curParam == "-help") params->setHelp(true); else
			if (curParam == "-helpcheckers") params->setHelpCheckers(true); else
			if (curParam == "-helpconfig") params->setHelpConfig(true); else
			if (curParam == "-helpdefault") params->setHelpDefault(true); else
			if (curParam == "-helpmasks") params->setHelpMasks(true); else {
				curValue = cmdParams[++x];
				if (curParam == "-c") params->setCheckerFileName(curValue); else
				if (curParam == "-checkertl") {
					intValue = toi(curValue);
					if (intValue == -1) {
						warningsQueue.pb("parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found");
						goto rept;
					}
					params->setCheckerTimeLimit(intValue);
				} else
				if (curParam == "-i") params->setInputFileName(curValue); else
				if (curParam == "-ml") {
					intValue = toi(curValue);
					if (intValue == -1) {
						warningsQueue.pb("parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found");
						goto rept;
					}
					params->setMemoryLimit(intValue);
				} else
				if (curParam == "-o") params->setOutputFileName(curValue); else
				if (curParam == "-p") params->setProgramFileName(curValue); else
				if (curParam == "-tc") {
					intValue = toi(curValue);
					if (intValue == -1) {
						warningsQueue.pb("parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found");
						goto rept;
					}
					params->setTestsCount(intValue);
				} else
				if (curParam == "-tim") params->getInputFileMask()->setFileMask(curValue); else
				if (curParam == "-tl") {
					intValue = toi(curValue);
					if (intValue == -1) {
						warningsQueue.pb("parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found");
						goto rept;
					}
					params->setTimeLimit(intValue);
				} else
				if (curParam == "-tom") params->getOutputFileMask()->setFileMask(curValue);
			}
			if (ok) definedParams.insert(curParam);
		}
rept:
		++x;
	}
	params->getInputFileMask()->parse();
	params->getOutputFileMask()->parse();
}
Esempio n. 12
0
char *get_ones(char digit)
{
  char *ones[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
  return ones[toi(digit) - 1];
}
Esempio n. 13
0
char *get_teens(char digit)
{
  char *teens[] = {"ten", "eleven", "twelve", "thirteen", "fourteen",
                   "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
  return teens[toi(digit)];
}
Esempio n. 14
0
char *get_tens(char digit)
{
  char *tens[] = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
  return tens[toi(digit) - 2];
}
Esempio n. 15
0
static int hextoi(const unsigned char *s) {
  return (toi(tolower(s[0])) << 4) | toi(tolower(s[1]));
}
 inline int toi(ForwardIter& i, ForwardIter j, int base)
 {
    typedef typename boost::is_convertible<ForwardIter, const char_type*&>::type tag_type;
    return toi(i, j, base, tag_type());
 }
Esempio n. 17
0
void Invocation::loadCFGFile() {
	ifstream * in = new ifstream(params->getCFGFileName());
	if (in->fail()) {
		in->close();
		delete in;
		if (params->getIsCFGFileSet()) warningsQueue.pb("configuration file \"" + params->getCFGFileName() + "\" was not found");
		return;
	}
	string s, curParam, curValue;
	int ls, x;
	bool ok;
	while (getline(*in, s)) {
		trim(s);
		if (s[0] == '[' || s[0] == ';') continue;
		ls = s.length();
		x = -1;
		for (int i = 0; i < ls; ++i)
			if (isDelim(s[i]) || s[i] == '=') {
				x = i;
				break;
			}
		if (x == -1) {
			warningsQueue.pb("error in configuration file format :: string \"" + s + "\" is incorrect. Use \"parameter=value\" definitions. Run with \"-helpconfig\" flag to see help message");
			continue;
		}
		curParam = lowercase(s.substr(0, x));
		if (curParam[0] != '-') curParam = "-" + curParam;
		while (x < ls && s[x] != '=') ++x;
		if (x++ >= ls) {
			warningsQueue.pb("error in configuration file format :: string \"" + s + "\" is incorrect. Use \"parameter=value\" definitions. Run with \"-helpconfig\" flag to see help message");
			continue;
		}
		while (x < ls && isDelim(s[x])) ++x;
		if (x >= ls) {
			warningsQueue.pb("error in configuration file format :: string \"" + s + "\" is incorrect. Use \"parameter=value\" definitions. Run with \"-helpconfig\" flag to see help message");
			continue;
		}
		curValue = s.substr(x);
		if (!flagsDict.count(curParam)) {
			warningsQueue.pb("unknown parameter \"" + curParam + "\" is defined in configuration file");
			continue;
		}
		ok = !definedParams.count(curParam);
		if (!ok) warningsQueue.pb("parameter \"" + curParam + "\" redefinition if configuration file. Last definition is accepted");
		int intValue;
		if (curParam == "-c") params->setCheckerFileName(curValue); else
		if (curParam == "-checkertl") {
			intValue = toi(curValue);
			if (intValue == -1) {
				warningsQueue.pb("parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found in configuration file");
				continue;
			}
			params->setCheckerTimeLimit(intValue);
		} else
		if (curParam == "-i") params->setInputFileName(curValue); else
		if (curParam == "-ml") {
			intValue = toi(curValue);
			if (intValue == -1) {
				warningsQueue.pb("configuration file :: parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found");
				continue;
			}
			params->setMemoryLimit(intValue);
		} else
		if (curParam == "-o") params->setOutputFileName(curValue); else
		if (curParam == "-p") params->setProgramFileName(curValue); else
		if (curParam == "-tc") {
			intValue = toi(curValue);
			if (intValue == -1) {
				warningsQueue.pb("configuration file :: parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found");
				continue;
			}
			params->setTestsCount(intValue);
		} else
		if (curParam == "-tim") params->getInputFileMask()->setFileMask(curValue); else
		if (curParam == "-tl") {
			intValue = toi(curValue);
			if (intValue == -1) {
				warningsQueue.pb("parameter \"" + curParam + "\" - expected value is a number but \"" + curValue + "\" found in configuration file");
				continue;
			}
			params->setTimeLimit(intValue);
		} else
		if (curParam == "-tom") params->getOutputFileMask()->setFileMask(curValue); else 
		if (curParam != "-nowarnings") {
			ok = false;
			warningsQueue.pb("parameter \"" + curParam + "\" can not be defined in configuration file");
		}
		if (ok) definedParams.insert(curParam);
	}
	in->close();
	delete in;
}
static void
parse_rockridge(struct iso9660 *iso9660, struct file_info *file,
    const unsigned char *p, const unsigned char *end)
{
	(void)iso9660; /* UNUSED */

	while (p + 4 < end  /* Enough space for another entry. */
	    && p[0] >= 'A' && p[0] <= 'Z' /* Sanity-check 1st char of name. */
	    && p[1] >= 'A' && p[1] <= 'Z' /* Sanity-check 2nd char of name. */
	    && p + p[2] <= end) { /* Sanity-check length. */
		const unsigned char *data = p + 4;
		int data_length = p[2] - 4;
		int version = p[3];

		/*
		 * Yes, each 'if' here does test p[0] again.
		 * Otherwise, the fall-through handling to catch
		 * unsupported extensions doesn't work.
		 */
		switch(p[0]) {
		case 'C':
			if (p[0] == 'C' && p[1] == 'E' && version == 1) {
				/*
				 * CE extension comprises:
				 *   8 byte sector containing extension
				 *   8 byte offset w/in above sector
				 *   8 byte length of continuation
				 */
				file->ce_offset = toi(data, 4)
				    * iso9660->logical_block_size
				    + toi(data + 8, 4);
				file->ce_size = toi(data + 16, 4);
				break;
			}
			/* FALLTHROUGH */
		case 'N':
			if (p[0] == 'N' && p[1] == 'M' && version == 1
				&& *data == 0) {
				/* NM extension with flag byte == 0 */
				/*
				 * NM extension comprises:
				 *   one byte flag
				 *   rest is long name
				 */
				/* TODO: Obey flags. */
				char *old_name = file->name;

				data++;  /* Skip flag byte. */
				data_length--;
				file->name = (char *)malloc(data_length + 1);
				if (file->name != NULL) {
					free(old_name);
					memcpy(file->name, data, data_length);
					file->name[data_length] = '\0';
				} else
					file->name = old_name;
				break;
			}
			/* FALLTHROUGH */
		case 'P':
			if (p[0] == 'P' && p[1] == 'D' && version == 1) {
				/*
				 * PD extension is padding;
				 * contents are always ignored.
				 */
				break;
			}
			if (p[0] == 'P' && p[1] == 'X' && version == 1) {
				/*
				 * PX extension comprises:
				 *   8 bytes for mode,
				 *   8 bytes for nlinks,
				 *   8 bytes for uid,
				 *   8 bytes for gid,
				 *   8 bytes for inode.
				 */
				if (data_length == 32) {
					file->mode = toi(data, 4);
					file->nlinks = toi(data + 8, 4);
					file->uid = toi(data + 16, 4);
					file->gid = toi(data + 24, 4);
					file->inode = toi(data + 32, 4);
				}
				break;
			}
			/* FALLTHROUGH */
		case 'R':
			if (p[0] == 'R' && p[1] == 'R' && version == 1) {
				iso9660->seenRockridge = 1;
				/*
				 * RR extension comprises:
				 *    one byte flag value
				 */
				/* TODO: Handle RR extension. */
				break;
			}
			/* FALLTHROUGH */
		case 'S':
			if (p[0] == 'S' && p[1] == 'L' && version == 1
			    && *data == 0) {
				int cont = 1;
				/* SL extension with flags == 0 */
				/* TODO: handle non-zero flag values. */
				data++;  /* Skip flag byte. */
				data_length--;
				while (data_length > 0) {
					unsigned char flag = *data++;
					unsigned char nlen = *data++;
					data_length -= 2;

					if (cont == 0)
						archive_strcat(&file->symlink, "/");
					cont = 0;

					switch(flag) {
					case 0x01: /* Continue */
						archive_strncat(&file->symlink,
						    (const char *)data, nlen);
						cont = 1;
						break;
					case 0x02: /* Current */
						archive_strcat(&file->symlink, ".");
						break;
					case 0x04: /* Parent */
						archive_strcat(&file->symlink, "..");
						break;
					case 0x08: /* Root */
					case 0x10: /* Volume root */
						archive_string_empty(&file->symlink);
						break;
					case 0x20: /* Hostname */
						archive_strcat(&file->symlink, "hostname");
						break;
					case 0:
						archive_strncat(&file->symlink,
						    (const char *)data, nlen);
						break;
					default:
						/* TODO: issue a warning ? */
						break;
					}
					data += nlen;
					data_length -= nlen;
				}
				break;
			}
			if (p[0] == 'S' && p[1] == 'P'
			    && version == 1 && data_length == 7
			    && data[0] == (unsigned char)'\xbe'
			    && data[1] == (unsigned char)'\xef') {
				/*
				 * SP extension stores the suspOffset
				 * (Number of bytes to skip between
				 * filename and SUSP records.)
				 * It is mandatory by the SUSP standard
				 * (IEEE 1281).
				 *
				 * It allows SUSP to coexist with
				 * non-SUSP uses of the System
				 * Use Area by placing non-SUSP data
				 * before SUSP data.
				 *
				 * TODO: Add a check for 'SP' in
				 * first directory entry, disable all SUSP
				 * processing if not found.
				 */
				iso9660->suspOffset = data[2];
				break;
			}
			if (p[0] == 'S' && p[1] == 'T'
			    && data_length == 0 && version == 1) {
				/*
				 * ST extension marks end of this
				 * block of SUSP entries.
				 *
				 * It allows SUSP to coexist with
				 * non-SUSP uses of the System
				 * Use Area by placing non-SUSP data
				 * after SUSP data.
				 */
				return;
			}
		case 'T':
			if (p[0] == 'T' && p[1] == 'F' && version == 1) {
				char flag = data[0];
				/*
				 * TF extension comprises:
				 *   one byte flag
				 *   create time (optional)
				 *   modify time (optional)
				 *   access time (optional)
				 *   attribute time (optional)
				 *  Time format and presence of fields
				 *  is controlled by flag bits.
				 */
				data++;
				if (flag & 0x80) {
					/* Use 17-byte time format. */
					if (flag & 1) /* Create time. */
						data += 17;
					if (flag & 2) { /* Modify time. */
						file->mtime = isodate17(data);
						data += 17;
					}
					if (flag & 4) { /* Access time. */
						file->atime = isodate17(data);
						data += 17;
					}
					if (flag & 8) { /* Attribute time. */
						file->ctime = isodate17(data);
						data += 17;
					}
				} else {
					/* Use 7-byte time format. */
					if (flag & 1) /* Create time. */
						data += 7;
					if (flag & 2) { /* Modify time. */
						file->mtime = isodate7(data);
						data += 7;
					}
					if (flag & 4) { /* Access time. */
						file->atime = isodate7(data);
						data += 7;
					}
					if (flag & 8) { /* Attribute time. */
						file->ctime = isodate7(data);
						data += 7;
					}
				}
				break;
			}
			/* FALLTHROUGH */
		default:
			/* The FALLTHROUGHs above leave us here for
			 * any unsupported extension. */
			{
				const unsigned char *t;
				fprintf(stderr, "\nUnsupported RRIP extension for %s\n", file->name);
				fprintf(stderr, " %c%c(%d):", p[0], p[1], data_length);
				for (t = data; t < data + data_length && t < data + 16; t++)
					fprintf(stderr, " %02x", *t);
				fprintf(stderr, "\n");
			}
		}



		p += p[2];
	}
}
/*
 * This routine parses a single ISO directory record, makes sense
 * of any extensions, and stores the result in memory.
 */
static struct file_info *
parse_file_info(struct iso9660 *iso9660, struct file_info *parent,
    const unsigned char *isodirrec)
{
	struct file_info *file;
	size_t name_len;
	int flags;

	/* TODO: Sanity check that name_len doesn't exceed length, etc. */

	/* Create a new file entry and copy data from the ISO dir record. */
	file = (struct file_info *)malloc(sizeof(*file));
	if (file == NULL)
		return (NULL);
	memset(file, 0, sizeof(*file));
	file->parent = parent;
	if (parent != NULL)
		parent->refcount++;
	file->offset = toi(isodirrec + DR_extent_offset, DR_extent_size)
	    * iso9660->logical_block_size;
	file->size = toi(isodirrec + DR_size_offset, DR_size_size);
	file->mtime = isodate7(isodirrec + DR_date_offset);
	file->ctime = file->atime = file->mtime;
	name_len = (size_t)*(const unsigned char *)(isodirrec + DR_name_len_offset);
	file->name = (char *)malloc(name_len + 1);
	if (file->name == NULL) {
		free(file);
		return (NULL);
	}
	memcpy(file->name, isodirrec + DR_name_offset, name_len);
	file->name[name_len] = '\0';
	flags = *(isodirrec + DR_flags_offset);
	if (flags & 0x02)
		file->mode = AE_IFDIR | 0700;
	else
		file->mode = AE_IFREG | 0400;

	/* Rockridge extensions overwrite information from above. */
	{
		const unsigned char *rr_start, *rr_end;
		rr_end = (const unsigned char *)isodirrec
		    + *(isodirrec + DR_length_offset);
		rr_start = (const unsigned char *)(isodirrec + DR_name_offset
		    + name_len);
		if ((name_len & 1) == 0)
			rr_start++;
		rr_start += iso9660->suspOffset;
		parse_rockridge(iso9660, file, rr_start, rr_end);
	}

	/* DEBUGGING: Warn about attributes I don't yet fully support. */
	if ((flags & ~0x02) != 0) {
		fprintf(stderr, "\n ** Unrecognized flag: ");
		dump_isodirrec(stderr, isodirrec);
		fprintf(stderr, "\n");
	} else if (toi(isodirrec + DR_volume_sequence_number_offset, 2) != 1) {
		fprintf(stderr, "\n ** Unrecognized sequence number: ");
		dump_isodirrec(stderr, isodirrec);
		fprintf(stderr, "\n");
	} else if (*(isodirrec + DR_file_unit_size_offset) != 0) {
		fprintf(stderr, "\n ** Unexpected file unit size: ");
		dump_isodirrec(stderr, isodirrec);
		fprintf(stderr, "\n");
	} else if (*(isodirrec + DR_interleave_offset) != 0) {
		fprintf(stderr, "\n ** Unexpected interleave: ");
		dump_isodirrec(stderr, isodirrec);
		fprintf(stderr, "\n");
	} else if (*(isodirrec + DR_ext_attr_length_offset) != 0) {
		fprintf(stderr, "\n ** Unexpected extended attribute length: ");
		dump_isodirrec(stderr, isodirrec);
		fprintf(stderr, "\n");
	}

	return (file);
}