Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r3548 - trunk/src/target/gsm/src/gsmd ([EMAIL PROTECTED])
   2. r3549 - trunk/src/target/gsm/src/gsmd ([EMAIL PROTECTED])
   3. r3550 - trunk/src/target/gsm/src/gsmd ([EMAIL PROTECTED])
   4. r3551 - in trunk/src/target/gsm: include/gsmd src/gsmd
      src/libgsmd       src/util ([EMAIL PROTECTED])
--- Begin Message ---
Author: tick
Date: 2007-12-03 07:18:24 +0100 (Mon, 03 Dec 2007)
New Revision: 3548

Modified:
   trunk/src/target/gsm/src/gsmd/atcmd.c
Log:
gsmd: Make gsmd llparse_byte() to be more tolerant for modem EVB board(Sean 
Chiang)


Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c       2007-12-01 03:05:45 UTC (rev 
3547)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c       2007-12-03 06:18:24 UTC (rev 
3548)
@@ -113,7 +113,7 @@
        case LLPARSE_STATE_IDLE_CR:
                if (byte == '\n')
                        llp->state = LLPARSE_STATE_IDLE_LF;
-               else
+               else if (byte != '\r')
                        llp->state = LLPARSE_STATE_ERROR;
                break;
        case LLPARSE_STATE_IDLE_LF:




--- End Message ---
--- Begin Message ---
Author: tick
Date: 2007-12-03 07:21:28 +0100 (Mon, 03 Dec 2007)
New Revision: 3549

Modified:
   trunk/src/target/gsm/src/gsmd/atcmd.c
Log:
gsmd: Without clearing mlbuf, when get multi-line response, extrsp_parse will 
be failed. because the garbage data left from the last time(line). (Sean Chiang)


Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c       2007-12-03 06:18:24 UTC (rev 
3548)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c       2007-12-03 06:21:28 UTC (rev 
3549)
@@ -231,6 +231,7 @@
                 }
                 rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
                 DEBUGP("Clearing mlbuf\n");
+                memset(g->mlbuf, 0, MLPARSE_BUF_SIZE);
                 g->mlbuf_len = 0;
         }
         
@@ -371,6 +372,7 @@
                                        cmd->resp = g->mlbuf;
                                        rc = cmd->cb(cmd, cmd->ctx, cmd->resp);
                                        DEBUGP("Clearing mlbuf\n");
+                                       memset(g->mlbuf, 0, MLPARSE_BUF_SIZE);
                                }
                                g->mlbuf_len = 0;
                        }




--- End Message ---
--- Begin Message ---
Author: tick
Date: 2007-12-03 07:42:17 +0100 (Mon, 03 Dec 2007)
New Revision: 3550

Modified:
   trunk/src/target/gsm/src/gsmd/atcmd.c
