##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 EVALUATION    14/Jan/2011  23:28:17 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  interwork                                            #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  D:\pasha\elf\googlecode\MySMSYS\Mss3\Mss3App.cpp     #
#    Command line    =  D:\pasha\elf\googlecode\MySMSYS\Mss3\Mss3App.cpp -D  #
#                       NEWSGOLD -D ELKA -D LANG_EN -lcN                     #
#                       D:\pasha\elf\googlecode\MySMSYS\Mss3\Release_ELKA_EN #
#                       \List\ -o D:\pasha\elf\googlecode\MySMSYS\Mss3\Relea #
#                       se_ELKA_EN\Obj\ -s9 --no_unroll --cpu_mode arm       #
#                       --endian little --cpu ARM926EJ-S --stack_align 4     #
#                       --interwork -e --fpu None --eec++ --dlib_config      #
#                       "D:\pasha\Embedded Workbench 4.0                     #
#                       Evaluation2\ARM\LIB\dl5tpainl8n.h" -I                #
#                       "D:\pasha\Embedded Workbench 4.0                     #
#                       Evaluation2\ARM\INC\" --inline_threshold=2           #
#    List file       =  D:\pasha\elf\googlecode\MySMSYS\Mss3\Release_ELKA_EN #
#                       \List\Mss3App.lst                                    #
#    Object file     =  D:\pasha\elf\googlecode\MySMSYS\Mss3\Release_ELKA_EN #
#                       \Obj\Mss3App.r79                                     #
#                                                                            #
#                                                                            #
##############################################################################

D:\pasha\elf\googlecode\MySMSYS\Mss3\Mss3App.cpp
      1          // Mss3App.cpp: implementation of the Mss3App class.
      2          //
      3          //////////////////////////////////////////////////////////////////////
      4          #include "include.h"
      5          #include "SiemensPDU.h"
      6          #include "MyIpcMessage.h"
      7          #include "File.h"
      8          #include "SmsData.h"
      9          #include "CreateMenu.h"
     10          #include "SmsListMenu.h"
     11          #include "DialogCSM.h"
     12          #include "LangPack.h"
     13          #include "Vibra.h"
     14          #include "PlaySound.h"
     15          //#include "ShortVibra.h"
     16          #include "SendList.h"
     17          #include "DaemonCSM.h"
     18          #include "CSMswaper.h"
     19          #include "Mss3App.h"
     20          
     21          //////////////////////////////////////////////////////////////////////
     22          // Construction/Destruction
     23          //////////////////////////////////////////////////////////////////////
     24          
     25          //DEL Mss3App::Mss3App()
     26          //DEL {
     27          //DEL 
     28          //DEL }
     29          
     30          //DEL Mss3App::~Mss3App()
     31          //DEL {
     32          //DEL 
     33          //DEL }
     34          extern "C"
     35          {
     36            extern void kill_data(void *p, void (*func_p)(void *));
     37            extern void InitConfig(void);
     38          }
     39          
     40          int Mss3App::Start(char *exename, char *fname)
     41          {
     42            if(IsAlreadyRuning())
     43            {
     44              if(!fname)
     45                SendMyIpc(SMSYS_IPC_MAIN);
     46              else if (fname[0] >= '0' && fname[0] <= '4' && fname[1] == ':' && strlen(fname) < 128)
     47              {
     48                char *filename=new char[128];
     49                strcpy(filename, fname);
     50                SendMyIpc(SMSYS_IPC_FVIEW, filename);
     51              }
     52              SUBPROC((void *)Mss3App::Killer);
     53              return 0;
     54            }
     55            InitSetting();
     56            DaemonCSM *daemon=new DaemonCSM;
     57            daemon->CreateDaemonCSM();
     58            //CSMSwaper::InitUnderIdleCSM();
     59            return 0;
     60          }
     61          
     62          void Mss3App::InitSetting()
     63          {
     64            InitConfig();
     65            InitDatPath();
     66          }
     67          
     68          void Mss3App::InitDatPath()
     69          {
     70            int x, xl;
     71            strcpy(sms_dat, CFG_SYSTEM_FOLDER);
     72            if((xl=strlen(sms_dat))>0)
     73            {
     74              x=sms_dat[xl-1];
     75              if((x!='\\')&&(x!='/'))
     76              {
     77                sms_dat[xl]='\\';
     78                sms_dat[xl+1]=0;
     79              }
     80              strcat(sms_dat, "SMS\\SMS.dat");
     81            }
     82            extern const char CFG_MAIN_FOLDER[128];
     83            strcpy(main_folder, CFG_MAIN_FOLDER);
     84            if((xl=strlen(main_folder))>0)
     85            {
     86              x=main_folder[xl-1];
     87              if((x!='\\')&&(x!='/'))
     88              {
     89                main_folder[xl]='\\';
     90                main_folder[xl+1]=0;
     91              }
     92            }
     93          }
     94          
     95          void Mss3App::Killer()
     96          {
     97            extern void *ELF_BEGIN;
     98            kill_data(&ELF_BEGIN,(void (*)(void *))mfree_adr());
     99          }
    100          
    101          int Mss3App::IsAlreadyRuning()
    102          {
    103            CSM_RAM *icsm;
    104            WSHDR *ws, wsn;
    105            unsigned short wsb[16];
    106            ws=CreateLocalWS(&wsn, wsb, 16);
    107            wsprintf(ws, ELFFNAMED);
    108            icsm=(CSM_RAM *)((CSM_RAM *)(CSM_root()->csm_q->csm.first))->next;
    109            while(((unsigned int)(icsm->constr)>>27)==0x15)
    110            {
    111              WSHDR *tws=(WSHDR *)(((char *)icsm->constr)+sizeof(CSM_DESC));
    112              if((tws->ws_malloc==NAMECSM_MAGIC1)&&(tws->ws_mfree==NAMECSM_MAGIC2))
    113              {
    114                if(!wstrncmp_nocase(tws, ws, sizeof(ELFFNAMED)))
    115                  return 1;
    116              }
    117              icsm=(CSM_RAM *)icsm->next;
    118            }
    119            return 0;
    120          }

   Maximum stack usage in bytes:

     Function                       CSTACK
     --------                       ------
     Mss3App::InitDatPath()            16
     Mss3App::InitSetting()             4
     Mss3App::IsAlreadyRuning()        64
     Mss3App::Killer()                  4
     Mss3App::Start(char *, char *)    12


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     Mss3App::Start(char *, char *)  164
     Mss3App::InitSetting()           16
     Mss3App::InitDatPath()          168
     Mss3App::Killer()                28
     Mss3App::IsAlreadyRuning()      168
     ?<Constant "Mss3D">               8
     ?<Constant "SMS\\SMS.dat">       12
      Others                         116

 
 660 bytes in segment CODE
  20 bytes in segment DATA_C
 
 544 bytes of CODE  memory (+ 116 bytes shared)
  20 bytes of CONST memory

Errors: none
Warnings: none
