main.cpp 839 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <QCoreApplication>
  2. #include "smartlightshm.h"
  3. #include "core.h"
  4. SL_Shm *slShm;
  5. WebDataShm *webData;
  6. bool load_shm()
  7. {
  8. int shmid;
  9. key_t key;
  10. if((key = ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1)
  11. return false;
  12. if((shmid = shmget(key,sizeof(SL_Shm),IPC_CREAT|0666))==-1)
  13. return false;
  14. slShm = static_cast<SL_Shm *>(shmat(shmid,nullptr,0));
  15. if((key = ftok(WEB_SHM_PATH,static_cast<int>(WEB_SHM_PORT)))==-1)
  16. return false;
  17. if((shmid = shmget(key,sizeof(WebDataShm),IPC_CREAT|0666))==-1)
  18. return false;
  19. webData = static_cast<WebDataShm *>(shmat(shmid,nullptr,0));
  20. return true;
  21. }
  22. int main(int argc, char *argv[])
  23. {
  24. QCoreApplication a(argc, argv);
  25. if(load_shm()){
  26. Core *core = new Core(nullptr);
  27. core->start();
  28. }
  29. return a.exec();
  30. }