Log:
gsmd: Just avoid unnecessary remove-timer() function call when get multi-line 
(Sean Chiang)


Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c       2007-12-03 06:21:28 UTC (rev 
3549)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c       2007-12-03 06:42:17 UTC (rev 
3550)
@@ -363,8 +363,6 @@
                        /* it might be a multiline response, so if there's a 
previous
                           response, send out mlbuf and start afresh with an 
empty buffer */
                        if (g->mlbuf_len) {
-                               /* remove timer if get respond before timeout */
-                               remove_timer(cmd);
                                if (!cmd->cb) {
                                        gsmd_log(GSMD_NOTICE, "command without 
cb!!!\n");
                                } else {




--- End Message ---
--- Begin Message ---
Author: tick
Date: 2007-12-03 08:08:22 +0100 (Mon, 03 Dec 2007)
New Revision: 3551

Modified:
   trunk/src/target/gsm/include/gsmd/gsmd.h
   trunk/src/target/gsm/include/gsmd/usock.h
   trunk/src/target/gsm/src/gsmd/usock.c
   trunk/src/target/gsm/src/libgsmd/libgsmd_phonebook.c
   trunk/src/target/gsm/src/util/shell.c
Log:
gsmd: Rewrite read, readrg and find of phonebook. (Sean Chiang)


Modified: trunk/src/target/gsm/include/gsmd/gsmd.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/gsmd.h    2007-12-03 06:42:17 UTC (rev 
3550)
+++ trunk/src/target/gsm/include/gsmd/gsmd.h    2007-12-03 07:08:22 UTC (rev 
3551)
@@ -98,9 +98,6 @@
        struct gsmd *gsmd;
        struct gsmd_fd gfd;                             /* the socket */
        u_int32_t subscriptions;                /* bitmaks of subscribed event 
groups */
-
-       struct llist_head pb_readrg_list;       /* our READRG phonebook list */
-       struct llist_head pb_find_list;         /* our FIND phonebook list */
 };
 
 #define GSMD_DEBUG     1       /* debugging information */

Modified: trunk/src/target/gsm/include/gsmd/usock.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/usock.h   2007-12-03 06:42:17 UTC (rev 
3550)
+++ trunk/src/target/gsm/include/gsmd/usock.h   2007-12-03 07:08:22 UTC (rev 
3551)
@@ -254,8 +254,6 @@
        GSMD_PHONEBOOK_GET_SUPPORT      = 6,
        GSMD_PHONEBOOK_LIST_STORAGE     = 7,
        GSMD_PHONEBOOK_SET_STORAGE      = 8,
-       GSMD_PHONEBOOK_RETRIEVE_READRG  = 9,
-       GSMD_PHONEBOOK_RETRIEVE_FIND    = 10,
 };
 
 /* Type-of-Address, Numbering-Plan-Identification field, GSM 03.40, 9.1.2.5 */
@@ -496,12 +494,17 @@
 #define        GSMD_PB_NUMB_MAXLEN     44
 #define GSMD_PB_TEXT_MAXLEN    14
 struct gsmd_phonebook {
-       u_int8_t index;
+       int8_t index;
        char numb[GSMD_PB_NUMB_MAXLEN+1];
        u_int8_t type;
        char text[GSMD_PB_TEXT_MAXLEN+1];
 } __attribute__ ((packed));
 
+struct gsmd_phonebooks {
+       struct gsmd_phonebook pb;
+       int8_t is_last;
+} __attribute__ ((packed));
+
 /* Refer to GSM 07.07 subclause 8.13 */
 /* FIXME: the tlength depends on SIM, use +CPBR=? to get */ 
 struct gsmd_phonebook_find {   
@@ -610,11 +613,6 @@
        char buf[];
 } __attribute__ ((packed));
 
-struct gsmd_phonebooks {
-       struct llist_head list;
-       struct gsmd_phonebook pb;
-} __attribute__ ((packed));
-
 extern struct gsmd_ucmd *ucmd_alloc(int extra_size);
 extern int usock_init(struct gsmd *g);
 extern void usock_cmd_enqueue(struct gsmd_ucmd *ucmd, struct gsmd_user *gu);

Modified: trunk/src/target/gsm/src/gsmd/usock.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/usock.c       2007-12-03 06:42:17 UTC (rev 
3550)
+++ trunk/src/target/gsm/src/gsmd/usock.c       2007-12-03 07:08:22 UTC (rev 
3551)
@@ -39,6 +39,7 @@
 #include <gsmd/atcmd.h>
 #include <gsmd/usock.h>
 #include <gsmd/talloc.h>
+#include <gsmd/extrsp.h>
 #include <gsmd/ts0707.h>
 #include <gsmd/sms.h>
 
@@ -664,78 +665,99 @@
 static int phonebook_find_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
 {
        struct gsmd_user *gu = ctx;
-       struct gsmd_phonebooks *gps;
-       char *fcomma, *lcomma, *ptr1, *ptr2 = NULL;
-       int num;
+       struct gsmd_phonebooks gps;
+       struct gsm_extrsp *er;
 
        DEBUGP("resp: %s\n", resp);
 
-       /*
-        * [+CPBF: <index1>,<number>,<type>,<text>[[...]
-        * <CR><LF>+CPBF: <index2>,<unmber>,<type>,<text>]]
-        */
-       num = 0;
-       ptr1 = strtok(resp, "\n");
+       er = extrsp_parse(cmd, resp);
 
-       while (ptr1) {
-               gps = talloc(__pb_ctx, struct gsmd_phonebooks);
-               ptr2 = strchr(ptr1, ' ');
-               gps->pb.index = atoi(ptr2+1);
+       if ( !er )
+               return -ENOMEM;
 
-               fcomma = strchr(ptr1, '"');
-               lcomma = strchr(fcomma+1, '"');
-               strncpy(gps->pb.numb, fcomma + 1, (lcomma-fcomma-1));
-               gps->pb.numb[(lcomma - fcomma) - 1] = '\0';
+       gps.is_last = (cmd->ret == 0 || cmd->ret == 4)? 1:0;
 
-               gps->pb.type = atoi(lcomma + 2);
+       if ( !strncmp(resp, "OK", 2) ) {
+               /* The record is empty or could not read yet */
+               gps.pb.index = 0;
+       }
+       else if ( !strncmp(resp, "+CME", 4) ) {
+               DEBUGP("== +CME error\n");
+               /* +CME ERROR: 21 */
+               gps.pb.index = 0 - atoi(strpbrk(resp, "0123456789"));
+       }
+       else if ( er->num_tokens == 4 &&
+                       er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC &&
+                       er->tokens[1].type == GSMD_ECMD_RTT_STRING &&
+                       er->tokens[2].type == GSMD_ECMD_RTT_NUMERIC &&
+                       er->tokens[3].type == GSMD_ECMD_RTT_STRING ) {
 
-               ptr2 = strrchr(ptr1, ',');
-               fcomma = ptr2 + 1;
-               lcomma = strchr(fcomma + 1, '"');
-               strncpy(gps->pb.text, fcomma + 1, (lcomma - fcomma - 1));
-               gps->pb.text[(lcomma - fcomma) - 1] = '\0';
+               /*
+                * [+CPBR: <index1>,<number>,<type>,<text>[[...]
+                * <CR><LF>+CPBR: <index2>,<unmber>,<type>,<text>]]
+                */
 
-               llist_add_tail(&gps->list, &gu->pb_find_list);
-
-               num++;
-
-               ptr1 = strtok(NULL, "\n");
+               gps.pb.index = er->tokens[0].u.numeric;
+               strcpy(gps.pb.numb, er->tokens[1].u.string);
+               gps.pb.type = er->tokens[2].u.numeric;
+               strcpy(gps.pb.text, er->tokens[3].u.string);
        }
+       else {
+               DEBUGP("Invalid Input : Parse error\n");
+               return -EINVAL;
+       }
+       
+       talloc_free(er);
 
-       talloc_free(__pb_ctx);
        return gsmd_ucmd_submit(gu, GSMD_MSG_PHONEBOOK, GSMD_PHONEBOOK_FIND,
-                       cmd->id, sizeof(num), &num);
+                       cmd->id, sizeof(gps), &gps);
 }
 
 static int phonebook_read_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
 {
        struct gsmd_user *gu = ctx;
        struct gsmd_phonebook gp;
-       char *fcomma, *lcomma;
-       char *ptr;
+       struct gsm_extrsp *er;
 
        DEBUGP("resp: %s\n", resp);
+       
+       er = extrsp_parse(cmd, resp);
 
-       /* check the record is empty or not */
-       if (!strncmp(resp, "+CPBR", 5)) {
-               ptr = strchr(resp, ' ');
-               gp.index = atoi(ptr + 1);
+       if ( !er )
+               return -ENOMEM;
+       
+       if ( !strncmp(resp, "OK", 2) ) {
+               /* The record is empty or could not read yet */
+               gp.index = 0;
+       }
+       else if ( !strncmp(resp, "+CME", 4) ) {
+               DEBUGP("== +CME error\n");
+               /* +CME ERROR: 21 */
+               gp.index = 0 - atoi(strpbrk(resp, "0123456789"));
+       }
+       else if ( er->num_tokens == 4 &&
+                       er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC &&
+                       er->tokens[1].type == GSMD_ECMD_RTT_STRING &&
+                       er->tokens[2].type == GSMD_ECMD_RTT_NUMERIC &&
+                       er->tokens[3].type == GSMD_ECMD_RTT_STRING ) {
 
-               fcomma = strchr(resp, '"');
-               lcomma = strchr(fcomma + 1, '"');
-               strncpy(gp.numb, fcomma + 1, (lcomma - fcomma - 1));
-               gp.numb[(lcomma-fcomma) - 1] = '\0';
+               /*
+                * [+CPBR: <index1>,<number>,<type>,<text>[[...]
+                * <CR><LF>+CPBR: <index2>,<unmber>,<type>,<text>]]
+                */
 
-               gp.type = atoi(lcomma + 2);
+               gp.index = er->tokens[0].u.numeric;
+               strcpy(gp.numb, er->tokens[1].u.string);
+               gp.type = er->tokens[2].u.numeric;
+               strcpy(gp.text, er->tokens[3].u.string);
+       }
+       else {
+               DEBUGP("Invalid Input : Parse error\n");
+               return -EINVAL;
+       }
+       
+       talloc_free(er);
 
-               ptr = strrchr(resp, ',');
-               fcomma = ptr + 1;
-               lcomma = strchr(fcomma + 1, '"');
-               strncpy(gp.text, fcomma + 1, (lcomma-fcomma - 1));
-               gp.text[(lcomma - fcomma) - 1] = '\0';
-       } else
-               gp.index = 0;
-
        return gsmd_ucmd_submit(gu, GSMD_MSG_PHONEBOOK, GSMD_PHONEBOOK_READ,
                        cmd->id, sizeof(gp), &gp);
 }
@@ -743,47 +765,52 @@
 static int phonebook_readrg_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
 {
        struct gsmd_user *gu = ctx;
-       struct gsmd_phonebooks *gps;
-       char *fcomma, *lcomma, *ptr1, *ptr2 = NULL;
-       int num;
+       struct gsmd_phonebooks gps;
+       struct gsm_extrsp *er;
 
        DEBUGP("resp: %s\n", resp);
 
-       /*
-        * [+CPBR: <index1>,<number>,<type>,<text>[[...]
-        * <CR><LF>+CPBR: <index2>,<unmber>,<type>,<text>]]
-        */
-       num = 0;
-       ptr1 = strtok(resp, "\n");
+       er = extrsp_parse(cmd, resp);
 
-       while (ptr1) {
-               gps = talloc(__pb_ctx, struct gsmd_phonebooks);
-               ptr2 = strchr(ptr1, ' ');
-               gps->pb.index = atoi(ptr2+1);
+       if ( !er )
+               return -ENOMEM;
 
-               fcomma = strchr(ptr1, '"');
-               lcomma = strchr(fcomma+1, '"');
-               strncpy(gps->pb.numb, fcomma + 1, (lcomma-fcomma-1));
-               gps->pb.numb[(lcomma - fcomma) - 1] = '\0';
+       gps.is_last = (cmd->ret == 0 || cmd->ret == 4)? 1:0;
 
-               gps->pb.type = atoi(lcomma + 2);
+       if ( !strncmp(resp, "OK", 2) ) {
+               /* The record is empty or could not read yet */
+               gps.pb.index = 0;
+       }
+       else if ( !strncmp(resp, "+CME", 4) ) {
+               DEBUGP("== +CME error\n");
+               /* +CME ERROR: 21 */
+               gps.pb.index = 0 - atoi(strpbrk(resp, "0123456789"));
+       }
+       else if ( er->num_tokens == 4 &&
+                       er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC &&
+                       er->tokens[1].type == GSMD_ECMD_RTT_STRING &&
+                       er->tokens[2].type == GSMD_ECMD_RTT_NUMERIC &&
+                       er->tokens[3].type == GSMD_ECMD_RTT_STRING ) {
 
-               ptr2 = strrchr(ptr1, ',');
-               fcomma = ptr2 + 1;
-               lcomma = strchr(fcomma + 1, '"');
-               strncpy(gps->pb.text, fcomma + 1, (lcomma - fcomma - 1));
-               gps->pb.text[(lcomma - fcomma) - 1] = '\0';
+               /*
+                * [+CPBR: <index1>,<number>,<type>,<text>[[...]
+                * <CR><LF>+CPBR: <index2>,<unmber>,<type>,<text>]]
+                */
 
-               llist_add_tail(&gps->list, &gu->pb_readrg_list);
-
-               num++;
-
-               ptr1 = strtok(NULL, "\n");
+               gps.pb.index = er->tokens[0].u.numeric;
+               strcpy(gps.pb.numb, er->tokens[1].u.string);
+               gps.pb.type = er->tokens[2].u.numeric;
+               strcpy(gps.pb.text, er->tokens[3].u.string);
        }
+       else {
+               DEBUGP("Invalid Input : Parse error\n");
+               return -EINVAL;
+       }
+       
+       talloc_free(er);
 
-       talloc_free(__pb_ctx);
        return gsmd_ucmd_submit(gu, GSMD_MSG_PHONEBOOK, GSMD_PHONEBOOK_READRG,
-                       cmd->id, sizeof(num), &num);
+                       cmd->id, sizeof(gps), &gps);
 }
 
 static int phonebook_write_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
@@ -978,54 +1005,6 @@
                cmd = atcmd_fill("AT+CPBR=?", 9+1,
                                 &phonebook_get_support_cb, gu, gph->id, NULL);
                break;
-       case GSMD_PHONEBOOK_RETRIEVE_READRG:
-               if (len < sizeof(*gph) + sizeof(int))
-                       return -EINVAL;
-
-               num = (int *) ((void *)gph + sizeof(*gph));
-               gp = talloc_size(__pb_ctx, sizeof(*gp) * (*num));
-               if (!llist_empty(&gu->pb_readrg_list))
-                       llist_for_each_entry_safe(cur, cur2,
-                                       &gu->pb_readrg_list, list) {
-                               gp->index = cur->pb.index;
-                               strcpy(gp->numb, cur->pb.numb);
-                               gp->type = cur->pb.type;
-                               strcpy(gp->text, cur->pb.text);
-                               gp++;
-
-                               llist_del(&cur->list);
-                               free(cur);
-                       }
-
-               ret = gsmd_ucmd_submit(gu, GSMD_MSG_PHONEBOOK,
-                               GSMD_PHONEBOOK_RETRIEVE_READRG, gph->id,
-                               sizeof(*gp) * (*num), gp);
-               talloc_free(gp);
-               return ret;
-       case GSMD_PHONEBOOK_RETRIEVE_FIND:
-               if (len < sizeof(*gph) + sizeof(int))
-                       return -EINVAL;
-
-               num = (int *) ((void *)gph + sizeof(*gph));
-               gp = talloc_size(__pb_ctx, sizeof(*gp) * (*num));
-               if (!llist_empty(&gu->pb_find_list))
-                       llist_for_each_entry_safe(cur, cur2,
-                                       &gu->pb_find_list, list) {
-                               gp->index = cur->pb.index;
-                               strcpy(gp->numb, cur->pb.numb);
-                               gp->type = cur->pb.type;
-                               strcpy(gp->text, cur->pb.text);
-                               gp++;
-
-                               llist_del(&cur->list);
-                               free(cur);
-                       }
-
-               ret = gsmd_ucmd_submit(gu, GSMD_MSG_PHONEBOOK,
-                               GSMD_PHONEBOOK_RETRIEVE_FIND, gph->id,
-                               sizeof(*gp) * (*num), gp);
-               talloc_free(gp);
-               return ret;
        default:
                return -EINVAL;
        }       
