Esempio n. 1
0
int main(int argc, char *argv[]){
	if(argc!=2){	//needs filename for command line argument
		fprintf(stderr,"chose a program name\n");
		exit(0);
	}
	filename=argv[1];
	int c;
	if((c=init_scan(filename))<0){ //file open
		error("init_scan;cannot open");
	}
	printf(">>>software5 ex01 Start!! #FILE NAME : %s\n",filename);
	debugPutOut();	//when define showDetail, it works
	init_idtab();	/*FROM "idList.c*/
	int i=0;	//get scan() feedback
	while(i>=0){
		i=scan();	/*FROM scan.c*/
		if(i!=0){
			tokenCount[i]++;
			if(i==TNAME){	//when
				id_countup(string_attr);	/*FROM "idList.c*/
			}
		}
	}
	printExistToken();	/*FROM "fileAccess.c*/
	print_idtab();	/*FROM "idList.c*/
	release_idtab();	/*FROM "idList.c*/
	end_scan();	/*FROM "fileAccess.c*/
	printf("<<<end\n");
	return EXIT_SUCCESS;
}
Esempio n. 2
0
void test_sort_1(CuTest *tc)
{
	/* General variable declaration. */
	db_query_mm_t mm;
	char segment[2000];
	init_query_mm(&mm, segment, 2000);
	
	scan_t scan;
	sort_t sort;
	db_tuple_t t;
	db_eet_t oneExpr[1];
	db_uint8 oneOrder[1];
	db_eetnode_attr_t attrNode;
	attrNode.base.type = DB_EETNODE_ATTR;
	db_int intResult;
	
	puts("**********************************************************************");
	puts("Test 1: Sort test_rel3 using first attribute in ascending order.");
	fflush(stdout);
	
	oneExpr[0].size = (1*sizeof(db_eetnode_attr_t) + 0*sizeof(db_eetnode_dbint_t));
	oneExpr[0].nodes = malloc((size_t)oneExpr[0].size);
	oneExpr[0].stack_size = oneExpr[0].size;
	oneOrder[0] = (db_uint8)DB_TUPLE_ORDER_ASC;
	
	attrNode.pos = 0;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(oneExpr[0].nodes))) = attrNode;
	
	init_scan(&scan, "test_rel3", &mm);
	init_sort(&sort, (db_op_base_t*)(&scan), oneExpr, 1, oneOrder, &mm);
	init_tuple(&t, sort.base.header->tuple_size, sort.base.header->num_attr, &mm);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 1 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	//printf("Result of next call: %d\n", intResult);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 73 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	close((db_op_base_t*)&sort, &mm);
	close((db_op_base_t*)&scan, &mm);
	free(oneExpr[0].nodes);
	close_tuple(&t, &mm);
	puts("**********************************************************************");
}
Esempio n. 3
0
int main(int nc, char *np[]) {
	if(nc < 2){
		printf("File has not been specified\n");
		return -1;
	}
	if(init_scan(np[1]) < 0){
		printf("file: %s does not open\n",np[1]);
		return -1;
	}

	token = scan();
	init_cross();
	if(parse_program()==NORMAL){
		//クロスリファレンス表の出力
		printCrossRef();
	}

	//globalidrootのクリア
	release_globalidtab();
	end_scan();
	return 0;
}
Esempio n. 4
0
void test_sort_11(CuTest *tc)
{
	/* General variable declaration. */
	db_query_mm_t mm;
	char segment[2000];
	init_query_mm(&mm, segment, 2000);
	
	scan_t scan;
	sort_t sort;
	db_tuple_t t;
	db_eet_t twoExpr[2];
	db_uint8 twoOrder[2];
	db_eetnode_attr_t attrNode;
	attrNode.base.type = DB_EETNODE_ATTR;
	db_eetnode_t opNode;
	db_eetnode_t *arr_p;
	db_int intResult;
	
	puts("**********************************************************************");
	puts("Test 11: Sort fruit_stock_1 using two complex expressions.");
	fflush(stdout);
	twoExpr[0].size = (1*sizeof(db_eetnode_attr_t) + 0*sizeof(db_eetnode_dbstring_t)+ 1*sizeof(db_eetnode_t));
	twoExpr[0].nodes = malloc((size_t)twoExpr[0].size);
	twoExpr[0].stack_size = twoExpr[0].size;
	twoExpr[1].size = (2*sizeof(db_eetnode_attr_t) + 0*sizeof(db_eetnode_dbint_t)+ 1*sizeof(db_eetnode_t));
	twoExpr[1].nodes = malloc((size_t)twoExpr[1].size);
	twoExpr[1].stack_size = twoExpr[1].size;
	twoOrder[0] = DB_TUPLE_ORDER_ASC;
	twoOrder[1] = DB_TUPLE_ORDER_ASC;
	
	arr_p = twoExpr[0].nodes;
	
	attrNode.pos = 1;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(arr_p))) = attrNode;
	arr_p = ((db_eetnode_t*)(((db_eetnode_attr_t*)(arr_p))+1));
	
	opNode.type = DB_EETNODE_FUNC_LENGTH_DBSTRING;
	*arr_p = opNode;
	arr_p++;
	
	arr_p = twoExpr[1].nodes;
	
	attrNode.pos = 2;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(arr_p))) = attrNode;
	arr_p = ((db_eetnode_t*)(((db_eetnode_attr_t*)(arr_p))+1));
	
	attrNode.pos = 3;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(arr_p))) = attrNode;
	arr_p = ((db_eetnode_t*)(((db_eetnode_attr_t*)(arr_p))+1));
	
	opNode.type = DB_EETNODE_OP_MOD;
	*arr_p = opNode;
	arr_p++;
	
	init_scan(&scan, "fruit_stock_2", &mm);
	init_sort(&sort, (db_op_base_t*)(&scan), twoExpr, 2, twoOrder, &mm);
	init_tuple(&t, sort.base.header->tuple_size, sort.base.header->num_attr, &mm);
	
	// TODO: I really should change getintbypos and such to return to an address.
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, (1 << 0) + (1 << 1) + (1 << 2) == t.isnull[0]);
	//intResult = getintbypos(&t, 0, sort.base.header);
	//printf("Int value at position %d the tuple: %d\n", 0, intResult);
	//CuAssertTrue(tc, 3 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, (1 << 1) + (1 << 2) == t.isnull[0]);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 8 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, (1 << 1) == t.isnull[0]);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 3 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, (1 << 0) + (1 << 1) == t.isnull[0]);
	//intResult = getintbypos(&t, 0, sort.base.header);
	//printf("Int value at position %d the tuple: %d\n", 0, intResult);
	//CuAssertTrue(tc, 3 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, (1 << 2) == t.isnull[0]);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 5 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, (1 << 0) + (1 << 2) == t.isnull[0]);
	//intResult = getintbypos(&t, 0, sort.base.header);
	//printf("Int value at position %d the tuple: %d\n", 0, intResult);
	//CuAssertTrue(tc, 3 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, (1 << 0) == t.isnull[0]);
	//intResult = getintbypos(&t, 0, sort.base.header);
	//printf("Int value at position %d the tuple: %d\n", 0, intResult);
	//CuAssertTrue(tc, 3 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	CuAssertTrue(tc, 0 == t.isnull[0]);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 2 == intResult);
	

	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	close((db_op_base_t*)&sort, &mm);
	close((db_op_base_t*)&scan, &mm);
	close_tuple(&t, &mm);
	free(twoExpr[0].nodes);
	free(twoExpr[1].nodes);
	puts("**********************************************************************");
}
Esempio n. 5
0
void test_sort_9(CuTest *tc)
{
	/* General variable declaration. */
	db_query_mm_t mm;
	char segment[2000];
	init_query_mm(&mm, segment, 2000);
	
	scan_t scan;
	sort_t sort;
	db_tuple_t t;
	db_eet_t oneExpr[1];
	db_uint8 oneOrder[1];
	db_eetnode_attr_t attrNode;
	attrNode.base.type = DB_EETNODE_ATTR;
	db_eetnode_t opNode;
	db_eetnode_t *arr_p;
	db_int intResult;
	
	puts("**********************************************************************");
	puts("Test 9: Sort fruit_stock_1 using (3rd > 4th), in descending order.");
	fflush(stdout);
	oneExpr[0].size = (2*sizeof(db_eetnode_attr_t) + 0*sizeof(db_eetnode_dbint_t)+ 2*sizeof(db_eetnode_t));
	oneExpr[0].nodes = malloc((size_t)oneExpr[0].size);
	oneExpr[0].stack_size = oneExpr[0].size;
	oneOrder[0] = DB_TUPLE_ORDER_DESC;
	
	arr_p = oneExpr[0].nodes;
	
	attrNode.pos = 2;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(arr_p))) = attrNode;
	arr_p = ((db_eetnode_t*)(((db_eetnode_attr_t*)(arr_p))+1));
	
	attrNode.pos = 3;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(arr_p))) = attrNode;
	
	init_scan(&scan, "fruit_stock_1", &mm);
	init_sort(&sort, (db_op_base_t*)(&scan), oneExpr, 1, oneOrder, &mm);
	init_tuple(&t, sort.base.header->tuple_size, sort.base.header->num_attr, &mm);
	
	opNode.type = DB_EETNODE_OP_GT;
	*arr_p = opNode;
	arr_p++;
	
	opNode.type = DB_EETNODE_OP_NOT;
	*arr_p = opNode;
	arr_p++;
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 1 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 2 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 3 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 4 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 5 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	close((db_op_base_t*)&sort, &mm);
	close((db_op_base_t*)&scan, &mm);
	close_tuple(&t, &mm);
	free(oneExpr[0].nodes);
	puts("**********************************************************************");
}
Esempio n. 6
0
void test_sort_7(CuTest *tc)
{
	/* General variable declaration. */
	db_query_mm_t mm;
	char segment[2000];
	init_query_mm(&mm, segment, 2000);
	
	scan_t scan;
	sort_t sort;
	db_tuple_t t;
	db_eet_t twoExpr[2];
	db_uint8 twoOrder[2];
	db_eetnode_attr_t attrNode;
	attrNode.base.type = DB_EETNODE_ATTR;
	db_int intResult;
	
	puts("**********************************************************************");
	puts("Test 7: Sort fruit_stock_1 using 4th and 3rd attributes, in asc/desc order (respectively).");
	fflush(stdout);
	
	twoExpr[0].size = (1*sizeof(db_eetnode_attr_t) + 0*sizeof(db_eetnode_dbint_t));
	twoExpr[0].nodes = malloc((size_t)twoExpr[0].size);
	twoExpr[0].stack_size = twoExpr[0].size;
	
	twoExpr[1].size = (1*sizeof(db_eetnode_attr_t) + 0*sizeof(db_eetnode_dbint_t));
	twoExpr[1].nodes = malloc((size_t)twoExpr[1].size);
	twoExpr[1].stack_size = twoExpr[1].size;
	
	twoOrder[0] = DB_TUPLE_ORDER_ASC;
	twoOrder[1] = DB_TUPLE_ORDER_DESC;
	
	attrNode.pos = 3;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(twoExpr[0].nodes))) = attrNode;
	
	attrNode.pos = 2;
	attrNode.tuple_pos = 0;
	(*((db_eetnode_attr_t*)(twoExpr[1].nodes))) = attrNode;
	
	init_scan(&scan, "fruit_stock_1", &mm);
	init_sort(&sort, (db_op_base_t*)(&scan), twoExpr, 2, twoOrder, &mm);
	init_tuple(&t, sort.base.header->tuple_size, sort.base.header->num_attr, &mm);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 3 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 1 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 2 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 5 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 1 == intResult);
	intResult = getintbypos(&t, 0, sort.base.header);
	printf("Int value at position %d the tuple: %d\n", 0, intResult);
	CuAssertTrue(tc, 4 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	intResult = next((db_op_base_t*)&sort, &t, &mm);
	CuAssertTrue(tc, 0 == intResult);
	
	close((db_op_base_t*)&sort, &mm);
	close((db_op_base_t*)&scan, &mm);
	close_tuple(&t, &mm);
	free(twoExpr[0].nodes);
	free(twoExpr[1].nodes);
	puts("**********************************************************************");
}
Esempio n. 7
0
//MAIN function
void main (void)
{
	/*Variable Declaration*/
	char pass[PASS_LENGTH], x; 	//pass is the pass entered. 'x' stores temp data
	int loop; 					//variable for loops
	char attempts, entered;		//amount of passcode attempts. amount of data entered (when entering passcode)
	
	/*Setup*/
	{
	DisplayInit();
	settim0 ();
	init_scan();
	init_door();
		/*This section may cause issues on DEV board as it's not configured to hold P1.4 low during normal operation*/
		P1M1|=0x10;
		P1M2&=0xEF; //sets P1.4 to '10'(input mode)
		if((P1&0x10)==0x10) //if P1.4 is held high (Hardware override to wipe eeprom)
		{
			eeprom_clear(0);
			Write("done");
			while(1); //infinite loop, Hardware must be reset again.
		}
		//*************************************************************************************************************/
		
	for(loop=0;loop<PASS_LENGTH;++loop)
	{
		pass[loop]=PASS_NULL; //sets the passcode to PASS_NULL
	}
	entered=0;
	attempts=0;
	Write("init");
	//Should I shut the door here? Spec doesn't Spec and I would assume so.
	}
	
	
	//infinite loop begins
	while(1)
	{
		/*--idling state.--*/
		
		x=passcode_entering(pass,30);	//store data to pass, 30seconds till idle
		
		if(x==KEY_ENTER)	//enter has been pressed.
		{
			while(scan()==1)
			key_flag=0;
			//code check portion
			if (code_check(pass)==1)
			{
				
				//passcode is correct
				//enter open routine
				door_routine();
				//should include passcode change section.
				
				
				//clear passcode, ready for idling
				for(loop=0;loop<PASS_LENGTH;++loop)
				{
					pass[loop]=PASS_NULL; 			//clears stored passcode
				}
				entered=0;
				attempts=0;
				Write("shut");
			}
			else 
			{
				//passcode incorrect
				++attempts;
				if(attempts>=3) //third fail will lock door down
				{
					Write("Bar ");
					
					for(clock=0;clock<(120*clock_freq);) 
						{/*enter three minute loop*/}
					
					attempts=0;	//reset attempts to 0
				}
				for(loop=0;loop<PASS_LENGTH;++loop)
				{
					pass[loop]=PASS_NULL; //clears stored passcode
				}
				Write("shut");
			}
		}//end of 'if(x==KEY_ENTER)'
		
		//clears stored passcode
		for(loop=0;loop<PASS_LENGTH;++loop)
		{
			pass[loop]=PASS_NULL; 
		}
		Write("shut");
		
		if(x==0) //display
			{
				attempts=0; //clears attempts if passcode entering times out
			}
		
	}
	//end of while(1) loop

	/*Error catching Area*/
	Write("Err1");
	while(1);
	/*********************/
}
Esempio n. 8
0
int main() {
  init_dicos();
  init_pile_table();
  init_scan();
  
  A = genForet();
  {// imprim foret G0
  	printf("-------- *********************** ---------\n");
  	printf("-------- Affichage foret G0 ---------\n");
  	printf("-------- *********************** ---------\n");
		ImprimArbre(A[0]);
		ImprimArbre(A[1]);
		ImprimArbre(A[2]);
		ImprimArbre(A[3]);
		ImprimArbre(A[4]);
  }

  printf("-------- *********************** ---------\nresultat analyse G0 : %d\n", AnalyseG0(A[0]));
  printf("-------- *********************** ---------\n\n");
  {//imprim foret GPL
		int i;
  	printf("-------- *********************** ---------\n");
  	printf("-------- Affichage foret GPL ---------\n");
  	printf("-------- *********************** ---------\n");
		for(i=5 ; i<tailleForet ; i++){
			ImprimArbre(A[i]);
		}
  }
  init_interpreter();
  init_scanGPL();
  printf("-------- *********************** ---------\nresultat analyse GPL : %d\n", AnalyseGPL(A[5]));
	printf("-------- *********************** ---------\n\n");
	
	printf("S = ");
	//on affiche la valeur de S avec du PCODE
	/*pcode[c0] = LDV;
	c0++;
  pcode[c0] = 0;
	c0++;
  pcode[c0] = WRTLN;
	c0++;*/
	pcode[c0] = STOP;
	c0++;
	c0=0;
	exec();
  
  
    printf("-------- *********************** ---------\n");
  	printf("-------- Test interpreter :---------\n");
  	printf("* Somme des N premiers entiers, entrez N *\n");
  	printf("-------- *********************** ---------\n");
  //test interpreter
  spx = 2;//3 variables
  
  //I=0;
  pcode[0] = LDA;
  pcode[1] = 0;
  pcode[2] = LDC;
  pcode[3] = 0;
  pcode[4] = AFF;
  //S=0;
  pcode[5] = LDA;
  pcode[6] = 1;
  pcode[7] = LDC;
  pcode[8] = 0;
  pcode[9] = AFF;
  //N=read();
  pcode[10] = LDA;
  pcode[11] = 2;
  pcode[12] = RDLN;
  pcode[13] = AFF;
  //while(I<=N){
  pcode[14] = LDV;
  pcode[15] = 0;
  pcode[16] = LDV;
  pcode[17] = 2;
  pcode[18] = INFE;
  pcode[19] = JIF;
  pcode[20] = 37;
  //S=S+I;
  pcode[21] = LDA;
  pcode[22] = 1;
  pcode[23] = LDV;
  pcode[24] = 1;
  pcode[25] = LDV;
  pcode[26] = 0;
  pcode[27] = ADD;
  pcode[28] = AFF;
  //I++;
  pcode[29] = LDA;
  pcode[30] = 0;
  pcode[31] = LDV;
  pcode[32] = 0;
  pcode[33] = INC;
  pcode[34] = AFF;
  
  //}
  pcode[35] = JMP;
  pcode[36] = 14;
  //writeln(S);
  pcode[37] = LDV;
  pcode[38] = 1;
  pcode[39] = WRTLN;
  pcode[40] = STOP;
  c0 = 0;
  
  exec();

  return 0;
}
Esempio n. 9
0
void  ufStnHdlr::ProcessCheckedScans(int maxscans) 
{
  //NOTE:  new scans go on one end of LL,  need to read them off the other end
  // so its a queue, not  a stack!!
  /*
    openvolume
    init_ppivol(rootscan)
    lastelev = -1
    for each scan in vol
    if not first & thiselev != lastelev
    setScanData(scan,scanPtr)
    if thiselev != lastdev
    init_scan(scanPtr)
    addScanData(scan,scanPtr) with approp. field set
    lastelev = thiselev

    setScanData(scan,scanPtr)  //write last elevation
    closeVolume
  */
  rdr_scan_node   *tempscannode;	
  rdr_scan	  *tempscan;
  rdr_scan	  *tempScanElev;
  //  uf		  *uf_out;
  char 		   uffilename[256];
  //  FILE		  *uffd;
  struct scan     *scandata;
  int		   lastelevang;
  int              scanngates;
  

  if (debug) 
    {
      printf(".");
      fflush(stdout);
    }
  
  //process members of checkedscans,  send to Uf!
  while (checkedscans_last && !stopFlag)
    {
      tempscannode = (rdr_scan_node *)checkedscans_last->prev;
      tempscan = (rdr_scan *)checkedscans_last->scan->rootScan();
      if (debug) printf(
			"ufStnHdlr::ProcessCheckedScans: scan %02d/%d/%d %02d:%02d:%02d\n",
			tempscan->year,tempscan->month,tempscan->day,tempscan->hour,
			tempscan->min,tempscan->sec);
      
      //open output file in default dir
      sprintf(uffilename,"%s%s%04d%02d%02d_%02d%02d%02d.uf",
	      stationName,radarTypeStr,
	      tempscan->year,tempscan->month,tempscan->day,
	      tempscan->hour,tempscan->min,tempscan->sec);
      printf("ufStnHdlr::ProcessCheckedScans:  Writing UF dataset to %s/%s\n",
	     path,uffilename);
      tempScanElev = tempscan->rootScan();
      ufInst = new uf(debug);

      if (ufInst->openVolume(path,uffilename))
	{
	  //check open OK?
	  if (init_ppivol(tempScanElev) == 0) {
	    
	  scanngates = int(1+(tempScanElev->max_rng*1000-tempScanElev->start_rng)/tempScanElev->rng_res);
	  //ufInst->setUfParams(&ppivol.rparams,&ppivol.scans[0],scanngates);
	  scandata = ppivol.scans;
	  
	  int elevind = 0;
	  int setUfOk = 0;
	  
	  lastelevang = -1;
	  
	  while (tempScanElev)  //and uf write OK?
	    {
	      //write out last elevation's data (if not first)
	      if (elevind && lastelevang != tempScanElev->set_angle)
		ufInst->setScanData(scandata);
	      
	      //add this elev and field to ppivol
	      if (lastelevang != tempScanElev->set_angle)
		{
		  elevind++;
		  init_scan(tempScanElev);
		  if (!setUfOk++) ufInst->setUfParams(&ppivol.rparams,&ppivol.scans[0],scanngates);
		}
	      
	      lastelevang = tempScanElev->set_angle;
	      addRapic2Scan(tempScanElev);
	      
	      tempScanElev = tempScanElev->NextScan(tempScanElev);
	    }
	  //SD debug
	  //dumpBuff();
	  
	  ufInst->setScanData(scandata); //write out last elevation's data, check uf write OK?
	  
	  //SD debug
	  //ufInst->dumpData(&ppivol);
	  
	  ufInst->closeVolume();
	  }
	  
	  else {
	    printf("ufStnHdlr::ProcessCheckedScans: ERROR, NOT Writing UF dataset to %s/%s due to lack of level data\n",
	     path,uffilename);
	    ufInst->closeVolume();
	  }
	  

	  
	}
      //remove old checkedscans.
      if(checkedscans_last->prev) checkedscans_last->prev->next = 0;      
      delete checkedscans_last;
      delete ufInst;
      checkedscans_last = tempscannode;
    }
  checkedscans = 0;  //this queue must be empty here
}