/****************************************************************** Function : SetScreenData Date : 2015-05-10 16:05:25 Author : xiaoheike Parameter : 无 Return : void Desc : 接收教师机发来的屏幕图像数据并调用显示方法 ******************************************************************/ void CMulticastDlg::SetScreenData() { // 接收到教师机的一幅屏幕图像数据的第几块的序号 int id = 0; while (false == m_isMulticastStop) { MULTICASTDATA multicastData; memset(&multicastData, 0, sizeof(MULTICASTDATA)); m_socketCenter.RecvDataUDP(m_socketMulticast, (char*)&multicastData, sizeof(MULTICASTDATA)); switch (multicastData.infoType) { case 1: // 位图数据信息 SetBmpTransDataNotLast(multicastData, id); break; case 2: // 接收最后一次发送的数据 SetBmpTransDataLast(multicastData, id); break; default: MessageBox(_T("未知的图像数据信息"), _T("提示"), MB_OK); CleanData(); exit(1); } ShowBmp(multicastData); } // CleanData(); }
int ImageText16Store::parseIdentity(Message *message, const unsigned char *buffer, unsigned int size, int bigEndian) const { ImageText16Message *imageText16 = (ImageText16Message *) message; // // Here is the fingerprint. // imageText16 -> len = *(buffer + 1); imageText16 -> drawable = GetULONG(buffer + 4, bigEndian); imageText16 -> gcontext = GetULONG(buffer + 8, bigEndian); imageText16 -> x = GetUINT(buffer + 12, bigEndian); imageText16 -> y = GetUINT(buffer + 14, bigEndian); if ((int) size > dataOffset) { int pad = (size - dataOffset) - (imageText16 -> len * 2); if (pad > 0) { CleanData((unsigned char *) buffer + size - pad, pad); } } #ifdef DEBUG *logofs << name() << ": Parsed Identity for message at " << this << ".\n" << logofs_flush; #endif return 1; }
void BgImage::SetImage(unsigned char* im, int x, int y, bool colorIm) { CleanData(); colorIm_ = colorIm; if (colorIm_ == false) im_ = new unsigned char[x*y]; else im_ = new unsigned char[x*y*3]; x_ = x; y_ = y; hasIm_ = true; int i; unsigned char *its, *itd; if (colorIm_ == false) { for (i=0, its=im, itd=im_; i<x*y; i++) { *(itd++) = *(its++); } } else { for (i=0, its=im, itd=im_; i<x*y*3; i++) { *(itd++) = *(its++); } } }
/* void gettimeofday(struct timeval, void* time_zone){ struct _timeb cur; _ftime(&cur); tv->tv_sec =cur.time; tv->tv_usec = cur.millitm * 1000; } */ CodeTorrent::~CodeTorrent() { HAGGLE_DBG2("Calling codetorrent destructor\n"); CleanMGData(); if (identity == CT_SERVER) { HAGGLE_DBG2("Cleaning up server\n"); CleanData(); } if (identity == CT_CLIENT) { HAGGLE_DBG2("Cleaning up client\n"); CleanMHelpful(); CleanBuffer(); delete[] rank_vec; delete[] rank_vec_in_buf; } // CBMEN, HL - Memory leak, only allocate when needed. /*if (cb) FreeCodedBlock(cb); */ delete[] num_blocks_gen; delete nc; }
/** @param hPrinter Handle to printer */ void CCPrintData::CleanOldData(HANDLE hPrinter) { // Do we have any timestamp registry keys for the printer? STRLIST lValues; if (!CCPrintRegistry::EnumRegistryValues(hPrinter, lValues, JOBDATA_TIME_PREFIX)) // Nothing for us return; DWORD dwTimeKey, dwProcessID; time_t tNow, tKey; // Go over values for (STRLIST::const_iterator i = lValues.begin(); i != lValues.end(); i++) { // Get the value if ((dwTimeKey = CCPrintRegistry::GetRegistryDWORD(hPrinter, (*i).c_str(), 0)) == 0) // Nothing here continue; tKey = (time_t)dwTimeKey; tNow = time(NULL); // Check if this is old (5 minutes or more) if (difftime(tNow, tKey) > 300) { // Yes, so get the process ID dwProcessID = _ttoi((*i).c_str() + _tcslen(JOBDATA_TIME_PREFIX)); if (dwProcessID == 0) continue; // And clean it up CleanData(hPrinter, dwProcessID); } } }
//------------------------------------------------------------------------------- // @ Player::~Player() //------------------------------------------------------------------------------- // Destructor //------------------------------------------------------------------------------- Player::~Player() { delete mTurret; mTurret = 0; CleanData(); } // End of Player::~Player()
wxURL::~wxURL() { CleanData(); #if wxUSE_PROTOCOL_HTTP if (m_proxy && m_proxy != ms_proxyDefault) delete m_proxy; #endif // wxUSE_PROTOCOL_HTTP #if wxUSE_URL_NATIVE delete m_nativeImp; #endif }
int ChangePropertyStore::parseIdentity(Message *message, const unsigned char *buffer, unsigned int size, int bigEndian) const { ChangePropertyMessage *changeProperty = (ChangePropertyMessage *) message; changeProperty -> mode = *(buffer + 1); changeProperty -> format = *(buffer + 16); changeProperty -> window = GetULONG(buffer + 4, bigEndian); changeProperty -> property = GetULONG(buffer + 8, bigEndian); changeProperty -> type = GetULONG(buffer + 12, bigEndian); changeProperty -> length = GetULONG(buffer + 20, bigEndian); // // Cleanup the padding bytes. // unsigned int uiFormat; unsigned int uiLengthInBytes; if ((int) size > CHANGEPROPERTY_DATA_OFFSET) { uiFormat = *(buffer + 16); uiLengthInBytes = changeProperty -> length; #ifdef DEBUG *logofs << name() << ": length " << uiLengthInBytes << ", format " << uiFormat << ", size " << size << ".\n" << logofs_flush; #endif if (uiFormat == 16) { uiLengthInBytes <<= 1; } else if (uiFormat == 32) { uiLengthInBytes <<= 2; } unsigned char *end = ((unsigned char *) buffer) + size; unsigned char *pad = ((unsigned char *) buffer) + CHANGEPROPERTY_DATA_OFFSET + uiLengthInBytes; CleanData((unsigned char *) pad, end - pad); } #ifdef DEBUG *logofs << name() << ": Parsed identity for message at " << message << ".\n" << logofs_flush; #endif return 1; }
int GetPropertyReplyStore::parseIdentity(Message *message, const unsigned char *buffer, unsigned int size, int bigEndian) const { GetPropertyReplyMessage *getPropertyReply = (GetPropertyReplyMessage *) message; getPropertyReply -> format = *(buffer + 1); getPropertyReply -> type = GetULONG(buffer + 8, bigEndian); getPropertyReply -> after = GetULONG(buffer + 12, bigEndian); getPropertyReply -> items = GetULONG(buffer + 16, bigEndian); // // Cleanup the padding bytes. // unsigned int uiLengthInBytes; unsigned int uiFormat; if ((int) size > GETPROPERTYREPLY_DATA_OFFSET) { uiLengthInBytes = getPropertyReply -> items; uiFormat = *(buffer + 1); #ifdef DEBUG *logofs << name() << ": length " << uiLengthInBytes << ", format " << uiFormat << ", size " << size << ".\n" << logofs_flush; #endif if (uiFormat == 16) { uiLengthInBytes <<= 1; } else if (uiFormat == 32) { uiLengthInBytes <<= 2; } unsigned char *end = ((unsigned char *) buffer) + size; unsigned char *pad = ((unsigned char *) buffer) + GETPROPERTYREPLY_DATA_OFFSET + uiLengthInBytes; CleanData((unsigned char *) pad, end - pad); } #ifdef DEBUG *logofs << name() << ": Parsed identity for message at " << message << ".\n" << logofs_flush; #endif return 1; }
const BgImage& BgImage::operator=(const BgImage& im) { if (this == &im) return *this; if (!im.IsAllocated()) { CleanData(); return *this; } PrivateCopyToThis(im); return *this; }
bool wxURL::ParseURL() { // If the URL was already parsed (m_protocol != NULL), pass this section. if (!m_protocol) { // Clean up CleanData(); // Make sure we have a protocol/scheme if (!HasScheme()) { m_error = wxURL_SNTXERR; return false; } // Find and create the protocol object if (!FetchProtocol()) { m_error = wxURL_NOPROTO; return false; } // Do we need a host name ? if (m_protoinfo->m_needhost) { // Make sure we have one, then if (!HasServer()) { m_error = wxURL_SNTXERR; return false; } } } #if wxUSE_PROTOCOL_HTTP if (m_useProxy) { // Third, we rebuild the URL. m_url = m_scheme + wxT(":"); if (m_protoinfo->m_needhost) m_url = m_url + wxT("//") + m_server; // We initialize specific variables. m_protocol = m_proxy; // FIXME: we should clone the protocol } #endif // wxUSE_PROTOCOL_HTTP m_error = wxURL_NOERR; return true; }
void BgImage::PrivateResize(int width, int height, bool color) { if ((hasIm_ == false) || (width != x_) || (height != y_) || (color != colorIm_)) { CleanData(); x_ = width; y_ = height; colorIm_ = color; if (color == false) im_ = new unsigned char[x_*y_]; else im_ = new unsigned char[x_*y_*3]; hasIm_ = true; } }
void wxURL::SetProxy(const wxString& url_proxy) { if ( !url_proxy ) { if ( m_proxy && m_proxy != ms_proxyDefault ) { m_proxy->Close(); delete m_proxy; } m_useProxy = false; } else { wxString tmp_str; wxString hostname, port; int pos; wxIPV4address addr; tmp_str = url_proxy; pos = tmp_str.Find(wxT(':')); // This is an invalid proxy name. if (pos == wxNOT_FOUND) return; hostname = tmp_str(0, pos); port = tmp_str(pos+1, tmp_str.Length()-pos); addr.Hostname(hostname); addr.Service(port); // Finally, create the whole stuff. if (m_proxy && m_proxy != ms_proxyDefault) delete m_proxy; m_proxy = new wxHTTP(); m_proxy->Connect(addr, true); // Watcom needs the 2nd arg for some reason CleanData(); // Reparse url. m_useProxy = true; ParseURL(); } }
/** @param hPrinter Handle to the printer @return true if successfully saved, false if failed */ bool CCPrintData::SaveProcessData(HANDLE hPrinter) { // Get process ID DWORD dwProcessID = GetCurrentProcessId(); // Remove old data for this process, if any CleanData(hPrinter, dwProcessID); // Save temporary file: // Get temp filename TCHAR cFilename[MAX_PATH + 1], cPath[MAX_PATH + 1], cFileKey[64], cTimeKey[64]; if (GetTempPath(MAX_PATH, cPath) == 0) return false; if (GetTempFileName(cPath, _T("CCPDF"), 0, cFilename) == 0) return false; // Save to the file if (!WriteToFile(cFilename)) { // Didn't work! Bale! _tunlink(cFilename); return false; } // Write timestamp to registry _stprintf_s(cTimeKey, _S(cTimeKey), JOBDATA_TIME_KEY, dwProcessID); if (!CCPrintRegistry::SetRegistryDWORD(hPrinter, cTimeKey, (DWORD) time(NULL))) { _tunlink(cFilename); return false; } // Write filename to registry _stprintf_s(cFileKey, _S(cFileKey), JOBDATA_FILE_KEY, dwProcessID); if (!CCPrintRegistry::SetRegistryString(hPrinter, cFileKey, cFilename)) { CCPrintRegistry::EraseRegistryValue(hPrinter, cTimeKey); _tunlink(cFilename); return false; } return true; }
CF<FactorizerType>::CF(arma::mat& data, FactorizerType factorizer, const size_t numUsersForSimilarity, const size_t rank) : numUsersForSimilarity(numUsersForSimilarity), rank(rank), factorizer(factorizer) { // Validate neighbourhood size. if (numUsersForSimilarity < 1) { Log::Warn << "CF::CF(): neighbourhood size should be > 0(" << numUsersForSimilarity << " given). Setting value to 5.\n"; //Setting Default Value of 5 this->numUsersForSimilarity = 5; } CleanData(data); // Check if the user wanted us to choose a rank for them. if (rank == 0) { // This is a simple heuristic that picks a rank based on the density of the // dataset between 5 and 105. const double density = (cleanedData.n_nonzero * 100.0) / cleanedData.n_elem; const size_t rankEstimate = size_t(density) + 5; // Set to heuristic value. Log::Info << "No rank given for decomposition; using rank of " << rankEstimate << " calculated by density-based heuristic." << std::endl; this->rank = rankEstimate; } // Operations independent of the query: // Decompose the sparse data matrix to user and data matrices. ApplyFactorizer<FactorizerType>(data, cleanedData, factorizer, this->rank, w, h); }
CMulticastDlg::~CMulticastDlg() { CleanData(); }
bool BlacklistTest(CDlgMain* dlg,CURL* curl,thread_status* this_struct) { dlg->console+=_T("\r\n*Retrieving Blacklist record."); dlg->UpdateData(FALSE); ScrollToBottom(dlg); CURLcode result; CString temp = _T("q="); CString temp2; temp+=dlg->res_domain;//GetDomain(dlg->settings->server_address); //temp+=_T("&check=check"); SetCurlUrl(curl,"http://www.blacklistalert.org/"); CleanData(this_struct); result = curl_easy_perform(curl); //<input type=hidden name="PHPSESSID" value="1885fc88a84fee781f38ef97da59386f"> int af = FindStr(this_struct->data,"name=\"PHPSESSID\" value=\"",0); int af2 = FindStr(this_struct->data,"\">",af); CString sess = CharToString(MidStr(this_struct->data,af+24,af2)); temp+=_T("&PHPSESSID=")+sess; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, StringToChar(temp)); SetCurlUrl(curl,"http://www.blacklistalert.org/"); CleanData(this_struct); result = curl_easy_perform(curl); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, ""); if((this_struct->data==NULL)) { //dlg->MessageBox(_T("Unable to retrieve blacklist records")); dlg->result_blacklistednum = _T("?"); dlg->console+=_T("\r\nUnable to get Blacklist record."); dlg->UpdateData(FALSE); ScrollToBottom(dlg); } else { int pos1 = FindStr(this_struct->data,"(Alphabetic order):</b><br>",0); int pos1end = FindStr(this_struct->data,"<hr>",pos1+10); int pos2 = FindStr(this_struct->data,"(Alphabetic order)</b><br>",pos1end); int pos2end = FindStr(this_struct->data,"<hr>",pos2+10); if((pos1==-1)||(pos1end==-1)||(pos2==-1)||(pos2end==-1)) { dlg->result_blacklistednum = _T("?"); dlg->result_blacklist = _T("?"); dlg->console+=_T("\r\nUnable to get Blacklist record."); dlg->UpdateData(FALSE); ScrollToBottom(dlg); } else { int pos4 = 0, pos5 = 0, pos6 = pos1+26, pos7 = 0, pos8 = 0, pos9 = 0; bool ok; bool no_result; int c_ok = 0; int c_listed = 0; int count = 0; int index = 0; while((pos4!=-1)&&(pos6<pos2end)) // < !!!!!!!!!!!!!!!!!!! { pos4 = FindStr(this_struct->data,"<br>",pos6); if(pos4==pos1end-4) pos4 = FindStr(this_struct->data,"<br>",pos2+26); else if(pos4==pos2end-4) break; pos5 = FindStr(this_struct->data,"<font color=",pos4); temp = MidStr(this_struct->data,pos4+4,pos5-1); index = dlg->blacklist.InsertItem(dlg->blacklist.GetItemCount(),temp); pos6 = FindStr(this_struct->data,">",pos5+5); pos7 = FindStr(this_struct->data,"</em>",pos6); pos8 = FindStr(this_struct->data,"href=\"",pos6); pos9 = FindStr(this_struct->data,"\">",pos8); // is blacklsited or not ok = (strcmp((const char*)MidStr(this_struct->data,pos5+12,pos6),"green")==0); no_result = (strcmp((const char*)MidStr(this_struct->data,pos5+12,pos6),"magenta")==0); if(ok) { dlg->blacklist.SetItemText(index,1,_T("OK")); c_ok++; } else if(no_result) { dlg->blacklist.SetItemText(index,1,_T("NO RESULT")); } else { dlg->blacklist.SetItemText(index,1,_T("LISTED")); c_listed++; if(pos8<pos7) { CString temp3(MidStr(this_struct->data,pos8+6,pos9)); dlg->blacklist.SetItemText(index,2,temp3); } } count++; temp.Format(_T("%d"),c_listed); temp2.Format(_T("%d"),count); temp+=_T("/"); temp+=temp2; dlg->result_blacklistednum = temp; dlg->UpdateData(FALSE); } if(c_listed) dlg->result_blacklist = _T("YES"); else dlg->result_blacklist = _T("NO"); dlg->console+=_T("\r\nSuccess."); dlg->UpdateData(FALSE); ScrollToBottom(dlg); } } return true; }
bool SpfTest(CDlgMain* dlg,CURL* curl,thread_status* this_struct) { dlg->console+=_T("\r\n*Retrieving SPF record."); dlg->UpdateData(FALSE); ScrollToBottom(dlg); CURLcode result; CString temp = _T("http://tools.bevhost.com/cgi-bin/dnslookup?data="); CString domain = dlg->res_domain;//GetDomain(dlg->settings->server_address); temp+=domain; temp+=_T("&server="); SetCurlUrl(curl,temp); CleanData(this_struct); result = curl_easy_perform(curl); if((result!=CURLE_OK)||(this_struct->data==NULL)) { //dlg->MessageBox(_T("Unable to retrieve spf record")); dlg->result_spfbox = _T(""); dlg->result_spf = _T("?"); dlg->console+=_T("\r\nUnable to get SPF record."); dlg->UpdateData(FALSE); ScrollToBottom(dlg); } else { int pos = 0; int pos_end = 0; dlg->result_spfbox = _T(""); while(true) { pos = FindStr(this_struct->data,"descriptive text \"",pos); pos_end = FindStr(this_struct->data,"\"",pos+19); if(pos!=-1) { dlg->result_spfbox+=MidStr(this_struct->data,pos+18,pos_end); dlg->result_spfbox+=_T("\r\n"); //dlg->result_spf_type = _T("TXT"); dlg->result_spf_domain = domain; } else break; pos+=1; } if(dlg->result_spfbox==_T("")) { dlg->console+=_T("\r\nNo SPF records found."); dlg->result_spfbox = _T("[No SPF records found]"); dlg->result_spf = _T("NO"); } else { dlg->console+=_T("\r\nSuccess."); dlg->result_spf = _T("YES"); } dlg->UpdateData(FALSE); ScrollToBottom(dlg); } return true; }
void CodeTorrent::LoadFile(int gen) { BlockPtr pblk; // before begining, erase everything in data CleanData(); // MOS - no data signals error //printf("loading filename=%s\n",filename); if (!(fp = fopen(filename, "rb"))) { HAGGLE_ERR("CODETORRENT ERROR: cannot open %s\n", filename); return; // MOS - need error handling } if(fp) HAGGLE_DBG2("Opening file %s for writing with file descriptor %d\n", filename, fileno(fp)); int i, j; int n_items = 0; int pos = 0; int temp; bool last_gen = false; int last_block_size; int gen_size = block_size * num_blocks_gen[gen]; // set gen_size for this gen unsigned char *fbuf = new unsigned char[gen_size]; for (i = 0; i < gen; i++) pos += num_blocks_gen[i]; pos *= block_size; fseek(fp, pos, SEEK_SET); // move file cursor to begining of n-th generation // read one generation temp = fread(fbuf, 1, gen_size, fp); //printf("read one generation %s\n",fbuf); if (temp + pos == file_size && gen == num_gens - 1) { last_gen = true; } else if (temp != gen_size) { HAGGLE_ERR("temp %d gen_size %d\n",temp,gen_size); #ifdef WIN32 HAGGLE_ERR("%s: fread(2) \n", strerror(errno)); #else HAGGLE_ERR("CODETORRENT ERROR: unexpected codetorrent read result\n"); #endif //printf("Press <enter>..."); //getchar(); //abort(); fclose(fp); // MOS delete[] fbuf; // MOS return; // MOS - need error handling } fclose(fp); // before begining, erase everything in data // CleanData(); // MOS - see above int numblockslen = num_blocks_gen[gen]; //printf("numblockslen =%d\n", numblockslen); // N.B. data is stored "unpacked" e.g., 4bit symbol => 8bit. for (i = 0; i < numblockslen; i++) { pblk = AllocBlock((block_size)); memset(pblk, 0, (block_size)); // if this is the last block if (last_gen && i == num_blocks_gen[gen] - 1) { last_block_size = temp - (num_blocks_gen[gen] - 1) * block_size; for (j = 0; j < (is_sim ? 1 : last_block_size); j++) { pblk[j] = NthSymbol(fbuf, field_size, block_size * i + j); } if (!is_sim) { for (; j < block_size; j++) { pblk[j] = 0; // padding zeros } } } else { for (j = 0; j < (is_sim ? 1 : block_size); j++) { pblk[j] = NthSymbol(fbuf, field_size, block_size * i + j); } } //printf("pushing back block |%u|\n", pblk); data.push_back(pblk); } // record which gen is in memory! gen_in_memory = gen; delete[] fbuf; }
template <class T> Array<T>::Array() { CleanData(); }
BgImage::~BgImage() { CleanData(); }
//------------------------------------------------------------------------------- // @ Player::ReadData() //------------------------------------------------------------------------------- // Read in geometry data //------------------------------------------------------------------------------- bool Player::ReadData() { // read in geometric data IvFileReader in("Tank.txt"); if (!in) return false; unsigned int numVerts; // get number of vertices in >> numVerts; if ( !in.good() ) return false; mVertices = IvRenderer::mRenderer->GetResourceManager()->CreateVertexBuffer(kCNPFormat, numVerts, nullptr, kDefaultUsage); IvCNPVertex* dataPtr = (IvCNPVertex*) mVertices->BeginLoadData(); // read positions for ( UInt32 i = 0; i < numVerts; ++i ) { float x, y, z; in >> x >> y >> z; dataPtr[i].position.Set(x,y,z); if (!in.good() ) { CleanData(); return false; } } // read normals for ( UInt32 i = 0; i < numVerts; ++i ) { float x, y, z; in >> x >> y >> z; dataPtr[i].normal.Set(x,y,z); if (!in.good() ) { CleanData(); return false; } } // read colors for ( UInt32 i = 0; i < numVerts; ++i ) { float r, g, b; in >> r >> g >> b; dataPtr[i].color.mRed = UChar8(r*255); dataPtr[i].color.mGreen = UChar8(g*255); dataPtr[i].color.mBlue = UChar8(b*255); dataPtr[i].color.mAlpha = 255; if (!in.good() ) { CleanData(); return false; } } if (!mVertices->EndLoadData()) { CleanData(); return false; } // get number of indices UInt32 numTankBodyIndices; in >> numTankBodyIndices; if ( !in.good() ) return false; // read indices mIndices = IvRenderer::mRenderer->GetResourceManager()->CreateIndexBuffer(numTankBodyIndices, nullptr, kDefaultUsage); UInt32* indexPtr = static_cast<UInt32*>(mIndices->BeginLoadData()); for ( UInt32 i = 0; i < numTankBodyIndices; ++i ) { in >> indexPtr[i]; if (!in.good() ) { CleanData(); return false; } } if (!mIndices->EndLoadData()) { CleanData(); return false; } // read in turret if ( !mTurret || !mTurret->ReadData() ) { CleanData(); return false; } return true; } // End of Player::ReadData()
/** @param hPrinter Handle to the printer */ void CCPrintData::CleanSaved(HANDLE hPrinter) { // Clean the data for this process CleanData(hPrinter, GetCurrentProcessId()); }
//构造函数 CUserItem::CUserItem() { CleanData(); }
CScreenMonitorDlg::~CScreenMonitorDlg() { CleanData(); }
int ConvertFile(std::string s_input_file_name, std::string s_output_file_name, std::string s_xml_file_name, std::string s_pack_file_name, std::string s_gatts_file_name) { // try to open the file for reading int i_ret = 0; std::ifstream x_infile; x_infile.open(s_input_file_name.c_str(), std::ios::in|std::ios_base::binary); if (!x_infile) { std::cerr << "Error: Input file: " << s_input_file_name << " could not be opened." << std::endl; i_ret = 1; } // check that the file is a UM field file by checking the headers if (i_ret != 1 && !IsUMFile(x_infile)) { std::cerr << "Error: Input file: " << s_input_file_name << " is not a UM file." << std::endl; i_ret = 1; } if (i_ret != 1) { // read headers UM_WORD *px_fixhdr, *px_pphdrs, *px_intc, *px_realc; UM_WORD *px_levc, *px_rowc, *px_colc, *px_fieldc; ReadHdrs(x_infile, px_fixhdr, px_pphdrs, px_intc, px_realc, px_levc, px_rowc, px_colc, px_fieldc); // get the reference time MTime x_ref_time(&(px_fixhdr[20]), px_fixhdr[7]); // read the data - note that this will have to be converted to it's // actual type by checking the pphdr UM_WORD* px_data = ReadData(x_infile, px_fixhdr, px_pphdrs); // check that some data was actually read. if (px_data == NULL) { std::cerr << "Error: Input file: " << s_input_file_name << " contains no data." << std::endl; i_ret = 1; } // create the lists for storing the info about the file std::list<Variable> x_var_list; if (i_ret != 1) ExtractVarFields(px_fixhdr, px_pphdrs, px_data, x_var_list); // read the xml file definition of level and variable names and attributes VarLevTrans x_var_lev_trans(s_xml_file_name); if (i_ret != 1 && !x_var_lev_trans.LoadAttributes()) { std::cerr << "Error: XML file: " << s_xml_file_name << " error in XML or file could not be opened." << std::endl; i_ret = 1; } // read the xml file for the packing details Packing x_packing(s_pack_file_name); if (i_ret != 1 && !x_packing.LoadAttributes()) { std::cerr << "Error: XML file: " << s_pack_file_name << " error in XML or file could not be opened." << std::endl; i_ret = 1; } // Pack the variables x_packing.PackVariables(x_var_list); GlobalAtts x_gatts; if (i_ret != 1) { if (s_gatts_file_name != "") if (!x_gatts.LoadAttributes(s_gatts_file_name)) { std::cerr << "Error: Failed to load global attributes file: " << s_gatts_file_name << std::endl; i_ret = 1; } } // write out the netCDF file - we have all the necessary info now if (i_ret != 1) i_ret = WriteNetCDFFile(s_output_file_name, x_var_list, x_ref_time, x_var_lev_trans, x_gatts); if (i_ret == 1) std::cerr << "Error: Output file could not be written." << std::endl; // clean up headers CleanHdrs(px_fixhdr, px_pphdrs, px_intc, px_realc, px_levc, px_rowc, px_colc, px_fieldc); CleanData(px_data); // close input file x_infile.close(); if (i_ret != 1) std::cout << "Converted file: " << s_input_file_name << " to: " << s_output_file_name << std::endl; } return i_ret; }