void SecondsToTimeString( char *buf, unsigned int seconds) { struct DateStamp ds; extern struct Locale *DefaultLocale; ds.ds_Days = seconds / 60 / 60 / 24; ds.ds_Minute = (seconds / 60) % (60 * 24); ds.ds_Tick = (seconds % 60) * 50; if (LocaleBase && DefaultLocale) { struct Hook date_hook; #if defined(__AMIGAOS4__) if ((SysBase->lib_Version > 51) || (SysBase->lib_Version == 51 && SysBase->lib_Revision >= 3)) { date_hook.h_Entry = (HOOKFUNC)Hookfunc_Date_Write; } else { date_hook.h_Entry = (HOOKFUNC)hookEntry; date_hook.h_SubEntry = (HOOKFUNC)Hookfunc_Date_Write; } #elif defined(__MORPHOS__) || defined(__AROS__) date_hook.h_Entry = (HOOKFUNC)hookEntry; date_hook.h_SubEntry = (HOOKFUNC)Hookfunc_Date_Write; #else date_hook.h_Entry = (HOOKFUNC)Hookfunc_Date_Write; #endif date_hook.h_Data = buf; FormatDate(DefaultLocale, DefaultLocale->loc_TimeFormat, &ds, &date_hook); } else { /* dos stuff should follow here */ *buf = 0; } }
static VOID DirPrintFileDateTime(TCHAR *lpDate, TCHAR *lpTime, LPWIN32_FIND_DATA lpFile, LPDIRSWITCHFLAGS lpFlags) { FILETIME ft; SYSTEMTIME dt; /* Select the right time field */ switch (lpFlags->stTimeField.eTimeField) { case TF_CREATIONDATE: if (!FileTimeToLocalFileTime(&lpFile->ftCreationTime, &ft)) return; FileTimeToSystemTime(&ft, &dt); break; case TF_LASTACCESSEDDATE : if (!FileTimeToLocalFileTime(&lpFile->ftLastAccessTime, &ft)) return; FileTimeToSystemTime(&ft, &dt); break; case TF_MODIFIEDDATE: if (!FileTimeToLocalFileTime(&lpFile->ftLastWriteTime, &ft)) return; FileTimeToSystemTime(&ft, &dt); break; } FormatDate(lpDate, &dt, lpFlags->b4Digit); FormatTime(lpTime, &dt); }
void BCountry::FormatDate(char* string, size_t maxSize, time_t time, bool longFormat) { BString fullString; FormatDate(&fullString, time, longFormat); strncpy(string, fullString.String(), maxSize); }
CString MainWindow::CreateFileList(SelectionSet* pSelSet) { SelectionEntry* pSelEntry; GenericEntry* pEntry; CString tmpStr, fullStr; WCHAR fileTypeBuf[ContentList::kFileTypeBufLen]; WCHAR auxTypeBuf[ContentList::kAuxTypeBufLen]; CString fileName, subVol, fileType, auxType, modDate, format, length; pSelEntry = pSelSet->IterNext(); while (pSelEntry != NULL) { pEntry = pSelEntry->GetEntry(); ASSERT(pEntry != NULL); fileName = DblDblQuote(pEntry->GetPathNameUNI()); subVol = pEntry->GetSubVolName(); ContentList::MakeFileTypeDisplayString(pEntry, fileTypeBuf); fileType = DblDblQuote(fileTypeBuf); // Mac HFS types might have '"'? ContentList::MakeAuxTypeDisplayString(pEntry, auxTypeBuf); auxType = DblDblQuote(auxTypeBuf); FormatDate(pEntry->GetModWhen(), &modDate); format = pEntry->GetFormatStr(); length.Format(L"%I64d", (LONGLONG) pEntry->GetUncompressedLen()); tmpStr.Format(L"\"%ls\"\t%ls\t\"%ls\"\t\"%ls\"\t%ls\t%ls\t%ls\r\n", (LPCWSTR) fileName, (LPCWSTR) subVol, (LPCWSTR) fileType, (LPCWSTR) auxType, (LPCWSTR) modDate, (LPCWSTR) format, (LPCWSTR) length); fullStr += tmpStr; pSelEntry = pSelSet->IterNext(); } return fullStr; }
void XLog::Flush() { if (0 == m_savingqueue_size) return; m_file_date_tmp = new SYSTEMTIME(); GetLocalTime(m_file_date_tmp); string sfile = m_logfilepath; sfile.append(m_computer_name); sfile.append("_"); sfile.append(ExtractFileName(ParamStr(0))); sfile.append("_"); sfile.append(FormatDate(*m_file_date_tmp)); sfile.append(".log"); if (!FileExists(sfile.c_str())) { // unsigned char head[2] = {0xFF,0xFE}; SaveBufferToFile(sfile,m_savingqueue_logical,m_savingqueue_size); } else { AppendBuf2File(sfile,m_savingqueue_logical,m_savingqueue_size); } m_savingqueue_size = 0; }
extern BOOL VerifyDateFormat ( HWND hwndField, HWND hwndError, HWND hwndSample, char *DateFormat ) { /************************************************************************** * Get the new value. * **************************************************************************/ char Local [100] ; Sys_GetWindowText ( hwndField, Local, sizeof(Local) ) ; GeneralDateFormat ( DateFormat, Local ) ; /************************************************************************** * Validate it. * **************************************************************************/ char Result [100] ; if ( FormatDate ( time(0), DateFormat, Result, sizeof(Result) ) ) { Sys_SetWindowText ( hwndSample, Result ) ; } else { ResourceString Message ( LibraryHandle, IDS_DATEFMT_ERROR1 ) ; Sys_SetWindowText ( hwndError, PCHAR(Message) ) ; Sys_BeepError ( ) ; Sys_SetFocus ( hwndField ) ; return ( FALSE ) ; } /* endif */ /************************************************************************** * Return no error. * **************************************************************************/ return ( TRUE ) ; }
int CRemoteFileDialog::AddFileItem(LPCTSTR szFileName, int nType, UINT nUniqueID, DWORD dwFileSize, const FILETIME* pLastMod, int nImage) { if (nImage == -1) { nImage = CSysImageList().GetFileImageIndex(szFileName); } int nItem = m_lcFiles.InsertItem(LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM, 0, szFileName, 0, 0, nImage, nUniqueID); // add to map FILEITEM fi; fi.sFilename = szFileName; fi.nType = nType; fi.dwSize = dwFileSize; if (pLastMod) { FILETIME ftLocal; FileTimeToLocalFileTime(pLastMod, &ftLocal); fi.dLastMod = COleDateTime(ftLocal); } m_mapItems[nUniqueID] = fi; // add size and date item if a file if (nType == RFDT_FILE && m_bInitReport) { m_lcFiles.SetItemText(nItem, 1, FormatSize(fi.dwSize)); m_lcFiles.SetItemText(nItem, 2, FormatDate(fi.dLastMod)); } return nItem; }
void CRemoteFileDialog::OnChangeView(UINT nCmdID) { int nView = VIEWS[nCmdID - ID_VIEW_SMALLICON]; int nPrevView = (m_lcFiles.GetStyle() & LVS_TYPEMASK); m_lcFiles.ModifyStyle(nPrevView, nView); if (!m_bInitReport && nView == LVS_REPORT) { // add all the other column info that has not been added yet // because the header control was not created int nItem = m_lcFiles.GetItemCount(); while (nItem--) { int nID = m_lcFiles.GetItemData(nItem); FILEITEM fi; VERIFY(m_mapItems.Lookup(nID, fi)); if (fi.nType == RFDT_FILE) { m_lcFiles.SetItemText(nItem, 1, FormatSize(fi.dwSize)); m_lcFiles.SetItemText(nItem, 2, FormatDate(fi.dLastMod)); } } m_bInitReport = TRUE; } }
void ShowTopTime(char *pTitle, int ForceUpdate) { char Str[24]; time_t CurrTime; static time_t PrevTime; struct tm *pLocalTm; /* If the time has not changed, then there is no need to update screen */ time(&CurrTime); if(CurrTime == PrevTime && !ForceUpdate) return; /* Format the date and time */ PrevTime = CurrTime; pLocalTm = localtime(&CurrTime); strcpy(Str, " "); FormatDate(Str + 1, pLocalTm); strcat(Str, " "); FormatTime(Str + strlen(Str), pLocalTm); /* Display the title, date and time */ ShowTopLine(pTitle, Str); }
void DateFormatCommand :: FormatDates( CSVRow & row ) { for ( unsigned int i = 0; i < row.size(); i++ ) { if ( ALib::Contains( mFields, i ) ) { string ds = row[i]; row[i] = FormatDate( ds ); } } }
void FileOutput::Write(LogLevel level, const std::string& loggerName, const std::string& message) { EnterCriticalSection(&this->writeLock); std::ofstream(this->fileName, std::ofstream::app | std::ofstream::out) << "[" << FormatDate() << " " << FormatTime() << "]" << "[" << loggerName << "]" << LevelStrings[(int)level] << " " << message << std::endl; LeaveCriticalSection(&this->writeLock); }
void AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry) { time_t createWhen, modWhen; CString createStr, modStr; createWhen = NufxArchive::DateTimeToSeconds(&pEntry->createWhen); modWhen = NufxArchive::DateTimeToSeconds(&pEntry->modWhen); FormatDate(createWhen, &createStr); FormatDate(modWhen, &modStr); LOGI(" Header for file '%hs':", pEntry->fileName); LOGI(" dataStorageLen=%d eof=%d blockCount=%d checksum=0x%04x", pEntry->dataStorageLen, pEntry->dataEof, pEntry->blockCount, pEntry->dataChecksum); LOGI(" fileType=0x%02x auxType=0x%04x storageType=0x%02x access=0x%04x", pEntry->fileType, pEntry->auxType, pEntry->storageType, pEntry->access); LOGI(" created %ls, modified %ls", (LPCWSTR) createStr, (LPCWSTR) modStr); LOGI(" fileNameLen=%d headerChecksum=0x%04x", pEntry->fileNameLen, pEntry->headerChecksum); }
String DateTime::Format(DateFormat format) const { String strDate = FormatDate(format); String strTime = FormatTime(format); if( format == DateFormat::ExpandedT || format == DateFormat::Compact ) { return strDate + "T" + strTime; } return strDate + " " + strTime; }
wxString CTimeFormat::Format(CDateTime const& time) { wxString ret; if( time.IsValid() ) { if( time.GetAccuracy() > CDateTime::days ) { ret = FormatDateTime(time.Degenerate()); } else { ret = FormatDate(time.Degenerate()); } } return ret; }
/* Return date string including weekday. Used for $D in prompt and %DATE% */ LPTSTR GetDateString(VOID) { static TCHAR szDate[32]; SYSTEMTIME t; INT len; GetLocalTime(&t); len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &t, _T("ddd"), szDate, sizeof szDate); szDate[len - 1] = _T(' '); FormatDate(&szDate[len], &t, TRUE); return szDate; }
static MRESULT APIENTRY Control ( HWND Window, ULONG, MPARAM mp1, MPARAM ) { /************************************************************************** * Find the instance data. * **************************************************************************/ PDATEFMT_PARMS Parms = PDATEFMT_PARMS ( Sys_GetWindowData ( Window ) ) ; /************************************************************************** * Decode the message. Find out what control sent it, and what the * * control had to say. * **************************************************************************/ USHORT id = SHORT1FROMMP ( mp1 ) ; USHORT Message = SHORT2FROMMP ( mp1 ) ; /************************************************************************** * Handle changes according to which control reported them. * **************************************************************************/ switch ( id ) { case IDD_DATEFMT_ENTRY: { if ( Message == EN_CHANGE ) { char Local [sizeof(Parms->Format)] ; Sys_GetWindowText ( CHILD(Window,id), Local, sizeof(Local) ) ; GeneralDateFormat ( Parms->Format, Local ) ; char Result [100] ; if ( FormatDate ( time(0), Parms->Format, Result, sizeof(Result) ) ) { Sys_SetWindowText ( CHILD(Window,IDD_DATEFMT_SAMPLE), Result ) ; Sys_SetWindowText ( CHILD(Window,IDD_DATEFMT_ERR), "" ) ; } else { ResourceString Message ( Parms->Library, IDS_DATEFMT_ERROR1 ) ; Sys_SetWindowText ( CHILD(Window,IDD_DATEFMT_ERR), PSZ(Message) ) ; } /* endif */ } /* endif */ return ( 0 ) ; } /* endcase */ } /* endswitch */ return ( 0 ) ; }
void iDlg_HallOfFame::DoCompose(const iRect& clRect) { iRect rc(clRect); // title gTextComposer.TextOut(dlgfc_hdr, gApp.Surface(),rc.point(),gTextMgr[TRID_MENU_HIGHSCORE], iRect(rc.x,rc.y,rc.w,15),AlignCenter); rc.y+=17; // Header gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_RANK], iRect(rc.x, rc.y, 30, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_LAND], iRect(rc.x+30, rc.y, 120, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_DATE], iRect(rc.x+30+120, rc.y, 50, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_DAYS], iRect(rc.x+30+120+50, rc.y, 40, 15),AlignTop); gTextComposer.TextOut(dlgfc_topic, gApp.Surface(),rc, gTextMgr[TRID_HOF_SCORE], iRect(rc.x+30+120+50+40, rc.y, 40, 15),AlignTop); rc.y += 15; // Entries uint32 eid; iTextComposer::FontConfig fc(iTextComposer::FS_MEDIUM, RGB16(192,192,192)); for (eid = 0; eid<m_hScore.Count() && eid<10; ++eid) { if (eid == (uint32)m_curScore) fc.cmpProps.faceColor = RGB16(255,192,128); else fc.cmpProps.faceColor = RGB16(192,192,192); gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d."),eid+1), iRect(rc.x, rc.y, 30, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, m_hScore.Entry(eid).land, iRect(rc.x+30, rc.y, 120, 15),AlignTopLeft); gTextComposer.TextOut(fc, gApp.Surface(),rc, FormatDate(m_hScore.Entry(eid).date, false), iRect(rc.x+30+120, rc.y, 50, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d"),m_hScore.Entry(eid).days), iRect(rc.x+30+120+50, rc.y, 40, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d"),m_hScore.Entry(eid).score), iRect(rc.x+30+120+50+40, rc.y, 40, 15),AlignTop); rc.y += 14; } fc.cmpProps.faceColor = RGB16(192,192,192); for (; eid<10; ++eid) { gTextComposer.TextOut(fc, gApp.Surface(),rc, iFormat(_T("%d."),eid+1), iRect(rc.x, rc.y, 30, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30, rc.y, 120, 15),AlignTopLeft); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30+120, rc.y, 50, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30+120+50, rc.y, 40, 15),AlignTop); gTextComposer.TextOut(fc, gApp.Surface(),rc, _T("-"), iRect(rc.x+30+120+50+40, rc.y, 40, 15),AlignTop); rc.y += 14; } }
Date::Date(OBJECTID id, BOOL bIsTemp):m_attributes(!bIsTemp) //If temp object, then don't do createStuff in attributes { DATE systemDate; DOS_DATE dosDate; m_version = VERSION; m_oiSelf = id; m_style = DT_DATEDEFAULT; SetTempObject(bIsTemp); if (!bIsTemp) { getdate(&dosDate); systemDate.da_year = dosDate.da_year; systemDate.da_mon = dosDate.da_mon; systemDate.da_day = dosDate.da_day; m_date = DateToJulian(systemDate); FormatDate(); } }
int lib_locale_f_FormatDate_2(emumsg_syscall_t *msg) { /* Switch to callback vector. Any callbacks will reply to the msg and it will call stage 3 of the callback instead of stage 3 of this call. */ msg->func = -10; /* Make real syscall */ FormatDate( (struct Locale *)msg->arg[0]._aptr, msg->arg[1]._strptr, (struct DateStamp *)msg->arg[2]._aptr, (struct Hook *)msg->arg[3]._aptr ); /* Switch to normal vector. All callbacks are done and now we want to go to stage 3 of this function. */ msg->func = 10; return HOOK_DONE; }
BOOL Date::LocalSetDateValue(long julian, BOOL bPostSignals)//Returns TRUE if the value changed { BOOL rVal = FALSE; // const long maxJulian = (long)((30000*146097+1)/4) - 578041L; const long maxJulian = 11383592L; const long minJulian = -578041L; // check the julian date is in the range of 19th century if (julian <= maxJulian && julian >= minJulian) { if (m_date != julian) { m_date = julian; SetHasChanged(TRUE); FormatDate(); rVal = TRUE; if (bPostSignals) PostChangedSignals(); } } return rVal; }
bool PutMetadata(Output_t *ds_output, int nband, Input_meta_t *meta, Param_t *param, Lut_t *lut, Geo_bounds_t* bounds) /* !C****************************************************************************** !Description: 'PutMetadata' writes metadata to the output file. !Input Parameters: ds_output 'output' data structure; the following fields are input: open geoloc 'geoloc' data structure; the following fields are input: (none) input 'input' data structure; the following fields are input: (none) !Output Parameters: ds_output 'output' data structure; the following fields are modified: (none) (returns) status: 'true' = okay 'false' = error return !Team Unique Header: ! Design Notes: 1. ds_output routine is currently a 'stub' and will be implemented later. 2. An error status is returned when: a. the file is not open for access. 3. Error messages are handled with the 'RETURN_ERROR' macro. 4. 'OutputFile' must be called before ds_output routine is called. !END**************************************************************************** */ { Myhdf_attr_t attr; char date[MAX_DATE_LEN + 1]; /*double dval[1]; */ double dval[NBAND_REFL_MAX]; char *string , short_name[250] , local_granule_id[250] , production_date[MAX_DATE_LEN + 1] , pge_ver[100] , process_ver[100] , long_name[250] ; int ib; const char *qa_band_names[NUM_QA_BAND] = {"fill_QA", "DDV_QA", "cloud_QA", "cloud_shadow_QA", "snow_QA", "land_water_QA", "adjacent_cloud_QA"}; char *QA_on[NBAND_SR_EXTRA] = {"N/A", "fill", "dark dense vegetation", "cloud", "cloud shadow", "snow", "water", "adjacent cloud", "N/A", "N/A", "N/A"}; char *QA_off[NBAND_SR_EXTRA] = {"N/A", "not fill", "clear", "clear", "clear", "clear", "land", "clear", "N/A", "N/A", "N/A"}; char* units_b; char* message; char lndsr_QAMAP[1000]; /* Check the parameters */ if (!ds_output->open) RETURN_ERROR("file not open", "PutMetadata", false); if (nband < 1 || nband > NBAND_REFL_MAX) RETURN_ERROR("invalid number of bands", "PutMetadata", false); /* Write the metadata */ attr.id = -1; if (meta->provider != PROVIDER_NULL) { string = Provider_string[meta->provider].string; attr.type = DFNT_CHAR8; attr.nval = strlen(string); attr.name = OUTPUT_PROVIDER; if (!PutAttrString(ds_output->sds_file_id, &attr, string)) RETURN_ERROR("writing attribute (data provider)", "PutMetadata", false); } if (meta->sat != SAT_NULL) { string = Sat_string[meta->sat].string; attr.type = DFNT_CHAR8; attr.nval = strlen(string); attr.name = OUTPUT_SAT; if (!PutAttrString(ds_output->sds_file_id, &attr, string)) RETURN_ERROR("writing attribute (satellite)", "PutMetadata", false); } if (meta->inst != INST_NULL) { string = Inst_string[meta->inst].string; attr.type = DFNT_CHAR8; attr.nval = strlen(string); attr.name = OUTPUT_INST; if (!PutAttrString(ds_output->sds_file_id, &attr, string)) RETURN_ERROR("writing attribute (instrument)", "PutMetadata", false); } if (!FormatDate(&meta->acq_date, DATE_FORMAT_DATEA_TIME, date)) RETURN_ERROR("formating acquisition date", "PutMetadata", false); attr.type = DFNT_CHAR8; attr.nval = strlen(date); attr.name = OUTPUT_ACQ_DATE; if (!PutAttrString(ds_output->sds_file_id, &attr, date)) RETURN_ERROR("writing attribute (acquisition date)", "PutMetadata", false); if (!FormatDate(&meta->prod_date, DATE_FORMAT_DATEA_TIME, date)) RETURN_ERROR("formating production date", "PutMetadata", false); attr.type = DFNT_CHAR8; attr.nval = strlen(date); attr.name = OUTPUT_L1_PROD_DATE; if (!PutAttrString(ds_output->sds_file_id, &attr, date)) RETURN_ERROR("writing attribute (production date)", "PutMetadata", false); attr.type = DFNT_FLOAT32; attr.nval = 1; attr.name = OUTPUT_SUN_ZEN; dval[0] = (double)meta->sun_zen * DEG; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (solar zenith)", "PutMetadata", false); attr.type = DFNT_FLOAT32; attr.nval = 1; attr.name = OUTPUT_SUN_AZ; dval[0] = (double)meta->sun_az * DEG; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (solar azimuth)", "PutMetadata", false); if (meta->wrs_sys != WRS_NULL) { string = Wrs_string[meta->wrs_sys].string; attr.type = DFNT_CHAR8; attr.nval = strlen(string); attr.name = OUTPUT_WRS_SYS; if (!PutAttrString(ds_output->sds_file_id, &attr, string)) RETURN_ERROR("writing attribute (WRS system)", "PutMetadata", false); attr.type = DFNT_INT16; attr.nval = 1; attr.name = OUTPUT_WRS_PATH; dval[0] = (double)meta->ipath; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (WRS path)", "PutMetadata", false); attr.type = DFNT_INT16; attr.nval = 1; attr.name = OUTPUT_WRS_ROW; dval[0] = (double)meta->irow; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (WRS row)", "PutMetadata", false); } attr.type = DFNT_INT8; attr.nval = 1; attr.name = OUTPUT_NBAND; dval[0] = (double)nband; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (number of bands)", "PutMetadata", false); attr.type = DFNT_INT8; attr.nval = nband; attr.name = OUTPUT_BANDS; for (ib = 0; ib < nband; ib++) dval[ib] = (double)meta->iband[ib]; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (band numbers)", "PutMetadata", false); /* Get the short name, local granule id and production date/time */ if (!Names(meta->sat, meta->inst, "SR", &meta->acq_date, meta->wrs_sys, meta->ipath, meta->irow, short_name, local_granule_id, production_date)) RETURN_ERROR("creating the short name and local granule id", "PutMetadata", false); attr.type = DFNT_CHAR8; attr.nval = strlen(short_name); attr.name = OUTPUT_SHORT_NAME; if (!PutAttrString(ds_output->sds_file_id, &attr, short_name)) RETURN_ERROR("writing attribute (short name)", "PutMetadata", false); attr.type = DFNT_CHAR8; attr.nval = strlen(local_granule_id); attr.name = OUTPUT_LOCAL_GRAN_ID; if (!PutAttrString(ds_output->sds_file_id, &attr, local_granule_id)) RETURN_ERROR("writing attribute (local granule id)", "PutMetadata", false); attr.type = DFNT_CHAR8; attr.nval = strlen(production_date); attr.name = OUTPUT_PROD_DATE; if (!PutAttrString(ds_output->sds_file_id, &attr, production_date)) RETURN_ERROR("writing attribute (production date)", "PutMetadata", false); if (sprintf(pge_ver, "%s", param->PGEVersion) < 0) RETURN_ERROR("creating PGEVersion","PutMetadata", false); attr.type = DFNT_CHAR8; attr.nval = strlen(pge_ver); attr.name = OUTPUT_PGEVERSION; if (!PutAttrString(ds_output->sds_file_id, &attr, pge_ver)) RETURN_ERROR("writing attribute (PGE Version)", "PutMetadata", false); if (sprintf(process_ver, "%s", param->ProcessVersion) < 0) RETURN_ERROR("creating ProcessVersion","PutMetadata", false); attr.type = DFNT_CHAR8; attr.nval = strlen(process_ver); attr.name = OUTPUT_PROCESSVERSION; if (!PutAttrString(ds_output->sds_file_id, &attr, process_ver)) RETURN_ERROR("writing attribute (Process Version)", "PutMetadata", false); attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_WEST_BOUND; dval[0] = bounds->min_lon * DEG; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (West Bounding Coords)", "PutMetadata", false); attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_EAST_BOUND; dval[0] = bounds->max_lon * DEG; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (East Bounding Coords)", "PutMetadata", false); attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_NORTH_BOUND; dval[0] = bounds->max_lat * DEG; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (North Bounding Coords)", "PutMetadata", false); attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_SOUTH_BOUND; dval[0] = bounds->min_lat * DEG; if (!PutAttrDouble(ds_output->sds_file_id, &attr, dval)) RETURN_ERROR("writing attribute (South Bounding Coords)", "PutMetadata", false); /* now write out the per sds attributes */ /*for (ib = 0; ib < NBAND_REFL_MAX; ib++) { */ /* for (ib = 0; ib < NBAND_SR_MAX; ib++) { EV 9/7/2009 */ for (ib = 0; ib < NBAND_SR_MAX-3; ib++) { //printf ("DEBUG: SDS metadata for band %d\n", ib); sprintf(long_name, lut->long_name_prefix, meta->iband[ib]); if (ib >= NBAND_REFL_MAX){sprintf(long_name,"%s", DupString(qa_band_names[ib - NBAND_REFL_MAX])); } //printf ("DEBUG: long name: %s\n", long_name); attr.type = DFNT_CHAR8; attr.nval = strlen(long_name); attr.name = OUTPUT_LONG_NAME; if (!PutAttrString(ds_output->sds_sr[ib].id, &attr, long_name)) RETURN_ERROR("writing attribute (long name)", "PutMetadata", false); attr.type = DFNT_CHAR8; if (ib <= nband) { /* reflective bands and atmos_opacity */ attr.nval = strlen(lut->units); attr.name = OUTPUT_UNITS; if (!PutAttrString(ds_output->sds_sr[ib].id, &attr, lut->units)) RETURN_ERROR("writing attribute (units ref)", "PutMetadata", false); } else { /* QA bands */ units_b=DupString("quality/feature classification"); attr.nval = strlen(units_b); attr.name = OUTPUT_UNITS; if (!PutAttrString(ds_output->sds_sr[ib].id, &attr, units_b)) RETURN_ERROR("writing attribute (units ref)", "PutMetadata", false); } attr.type = DFNT_INT16; attr.nval = 2; attr.name = OUTPUT_VALID_RANGE; dval[0] = (double)lut->min_valid_sr; dval[1] = (double)lut->max_valid_sr; if(ib >= nband+FILL && ib <= nband+ADJ_CLOUD) { /* QA bands */ dval[0] = (double)(0); dval[1] = (double)(255); } if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (valid range ref)","PutMetadata",false); if (ib <= nband) { /* reflective bands and atmos_opacity */ attr.type = DFNT_INT16; attr.nval = 1; attr.name = OUTPUT_FILL_VALUE; dval[0] = (double)lut->output_fill; if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (valid range ref)","PutMetadata",false); attr.type = DFNT_INT16; attr.nval = 1; attr.name = OUTPUT_SATU_VALUE; dval[0] = (double)lut->out_satu; if (ib != nband+ATMOS_OPACITY) /* doesn't apply for atmos opacity */ if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (saturate value ref)","PutMetadata",false); attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_SCALE_FACTOR; dval[0] = (double)lut->scale_factor; if (ib == nband+ATMOS_OPACITY) dval[0] = (double) 0.001; if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (scale factor ref)", "PutMetadata", false); if (ib != nband+ATMOS_OPACITY) { /* don't apply for atmos opacity */ attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_ADD_OFFSET; dval[0] = (double)lut->add_offset; if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (add offset ref)", "PutMetadata", false); attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_SCALE_FACTOR_ERR; dval[0] = (double)lut->scale_factor_err; if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (scale factor err ref)", "PutMetadata", false); attr.type = DFNT_FLOAT64; attr.nval = 1; attr.name = OUTPUT_ADD_OFFSET_ERR; dval[0] = (double)lut->add_offset_err; if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (add offset err ref)", "PutMetadata", false); attr.type = DFNT_FLOAT32; attr.nval = 1; attr.name = OUTPUT_CALIBRATED_NT; dval[0] = (double)lut->calibrated_nt; if (!PutAttrDouble(ds_output->sds_sr[ib].id, &attr, dval)) RETURN_ERROR("writing attribute (calibrated nt ref)","PutMetadata",false); } /* end if not atmos opacity */ } /* end if no QA bands */ if (ib >= nband+FILL && ib <= nband+ADJ_CLOUD) { //printf ("DEBUG: Writing lndsr_QAMAP for band %d\n", ib); attr.type = DFNT_CHAR8; sprintf (lndsr_QAMAP, "\n\tQA pixel values are either off or on:\n" "\tValue Description\n" "\t0\t%s\n" "\t255\t%s", QA_off[ib-nband], QA_on[ib-nband]); message=DupString(lndsr_QAMAP); //printf ("DEBUG: %s\n", lndsr_QAMAP); attr.nval = strlen(message); attr.name = "QA index"; if (!PutAttrString(ds_output->sds_sr[ib].id, &attr, message)) RETURN_ERROR("writing attribute (QA index)", "PutMetadata", false); } } /* end for ib */ return true; }
void ChatTab::AppendMessage (Plugins::IMessage *msg) { Plugins::ICLEntry *other = qobject_cast<Plugins::ICLEntry*> (msg->OtherPart ()); if (!other && msg->OtherPart ()) { qWarning () << Q_FUNC_INFO << "message's other part doesn't implement ICLEntry" << msg->GetObject () << msg->OtherPart (); return; } if (msg->GetDirection () == Plugins::IMessage::DOut && other->GetEntryType () == Plugins::ICLEntry::ETMUC) return; QWebFrame *frame = Ui_.View_->page ()->mainFrame (); bool shouldScrollFurther = (frame->scrollBarMaximum (Qt::Vertical) == frame->scrollBarValue (Qt::Vertical)); QString body = FormatBody (msg->GetBody (), msg); QString string = QString ("%1 ") .arg (FormatDate (msg->GetDateTime (), msg)); string.append (' '); switch (msg->GetDirection ()) { case Plugins::IMessage::DIn: { switch (msg->GetMessageType ()) { case Plugins::IMessage::MTChatMessage: case Plugins::IMessage::MTMUCMessage: { QString entryName = Qt::escape (other->GetEntryName ()); entryName = FormatNickname (entryName, msg); if (body.startsWith ("/me ")) { body = body.mid (3); string.append ("*** "); string.append (entryName); string.append (' '); } else { string.append (entryName); string.append (": "); } break; } case Plugins::IMessage::MTEventMessage: string.append ("! "); break; } break; } case Plugins::IMessage::DOut: string.append (FormatNickname ("R", msg)); string.append (": "); break; } string.append (body); QWebElement elem = frame->findFirstElement ("body"); elem.appendInside (QString ("<div>%1</div").arg (string)); if (shouldScrollFurther) QTimer::singleShot (100, this, SLOT (scrollToEnd ())); }
void EkstraktorMainWindow::SetLastDatabaseDate(time_t newest) { lastDatabaseText->SetLabel( wxString(LAST_DATE_STR) + FormatDate(newest)); }
void EkstraktorMainWindow::SetFirstDatabaseDate(time_t oldest) { firstDatabaseText->SetLabel( wxString(FIRST_DATE_STR) + FormatDate(oldest) ); }
void EkstraktorMainWindow::SetStopDate(time_t stop_time) { stopDateText->SetLabel( wxString(STOP_DATE_STR) + FormatDate(stop_time) ); }
int create_6S_tables(sixs_tables_t *sixs_tables, Input_meta_t *meta) { char cmd[128],sixs_cmd_filename[1024],sixs_out_filename[1024],line_in[256]; /* char tmp_file[1024], cmd_string[1024]; */ int i,j,k; FILE *fd; float tgoz,tgco2,tgo2,tgno2,tgch4,tgco; int tm_band[SIXS_NB_BANDS]={25,26,27,28,29,30}; char short_name[1024]; char local_granule_id[1024]; char acq_date_string[MAX_DATE_LEN + 1]; const char *sat_names[SAT_MAX] = {"1", "2", "3", "4", "5", "7"}; const char *inst_names[INST_MAX] = {"M", "T", "E"}; const char *wrs_names[WRS_MAX] = {"1", "2"}; struct etm_spectral_function_t etm_spectral_function = { {54,61,65,81,131,155}, {0.420,0.500,0.580,0.730,1.501,2.0}, {0.550,0.650,0.740,0.930,1.825,2.386}, { {0.000,0.000,0.000,0.000,0.000,0.000,0.016,0.071,0.287,0.666,0.792,0.857,0.839,0.806,0.779,0.846,0.901,0.900,0.890,0.851,0.875,0.893,0.884,0.930,0.958,0.954,0.980,0.975,0.965,0.962,0.995,0.990,0.990,0.979,0.983,0.969,0.960,0.768,0.293,0.054,0.009,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000}, {0.001,0.002,0.003,0.012,0.026,0.074,0.174,0.348,0.552,0.696,0.759,0.785,0.822,0.870,0.905,0.929,0.947,0.952,0.952,0.951,0.953,0.950,0.954,0.967,0.959,0.941,0.933,0.938,0.951,0.956,0.955,0.956,0.973,0.992,1.000,0.976,0.942,0.930,0.912,0.799,0.574,0.340,0.185,0.105,0.062,0.038,0.021,0.011,0.005,0.002,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000}, {0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.001,0.002,0.010,0.047,0.174,0.419,0.731,0.921,0.942,0.937,0.937,0.949,0.965,0.973,0.970,0.958,0.955,0.962,0.980,0.993,0.998,1.000,0.995,0.992,0.988,0.977,0.954,0.932,0.880,0.729,0.444,0.183,0.066,0.025,0.012,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000}, {0.000,0.000,0.000,0.000,0.000,0.002,0.004,0.002,0.001,0.020,0.032,0.052,0.069,0.110,0.175,0.271,0.402,0.556,0.705,0.812,0.871,0.896,0.908,0.918,0.926,0.928,0.930,0.926,0.925,0.928,0.923,0.916,0.908,0.903,0.909,0.924,0.946,0.954,0.971,0.969,0.967,0.965,0.967,0.961,0.949,0.931,0.925,0.929,0.943,0.961,0.985,0.992,0.998,0.992,0.994,0.997,0.998,1.000,0.991,0.988,0.969,0.926,0.868,0.817,0.819,0.880,0.854,0.572,0.256,0.104,0.044,0.022,0.011,0.007,0.000,0.000,0.000,0.000,0.000,0.000,0.000}, {0.000,0.003,0.000,0.001,0.007,0.008,0.008,0.012,0.012,0.028,0.041,0.062,0.087,0.114,0.176,0.230,0.306,0.410,0.481,0.543,0.598,0.642,0.686,0.719,0.750,0.785,0.817,0.845,0.867,0.881,0.902,0.900,0.896,0.892,0.899,0.882,0.872,0.872,0.872,0.878,0.868,0.860,0.877,0.884,0.897,0.895,0.898,0.912,0.921,0.927,0.937,0.947,0.948,0.954,0.961,0.962,0.962,0.964,0.969,0.956,0.952,0.951,0.952,0.953,0.939,0.934,0.928,0.943,0.945,0.935,0.944,0.947,0.944,0.949,0.960,0.966,0.971,0.978,0.993,0.998,0.996,0.996,0.997,0.986,0.990,0.988,0.992,0.985,0.982,0.978,0.970,0.966,0.952,0.927,0.883,0.832,0.751,0.656,0.577,0.483,0.393,0.310,0.239,0.184,0.142,0.104,0.080,0.063,0.049,0.041,0.036,0.023,0.021,0.019,0.012,0.006,0.008,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000}, {0.004,0.001,0.003,0.000,0.002,0.001,0.002,0.002,0.012,0.008,0.009,0.018,0.017,0.031,0.037,0.046,0.058,0.076,0.088,0.110,0.149,0.196,0.242,0.303,0.367,0.437,0.519,0.610,0.677,0.718,0.756,0.774,0.784,0.775,0.789,0.782,0.778,0.766,0.762,0.768,0.775,0.769,0.788,0.808,0.794,0.823,0.811,0.819,0.836,0.837,0.836,0.851,0.859,0.855,0.871,0.873,0.875,0.859,0.872,0.859,0.872,0.863,0.865,0.868,0.877,0.873,0.869,0.876,0.868,0.879,0.873,0.876,0.880,0.874,0.870,0.858,0.863,0.859,0.844,0.859,0.854,0.863,0.868,0.856,0.847,0.861,0.851,0.852,0.838,0.847,0.840,0.831,0.836,0.838,0.822,0.838,0.839,0.842,0.854,0.862,0.873,0.868,0.879,0.891,0.898,0.919,0.920,0.926,0.928,0.934,0.936,0.953,0.954,0.952,0.960,0.973,0.985,0.972,0.970,0.994,0.989,0.975,1.000,0.991,0.968,0.966,0.956,0.929,0.929,0.926,0.903,0.924,0.929,0.928,0.920,0.853,0.775,0.659,0.531,0.403,0.275,0.218,0.131,0.104,0.075,0.052,0.029,0.028,0.014,0.019,0.013,0.007,0.015,0.000,0.004} } }; sixs_tables->aot[0]=0.01; sixs_tables->aot[1]=0.05; sixs_tables->aot[2]=0.10; sixs_tables->aot[3]=0.15; sixs_tables->aot[4]=0.20; sixs_tables->aot[5]=0.30; sixs_tables->aot[6]=0.40; sixs_tables->aot[7]=0.60; sixs_tables->aot[8]=0.80; sixs_tables->aot[9]=1.00; sixs_tables->aot[10]=1.20; sixs_tables->aot[11]=1.40; sixs_tables->aot[12]=1.60; sixs_tables->aot[13]=1.80; sixs_tables->aot[14]=2.00; /* Determine the 6s command and output filenames */ if (sprintf(short_name, "L%s%s%s", sat_names[meta->sat], inst_names[meta->inst], "SR") < 0) { fprintf(stderr, "ERROR:creating short name\n"); exit(-1); } if (!FormatDate(&meta->acq_date, DATE_FORMAT_DATEB, acq_date_string)) { fprintf(stderr, "ERROR:formatting acquisition date\n"); exit(-1); } acq_date_string[4] = '\0'; sprintf(local_granule_id, "%s.a%4s%3s.w%1sp%03dr%03d", short_name, acq_date_string, &acq_date_string[5], wrs_names[meta->wrs_sys], meta->ipath, meta->irow); sprintf (sixs_cmd_filename, "sixs_cmd_%s", local_granule_id); sprintf (sixs_out_filename, "sixs_output_%s", local_granule_id); /* Run 6s */ for (i=0;i<SIXS_NB_BANDS;i++) { for (j=0;j<SIXS_NB_AOT;j++) { printf("Processing 6s for band %d AOT %2d\r",i+1,j+1); fflush(stdout); if ((fd=fopen(sixs_cmd_filename,"w"))==NULL) { fprintf(stderr,"ERROR: creating temporary file %s\n",sixs_cmd_filename); exit(-1); } fprintf(fd,"%s <<+ >%s\n",get_sixs_path(),sixs_out_filename); fprintf(fd,"0 (user defined)\n"); fprintf(fd,"%.2f %.2f %.2f %.2f %d %d (geometrical conditions sza saz vza vaz month day)\n",sixs_tables->sza,sixs_tables->phi,sixs_tables->vza,0.,sixs_tables->month,sixs_tables->day); fprintf(fd,"8 (option for water vapor and ozone)\n"); fprintf(fd,"%.2f %.2f (water vapor and ozone)\n",sixs_tables->uwv,sixs_tables->uoz); fprintf(fd,"1 (continental model)\n"); fprintf(fd,"0 (option for optical thickness at 550 nm)\n"); fprintf(fd,"%.3f (value of aot550\n",sixs_tables->aot[j]); fprintf(fd,"%f (target level)\n",sixs_tables->target_alt); fprintf(fd,"-1000 (sensor level : -1000=satellite level)\n"); switch (sixs_tables->Inst) { case SIXS_INST_TM: fprintf(fd,"%d (predefined band)\n",tm_band[i]); break; case SIXS_INST_ETM: fprintf(fd,"1 (user defined filter function)\n"); fprintf(fd,"%05.3f %05.3f (wlinf wlsup)\n",etm_spectral_function.wlinf[i],etm_spectral_function.wlsup[i]); for (k=0;k<etm_spectral_function.nbvals[i];k++) { fprintf(fd,"%05.3f ",etm_spectral_function.response[i][k]); if (!((k+1)%10)) fprintf(fd,"\n"); } if (k%10) fprintf(fd,"\n"); break; default: fprintf(stderr,"ERROR: Unknown Instrument in six_run parameters\n"); exit(-1); } fprintf(fd,"0 (homogeneous surface)\n"); fprintf(fd,"0 (no directional effects)\n"); fprintf(fd,"0 (constant value for rho)\n"); fprintf(fd,"%.3f (value of rho)\n",sixs_tables->srefl); fprintf(fd,"-1 (no atmospheric correction)\n"); fprintf(fd,"0\n"); fprintf(fd,"+\n"); fclose(fd); /* Modified 9/26/2014 to run bash shell vs. sh */ sprintf(cmd,"bash %s",sixs_cmd_filename); if (system(cmd)) { fprintf(stderr,"ERROR: Can't run 6S \n"); exit(-1); } if ((fd=fopen(sixs_out_filename,"r"))==NULL) { fprintf(stderr,"ERROR: reading temporary file %s\n",sixs_out_filename); exit(-1); } while (fgets(line_in,256,fd)) { line_in[strlen(line_in)-1]='\0'; if (j==0) { if (!strncmp(line_in,"* rayl. sca. trans. :",27)) { k=27; while (line_in[k]==' ') k++; sscanf(&line_in[k],"%f",&sixs_tables->T_r_down[i]); while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->T_r_up[i]); while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->T_r[i]); } if (!strncmp(line_in,"* water \" \" :",27)) { k=27; while (line_in[k]==' ') k++; while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->T_g_wv[i]); } if (!strncmp(line_in,"* ozone \" \" :",27)) { k=27; while (line_in[k]==' ') k++; while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&tgoz); } if (!strncmp(line_in,"* co2 \" \" :",27)) { k=27; while (line_in[k]==' ') k++; while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&tgco2); } if (!strncmp(line_in,"* oxyg \" \" :",27)) { k=27; while (line_in[k]==' ') k++; while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&tgo2); } if (!strncmp(line_in,"* no2 \" \" :",27)) { k=27; while (line_in[k]==' ') k++; while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&tgno2); } if (!strncmp(line_in,"* ch4 \" \" :",27)) { k=27; while (line_in[k]==' ') k++; while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&tgch4); } if (!strncmp(line_in,"* co \" \" :",27)) { k=27; while (line_in[k]==' ') k++; while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&tgco); } sixs_tables->T_g_og[i]=tgoz*tgco2*tgo2*tgno2*tgno2*tgch4*tgco; } if (!strncmp(line_in,"* spherical albedo :",27)) { k=27; while (line_in[k]==' ') /* blank */ k++; if (j==0) sscanf(&line_in[k],"%f",&sixs_tables->S_r[i]); while (line_in[k]!=' ') /* Rayleigh */ k++; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* Aerosol */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->S_ra[i][j]); } if (!strncmp(line_in,"* optical depth total:",27)) { k=27; while (line_in[k]==' ') /* blank */ k++; while (line_in[k]!=' ') /* Rayleigh */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->aot_wavelength[i][j]); } if (!strncmp(line_in,"* aeros. sca. \" :",27)) { k=27; while (line_in[k]==' ') k++; sscanf(&line_in[k],"%f",&sixs_tables->T_a_down[i][j]); while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->T_a_up[i][j]); while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->T_a[i][j]); } if (!strncmp(line_in,"* total sca. \" :",27)) { k=27; while (line_in[k]==' ') k++; sscanf(&line_in[k],"%f",&sixs_tables->T_ra_down[i][j]); while (line_in[k]!=' ') /* downward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->T_ra_up[i][j]); while (line_in[k]!=' ') /* upward */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->T_ra[i][j]); } if (!strncmp(line_in,"* reflectance I :",27)) { k=27; while (line_in[k]==' ') /* blank */ k++; if (j==0) sscanf(&line_in[k],"%f",&sixs_tables->rho_r[i]); while (line_in[k]!=' ') /* rayleigh */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->rho_a[i][j]); while (line_in[k]!=' ') /* aerosols */ k++; while (line_in[k]==' ') /* blank */ k++; sscanf(&line_in[k],"%f",&sixs_tables->rho_ra[i][j]); } } fclose(fd); /* For OZONE debugging: sprintf (tmp_file, "%s_b%d_aot%02d", sixs_cmd_filename, i, j); sprintf (cmd_string, "cp %s %s", sixs_cmd_filename, tmp_file); system (cmd_string); sprintf (tmp_file, "%s_b%d_aot%02d", sixs_out_filename, i, j); sprintf (cmd_string, "cp %s %s", sixs_out_filename, tmp_file); system (cmd_string); */ } /* for j */ } /* for i */ printf ("\n"); unlink(sixs_cmd_filename); unlink(sixs_out_filename); return 0; }
// /////////////////////////////////////////////////////////////////////////// // CString FormatDate( const COleDateTime& dt ) { return FormatDate(dt.GetYear(), dt.GetMonth(), dt.GetDay()); }
void DebugPrint(char * report, char * file, int line, int type) { printf("%s %s %d %s %s\n", FormatDate(0), file, line, GetTypeStr(type), report); }
static int _fastcall _list( LPTSTR pszFileName ) { register int c, i; TCHAR szDescription[512], szHeader[132], szLine[32]; long lTemp, lRow; POPWINDOWPTR wn = NULL; FILESEARCH dir; // get default normal and inverse attributes if ( gpIniptr->ListColor != 0 ) { SetScrColor( nScreenRows, nScreenColumns, gpIniptr->ListColor ); } // set colors GetAtt( (unsigned int *)&nNormal, (unsigned int *)&nInverse ); if ( gpIniptr->ListStatusColor != 0 ) nInverse = gpIniptr->ListStatusColor; // flip the first line to inverse video clear_header(); // open the file & initialize buffers if ( ListOpenFile( pszFileName )) return ERROR_EXIT; // kludge for empty files or pipes if ( LFile.lSize == 0L ) LFile.lSize = 1L; for ( ; ; ) { // display header if ( fDirtyHeader ) { clear_header(); sprintf( szHeader, LIST_HEADER, fname_part(LFile.szName), gchVerticalBar, gchVerticalBar, gchVerticalBar ); WriteStrAtt( 0, 0, nInverse, szHeader ); fDirtyHeader = 0; } // display location within file // (don't use color_printf() so we won't have // problems with windowed sessions) i = sprintf( szHeader, LIST_LINE, LFile.nListHorizOffset, LFile.lCurrentLine + gpIniptr->ListRowStart, (int)((( LFile.lViewPtr + 1 ) * 100 ) / LFile.lSize )); WriteStrAtt( 0, ( nScreenColumns - i ), nInverse, szHeader ); SetCurPos( 0, 0 ); if ( lListFlags & LIST_SEARCH ) { lListFlags &= ~LIST_SEARCH; fSearchFlags = 0; if ( lListFlags & LIST_REVERSE ) { c = LIST_FIND_CHAR_REVERSE; fSearchFlags |= FFIND_REVERSE_SEARCH; // goto the last row while ( ListMoveLine( 1 ) != 0 ) ; } else c = LIST_FIND_CHAR; if ( lListFlags & LIST_NOWILDCARDS ) fSearchFlags |= FFIND_NOWILDCARDS; bListSkipLine = 0; goto FindNext; } // get the key from the BIOS, because // STDIN might be redirected if ((( c = cvtkey( GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT), MAP_GEN | MAP_LIST)) == (TCHAR)ESC )) break; switch ( c ) { case CTRLC: return CTRLC; case CUR_LEFT: case CTL_LEFT: if (( lListFlags & LIST_WRAP ) || ( LFile.nListHorizOffset == 0 )) goto bad_key; if (( LFile.nListHorizOffset -= (( c == CUR_LEFT ) ? 8 : 40 )) < 0 ) LFile.nListHorizOffset = 0; break; case CUR_RIGHT: case CTL_RIGHT: if (( lListFlags & LIST_WRAP ) || ( LFile.nListHorizOffset >= MAXLISTLINE + 1 )) goto bad_key; if ((LFile.nListHorizOffset += ((c == CUR_RIGHT) ? 8 : 40 )) > MAXLISTLINE + 1 ) LFile.nListHorizOffset = MAXLISTLINE+1; break; case CUR_UP: if ( ListMoveLine( -1 ) == 0 ) goto bad_key; Scroll(1, 0, nScreenRows, nScreenColumns, -1, nNormal); DisplayLine( 1, LFile.lViewPtr ); continue; case CUR_DOWN: if ( ListMoveLine( 1 ) == 0 ) goto bad_key; Scroll( 1, 0, nScreenRows, nScreenColumns, 1, nNormal ); // display last line lTemp = LFile.lViewPtr; lRow = (nScreenRows - 1); lTemp += MoveViewPtr( lTemp, &lRow ); if ( lRow == ( nScreenRows - 1 )) DisplayLine( nScreenRows, lTemp ); continue; case HOME: ListHome(); break; case END: // goto the last row list_wait( LIST_WAIT ); while ( ListMoveLine( 1 ) != 0 ) ; case PgUp: // already at TOF? if ( LFile.lViewPtr == 0L ) goto bad_key; for ( i = 1; (( i < nScreenRows ) && ( ListMoveLine( -1 ) != 0 )); i++ ) ; break; case PgDn: case SPACE: if ( ListMoveLine( nScreenRows - 1 ) == 0 ) goto bad_key; break; case F1: // help // don't allow a ^X exit from HELP _help( gpInternalName, HELP_NX ); continue; case TAB: // change tab size // disable ^C / ^BREAK handling HoldSignals(); wn = wOpen( 2, 5, 4, strlen( LIST_TABSIZE ) + 10, nInverse, LIST_TABSIZE_TITLE, NULL ); wn->nAttrib = nNormal; wClear(); wWriteListStr( 0, 1, wn, LIST_TABSIZE ); egets( szLine, 2, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF | EDIT_DIGITS)); wRemove( wn ); if (( i = atoi( szLine )) > 0 ) TABSIZE = i; // enable ^C / ^BREAK handling EnableSignals(); break; case DEL: // delete this file if (( lListFlags & LIST_STDIN ) == 0 ) { // disable ^C / ^BREAK handling HoldSignals(); wn = wOpen( 2, 5, 4, strlen( LIST_DELETE ) + 10, nInverse, LIST_DELETE_TITLE, NULL ); wn->nAttrib = nNormal; wClear(); wWriteListStr( 0, 1, wn, LIST_DELETE ); i = GetKeystroke( EDIT_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT ); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); if ( i == (TCHAR)YES_CHAR ) { if ( LFile.hHandle > 0 ) _close( LFile.hHandle ); LFile.hHandle = -1; remove( pszFileName ); return 0; } } break; case INS: // save to a file ListSaveFile(); break; case LIST_INFO_CHAR: { unsigned int uSize = 1024; TCHAR _far *lpszText, _far *lpszArg; int fFSType, fSFN = 1; TCHAR szBuf[16]; DOSFILEDATE laDir, crDir; // disable ^C / ^BREAK handling HoldSignals(); memset( &dir, '\0', sizeof(FILESEARCH) ); if (( lListFlags & LIST_STDIN ) == 0 ) { if ( find_file( FIND_FIRST, LFile.szName, 0x07 | FIND_CLOSE | FIND_EXACTLY, &dir, NULL ) == NULL ) { honk(); continue; } } // display info on the current file i = (( lListFlags & LIST_STDIN ) ? 5 : 10 ); if (( fFSType = ifs_type( LFile.szName )) != FAT ) i = 11; wn = wOpen( 2, 1, i, 77, nInverse, gpInternalName, NULL ); wn->nAttrib = nNormal; wClear(); i = 0; if ( lListFlags & LIST_STDIN ) wWriteStrAtt( 0, 1, nNormal, LIST_INFO_PIPE ); else { szDescription[0] = _TEXT('\0'); process_descriptions( LFile.szName, szDescription, DESCRIPTION_READ ); lpszText = lpszArg = (TCHAR _far *)AllocMem( &uSize ); strcpy(szBuf, FormatDate( dir.fd.file_date.months, dir.fd.file_date.days, dir.fd.file_date.years + 80, 0 )); if (fFSType != FAT) { FileTimeToDOSTime( &(dir.ftLastAccessTime), &( laDir.ft.wr_time), &( laDir.fd.wr_date) ); FileTimeToDOSTime( &(dir.ftCreationTime), &(crDir.ft.wr_time), &(crDir.fd.wr_date) ); strcpy( szLine, FormatDate( laDir.fd.file_date.months, laDir.fd.file_date.days, laDir.fd.file_date.years + 80, 0 )); sprintf_far( lpszText, LIST_INFO_LFN, LFile.szName, szDescription, dir.ulSize, szBuf, dir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0],dir.ft.file_time.minutes, szLine, laDir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0], laDir.ft.file_time.minutes, FormatDate( crDir.fd.file_date.months, crDir.fd.file_date.days, crDir.fd.file_date.years + 80, 0 ), crDir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0], crDir.ft.file_time.minutes); } else { sprintf_far( lpszText, LIST_INFO_FAT, LFile.szName, szDescription, dir.ulSize, szBuf, dir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0],dir.ft.file_time.minutes ); } // print the text for ( ; ( *lpszArg != _TEXT('\0') ); i++ ) { sscanf_far( lpszArg, _TEXT("%[^\n]%*c%n"), szHeader, &uSize ); // allow for long filenames ... if (( i == 0 ) && ( strlen( szHeader ) > 73 )) { c = szHeader[73]; szHeader[73] = _TEXT('\0'); wWriteStrAtt( i++, 1, nNormal, szHeader ); szHeader[73] = (TCHAR)c; wWriteStrAtt( i, 15, nNormal, szHeader+73 ); fSFN = 0; } else wWriteStrAtt( i, 1, nNormal, szHeader ); lpszArg += uSize; } FreeMem( lpszText ); } wWriteListStr( i+fSFN, 1, wn, PAUSE_PROMPT ); GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY ); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); continue; } case LIST_GOTO_CHAR: // goto the specified line / hex offset // disable ^C / ^BREAK handling HoldSignals(); wn = wOpen( 2, 5, 4, strlen( LIST_GOTO_OFFSET ) + 20, nInverse, LIST_GOTO_TITLE, NULL ); wn->nAttrib = nNormal; wClear(); wWriteListStr( 0, 1, wn, (( lListFlags & LIST_HEX) ? LIST_GOTO_OFFSET : LIST_GOTO)); i = egets( szLine, 10, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF)); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); if ( i == 0 ) break; list_wait( LIST_WAIT ); // if in hex mode, jump to offset if ( lListFlags & LIST_HEX ) { strupr( szLine ); sscanf( szLine, _TEXT("%lx"), &lRow ); lRow = lRow / 0x10; } else if ( sscanf( szLine, FMT_LONG, &lRow ) == 0 ) continue; lRow -= gpIniptr->ListRowStart; if ( lRow >= 0 ) { LFile.lViewPtr = MoveViewPtr( 0L, &lRow ); LFile.lCurrentLine = lRow; } else { LFile.lViewPtr += MoveViewPtr( LFile.lViewPtr, &lRow ); LFile.lCurrentLine += lRow; } break; case LIST_HIBIT_CHAR: // toggle high bit filter lListFlags ^= LIST_HIBIT; break; case LIST_WRAP_CHAR: // toggle line wrap lListFlags ^= LIST_WRAP; nRightMargin = (( lListFlags & LIST_WRAP ) ? GetScrCols() : MAXLISTLINE ); // recalculate current line list_wait( LIST_WAIT ); // get start of line LFile.nListHorizOffset = 0; // line number probably changed, so recompute everything LFile.lCurrentLine = ComputeLines( 0L, LFile.lViewPtr ); LFile.lViewPtr = MoveViewPtr( 0L, &(LFile.lCurrentLine )); break; case LIST_HEX_CHAR: // toggle hex display lListFlags ^= LIST_HEX; // if hex, reset to previous 16-byte // boundary if ( lListFlags & LIST_HEX ) { LFile.lViewPtr -= ( LFile.lViewPtr % 16 ); } else { // if not hex, reset to start of line ListMoveLine( 1 ); ListMoveLine( -1 ); } // recalculate current line list_wait( LIST_WAIT ); LFile.lCurrentLine = ComputeLines( 0L, LFile.lViewPtr ); break; case LIST_FIND_CHAR: case LIST_FIND_CHAR_REVERSE: // find first matching string bListSkipLine = 0; //lint -fallthrough case LIST_FIND_NEXT_CHAR: case LIST_FIND_NEXT_CHAR_REVERSE: // find next matching string if (( c == LIST_FIND_CHAR ) || ( c == LIST_FIND_CHAR_REVERSE )) { // disable ^C / ^BREAK handling HoldSignals(); fSearchFlags = 0; wn = wOpen( 2, 1, 4, 75, nInverse, (( c == LIST_FIND_NEXT_CHAR_REVERSE ) ? LIST_FIND_TITLE_REVERSE : LIST_FIND_TITLE ), NULL ); wn->nAttrib = nNormal; wClear(); if ( lListFlags & LIST_HEX ) { wWriteListStr( 0, 1, wn, LIST_FIND_HEX ); if ( GetKeystroke( EDIT_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT ) == YES_CHAR ) fSearchFlags |= FFIND_HEX_SEARCH; wClear(); } wWriteListStr( 0, 1, wn, LIST_FIND ); egets( szListFindWhat, 64, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF)); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); } else { FindNext: // a "Next" has to be from current position fSearchFlags &= ~FFIND_TOPSEARCH; } if ( szListFindWhat[0] == _TEXT('\0') ) continue; sprintf( szDescription, LIST_FIND_WAIT, szListFindWhat ); list_wait( szDescription ); // save start position lTemp = LFile.lViewPtr; lRow = LFile.lCurrentLine; if (( c == LIST_FIND_CHAR_REVERSE ) || ( c == LIST_FIND_NEXT_CHAR_REVERSE )) { // start on the previous line fSearchFlags |= FFIND_REVERSE_SEARCH; } else { fSearchFlags &= ~FFIND_REVERSE_SEARCH; // skip the first line (except on /T"xxx") if ( bListSkipLine ) ListMoveLine( 1 ); } bListSkipLine = 1; if ( SearchFile( fSearchFlags ) != 1 ) { ListSetCurrent( lTemp ); LFile.lViewPtr = lTemp; LFile.lCurrentLine = lRow; } else LFile.fDisplaySearch = (( fSearchFlags & FFIND_CHECK_CASE ) ? 2 : 1 ); break; case LIST_PRINT_CHAR: // print the file ListPrintFile(); continue; case LIST_CONTINUE_CHAR: case CTL_PgDn: return 0; case LIST_PREVIOUS_CHAR: case CTL_PgUp: // previous file if ( nCurrent > 0 ) { nCurrent--; return 0; } //lint -fallthrough default: bad_key: honk(); continue; } // rewrite the display ListUpdateScreen(); } return 0; }