#include <stdio.h>
void info();
int atoi(char s[]);
int function(char Tbs_name[50],char Route_data_name[80],char Other_name[50],int Mix,int Max,int Size);
int main(int argc, char *argv[])
{
/*
argv[1] --Rbs_name
argv[2] --Route_data_name
argv[3] --Other_name
argv[4] --Mix
argv[5] --Max
argv[6] --Size
*/
int mix,max,size;
if(argc!=7)
{
info();
return 1;
}
mix=atoi(argv[4]);
max=atoi(argv[5]);
size=atoi(argv[6]);
if(mix>=max)
{
info();
return 1;
}
function(argv[1],argv[2],argv[3],mix,max,size);
return 1;
}
int atoi(char s[])
{int i,n;
n = 0;
for(i = 0; s[i]>='0'&&s[i]<='9';++i)
n= 10*n + (s[i] - '0');
return n;
}
int function(char Tbs_name[50],char Route_data_name[80],char Other_name[50],int Mix,int Max,int Size)
{
int i=0;
//start--
printf("alter tablespace %s\n",Tbs_name);
printf("add datafile\n");
i=Mix;
for (;i<Max;i++)
{
printf("'%s%d%s' ", Route_data_name,i,Other_name);
printf("size %dm autoextend off,\n",Size);
}
printf("'%s%d%s' ", Route_data_name,i,Other_name);
printf("size %dm autoextend off;\n",Size);
//end
printf("\n\n");
return 1;
}
void info()
{
//This is a Example
printf("---------------------------------------------------------------------------\n\n");
printf(" Format:\n");
printf(" function(Tbs_name,Route_data_name,Other_name,Mix,Max,Size);\n\n");
printf(" alter tablespace [Tbs_name]\n" );
printf(" add datafile\n");
printf(" '[Route_dataname] [mix] [max] [other_name]' size [size]m autoextend off;\n\n\n");
printf(" This is a example.\n");
printf(" alter tablespace tbs_name\n");
printf(" add datafile\n");
printf(" '/u01/data_01.dbf' size 1024m autoextend off,\n");
printf(" '/u01/data_02.dbf' size 1024m autoextend off;\n\n");
printf("---------------------------------------------------------------------------\n\n\n");
printf("How to use!\n");
printf("APP.exe tbs_name Route_dataname Other_name Mix Max Size \n\n");
printf("---------------------------------------------------------------------------\n\n\n");
}
/*-------------------------------------version_2----------------------------------------------------*/
int main_version_2()
{
//some default value
int size=10;
int mix=1;
int max=2;
int i=0;
char tbs_name[50];
char Route_dataname[50];
char other_name[50];
while(1)
{
info();
//tbs_name
printf("please input tbs_name:\n");
scanf("%s",tbs_name);
printf("The Tbs_name is %s\n\n",tbs_name);
//data_name
printf("please input Route_dataname:\n");
scanf("%s",Route_dataname);
printf("The Route_dataname is %s\n\n",tbs_name);
//input other_nmae
printf("please input other_name:\n");
scanf("%s",other_name);
printf("The Route_dataname is %s\n\n",other_name);
//input min,max ,size
printf("please input min,max and size value:\n");
scanf("%d %d %d",&mix,&max,&size);
printf("mix=%d,max=%d,size=%d\n\n",mix,max,size);
if (mix>=max)
return 0;
//then do
//start--
printf("alter tablespace %s\n",tbs_name);
printf("add datafile\n");
i=mix;
for (;i<max;i++)
{
printf("'%s%d%s' ", Route_dataname,i,other_name);
printf("size %dm autoextend off,\n",size);
}
printf("'%s%d%s' ", Route_dataname,i,other_name);
printf("size %dm autoextend off;\n",size);
//end
printf("\n\n");
}
return 1;
}
void info_2()
{
//This is a Example
printf("---------------------------------------------------------------------------\n\n");
printf(" Format:\n");
printf(" function(Tbs_name,Route_data_name,Other_name,Mix,Max,Size);\n\n");
printf(" alter tablespace [Tbs_name]\n" );
printf(" add datafile\n");
printf(" '[Route_dataname] [mix] [max] [other_name]' size [size]m autoextend off;\n\n\n");
printf(" This is a example.\n");
printf(" alter tablespace tbs_name\n");
printf(" add datafile\n");
printf(" '/u01/data_01.dbf' size 1024m autoextend off,\n");
printf(" '/u01/data_02.dbf' size 1024m autoextend off;\n\n");
printf("---------------------------------------------------------------------------\n\n\n");
}
|