Index: gwlib/cfg.def
===================================================================
RCS file: /home/cvs/gateway/gwlib/cfg.def,v
retrieving revision 1.142
diff -a -u -r1.142 cfg.def
--- gwlib/cfg.def	6 Dec 2009 17:24:14 -0000	1.142
+++ gwlib/cfg.def	23 Apr 2010 09:57:35 -0000
@@ -532,6 +532,7 @@
     OCTSTR(keepalive-cmd)
     OCTSTR(broken)
     OCTSTR(message-storage)
+    OCTSTR(message-start)
     OCTSTR(enable-mms)
     OCTSTR(reset-string)
 )
Index: gw/smsc/smsc_at.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.c,v
retrieving revision 1.63
diff -a -u -r1.63 smsc_at.c
--- gw/smsc/smsc_at.c	24 Aug 2009 09:49:08 -0000	1.63
+++ gw/smsc/smsc_at.c	23 Apr 2010 09:57:36 -0000
@@ -1087,6 +1087,7 @@
          */
         int i;
         int message_count = 0; /* cound number of messages collected */
+        ModemDef *modem = privdata->modem;
 
         debug("bb.smsc.at2", 0, "AT2[%s]: %d messages waiting in memory", 
               octstr_get_cstr(privdata->name), privdata->sms_memory_usage);
@@ -1094,8 +1095,7 @@
         /*
          * loop till end of memory or collected enouch messages
          */
-        for (i = 1; i <= privdata->sms_memory_capacity &&
-             message_count < privdata->sms_memory_usage; ++i) { 
+        for (i = modem->message_start; i < (privdata->sms_memory_capacity  + modem->message_start) && message_count < privdata->sms_memory_usage; ++i) {
 
             /* if (meanwhile) there are pending CMTI notifications, process these first
              * to not let CMTI and sim buffering sit in each others way */
@@ -2827,6 +2827,8 @@
             modem->keepalive_cmd = octstr_create("AT");
 
         modem->message_storage = cfg_get(grp, octstr_imm("message-storage"));
+        if (cfg_get_integer(&modem->message_start, grp, octstr_imm("message-start")))
+            modem->message_start = 1;
 
         cfg_get_bool(&modem->enable_mms, grp, octstr_imm("enable-mms"));
 
Index: gw/smsc/smsc_at.h
===================================================================
RCS file: /home/cvs/gateway/gw/smsc/smsc_at.h,v
retrieving revision 1.18
diff -a -u -r1.18 smsc_at.h
--- gw/smsc/smsc_at.h	12 Aug 2009 15:38:27 -0000	1.18
+++ gw/smsc/smsc_at.h	23 Apr 2010 09:57:36 -0000
@@ -111,6 +111,7 @@
     Octstr *keepalive_cmd;
     int	broken;
     Octstr *message_storage;
+    long	message_start;
     int	enable_mms;
 } ModemDef;
 
