📄 smsreceiver.cpp
字号:
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <qstring.h>
#include <qdir.h>
#include "log.h"
#include "atphone.h"
char sDevPath[255] = "/dev/usb/ttyACM0";
char sLogPath[255] = "./";
bool GetCfg(void)
{
FILE *fCnf;
char *p;
char sBuf[255];
if ((fCnf=fopen("smsreceiver.cfg","rt"))==NULL)
{
puts("Config file smsreceiver.cfg don't finded. Using defaults..");
return false;
}
while (!feof(fCnf))
{
fgets(sBuf, sizeof(sBuf)-1, fCnf);
if (strstr(sBuf, "Port")!=NULL)
{
if ((p=strchr(sBuf,'='))!=NULL)
{
strcpy(sDevPath,p+sizeof(char));
if((p=strchr(sDevPath,'\n'))!=NULL) (*p)=0;
}
}
else if (strstr(sBuf, "LogFilePath")!=NULL)
{
if ((p=strchr(sBuf,'='))!=NULL)
{
strcpy(sLogPath,p+sizeof(char));
if((p=strchr(sLogPath,'\n'))!=NULL) (*p)=0;
}
}
}
fclose(fCnf);
return true;
}
int main(int argc, char *argv[])
{
CLog Log, Sms;
char acLogName[255];
CATPhone phone;
puts ("SMS Receiver, v.0.1, by Igor E. Vlassov, 2005");
puts("Note: Change parameter Port in file smsreceiver.cfg as u need also");
GetCfg();
printf("Port = \"%s\"\n", sDevPath);
phone.Init(sDevPath,"19200");
srand(time(NULL));
sprintf(acLogName,"%ssms%d.in",sLogPath,rand());
printf("OutSmsFile = %s\n",acLogName);
Log.Start("smsreceiver.log");
Sms.Start(acLogName);
phone.InitLogs(&Log, &Sms);
if (!phone.isGSMmodem()) phone.Exit(1);
if (!phone.SetSMStextMode()) phone.Exit(1);
phone.ListSMS();
Sms.Stop();
if (QFileInfo(acLogName).size()==0) unlink(acLogName);
phone.Exit();
return EXIT_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -