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

📄 one.c

📁 这个项目里有两个关于收、发GSM 手机短信的C语言程序
💻 C
字号:
/* * Plugin for one (austria) * sms are sent trough their webpage www.one.at * * Authors:     Gerhard Khueny <e9625442@student.tuwien.ac.at> * * TODO:         * * Fixes: * * For license terms, see the file COPYING in the project directory. */#include <string.h>#include <glib.h>#include <gsms-plugin.h>#define LINE            128#define MAXMSG          8192#define SERVERHOST      "www.one-service.at"#define PORT            80gint init_plugin (PluginData *pd);static void destroy_plugin (PluginData *pd);static gint send_sms(PluginData *pd, gchar * text, gchar * tel); static gint send_sms(PluginData *pd, gchar * text, gchar * tel){	gchar *tmp, *url_text, *buffer, line[LINE], *body;	GsmsHttpConnection *c;       		/* send first request and get the magic in the page */	if( (c = gsms_plugin_http_connect(SERVERHOST, PORT)) == NULL) {		g_log(MODULE_LOG_DOMAIN, G_LOG_LEVEL_WARNING,		      "Unable to connect to server %s:%d", SERVERHOST, PORT);		return -1;	}	buffer = gsms_plugin_http_request_simple(c, "/sms/csproxy2.exe",						 NULL, "GET", NULL, 						 "CMD=WWWSMS&SCRN=SMS");	if( buffer == NULL) {		g_log(MODULE_LOG_DOMAIN, G_LOG_LEVEL_WARNING,		      "Http Request  http://%s:%d/sms/csproxy2.exe failed", 		      SERVERHOST, PORT);		gsms_http_close(c);				return -1;	}	/* Parse MAGIC */	g_log(MODULE_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Parsing page ...");	if ((tmp = (gchar *) strstr(buffer, "name=\"MAGIC\"")) == NULL) {		g_log(MODULE_LOG_DOMAIN, G_LOG_LEVEL_WARNING,		      "Parse: No MAGIC found");		gsms_http_close(c);		g_free(buffer);		return -1;	}	tmp = (gchar *) strstr(tmp, "value=\""),	    tmp = (gchar *) index(tmp, '"');	g_snprintf(line, 7, "%s", (tmp + 1));	g_free(buffer);	/* send the sms message to the cgi*/	url_text =  gsms_http_url_encode(text);	if(strncmp(tel, "+43699", 6) == 0) {	       body = g_strdup_printf ("CMD=WWWSMS&SCRN=SMSSEND&MAGIC=%s&NET=%%2B43699"				       "&theNumber=%s&theText=%s&theLength=250&senden.x"				       "=16&senden.y=64",line, tel+6, url_text);			}	else if(strncmp(tel, "+43664", 6) == 0) {	       body = g_strdup_printf ("CMD=WWWSMS&SCRN=SMSSEND&MAGIC=%s&NET=%%2B43664"				       "&theNumber=%s&theText=%s&theLength=250&senden.x"				       "=16&senden.y=64",line, tel+6, url_text);			} 	else if(strncmp(tel, "+43676", 6) == 0) {	       body = g_strdup_printf ("CMD=WWWSMS&SCRN=SMSSEND&MAGIC=%s&NET=%%2B43676"				       "&theNumber=%s&theText=%s&theLength=250&senden.x"				       "=16&senden.y=64",line, tel+6, url_text);			}	else if(strncmp(tel, "+43650", 6) == 0) {	       body = g_strdup_printf ("CMD=WWWSMS&SCRN=SMSSEND&MAGIC=%s&NET=%%2B43650"				       "&theNumber=%s&theText=%s&theLength=250&senden.x"				       "=16&senden.y=64",line, tel+6, url_text);			}		else {				g_log(MODULE_LOG_DOMAIN, G_LOG_LEVEL_WARNING,		      "Invalid prefix for Austria-One Plugin");		return -1;	}	g_free(url_text);	buffer = gsms_plugin_http_request_simple		(c,		 "/sms/csproxy2.exe",		 "http://www.one-service.at/sms/csproxy2.exe"		 "?CMD=WWWSMS&SCRN=SMS",		 "POST",		 "application/x-www-form-urlencoded", 		 body);	if( buffer == NULL) {		g_log(MODULE_LOG_DOMAIN, G_LOG_LEVEL_WARNING,		      "Http Request  http://%s:%d/sms/csproxy2.exe failed", 		      SERVERHOST, PORT);		gsms_http_close(c);				return -1;	}	g_free(buffer);	gsms_http_close(c);			return 0;}voiddestroy_plugin (PluginData *pd){	g_free(pd->networks->data);}gintinit_plugin (PluginData *pd){	GSMNetwork *network;	/* initialize */	pd->destroy_plugin = destroy_plugin;	pd->send_sms = send_sms;	pd->name = "www.one.at";	pd->authors = "Gerhard Khueny <e9625442@student.tuwien.ac.at>";	pd->default_priority = 200;	network = g_new(GSMNetwork, 1);	network->prefix = "+43699";	network->name = "One";	pd->networks = g_slist_append(pd->networks, network);	network = g_new(GSMNetwork, 1);	network->prefix = "+43664";	network->name = "A1";	pd->networks = g_slist_append(pd->networks, network);	network = g_new(GSMNetwork, 1);	network->prefix = "+43676";	network->name = "MAX";	pd->networks = g_slist_append(pd->networks, network);	network = g_new(GSMNetwork, 1);	network->prefix = "+43650";	network->name = "Telering Austria";	pd->networks = g_slist_append(pd->networks, network);		return PLUGIN_OK;}

⌨️ 快捷键说明

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