cTDT::cTDT(const u_char *Data) :SI::TDT(Data, false) { CheckParse(); time_t sattim = getTime(); time_t loctim = time(NULL); int diff = abs(sattim - loctim); if (diff > 2) { mutex.Lock(); if (abs(diff - lastDiff) < 3) { isyslog("System Time = %s (%ld)", *TimeToString(loctim), loctim); isyslog("Local Time = %s (%ld)", *TimeToString(sattim), sattim); if (stime(&sattim) < 0){ char __errorstr[256]; strerror_r(errno,__errorstr,256); __errorstr[255]=0; esyslog("ERROR while setting system time: %s",__errorstr); } } lastDiff = diff; mutex.Unlock(); } }
bool CRCSection::CheckCRCAndParse() { //M7X0 BEGIN AK // For Debuging is the driver delivers only Sections // with valid CRC. CRC-Checking can be dropped. // No need to check this any more driver delivers // CRC invalid sections #if 0 if (!isCRCValid()) { dsyslog("DEBUG: CRC of a section invalid!"); return false; } #endif //M7X0 END AK CheckParse(); return isValid(); }
cTDT::cTDT(const u_char *Data) :SI::TDT(Data, false) { CheckParse(); time_t sattim = getTime(); time_t loctim = time(NULL); int diff = abs(sattim - loctim); if (diff > 2) { mutex.Lock(); if (abs(diff - lastDiff) < 3) { isyslog("System Time = %s (%ld)", *TimeToString(loctim), loctim); isyslog("Local Time = %s (%ld)", *TimeToString(sattim), sattim); if (stime(&sattim) < 0) esyslog("ERROR while setting system time: %m"); } lastDiff = diff; mutex.Unlock(); } }
bool CRCSection::CheckCRCAndParse() { if (!isCRCValid()) return false; CheckParse(); return isValid(); }
bool CSimpleObject::Parse(FILE* fp) { char buf[256]; int nVertices,nTriangles; std::vector<Vec3f> vecVertices; std::vector<Array<int,3> > vecTriangles; nVertices = 0; nTriangles = 0; vecVertices.clear(); vecTriangles.clear(); int lineNumber = 0; while(fscanf(fp, "%s", buf) != EOF) { lineNumber ++; switch(buf[0]) { case '#': /* comment */ /* eat up rest of line */ fgets(buf, sizeof(buf), fp); break; case 'v': /* v, vn, vt */ switch(buf[1]) { case '\0': /* vertex */ { Vec3f vP; if(fscanf(fp, "%f %f %f", &vP.x, &vP.y, &vP.z)==3) { if(vecVertices.size()==0) { xmax=xmin=vP.x; ymax=ymin=vP.y; zmax=zmin=vP.z; } else { if(vP.x>xmax) xmax=vP.x; if(vP.x<xmin) xmin=vP.x; if(vP.y>ymax) ymax=vP.y; if(vP.y<ymin) ymin=vP.y; if(vP.z>zmax) zmax=vP.z; if(vP.z<zmin) zmin=vP.z; } nVertices++; vecVertices.push_back(vP); } else { printf("Error: Wrong Number of Values(Should be 3). at Line %d\n",lineNumber); return false; } } break; default: /* eat up rest of line */ fgets(buf, sizeof(buf), fp); break; } break; case 'f': /* face */ { int v,n,t; Array<int,3> vIndices; if(fscanf(fp, "%s", buf)!=1) { printf("Error: Wrong Face at Line %d\n",lineNumber); return false; } /* can be one of %d, %d//%d, %d/%d, %d/%d/%d %d//%d */ if (strstr(buf, "//")) { /* v//n */ if( sscanf(buf, "%d//%d", &vIndices[0],&n) ==2 && fscanf(fp, "%d//%d", &vIndices[1], &n) ==2 && fscanf(fp, "%d//%d", &vIndices[2], &n) ==2) { nTriangles++; vecTriangles.push_back(vIndices); } else { printf("Error: Wrong Face at Line %d\n",lineNumber); return false; } } else if (sscanf(buf, "%d/%d/%d", &v, &t, &n) == 3) { /* v/t/n */ vIndices[0] = v; if( fscanf(fp, "%d/%d/%d", &vIndices[1], &t, &n) ==3 && fscanf(fp, "%d/%d/%d", &vIndices[2], &t, &n) ==3 ) { nTriangles++; vecTriangles.push_back(vIndices); } else { printf("Error: Wrong Face at Line %d\n",lineNumber); return false; } } else if (sscanf(buf, "%d/%d", &v, &t) == 2) { /* v/t */ vIndices[0] = v; if( fscanf(fp, "%d/%d", &vIndices[1], &t) ==2 && fscanf(fp, "%d/%d", &vIndices[2], &t) ==2 ) { nTriangles++; vecTriangles.push_back(vIndices); } else { printf("Error: Wrong Face at Line %d\n",lineNumber); return false; } } else { /* v */ if( sscanf(buf, "%d", &vIndices[0]) ==1 && fscanf(fp, "%d", &vIndices[1]) ==1 && fscanf(fp, "%d", &vIndices[2]) ==1 ) { nTriangles++; vecTriangles.push_back(vIndices); } else { printf("Error: Wrong Face at Line %d\n",lineNumber); return false; } } } break; default: /* eat up rest of line */ fgets(buf, sizeof(buf), fp); break; } } if(CheckParse(vecVertices.size(),vecTriangles)) { Destroy(); m_nVertices = vecVertices.size(); m_nTriangles = vecTriangles.size(); m_pVertexList = new Vec3f[m_nVertices]; m_pTriangleList = new Array<int,3> [m_nTriangles]; for(int i=0;i<m_nVertices;i++) m_pVertexList[i] = vecVertices[i]; for(int i=0;i<m_nTriangles;i++) { for(int j=0;j<3;j++) m_pTriangleList[i][j] = vecTriangles[i][j] - 1; } return true; } else return false; }