1234567891011121314151617181920212223242526272829303132333435363738 |
- #include <QCoreApplication>
- #include "ytservicecore.h"
- #include "core.h"
- YT_SERVICE_SHM *ytShm;
- WebDataShm *webData;
- UserInfoShm *userinfoShm;
- bool load_shm(){
- int shmid;
- key_t key;
- if((key = ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1)
- return false;
- if((shmid = shmget(key,sizeof(YT_SERVICE_SHM),IPC_CREAT|0666))==-1)
- return false;
- ytShm = static_cast<YT_SERVICE_SHM *>(shmat(shmid,nullptr,0));
- if((key = ftok(UISHM_PATH,static_cast<int>(UISHM_PORT)))==-1)
- return false;
- if((shmid = shmget(key,sizeof(UserInfoShm),IPC_CREAT|0666))==-1)
- return false;
- userinfoShm = static_cast<UserInfoShm *>(shmat(shmid,nullptr,0));
- if((key = ftok(WEB_SHM_PATH,static_cast<int>(WEB_SHM_PORT)))==-1)
- return false;
- if((shmid = shmget(key,sizeof(WebDataShm),IPC_CREAT|0666))==-1)
- return false;
- webData = static_cast<WebDataShm *>(shmat(shmid,nullptr,0));
- return true;
- }
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- if(load_shm()){
- Core *c = new Core(nullptr);
- c->start();
- }
- return a.exec();
- }
|