/*************FILE NAME CREATION**********************************/
#include "descript.h"
#include "flag.h"

void filename(char name1[], char name2[], char cln1[], char path [], int route, char ini_file[])
// name1, name2, cln1 - output parameters
{
 char fno[80], route_path[90], name_route[4];
 char command[180]; /*DOS command*/
 FILE *ffiot;

 name_route[0]=ini_file[5];
 name_route[1]=ini_file[6]; 
 name_route[2]=ini_file[7]; 
 name_route[3]='\0'; 

 sprintf(command,"%03i_",route);
 sscanf(command,"%s",fno);

 strncat(strcpy(route_path,path),fno,3);
 strcat(route_path,"/tmp.dat");
 
 if ((ffiot=fopen(route_path,"w+"))==0)
/*************Create directory mmm*************************/
 {
  strncat(strcat(strcat(strcat(strcpy(command,"mkdir "),path),name_route),"_"),fno,3);
  system(command);
/**********************************************************/

/*************Create directory Cln1************************/
  strcat(command,"/Cln1");
  system(command);
/**********************************************************/
 }
 strcat(strncat(strcat(strcat(strcpy(name1,path),name_route),"_"),fno,3),"/Cln1/");
 strcat(strcat(strcat(strcat(strcat(strncat(name1,ini_file,5),"_"),name_route),"_"),fno),"cln1Er.log");

 strcat(strncat(strcat(strcat(strcpy(name2,path),name_route),"_"),fno,3),"/Cln1/");
 strcat(strcat(strcat(strcat(strcat(strncat(name2,ini_file,5),"_"),name_route),"_"),fno),"mis_cln1.dat");

 strcat(strncat(strcat(strcat(strcpy(cln1,path),name_route),"_"),fno,3),"/Cln1/");
 strcat(strcat(strcat(strcat(strcat(strncat(cln1,ini_file,5),"_"),name_route),"_"),fno),"cln1.pam");
 if (ffiot!=0) {fclose(ffiot); remove(route_path);}
}