@@ -1154,8 +1133,6 @@
                newuser->gsmd = g;
                newuser->subscriptions = 0xffffffff;
                INIT_LLIST_HEAD(&newuser->finished_ucmds);
-               INIT_LLIST_HEAD(&newuser->pb_readrg_list);
-               INIT_LLIST_HEAD(&newuser->pb_find_list);
 
                llist_add(&newuser->list, &g->users);
                gsmd_register_fd(&newuser->gfd);

Modified: trunk/src/target/gsm/src/libgsmd/libgsmd_phonebook.c
===================================================================
--- trunk/src/target/gsm/src/libgsmd/libgsmd_phonebook.c        2007-12-03 
06:42:17 UTC (rev 3550)
+++ trunk/src/target/gsm/src/libgsmd/libgsmd_phonebook.c        2007-12-03 
07:08:22 UTC (rev 3551)
@@ -199,51 +199,3 @@
 {
        return lgsm_send_simple(lh, GSMD_MSG_PHONEBOOK, 
GSMD_PHONEBOOK_GET_SUPPORT);
 }
-
-int lgsm_pb_retrieve_readrg(struct lgsm_handle *lh, int num)
-{
-       struct gsmd_msg_hdr *gmh;
-       int rc;
-
-       gmh = lgsm_gmh_fill(GSMD_MSG_PHONEBOOK,
-                       GSMD_PHONEBOOK_RETRIEVE_READRG, sizeof(int));
-       if (!gmh)
-               return -ENOMEM;
-
-       *(int *)(gmh->data) = num;
-
-       rc = lgsm_send(lh, gmh);
-       if (rc < gmh->len + sizeof(*gmh)) {
-               lgsm_gmh_free(gmh);
-               return -EIO;
-       }
-
-       lgsm_gmh_free(gmh);
-
-       return 0;
-}
-
-int lgsm_pb_retrieve_find(struct lgsm_handle *lh, int num)
-{
-       struct gsmd_msg_hdr *gmh;
-       int rc;
-
-       gmh = lgsm_gmh_fill(GSMD_MSG_PHONEBOOK,
-                       GSMD_PHONEBOOK_RETRIEVE_FIND, sizeof(int));
-       if (!gmh)
-               return -ENOMEM;
-
-       *(int *)(gmh->data) = num;
-
-       rc = lgsm_send(lh, gmh);
-       if (rc < gmh->len + sizeof(*gmh)) {
-               lgsm_gmh_free(gmh);
-               return -EIO;
-       }
-
-       lgsm_gmh_free(gmh);
-
-       return 0;
-}
-
-

