Add auto-toolchain mode.
Auto-Toolchain: Passing 5 paraments, this program will switch to auto mode. In this mode, data will be fetched and saved to a file automatically. Fix Bug: Now if you don't press any key, the program will enter normal mode and start fetching data with default settings.
This commit is contained in:
parent
9c953fc2f9
commit
5543cc6473
30
main.cpp
30
main.cpp
@ -120,7 +120,7 @@ void RemoteQuery(string PreCode,int ID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************参数设置***************/
|
/*****************参数设置***************/
|
||||||
char _head_str[16];
|
char _head_str[16]{"15080801"};
|
||||||
const char* HEAD_STR = _head_str;
|
const char* HEAD_STR = _head_str;
|
||||||
|
|
||||||
int _num = 40;
|
int _num = 40;
|
||||||
@ -330,13 +330,29 @@ bool EnterSingleMode()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
bool _out_file_targeted=false;
|
||||||
|
char _out_file_name[1024];
|
||||||
|
|
||||||
|
int main(int argc,char* argv[])
|
||||||
|
{
|
||||||
|
/// Èç¹ûargc==5,Ôò½øÈë×Ô¶¯Ä£Ê½.
|
||||||
|
if(argc!=5)
|
||||||
{
|
{
|
||||||
if(EnterSingleMode())
|
if(EnterSingleMode())
|
||||||
{
|
{
|
||||||
printf("已从特殊模式退出.\n");
|
printf("已从特殊模式退出.\n");
|
||||||
if(!_begin_after_singlemode) return 0;
|
if(!_begin_after_singlemode) return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(argc==4)
|
||||||
|
{
|
||||||
|
strncpy(_head_str,argv[1],8);
|
||||||
|
sscanf(argv[2],"%d",&_beginnum);
|
||||||
|
sscanf(argv[3],"%d",&_num);
|
||||||
|
_out_file_targeted=true;
|
||||||
|
strcpy(_out_file_name,argv[4]);
|
||||||
|
}
|
||||||
|
|
||||||
printf("已启动为自动模式.\n");
|
printf("已启动为自动模式.\n");
|
||||||
printf("Target: Fetch %s01 to %s%02d...\n",HEAD_STR,HEAD_STR,NUM);
|
printf("Target: Fetch %s01 to %s%02d...\n",HEAD_STR,HEAD_STR,NUM);
|
||||||
@ -421,15 +437,23 @@ int main()
|
|||||||
|
|
||||||
printf("解析完成.\n");
|
printf("解析完成.\n");
|
||||||
|
|
||||||
|
string fname;
|
||||||
|
if(_out_file_targeted)
|
||||||
|
{
|
||||||
s_time now=whattime();
|
s_time now=whattime();
|
||||||
char gpbuff[1024];
|
char gpbuff[1024];
|
||||||
sprintf(gpbuff,"-%04d%02d%02d-%02d%02d%02d",now.year,now.mon,now.day,now.hour,now.min,now.sec);
|
sprintf(gpbuff,"-%04d%02d%02d-%02d%02d%02d",now.year,now.mon,now.day,now.hour,now.min,now.sec);
|
||||||
string fname;
|
|
||||||
printf("请输入保存文件名称,时间将会自动追加到结尾,后缀名为txt\n");
|
printf("请输入保存文件名称,时间将会自动追加到结尾,后缀名为txt\n");
|
||||||
getline(cin,fname);
|
getline(cin,fname);
|
||||||
fname=string("result/")+fname;
|
fname=string("result/")+fname;
|
||||||
fname.append(gpbuff);
|
fname.append(gpbuff);
|
||||||
fname.append(".txt");
|
fname.append(".txt");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fname=string(_out_file_name);
|
||||||
|
}
|
||||||
|
|
||||||
printf("正在保存到 %s\n",fname.c_str());
|
printf("正在保存到 %s\n",fname.c_str());
|
||||||
|
|
||||||
ofstream ofs(fname);
|
ofstream ofs(fname);
|
||||||
|
Reference in New Issue
Block a user