1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include <QCoreApplication>
- #include "dmpdatacore.h"
- #include "datashm.h"
- ServerDogShm *dogshm;
- DMPDevList *datashm;
- 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(ServerDogShm),IPC_CREAT|0666))==-1){
- return false;
- }
- dogshm=static_cast<ServerDogShm*>(shmat(shmid,nullptr,0));
- if((key=ftok(DATA_PATH,static_cast<int>(DATA_PORT)))==-1){
- return false;
- }
- if((shmid=shmget(key,sizeof (DMPDevList),IPC_CREAT|0666))==-1){
- return false;
- }
- printf("dmp dataserver shmid = %d\n",shmid);
- datashm=static_cast<DMPDevList*>(shmat(shmid,nullptr,0));
- return true;
- }
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- if(load_shm()){
- DmpDataCore *core = new DmpDataCore(nullptr);
- core->start();
- }
- return a.exec();
- }
|