main.cpp 650 B

123456789101112131415161718192021222324252627282930313233
  1. #include <QCoreApplication>
  2. #include "dogshm.h"
  3. #include "dogcore.h"
  4. ServerDogShm *dogshm;
  5. bool shm_load()
  6. {
  7. int shmid;
  8. key_t key;
  9. if((key=ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1){
  10. return false;
  11. }
  12. if((shmid=shmget(key,sizeof(ServerDogShm),IPC_CREAT|0666))==-1){
  13. return false;
  14. }
  15. printf("dmp dog shmid = %d\n",shmid);
  16. dogshm=static_cast<ServerDogShm*>(shmat(shmid,nullptr,0));
  17. return true;
  18. }
  19. int main(int argc, char *argv[])
  20. {
  21. QCoreApplication a(argc, argv);
  22. if(shm_load()){
  23. DogCore *dogcore = new DogCore(nullptr);
  24. dogcore->start();
  25. }
  26. return a.exec();
  27. }