nsresult CacheStorage::ChooseApplicationCache(nsIURI* aURI, nsIApplicationCache** aCache) { nsresult rv; nsCOMPtr<nsIApplicationCacheService> appCacheService = do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString cacheKey; rv = aURI->GetAsciiSpec(cacheKey); NS_ENSURE_SUCCESS(rv, rv); rv = appCacheService->ChooseApplicationCache(cacheKey, LoadInfo(), aCache); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
//========================================== // 関数 : LoadBMPFromFilePointer // 目的 : 受け取ったファイルポインタが示すBMPファイルのロード // 戻り値: TImageInfo * ※読み込みに失敗した場合はNULLを返す // 引数 : FILE * pf ファイルポインタ //========================================== TImageInfo * LoadBMPFromFilePointer(FILE * pf) { TImageInfo * pBmp; // BMP用構造体のポインタ int nWidth; // 横幅情報受け取り用 int nHeight; // 縦幅情報受け取り用 unsigned short wBitCount; // ビット数情報受け取り用 unsigned long dwCompression; // 圧縮情報受け取り用 bool nResult; // 処理結果受け取り用 nResult = LoadHeader(pf); if (nResult == false) return NULL; // ファイルヘッダ部の読み込みに失敗した場合、処理を終了して関数から脱出する // 情報ヘッダ部の読み込みを行い、横幅・縦幅・ビット数・圧縮情報 のデータを受け取る nResult = LoadInfo(pf, &nWidth, &nHeight, &wBitCount, &dwCompression); if (nResult == false) return NULL; // 情報ヘッダ部の読み込みに失敗した場合、処理を終了して関数から脱出する pBmp = (TImageInfo *)malloc(sizeof(TImageInfo)); // TImageInfo型変数を動的確保する pBmp->nWidth = nWidth; // 先ほど取得した横幅情報を代入する pBmp->nHeight = nHeight; // 先ほど取得した縦幅情報を代入する pBmp->pbyPixels = NULL; // ピクセル情報を入れるポインタはNULLで初期化しておく if (wBitCount != 24) // 24bit形式でなかった場合 { pBmp->bEffective = false; // 対応できない形式であるため、フラグを折って関数から脱出する return pBmp; } if (dwCompression != 0) // 圧縮されている場合 { pBmp->bEffective = false; // 対応できない形式であるため、フラグを折って関数から脱出する return pBmp; } pBmp->bEffective = true; // 以上の条件をクリアしたということは対応できる形式であるため、フラグを立てておく pBmp->pbyPixels = LoadRGB(pf, pBmp->nWidth, pBmp->nHeight); // RGB情報を読み込む if (pBmp->pbyPixels == NULL) // RGB情報の読み込みに失敗した場合 { free(pBmp); // TImageInfo用に確保したメモリを解放する return NULL; } return pBmp; }
int CTexturePreviewDialog::ShowModal() { if (m_bInitialized) { LoadInfo();//check new CenterOnScreen(); //TODO:set the last selection, but it may doesn't work m_pListCtrl->SetItemState(m_nCurrentIndex, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); if (wxDialog::ShowModal() == wxID_CANCEL) { m_nCurrentIndex = INVALID_DATA; } } else { wxMessageBox(_T("in initialization please wait a moment")); } return m_nCurrentIndex; }
void LoadChemStationDataDialog::loadMultipleDirectories(const QModelIndex &index) { const QModelIndexList &indexes = qtrv_fileSystem->selectionModel()->selectedIndexes(); const ChemStationBatchLoader::Filter filter = m_batchLoadModel->filter(index); QStringList dirPaths; if (!filter.isValid) return; for (const QModelIndex &idx : indexes) { const QString path = m_fsModel->filePath(idx); if (dirPaths.contains(path)) continue; dirPaths.push_back(m_fsModel->filePath(idx)); } m_loadInfo = LoadInfo(m_loadingMode, "", dirPaths, filter); accept(); }
bool CBody::LoadPhys() { #define VA_NUM 24 #define VA_FMT "%31s | %d | %f %f | %f | %f %f | %f %f | %f %f | %f %f | %f %f | %d | %12s %12s | %12s | %12s | %12s %12s | %12s | %12s" #define VA_ARGS \ tmpname, \ (int *)&type, \ &distance, \ &radius, \ &shape, \ &orbit_period, \ &own_period, \ &orbit_rot_start, \ &own_rot_start, \ &orb_incl[3], \ &own_incl[3], \ &orb_incl_dir_angle, \ &own_incl_dir_angle, \ &clouds_period, \ &clouds_rot_start, \ &numsubbodies, \ tex_names[0][0], \ tex_names[0][1], \ tex_names[1][0], \ tex_names[2][1], \ tex_names[3][0], \ tex_names[3][1], \ obj_name, \ info_name ///////////////////// float orb_incl_dir_angle, own_incl_dir_angle; char tmpname[sizeof(name)]; int l; int i; int idx; do { ZeroMemory(tex_names,sizeof(tex_names)); ZeroMemory(obj_name,sizeof(obj_name)); ZeroMemory(info_name,sizeof(info_name)); lineindex++; if (lineindex>=numlines) { CLog::Log(LOG_ERROR,"Unable to load body - unexpected end of file."); return false; } } while (sscanf(textlines[lineindex],VA_FMT,VA_ARGS)!=VA_NUM || textlines[lineindex][0]=='/'); l=strlen(tmpname); for (i=0;i<l;i++) if (tmpname[i]=='_') tmpname[i]=' '; for (i=l-1;i>=0;i--) { if (tmpname[i]!=' ') break; tmpname[i]=0; } for (idx=0;idx<l;idx++) if (tmpname[idx]!=' ') break; strcpy(name,tmpname+idx); if (obj_name[0]=='.') obj_name[0]=0; if (info_name[0]=='.') info_name[0]=0; for (i=0;i<4;i++) { if (tex_names[i][0][0]=='.') tex_names[i][0][0]=0; if (tex_names[i][1][0]=='.') tex_names[i][1][0]=0; } if (tex_names[2][1][0]!=0) strcpy(tex_names[2][0],tex_names[0][0]); if (orb_incl_dir_angle==0.0f) orb_incl_dir_angle=(float)(rand()%(360*64))/64.0f; if (own_incl_dir_angle==0.0f) own_incl_dir_angle=(float)(rand()%(360*64))/64.0f; orb_incl[0]=radius*(float)cos(orb_incl_dir_angle*M_PI/180); orb_incl[1]=radius*(float)sin(orb_incl_dir_angle*M_PI/180); orb_incl[2]=0.0f; own_incl[0]=radius*(float)cos(own_incl_dir_angle*M_PI/180); own_incl[1]=radius*(float)sin(own_incl_dir_angle*M_PI/180); own_incl[2]=0.0f; if (!orbit_period) orbit_period=(float)sqrt(distance*distance*distance); distance*=(type!=rings?distmult:radmult); radius*=radmult; orbit_period*=orbtimemult; own_period*=owntimemult; clouds_period*=owntimemult; if (!own_period) own_period=orbit_period; if (orbit_rot_start==0.0f) orbit_rot_start=(float)(rand()%(360*64))/64.0f; if (own_rot_start==0.0f) own_rot_start=(float)(rand()%(360*64))/64.0f; else if (own_period==orbit_period) own_rot_start+=orbit_rot_start; if (clouds_rot_start==0.0f) clouds_rot_start=(float)(rand()%(360*64))/64.0f; clouds_rot_start/=360.0f; orbit_rot=orbit_rot_start; own_rot=own_rot_start; clouds_offset=clouds_rot_start; if (info_name[0]) { if (!LoadInfo()) { CLog::Log(LOG_ERROR,"Failed to load body info - ignoring."); } } return true; }
MediaFileInfo::MediaFileInfo(BMediaFile* file) { LoadInfo(file); }
bool TmxObjectGroup2D::Load(const XMLElement& element, const TileMapInfo2D& info) { LoadInfo(element); for (XMLElement objectElem = element.GetChild("object"); objectElem; objectElem = objectElem.GetNext("object")) { SharedPtr<TileMapObject2D> object(new TileMapObject2D()); if (objectElem.HasAttribute("name")) object->name_ = objectElem.GetAttribute("name"); if (objectElem.HasAttribute("type")) object->type_ = objectElem.GetAttribute("type"); if (objectElem.HasAttribute("gid")) object->objectType_ = OT_TILE; else if (objectElem.HasChild("polygon")) object->objectType_ = OT_POLYGON; else if (objectElem.HasChild("polyline")) object->objectType_ = OT_POLYLINE; else if (objectElem.HasChild("ellipse")) object->objectType_ = OT_ELLIPSE; else object->objectType_ = OT_RECTANGLE; const Vector2 position(objectElem.GetFloat("x"), objectElem.GetFloat("y")); const Vector2 size(objectElem.GetFloat("width"), objectElem.GetFloat("height")); switch (object->objectType_) { case OT_RECTANGLE: case OT_ELLIPSE: object->position_ = info.ConvertPosition(Vector2(position.x_, position.y_ + size.y_)); object->size_ = Vector2(size.x_ * PIXEL_SIZE, size.y_ * PIXEL_SIZE); break; case OT_TILE: object->position_ = info.ConvertPosition(position); object->gid_ = objectElem.GetInt("gid"); object->sprite_ = tmxFile_->GetTileSprite(object->gid_); if (objectElem.HasAttribute("width") || objectElem.HasAttribute("height")) { object->size_ = Vector2(size.x_ * PIXEL_SIZE, size.y_ * PIXEL_SIZE); } else if (object->sprite_) { IntVector2 spriteSize = object->sprite_->GetRectangle().Size(); object->size_ = Vector2(spriteSize.x_, spriteSize.y_); } break; case OT_POLYGON: case OT_POLYLINE: { Vector<String> points; const char* name = object->objectType_ == OT_POLYGON ? "polygon" : "polyline"; XMLElement polygonElem = objectElem.GetChild(name); points = polygonElem.GetAttribute("points").Split(' '); if (points.Size() <= 1) continue; object->points_.Resize(points.Size()); for (unsigned i = 0; i < points.Size(); ++i) { points[i].Replace(',', ' '); Vector2 point = position + ToVector2(points[i]); object->points_[i] = info.ConvertPosition(point); } } break; default: break; } if (objectElem.HasChild("properties")) { object->propertySet_ = new PropertySet2D(); object->propertySet_->Load(objectElem.GetChild("properties")); } objects_.Push(object); } if (element.HasChild("properties")) LoadPropertySet(element.GetChild("properties")); return true; }
void CTexturePreviewDialog::InitTexture() { LoadInfo(); m_bInitialized = true; }
/* * Load a program into an existing address space. The program comes from * the Linux file named "name", and its arguments come from the array at * "args", which is in standard argv format. The argument "proc" points * to the process or PCB structure for the process into which the program * is to be loaded. */ int LoadProgram(char *name, char *args[], PCB *proc) //==>> Declare the argument "proc" to be a pointer to your PCB or //==>> process descriptor data structure. We assume you have a member //==>> of this structure used to hold the cpu context //==>> for the process holding the new program. { int fd; int (*entry)(); struct load_info li; int i; char *cp; char **cpp; char *cp2; int argcount; int size; int text_pg1; int data_pg1; int data_npg; int stack_npg; long segment_size; char *argbuf; /* * Open the executable file */ if ((fd = open(name, O_RDONLY)) < 0) { TracePrintf(0, "LoadProgram: can't open file '%s'\n", name); return FAILURE; } if (LoadInfo(fd, &li) != LI_NO_ERROR) { TracePrintf(0, "LoadProgram: '%s' not in Yalnix format\n", name); close(fd); return FAILURE; } if (li.entry < VMEM_1_BASE) { TracePrintf(0, "LoadProgram: '%s' not linked for Yalnix\n", name); close(fd); return FAILURE; } /* * Figure out in what region 1 page the different program sections * start and end */ text_pg1 = (li.t_vaddr - VMEM_1_BASE) >> PAGESHIFT; data_pg1 = (li.id_vaddr - VMEM_1_BASE) >> PAGESHIFT; data_npg = li.id_npg + li.ud_npg; /* * Store end of bss as UserDataEnd and as user brk */ proc->userDataEnd = (void *) UP_TO_PAGE(li.ud_end); proc->brk = proc->userDataEnd + 1; /* * Figure out how many bytes are needed to hold the arguments on * the new stack that we are building. Also count the number of * arguments, to become the argc that the new "main" gets called with. */ size = 0; for (i = 0; args[i] != NULL; i++) { TracePrintf(3, "counting arg %d = '%s'\n", i, args[i]); size += strlen(args[i]) + 1; } argcount = i; TracePrintf(2, "LoadProgram: argsize %d, argcount %d\n", size, argcount); /* * The arguments will get copied starting at "cp", and the argv * pointers to the arguments (and the argc value) will get built * starting at "cpp". The value for "cpp" is computed by subtracting * off space for the number of arguments (plus 3, for the argc value, * a NULL pointer terminating the argv pointers, and a NULL pointer * terminating the envp pointers) times the size of each, * and then rounding the value *down* to a double-word boundary. */ cp = ((char *)VMEM_1_LIMIT) - size; cpp = (char **) (((int)cp - ((argcount + 3 + POST_ARGV_NULL_SPACE) *sizeof (void *))) & ~7); /* * Compute the new stack pointer, leaving INITIAL_STACK_FRAME_SIZE bytes * reserved above the stack pointer, before the arguments. */ cp2 = (caddr_t)cpp - INITIAL_STACK_FRAME_SIZE; TracePrintf(1, "prog_size %d, text %d data %d bss %d pages\n", li.t_npg + data_npg, li.t_npg, li.id_npg, li.ud_npg); /* * Compute how many pages we need for the stack */ stack_npg = (VMEM_1_LIMIT - DOWN_TO_PAGE(cp2)) >> PAGESHIFT; TracePrintf(11, "LoadProgram: heap_size %d, stack_size %d\n", li.t_npg + data_npg, stack_npg); /* * Store stack base in pcb */ proc->stackBase = (void *) DOWN_TO_PAGE(cp2); /* * If free frames are not enough, return FAILURE */ int page_in_use = (Page(proc->brk) - MAX_PT_LEN) + (NUM_VPN - Page(proc->stackBase)); if (page_in_use > FreeFrameCount) { return FAILURE; } /* leave at least one page between heap and stack */ if (stack_npg + data_pg1 + data_npg >= MAX_PT_LEN) { close(fd); return FAILURE; } /* * This completes all the checks before we proceed to actually load * the new program. From this point on, we are committed to either * loading succesfully or killing the process. */ /* * Set the new stack pointer value in the process's exception frame. */ //==>> Here you replace your data structure proc //==>> proc->context.sp = cp2; proc->uctxt.sp = cp2; /* * Now save the arguments in a separate buffer in region 0, since * we are about to blow away all of region 1. */ cp2 = argbuf = (char *)malloc(size); //==>> You should perhaps check that malloc returned valid space if (NULL == cp2) { TracePrintf(0, "Malloc returned NULL when saving arguments in a separate buffer in region 0.\n"); close(fd); return FAILURE; } for (i = 0; args[i] != NULL; i++) { TracePrintf(3, "saving arg %d = '%s'\n", i, args[i]); strcpy(cp2, args[i]); cp2 += strlen(cp2) + 1; } /* * Set up the page tables for the process so that we can read the * program into memory. Get the right number of physical pages * allocated, and set them all to writable. */ //==>> Throw away the old region 1 virtual address space of the //==>> curent process by freeing //==>> all physical pages currently mapped to region 1, and setting all //==>> region 1 PTEs to invalid. //==>> Since the currently active address space will be overwritten //==>> by the new program, it is just as easy to free all the physical //==>> pages currently mapped to region 1 and allocate afresh all the //==>> pages the new program needs, than to keep track of //==>> how many pages the new process needs and allocate or //==>> deallocate a few pages to fit the size of memory to the requirements //==>> of the new process. disablePTE(MAX_PT_LEN, NUM_VPN); //==>> Allocate "li.t_npg" physical pages and map them starting at //==>> the "text_pg1" page in region 1 address space. //==>> These pages should be marked valid, with a protection of //==>> (PROT_READ | PROT_WRITE). enablePTE(MAX_PT_LEN + text_pg1, MAX_PT_LEN + text_pg1 + li.t_npg, PROT_READ | PROT_WRITE); //==>> Allocate "data_npg" physical pages and map them starting at //==>> the "data_pg1" in region 1 address space. //==>> These pages should be marked valid, with a protection of //==>> (PROT_READ | PROT_WRITE). enablePTE(MAX_PT_LEN + data_pg1, MAX_PT_LEN + data_pg1 + data_npg, PROT_READ | PROT_WRITE); /* * Allocate memory for the user stack too. */ //==>> Allocate "stack_npg" physical pages and map them to the top //==>> of the region 1 virtual address space. //==>> These pages should be marked valid, with a //==>> protection of (PROT_READ | PROT_WRITE). enablePTE(NUM_VPN - stack_npg, NUM_VPN, PROT_READ | PROT_WRITE); /* * All pages for the new address space are now in the page table. * But they are not yet in the TLB, remember! */ /* * Read the text from the file into memory. */ lseek(fd, li.t_faddr, SEEK_SET); segment_size = li.t_npg << PAGESHIFT; if (read(fd, (void *) li.t_vaddr, segment_size) != segment_size) { close(fd); //==>> KILL is not defined anywhere: it is an error code distinct //==>> from ERROR because it requires different action in the caller. //==>> Since this error code is internal to your kernel, you get to define it. return KILL; } /* * Read the data from the file into memory. */ lseek(fd, li.id_faddr, 0); segment_size = li.id_npg << PAGESHIFT; if (read(fd, (void *) li.id_vaddr, segment_size) != segment_size) { close(fd); return KILL; } /* * Now set the page table entries for the program text to be readable * and executable, but not writable. */ //==>> Change the protection on the "li.t_npg" pages starting at //==>> virtual address VMEM_1_BASE + (text_pg1 << PAGESHIFT). Note //==>> that these pages will have indices starting at text_pg1 in //==>> the page table for region 1. //==>> The new protection should be (PROT_READ | PROT_EXEC). //==>> If any of these page table entries is also in the TLB, either //==>> invalidate their entries in the TLB or write the updated entries //==>> into the TLB. It's nice for the TLB and the page tables to remain //==>> consistent. for (i = 0; i < li.t_npg; i++) { changePTE(MAX_PT_LEN + text_pg1 + i, PROT_READ | PROT_EXEC, -1); } close(fd); /* we've read it all now */ /* * Zero out the uninitialized data area */ bzero(li.id_end, li.ud_end - li.id_end); /* * Set the entry point in the exception frame. */ //==>> Here you should put your data structure (PCB or process) //==>> proc->context.pc = (caddr_t) li.entry; proc->uctxt.pc = (caddr_t) li.entry; /* * Now, finally, build the argument list on the new stack. */ #ifdef LINUX memset(cpp, 0x00, VMEM_1_LIMIT - ((int) cpp)); #endif *cpp++ = (char *)argcount; /* the first value at cpp is argc */ cp2 = argbuf; for (i = 0; i < argcount; i++) { /* copy each argument and set argv */ *cpp++ = cp; strcpy(cp, cp2); cp += strlen(cp) + 1; cp2 += strlen(cp2) + 1; } free(argbuf); *cpp++ = NULL; /* the last argv is a NULL pointer */ *cpp++ = NULL; /* a NULL pointer for an empty envp */ return SUCCESS; }