void readingTheShMem()
{
int tOTL=0;
int tONL=0;
int tSNL=0;
int tSLL=0;
int tIDL=0;
int tMDL=0;
int readingLength;
//lock the file for writing
memset (&lock, 0, sizeof(lock));
lock.l_type = F_WRLCK;
fcntl (fd, F_SETLKW, &lock);
struct ShMem *infoVar=(ShMem*)((char*)file_memory);
tOTL = infoVar->oTL;
tONL = infoVar->oNL;
tSNL = infoVar->sNL;
tSLL = infoVar->sLL;
tIDL = infoVar->iDL;
tMDL = infoVar->mDL;
readingLength = tOTL + tONL + tSNL + tSLL + tIDL + tMDL ;
char *readingStrs[readingLength];
printf("reading length = %d\n", readingLength);
printf("the infoVar->oAndS_str reading points to=%p\n",&(infoVar->oAndS_str));
memcpy(readingStrs, &(infoVar->oAndS_str), readingLength);
//unlock the file to allow access
lock.l_type = F_UNLCK;
fcntl (fd, F_SETLKW, &lock);
char *tOT[tOTL]; memcpy(tOT,readingStrs,tOTL);
printf("tOTL = %d and oT ptr = %p\n", tOTL, readingStrs);
char *tON[tONL]; memcpy(tON,(readingStrs+tOTL),tONL);
printf("tONL = %d and oN ptr = %p\n", tONL, (readingStrs+tOTL));
char *tSN[tSNL]; memcpy(tSN,(readingStrs+tOTL+tONL),tSNL);
printf("tSNL = %d and sN ptr = %p\n", tSNL, (readingStrs+tOTL+tONL));
char *tSL[tSLL]; memcpy(tSL,(readingStrs+tOTL+tONL+tSNL),tSLL);
printf("tSLL = %d and sL ptr = %p\n", tSLL, (readingStrs+tOTL+tONL+tSNL));
char *tID[tIDL]; memcpy(tID,(readingStrs+tOTL+tONL+tSNL+tSLL),tIDL);
printf("tIDL = %d and iD ptr = %p\n", tIDL, (readingStrs+tOTL+tONL+tSNL+tSLL));
char tMD[tMDL]; memcpy(tMD,(readingStrs+tOTL+tONL+tSNL+tSLL+tIDL),tMDL);
printf("tMDL = %d and mD ptr = %p\n", tMDL, (readingStrs+tOTL+tONL+tSNL+tSLL+tIDL));
printf("oT = %s\n",tOT);
printf("oN = %s\n",tON);
printf("sN = %s\n",tSN);
printf("sL = %s\n",tSL);
printf("iD = %s\n",tID);
printf("mD = %s\n",tMD);
operatorTel
= QString::fromLocal8Bit((const char*)tOT
);
operatorName
= QString::fromLocal8Bit((const char*)tON
);
stationNum
= QString::fromLocal8Bit((const char*)tSN
);
stationLoc
= QString::fromLocal8Bit((const char*)tSL
);
installationDate
= QString::fromLocal8Bit((const char*)tID
);
maintenanceDate
= QString::fromLocal8Bit((const char*)tMD
);
//do smth with these variables now
}
void readingTheShMem()
{
int tOTL=0;
int tONL=0;
int tSNL=0;
int tSLL=0;
int tIDL=0;
int tMDL=0;
int readingLength;
//lock the file for writing
memset (&lock, 0, sizeof(lock));
lock.l_type = F_WRLCK;
fcntl (fd, F_SETLKW, &lock);
struct ShMem *infoVar=(ShMem*)((char*)file_memory);
tOTL = infoVar->oTL;
tONL = infoVar->oNL;
tSNL = infoVar->sNL;
tSLL = infoVar->sLL;
tIDL = infoVar->iDL;
tMDL = infoVar->mDL;
readingLength = tOTL + tONL + tSNL + tSLL + tIDL + tMDL ;
char *readingStrs[readingLength];
printf("reading length = %d\n", readingLength);
printf("the infoVar->oAndS_str reading points to=%p\n",&(infoVar->oAndS_str));
memcpy(readingStrs, &(infoVar->oAndS_str), readingLength);
//unlock the file to allow access
lock.l_type = F_UNLCK;
fcntl (fd, F_SETLKW, &lock);
char *tOT[tOTL]; memcpy(tOT,readingStrs,tOTL);
printf("tOTL = %d and oT ptr = %p\n", tOTL, readingStrs);
char *tON[tONL]; memcpy(tON,(readingStrs+tOTL),tONL);
printf("tONL = %d and oN ptr = %p\n", tONL, (readingStrs+tOTL));
char *tSN[tSNL]; memcpy(tSN,(readingStrs+tOTL+tONL),tSNL);
printf("tSNL = %d and sN ptr = %p\n", tSNL, (readingStrs+tOTL+tONL));
char *tSL[tSLL]; memcpy(tSL,(readingStrs+tOTL+tONL+tSNL),tSLL);
printf("tSLL = %d and sL ptr = %p\n", tSLL, (readingStrs+tOTL+tONL+tSNL));
char *tID[tIDL]; memcpy(tID,(readingStrs+tOTL+tONL+tSNL+tSLL),tIDL);
printf("tIDL = %d and iD ptr = %p\n", tIDL, (readingStrs+tOTL+tONL+tSNL+tSLL));
char tMD[tMDL]; memcpy(tMD,(readingStrs+tOTL+tONL+tSNL+tSLL+tIDL),tMDL);
printf("tMDL = %d and mD ptr = %p\n", tMDL, (readingStrs+tOTL+tONL+tSNL+tSLL+tIDL));
printf("oT = %s\n",tOT);
printf("oN = %s\n",tON);
printf("sN = %s\n",tSN);
printf("sL = %s\n",tSL);
printf("iD = %s\n",tID);
printf("mD = %s\n",tMD);
operatorTel = QString::fromLocal8Bit((const char*)tOT);
operatorName = QString::fromLocal8Bit((const char*)tON);
stationNum = QString::fromLocal8Bit((const char*)tSN);
stationLoc = QString::fromLocal8Bit((const char*)tSL);
installationDate = QString::fromLocal8Bit((const char*)tID);
maintenanceDate = QString::fromLocal8Bit((const char*)tMD);
//do smth with these variables now
}
To copy to clipboard, switch view to plain text mode
Bookmarks