#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "set.h"
#include "glva.h"


void alfclose(void){
	int i, is;
	
	fclose(ifp_econ);
	
	if(Seidn!=0){
		fclose(ifp10_usys[0]);
	} else {
		for(i=1; i<=4; i++){
			fclose(ifp10_usys[i]);
		}
	}
	
	fclose(ifp_kyos);
	
	if(Cntlset==1) fclose(ifp27_tuma);
	
	if(Seidn==0 || Seidn==1) fclose(ifp_nofu);
	
	fclose(ifp_kaiteb);
	
	if(Cutrfile1[0]=='0'){ 
		fclose(ifp_kaitea);
	}else if(Cutrfile1[0]=='1'){
		fclose(ifp_kokukaite);
	}
	
	if(Fpset!=9) fclose(ifp_wakum);
	
	if(Cutrfile1[0]=='1' && Fpset == 8){
		fclose(ifp_bas_cuta);
	}else if(Fpset == 9){
		fclose(ifp_asys_cuta);
		fclose(ifp_asys_cutb);
	}
	
	if(Fpset!=9){
		fclose(ofp_cuta);
		fclose(ofp_cutb);
	}
	
	if(Cntlset==1) is=0;
	else           is=1;
	
	if(Saimu==0 || Saimu==1 || Saimu==2 || Saimu==6){

		if(Seidn!=0){
			fclose(ofp01_shushi[0]);
			if(Nenbeex2==1) fclose(ofp90_nenbe[0]);
		} else {
			for(i=is; i<=4; i++){
				fclose(ofp01_shushi[i]);
				if(Nenbeex2==1) fclose(ofp90_nenbe[i]);
			}
		}
	}else if(Saimu==3 || Saimu==4 || Saimu==5){

		if(Fpset==9 && Seidn==1) fclose(ofp01_shushi[0]);
	}
	
	if(Flg_Kmakuro==1 || Flg_Kmakuro==3 ){
		fclose(ofp_Tokutyo);
	}
	
	fclose(ofp_test);
	fclose(ifp_Touitu);

}

