Changes to test_ppg programm

"Wilfried Goesgens" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hy, we've started testing, and got blocked by test_ppg sending outdated 
timestamps and not wanting our xml. So i've modified it to take some further 
arguments to the -H directive to add custom phone values and insert a actual 
timestamp as start and add 600 secs to the expire timestamp. so now there 
will  be an sms sent by test_ppg if a correct number is specified. 

I took snprintf to merge the string, as i don't know yet which octstr_* 
function to choose, please correct me on that... 

Wilfried Goesgens
test_ppg.c.diff (text/plain, 4.6 KB)
Index: test_ppg.c
===================================================================
RCS file: /home/cvs/gateway/test/test_ppg.c,v
retrieving revision 1.26
diff -r1.26 test_ppg.c
71a72,80
> #define EXPIRE_TIME_SEC 600
> #define VENDOR_URL "[email protected]\">"
> 
> 
> //#define _XOPEN_SOURCE_EXTENDED
> //#define _GNU_SOURCE
> 
> #include <sys/time.h>
> #include <time.h>
76a86
> 
119a130,134
> static char *phonenumber="+11111";
> static char *target_url="http://www.slashdot.org";
> static char *signature="[email protected]";
> static char *message_text="News for Nerds. Stuff that matters";
> 
343a359,370
> 	char  expire_time_str[22];
> 	char  actual_time_str[22];
> 	struct tm dummy, dummy2;
> 	struct timezone tz;//=DST_MET;//TIMEZONE;
> 	struct timeval actualtime;
> 
> 	if (0==gettimeofday(&actualtime, &tz))
> 	  {
> 		time_t expiretime=actualtime.tv_sec+EXPIRE_TIME_SEC;
> 		strftime(actual_time_str, 22, "%Y-%m-%dT%H:%M:%SZ",gmtime_r(&actualtime.tv_sec,&dummy));
> 		strftime(expire_time_str, 22, "%Y-%m-%dT%H:%M:%SZ",gmtime_r(&expiretime,&dummy2));
> 	  }
348,353c375,382
<         push_content = octstr_create("\r\n\r\n"
<                   "--asdlfkjiurwgasf\r\n"
<                   "Content-Type: application/xml\r\n\r\n"
<                   "<?xml version=\"1.0\"?>"
<                   "<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP//EN\""
<                              " \"http://www.wapforum.org/DTD/pap_1.0.dtd\">"
---
> 	  char request[5000];
> 	  snprintf(request,5000,
> 			   "\r\n\r\n"
> 			   "--asdlfkjiurwgasf\r\n"
> 			   "Content-Type: application/xml\r\n\r\n"
> 			   "<?xml version=\"1.0\"?>"
> 			   "<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP//EN\""
> 			   " \"http://www.wapforum.org/DTD/pap_1.0.dtd\">"
356,357c385,386
<                           " deliver-before-timestamp=\"2002-11-01T06:45:00Z\""
<                           " deliver-after-timestamp=\"2000-02-27T06:45:00Z\""
---
> 			   " deliver-before-timestamp=\"%s\"" // date 1
> 			   " deliver-after-timestamp=\"%s\"" // expiredate 1
359,360c388,389
< 			     "<address address-value=\"WAPPUSH=+358408676001/"
< 			 	"[email protected]\">"
---
> 			   "<address address-value=\"WAPPUSH=%s/" //phone
> 			   VENDOR_URL
371,383c400,412
<                   "</pap>\r\n\r\n"         
<                   "--asdlfkjiurwgasf\r\n"
<                   "Content-Type: text/vnd.wap.si\r\n\r\n"
<                   "<?xml version=\"1.0\"?>"
<                   "<!DOCTYPE si PUBLIC \"-//WAPFORUM//DTD SI 1.0//EN\" "
<                     " \"http://www.wapforum.org/DTD/si.dtd\">"
<                   "<si>"
<                       "<indication href=\"http://wap.iobox.fi\""
<                           " si-id=\"[email protected]\""
<                           " action=\"signal-high\""
<                           " created=\"1999-06-25T15:23:15Z\""
<                           " si-expires=\"2002-12-30T00:00:00Z\">"
<                           "Want to test a fetch?"
---
> 			   "</pap>\r\n\r\n"         
> 			   "--asdlfkjiurwgasf\r\n"
> 			   "Content-Type: text/vnd.wap.si\r\n\r\n"
> 			   "<?xml version=\"1.0\"?>"
> 			   "<!DOCTYPE si PUBLIC \"-//WAPFORUM//DTD SI 1.0//EN\" "
> 			   " \"http://www.wapforum.org/DTD/si.dtd\">"
> 			   "<si>"
> 			   "<indication href=\"%s\"" //target url
> 			              " si-id=\"%s\"" // signatur
> 			              " action=\"signal-high\"" 
> 			              " created=\"%s\"" // date 2
> 			              " si-expires=\"%s\">" // expire 2
> 			              "%s" // Message text
385,387c414,426
<                    "</si>\r\n\r\n"
<                  "--asdlfkjiurwgasf--\r\n\r\n"
<                  "");
---
> 			   "</si>\r\n\r\n"
> 			   "--asdlfkjiurwgasf--\r\n\r\n"
> 			   "",
> 			   (char*)actual_time_str,
> 			   (char*)expire_time_str,
> 			   phonenumber,
> 			   target_url,
> 			   signature, // [email protected]
> 			   (char*)actual_time_str,
> 			   (char*)expire_time_str,
> 			   message_text); //Want to test a fetch?
> 		push_content = octstr_create(request);
> 								 
731d769
<     info(0, "flag -b is set, too");
732a771,774
>     info(0, "-P Specify Phonenumber");
>     info(0, "-U Specify targetUrl");
>     info(0, "-I Specify sIgnature");
>     info(0, "-M Specify Messagetext");
762c804
<     while ((opt = getopt(argc, argv, "HhBbnEpv:qr:t:c:a:i:e:k:d:s:S:")) != EOF) {
---
>     while ((opt = getopt(argc, argv, "HhBbnEpv:qr:t:c:a:i:e:k:d:s:S:P:U:I:M:")) != EOF) {
788a831,846
> 	    break;
> 
> 	    case 'P':
> 		  phonenumber=optarg;
> 	    break;
> 
> 	    case 'U':
> 		  target_url=optarg;
> 	    break;
> 
> 	    case 'I':
> 		  signature=optarg;
> 	    break;
> 
> 	    case 'M':
> 		  message_text=optarg;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.