Modified: trunk/src/target/gsm/src/util/shell.c
===================================================================
--- trunk/src/target/gsm/src/util/shell.c       2007-12-03 06:42:17 UTC (rev 
3550)
+++ trunk/src/target/gsm/src/util/shell.c       2007-12-03 07:08:22 UTC (rev 
3551)
@@ -41,8 +41,6 @@
 #endif
 
 #define STDIN_BUF_SIZE 1024
-static int nFIND = 0;
-static int nREADRG = 0;
 
 int pending_responses = 0;
 
@@ -57,39 +55,63 @@
 static int pb_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
 {
        struct gsmd_phonebook *gp;
-       struct gsmd_phonebook_support *gps;
+       struct gsmd_phonebooks *gps;
+       struct gsmd_phonebook_support *gpsu;
        struct gsmd_phonebook_storage *gpst;
        char *payload;
-       char *fcomma, *lcomma, *ptr = NULL;
-       int *num;
-       char buf[128];
        int i;
 
        switch (gmh->msg_subtype) {
        case GSMD_PHONEBOOK_FIND:               
-               num = (int *) ((char *)gmh + sizeof(*gmh));
-               printf("Records:%d\n", *num);
+               gps = (struct gsmd_phonebooks *) ((char *)gmh + sizeof(*gmh));
 
-               nFIND = *num;
+               if (gps->pb.index > 0)
+                       printf("%d, %s, %d, %s\n",
+                                       gps->pb.index, gps->pb.numb,
+                                       gps->pb.type, gps->pb.text);
+               else if (gps->pb.index < 0)
+                       /* If index < 0, error happens */
+                       printf("+CME ERROR %d\n", (0-(gps->pb.index)));
+               else
+                       /* The record doesn't exist or could not read yet */
+                       printf("Doesn't exist or couldn't read it yet\n");
+
+               if (gps->is_last)
+                       pending_responses --;
                break;
        case GSMD_PHONEBOOK_READRG:
-               num = (int *) ((char *)gmh + sizeof(*gmh));
-               printf("Records:%d\n", *num);
+               gps = (struct gsmd_phonebooks *) ((char *)gmh + sizeof(*gmh));
 
-               nREADRG = *num;
+               if (gps->pb.index > 0)
+                       printf("%d, %s, %d, %s\n",
+                                       gps->pb.index, gps->pb.numb,
+                                       gps->pb.type, gps->pb.text);
+               else if (gps->pb.index < 0)
+                       /* If index < 0, error happens */
+                       printf("+CME ERROR %d\n", (0-(gps->pb.index)));
+               else
+                       /* The record doesn't exist or could not read yet */
+                       printf("Doesn't exist or couldn't read it yet\n");
+
+               if (gps->is_last)
+                       pending_responses --;
                break;
        case GSMD_PHONEBOOK_READ:
                gp = (struct gsmd_phonebook *) ((char *)gmh + sizeof(*gmh));
-               if (gp->index)
+               if (gp->index > 0)
                        printf("%d, %s, %d, %s\n",
                                        gp->index, gp->numb,
                                        gp->type, gp->text);
+               else if (gp->index < 0)
+                       /* If index < 0, error happens */
+                       printf("+CME ERROR %d\n", (0-(gp->index)));
                else
-                       printf("Empty\n");
+                       /* The record doesn't exist or could not read yet */
+                       printf("Doesn't exist or couldn't read it yet\n");
                break;
        case GSMD_PHONEBOOK_GET_SUPPORT:
-               gps = (struct gsmd_phonebook_support *) ((char *)gmh + 
sizeof(*gmh));
-               printf("(1-%d), %d, %d\n", gps->index, gps->nlength, 
gps->tlength);
+               gpsu = (struct gsmd_phonebook_support *) ((char *)gmh + 
sizeof(*gmh));
+               printf("(1-%d), %d, %d\n", gpsu->index, gpsu->nlength, 
gpsu->tlength);
                pending_responses --;
                break;
 
@@ -111,26 +133,6 @@
                payload = (char *)gmh + sizeof(*gmh);
                printf("%s\n", payload);
                break;
-       case GSMD_PHONEBOOK_RETRIEVE_READRG:
-               gp = (struct gsmd_phonebook *) ((char *)gmh + sizeof(*gmh));
-
-               for (i=0; i<nREADRG; i++) {
-                       printf("%d,%s,%d,%s\n", gp->index, gp->numb, gp->type, 
gp->text);
-                       gp++;
-               }
-
-               nREADRG = 0;
-               break;
-       case GSMD_PHONEBOOK_RETRIEVE_FIND:
-               gp = (struct gsmd_phonebook *) ((char *)gmh + sizeof(*gmh));
-
-               for (i = 0; i < nFIND; i++) {
-                       printf("%d,%s,%d,%s\n", gp->index, gp->numb, gp->type, 
gp->text);
-                       gp++;
-               }
-
-               nFIND = 0;
-               break;
        default:
                return -EINVAL;
        }       
@@ -425,8 +427,6 @@
                "\tps\tPB Support\n"
                "\tpm\tPB Memory\n"
                "\tpp\tPB Set Memory (pp=storage)\n"
-               "\tpRr\tRetrieve Readrg Records\n"
-               "\tpRf\tRetrieve Find Records\n"
                "\tsd\tSMS Delete (sd=index,delflg)\n"
                "\tsl\tSMS List (sl=stat)\n"
                "\tsr\tSMS Read (sr=index)\n"
@@ -570,6 +570,7 @@
                                ptr = strchr(buf, ',');
                                pb_readrg.index2 = atoi(ptr+1);
                                lgsm_pb_read_entries(lgsmh, &pb_readrg);
+                               pending_responses ++;
                        } else if ( !strncmp(buf, "pr", 2)) {
                                ptr = strchr(buf, '=');
                                lgsm_pb_read_entry(lgsmh, atoi(ptr+1));
@@ -584,6 +585,7 @@
                                pb_find.findtext[strlen(ptr+1)] = '\0'; 
                        
                                lgsm_pb_find_entry(lgsmh, &pb_find);
+                               pending_responses ++;
                        } else if ( !strncmp(buf, "pw", 2)) {
                                printf("Write Phonebook Entry\n");
                                struct lgsm_phonebook pb;
@@ -616,16 +618,6 @@
                                printf("Get Phonebook Support\n");
                                lgsm_pb_get_support(lgsmh);
                                pending_responses ++;
-                       } else if( !strncmp(buf, "pRr", 3) ) {
-                               printf("Retrieve Readrg Records\n");
-
-                               if ( nREADRG )
-                                       lgsm_pb_retrieve_readrg(lgsmh, nREADRG);
-                       } else if( !strncmp(buf, "pRf", 3) ) {
-                               printf("Retrieve Find Records\n");
-
-                               if ( nFIND )
-                                       lgsm_pb_retrieve_find(lgsmh, nFIND);
                        } else if ( !strncmp(buf, "sd", 2)) {           
                                printf("Delete SMS\n");                 
                                struct lgsm_sms_delete sms_del;




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to