PG_Label::TextAlign PG_Layout::GetParamAlign(const char **Source, const char *What) { PG_Label::TextAlign ret = PG_Label::LEFT; char *c = PG_Layout::GetParamStr(Source,What); if (c[0]==0) return PG_Label::LEFT; if (tcscmp(T(c),T("left")) == 0) ret = PG_Label::LEFT; if (tcscmp(T(c),T("right")) == 0) ret = PG_Label::RIGHT; if (tcscmp(T(c),T("center")) == 0) ret = PG_Label::CENTER; return ret; }
PG_Draw::BkMode PG_Layout::GetParamIMode(const char **Source, const char *What) { PG_Draw::BkMode ret = PG_Draw::TILE; char *c = PG_Layout::GetParamStr(Source,What); if (tcscmp(T(c),T("tile")) == 0) ret = PG_Draw::TILE; if (tcscmp(T(c),T("stretch")) == 0) ret = PG_Draw::STRETCH; if (tcscmp(T(c),T("3tileh")) == 0) ret = PG_Draw::TILE3H; if (tcscmp(T(c),T("3tilev")) == 0) ret = PG_Draw::TILE3V; if (tcscmp(T(c),T("9tile")) == 0) ret = PG_Draw::TILE9; return(ret); }
char *PG_Layout::GetParamStr(const char **Source, const char *What) { char **c; for (c = (char **)Source;*c; c += 2) if (tcscmp(T(*c),T(What)) == 0) return(*(c+1)); return(&Empty); }
Boolean EntityApp::makeSystemId(int nFiles, AppChar *const *files, StringC &result) { Vector<StringC> filenames(nFiles == 0 ? 1 : nFiles); int i; for (i = 0; i < nFiles; i++) filenames[i] = convertInput(tcscmp(files[i], SP_T("-")) == 0 ? SP_T("<OSFD>0") : files[i]); if (nFiles == 0) filenames[0] = convertInput(SP_T("<OSFD>0")); return entityManager()->mergeSystemIds(filenames, mapCatalogDocument_, systemCharset_, *this, result); }
static void UpdateList(openfile* p, bool_t Silent, int ListMode) { streamdir DirItem; stream* Stream; int Result; openitem New; LVITEM Item; int No=0; int Pos=0; int State = LVIS_FOCUSED; int Len; const tchar_t* s; bool_t HasHost; if (!p->Multiple || (p->Flags & OPENFLAG_SINGLE)) State |= LVIS_SELECTED; Len = tcslen(p->Path); if (Len && (p->Path[Len-1] == '\\' || p->Path[Len-1] == '/')) p->Path[--Len] = 0; tcscpy_s(p->Base,TSIZEOF(p->Base),p->Path); s = p->Path[0] ? p->Path : T("\\"); AddHistory(p,s); if (!ListMode) return; ++p->InUpdate; WaitBegin(); ShowWindow(p->WndList,SW_HIDE); ClearList(p); Item.mask=LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM; Item.pszText=T(""); Item.cchTextMax=1; Item.iSubItem=0; Stream = GetStream(p->Path,Silent); if (Stream) { s = GetMime(p->Path,NULL,0,&HasHost); if (*s) { Item.iImage=IMG_DIRUP; Item.iItem = No; Item.lParam = 0; ListView_InsertItem(p->WndList,&Item); ListView_SetItemText(p->WndList,No,0,T("..")); ListView_SetItemText(p->WndList,No,1,(tchar_t*)LangStr(OPENFILE_ID,OPENFILE_UP)); ++No; } Result = Stream->EnumDir(Stream,p->Path,p->Exts,*p->CurrentFileType!=-1,&DirItem); if (ListMode==2 && Result == ERR_FILE_NOT_FOUND && UpperPath(p->Path,p->Last,TSIZEOF(p->Last))) { WaitEnd(); --p->InUpdate; p->LastClick = -1; UpdateList(p,Silent,ListMode); return; } if (Result == ERR_NOT_DIRECTORY && !Silent) { New.FileName[0] = 0; New.Ext[0] = 0; New.Image = IMG_FILE; New.Size = 0; Item.lParam = (DWORD)malloc(sizeof(openitem)); if (Item.lParam) { p->Last[0] = 0; Pos = No; State = LVIS_SELECTED; PostMessage(p->Win.Wnd,WM_COMMAND,PLATFORM_OK,0); *(openitem*)Item.lParam = New; Item.iItem = No; Item.iImage = New.Image; ListView_InsertItem(p->WndList,&Item); ++No; } } if (Result == ERR_NONE) Stream->Get(Stream,STREAM_BASE,p->Base,sizeof(p->Base)); while (Result == ERR_NONE) { tchar_t Size[32]; tchar_t Date[32]; int i; for (i=0;i<No;++i) { LVITEM Item; Item.iItem=i; Item.iSubItem = 0; Item.mask=LVIF_PARAM; ListView_GetItem(p->WndList,&Item); if (Item.lParam && tcscmp(((openitem*)Item.lParam)->FileName,DirItem.FileName)==0) break; } if (i==No) { tchar_t DisplayName[MAXPATH]; tcscpy_s(New.FileName,TSIZEOF(New.FileName),DirItem.FileName); New.DisplayName = DirItem.DisplayName[0] != 0; tcscpy_s(DisplayName,TSIZEOF(DisplayName),New.DisplayName?DirItem.DisplayName:DirItem.FileName); Size[0] = 0; Date[0] = 0; if (DirItem.Size < 0) { New.Image = IMG_DIR; New.Size = 0; New.Date = 0; tcscpy_s(New.Ext,TSIZEOF(New.Ext),LangStr(OPENFILE_ID,OPENFILE_DIR)); tcscpy_s(New.Name,TSIZEOF(New.Name),DisplayName); //keep extension } else { switch (DirItem.Type) { case FTYPE_AUDIO: New.Image = IMG_AUDIO; break; case FTYPE_PLAYLIST: New.Image = IMG_PLAYLIST; break; case FTYPE_VIDEO: New.Image = IMG_VIDEO; break; default: New.Image = IMG_FILE; break; } New.Size = DirItem.Size; New.Date = DirItem.Date; SplitURL(DisplayName,NULL,0,NULL,0,New.Name,TSIZEOF(New.Name),New.Ext,TSIZEOF(New.Ext)); tcsupr(New.Ext); if (New.Size >= 0) { if (New.Size < 10000*1024) stprintf_s(Size,TSIZEOF(Size),T("%d KB"),New.Size/1024); else stprintf_s(Size,TSIZEOF(Size),T("%d MB"),New.Size/(1024*1024)); } if (New.Date >= 0) { FILETIME Time; SYSTEMTIME SysTime; Time.dwHighDateTime = (DWORD)(New.Date >> 32); Time.dwLowDateTime = (DWORD)(New.Date); if (FileTimeToSystemTime(&Time,&SysTime)) GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&SysTime,NULL,Date,TSIZEOF(Date)); } } Item.lParam = (DWORD)malloc(sizeof(openitem)); if (Item.lParam) { *(openitem*)Item.lParam = New; Item.iItem = No; Item.iImage = New.Image; ListView_InsertItem(p->WndList,&Item); ListView_SetItemText(p->WndList,No,0,New.Name); ListView_SetItemText(p->WndList,No,1,New.Ext); ListView_SetItemText(p->WndList,No,2,Size); ListView_SetItemText(p->WndList,No,3,Date); ++No; } } Result = Stream->EnumDir(Stream,NULL,NULL,0,&DirItem); }
static int flv_read_metabody(flv* p, format_reader* Reader, int64_t next_pos) { AMFDataType type; char buffer[11]; //only needs to hold the string "onMetaData". Anything longer is something we don't want. //first object needs to be "onMetaData" string type = Reader->Read8(Reader); if(type != AMF_DATA_TYPE_STRING || amf_get_string(p,Reader, buffer, sizeof(buffer)) < 0 || tcscmp(buffer, "onMetaData")) return -1; //parse the second object (we want a mixed array) if(amf_parse_object(p,Reader, buffer, next_pos, 0) < 0) return -1; return 0; }
static int amf_parse_object(flv* p, format_reader* Reader, const char *key, int64_t max_pos, int depth) { AMFDataType amf_type; char str_val[256]; conv c; double num_val; num_val = 0; amf_type = Reader->Read8(Reader); switch(amf_type) { case AMF_DATA_TYPE_NUMBER: { c.src = Reader->ReadBE64(Reader); num_val =c.dst; } break; case AMF_DATA_TYPE_BOOL: num_val = Reader->Read8(Reader); break; case AMF_DATA_TYPE_STRING: if(amf_get_string(p,Reader, str_val, sizeof(str_val)) < 0) return -1; break; case AMF_DATA_TYPE_OBJECT: { while(Reader->FilePos < max_pos - 2 && amf_get_string(p,Reader, str_val, sizeof(str_val)) > 0) { if(amf_parse_object(p,Reader, str_val, max_pos, depth + 1) < 0) { return -1; //if we couldn't skip, bomb out. } } if(Reader->Read8(Reader) != AMF_END_OF_OBJECT) return -1; } break; case AMF_DATA_TYPE_NULL: case AMF_DATA_TYPE_UNDEFINED: case AMF_DATA_TYPE_UNSUPPORTED: break; //these take up no additional space case AMF_DATA_TYPE_MIXEDARRAY: Reader->Skip(Reader,4); //skip 32-bit max array index while(Reader->FilePos < max_pos - 2 && amf_get_string(p,Reader, str_val, sizeof(str_val)) > 0) { //this is the only case in which we would want a nested parse to not skip over the object if(amf_parse_object(p,Reader, str_val, max_pos, depth + 1) < 0) return -1; } if(Reader->Read8(Reader) != AMF_END_OF_OBJECT) return -1; break; case AMF_DATA_TYPE_ARRAY: { unsigned int arraylen, i; arraylen = Reader->ReadBE32(Reader); if(strcmp(key,"times")==0||strcmp(key,"filepositions")==0) { if(p->IndexNum == 0) { int32_t size; p->IndexNum = arraylen; size = sizeof(flvindex)*p->IndexNum; size = ((size+SAFETAIL-1)/SAFETAIL)*SAFETAIL; if (!AllocBlock(size,&p->IndexBuffer,0,HEAP_ANY)) return ERR_OUT_OF_MEMORY; } } p->IndexCur = 0; for(i = 0; i < arraylen && Reader->FilePos < max_pos - 1; i++) { if(amf_parse_object(p,Reader, key, max_pos, depth + 1) < 0) return -1; //if we couldn't skip, bomb out. } } break; case AMF_DATA_TYPE_DATE: Reader->Skip(Reader, 8 + 2); //timestamp (double) and UTC offset (int16) break; default: //unsupported type, we couldn't skip return -1; } if(depth == 1 &&key) { //only look for metadata values when we are not nested and key != NULL if(amf_type == AMF_DATA_TYPE_BOOL) { } else if(amf_type == AMF_DATA_TYPE_NUMBER) { if(!tcscmp(key, "duration")) p->Format.Duration = Scale(num_val, TICKSPERSEC, 1); } else if (amf_type == AMF_DATA_TYPE_STRING) { } else if(amf_type == AMF_DATA_TYPE_DATE) { } } else if(key) { if(tcscmp(key,"times")==0) { ((flvindex*)IndexBuffer(p,p->IndexCur))->times = num_val; p->IndexCur++; } else if(tcscmp(key,"filepositions")==0) { ((flvindex*)IndexBuffer(p,p->IndexCur))->pos = num_val; p->IndexCur++; } } return 0; }