surpport seeking the recorded video
[vuplus_openembedded] / recipes / gsm / files / 024_sms-text-in-bracket.patch
1 http://bugzilla.openmoko.org/cgi-bin/bugzilla/show_bug.cgi?id=834
2
3 From: Kristian Mueller <kristian@mput.de>
4 Subject: [PATCH] libgsmd-tool does not allow sms with more than one word
5
6 libgsmd-tool only allows for command strings without spaces. 
7 SMS messages with more than one word will be parsed as multible commands.
8 The patch introduces SMS message text in bracket and fixes a NULL pointer
9 reference on mailformed "ss" commands.
10
11 Signed-off-by: Jim Huang <jserv@openmoko.org>
12 ---
13  src/util/shell.c |   32 ++++++++++++++++++++++++++------
14  1 file changed, 26 insertions(+), 6 deletions(-)
15
16 Index: gsm/src/util/shell.c
17 ===================================================================
18 --- gsm.orig/src/util/shell.c   2007-08-31 16:15:30.000000000 +0800
19 +++ gsm/src/util/shell.c        2007-09-17 23:35:31.000000000 +0800
20 @@ -389,7 +389,7 @@
21                 "\tsd\tSMS Delete (sd=index,delflg)\n"
22                 "\tsl\tSMS List (sl=stat)\n"
23                 "\tsr\tSMS Read (sr=index)\n"
24 -               "\tss\tSMS Send (ss=number,text)\n"
25 +               "\tss\tSMS Send (ss=number,text|[\"text\"])\n"
26                 "\tsw\tSMS Write (sw=stat,number,text)\n"
27                 "\tsm\tSMS Storage stats\n"
28                 "\tsM\tSMS Set preferred storage (sM=mem1,mem2,mem3)\n"
29 @@ -612,16 +612,36 @@
30                                         
31                                 lgsm_sms_read(lgsmh, atoi(ptr+1));                              
32                         } else if ( !strncmp(buf, "ss", 2)) {
33 -                               printf("Send SMS\n");           
34                                 struct lgsm_sms sms;
35  
36                                 ptr = strchr(buf, '=');
37                                 fcomma = strchr(buf, ',');
38 -                               strncpy(sms.addr, ptr+1, fcomma-ptr-1);
39 -                               sms.addr[fcomma-ptr-1] = '\0';
40 -                               packing_7bit_character(fcomma+1, &sms);
41 +                               if (!ptr || !fcomma) {
42 +                                       printf("Wrong command format\n");
43 +                               } else {
44 +                                       strncpy(sms.addr, ptr+1, fcomma-ptr-1);
45 +                                       sms.addr[fcomma-ptr-1] = '\0';
46 +
47 +                                       /* todo define \" to allow " in text */
48 +                                       if (fcomma[1] == '"' &&
49 +                                               !strchr(fcomma+2, '"')) {
50 +                                               /* read until closing '"' */
51 +                                               rc = fscanf(stdin, "%[^\"]\"",
52 +                                                       fcomma+strlen(fcomma));
53 +                                               if (rc == EOF) {
54 +                                                       printf("EOF\n");
55 +                                                       return -1;
56 +                                               }
57 +                                               /* remove brackets */
58 +                                               fcomma++;
59 +                                               fcomma[strlen(fcomma)] = '\0';
60 +                                       }
61 +
62 +                                       printf("Send SMS\n");
63 +                                       packing_7bit_character(fcomma+1, &sms);
64  
65 -                               lgsm_sms_send(lgsmh, &sms);
66 +                                       lgsm_sms_send(lgsmh, &sms);
67 +                               }
68                         } else if ( !strncmp(buf, "sw", 2)) {   
69                                 printf("Write SMS\n");                          
70                                 struct lgsm_sms_write sms_write;