⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sms_send.cpp

📁 sms发送短信的程序
💻 CPP
字号:
/*************************************************************************** *   Copyright (C) 2004 by Igor Vlassov                                    * *   iev@iev.cor.ru                                                        * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         * *   You should have received a copy of the GNU General Public License     * *   along with this program; if not, write to the                         * *   Free Software Foundation, Inc.,                                       * *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * ***************************************************************************/#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <iostream>#include <cstdlib>#include "atphone.h"using namespace std;char sDevPath[255] = "/dev/usb/ttyACM0";bool GetCfg(void){	FILE *fCnf;	char *p;	if ((fCnf=fopen("sms_send.cfg","rt"))==NULL) 	{		puts("Config file sms_send.cfg don't finded. Using defaults..");		return false;	}	while (!feof(fCnf))	{		fgets(sDevPath, sizeof(sDevPath)-1, fCnf);		if (strstr(sDevPath, "Port")!=NULL) 		{			if ((p=strchr(sDevPath,'='))!=NULL) 			{				strcpy(sDevPath,p+sizeof(char));				if((p=strchr(sDevPath,'\n'))!=NULL) (*p)=0;				fclose(fCnf);				return true;			}		}			}		fclose(fCnf);		return false;}int main(int argc, char *argv[]){  char sBuf[256], sPhone[50];  char *p;  CATPhone phone;  FILE *fCnf;  int len;    cout << "SMS Dispatcher, v.0.1b by Igor E. Vlassov, 2004, v.0.1b" << endl;    if (argc<2)  {  	puts("Usage: sms_send file_name_with_phone_numbers_&_messages_in_format:");	puts("phone_number message");	puts("Sample: +79043952233 Hello World!\n");	puts("Change parameter Port in file sms_send.cfg as u need also");      exit(1);   }  if ((fCnf=fopen(argv[1],"rt"))==NULL)  {  	printf("Input file %s don't finded\n", argv[1]);	exit(1);  }    GetCfg();  printf("Port = \"%s\"", sDevPath);  phone.Init(sDevPath,"19200");  phone.StartLog("sms_send.log");  if (!phone.isGSMmodem()) phone.Exit(1);  if (!phone.SetSMStextMode())  phone.Exit(1);    while (!feof(fCnf))  {    	p = fgets(sBuf, sizeof(sBuf)-1, fCnf);	if(strchr(sBuf,' ')!=NULL) p=strchr(sBuf,' ');	else if (strchr(sBuf,'\t')!=NULL) p=strchr(sBuf,'\t');	else 	{		phone.OutLog(sBuf);		phone.OutLog("Space between phone number & message not found!");		continue;	}	len = (p-sBuf)/sizeof(char);	strncpy(sPhone,sBuf,len);	sPhone[len]=0;  	if(phone.StoreSMS2mem(sPhone, &sBuf[(p-sBuf+sizeof(char))/sizeof(char)]))  	{		phone.SendSMSFromMem();		phone.DelSMSFromMem();  	}  }  phone.Exit();    fclose(fCnf);    return EXIT_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -