예제 #1
0
Boolean DoUI (GPtr globals)
{		
	short item;
	Str255 hS = ""; //histstatus
	int16	currentResources = 0;

	DialogPtr dp;
	DialogTHndl dt;
	
	gStuff->theRect.top =
	gStuff->theRect.left =
	gStuff->theRect.bottom =
	gStuff->theRect.right = 0;
	
	dt = (DialogTHndl) GetResource ('DLOG', uiID);
	HNoPurge ((Handle) dt);
	
	CenterDialog (dt);

	dp = GetNewDialog (uiID, nil, (WindowPtr) -1);

	(void) SetDialogDefaultItem (dp, ok);
	(void) SetDialogCancelItem (dp, cancel);

	PIGetString(kHistStatus, hS); // get status string
	
	do
	{
		
		currentResources = CountPIResources(histResource);
		
		if (gCurrentHistory < 1)
			gCurrentHistory = 1;
		if (gCurrentHistory > currentResources)
			gCurrentHistory = currentResources;
		
		if (currentResources <= kDHistTotal || 
			gCurrentHistory+kDHistTotal > currentResources)
			PIDisableControl (dp, kDDownButton); // nothing extra to show
		else
			PIEnableControl (dp, kDDownButton);
		
		if (gCurrentHistory < 2)
			PIDisableControl (dp, kDUpButton);
		else
			PIEnableControl (dp, kDUpButton);
		
		if (currentResources >= gCurrentHistory && currentResources > 0)
			{
			PIEnableControl (dp, kDTrimFirst);
			PIEnableControl (dp, kDTrimLast);
			}
		else
		{
			PIDisableControl (dp, kDTrimFirst);
			PIDisableControl (dp, kDTrimLast);
		}
		
		UpdateHistories(globals, dp, currentResources, hS);

		MoveableModalDialog (dp, gStuff->processEvent, nil, &item);

		switch (item)
		{
			case cancel:
				gResult = userCanceledErr;
				// have to set this so we don't get recorded
				break;
			case kDTrimFirst:
				if (currentResources >= gCurrentHistory)
				{
					DeletePIResource (histResource, gCurrentHistory);
					gStuff->dirty = TRUE;
				}
				break;
			case kDTrimLast:
				if (currentResources >= gCurrentHistory + kDHistTotal-1)
				{
					DeletePIResource (histResource, gCurrentHistory+ kDHistTotal-1);
					gStuff->dirty = TRUE;
				}
				else if (currentResources > 0)
				{
					DeletePIResource (histResource, currentResources);
					gStuff->dirty = TRUE;
				}
				break;
			case kDUpButton:
				gCurrentHistory--;
				break;
			case kDDownButton:
				gCurrentHistory++;
				break;
		} // end switch (item)
	} while (item != ok && item != cancel);

	DisposeDialog (dp);
	HPurge ((Handle) dt);
	
	return (item == ok);
}
예제 #2
0
MediaDecoderStateMachine* MP4Decoder::CreateStateMachine()
{
  MediaDecoderReader* reader = new MediaFormatReader(this, new MP4Demuxer(GetResource()));

  return new MediaDecoderStateMachine(this, reader);
}
예제 #3
0
void CMainDialog::StartQuestion(ResTextType text, bool warningYes, bool warningNo, bool fireParticles, DialogCallback yes, DialogCallback no)
{
    std::string name;
    GetResource(RES_TEXT, text, name);
    StartQuestion(name, warningYes, warningNo, fireParticles, yes, no);
}
예제 #4
0
const CResource* CResourceHandler::GetResourceByName(const std::string& resourceName) const
{
	return GetResource(GetResourceId(resourceName));
}
/**
 * Checks whether the names of resources, targets and programs are unique
 *
 * @param           
 * @return          
 * @exception       -
 * @see             
*/
bool CProjectWizardData::CheckUniqueNames ()
{
    int iResource1;
    int iResource2;
    int iTask1;
    int iTask2;
    CProjectWizardResource *pResource1;
    CProjectWizardResource *pResource2;
    CProjectWizardTask *pTask1;
    CProjectWizardTask *pTask2;
    int iNumResources = GetResourceCount();

    for (iResource1 = 0; iResource1 < iNumResources; ++iResource1)
    {
        pResource1 = GetResource(iResource1);

        for (iResource2 = iResource1 + 1; iResource2 < GetResourceCount (); ++iResource2)
        {
            pResource2 = GetResource (iResource2);

            if (!CompareNames (IDS_ERR_NON_UNIQUE_RESOURCE, pResource1->GetResource (), pResource2->GetResource (), TRUE))
                return (false);

            if (!CompareNames (IDS_ERR_NON_UNIQUE_TARGET, pResource1->GetTarget (), pResource2->GetTarget (), FALSE))
                return (false);
        };

        for (iTask1 = 0; iTask1 < pResource1->GetTaskCount (); ++iTask1)
        {
            pTask1 = pResource1->GetTask (iTask1);

            if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetName (), pTask1->GetProgram (), TRUE))
                return (false);

            for (iTask2 = iTask1 + 1; iTask2 < pResource1->GetTaskCount (); ++iTask2)
            {
                pTask2 = pResource1->GetTask (iTask2);

                if (!CompareNames (IDS_ERR_NON_UNIQUE_TASK, pTask1->GetName (), pTask2->GetName (), TRUE))
                    return (false);

                if (!CompareNames (IDS_ERR_NON_UNIQUE_PROGRAM, pTask1->GetProgram (), pTask2->GetProgram (), TRUE))
                    return (false);

                if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetName (), pTask2->GetProgram (), TRUE))
                    return (false);

                if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetProgram (), pTask2->GetName (), TRUE))
                    return (false);
            };

            for (iResource2 = iResource1 + 1; iResource2 < GetResourceCount (); ++iResource2)
            {
                pResource2 = GetResource (iResource2);

                for (iTask2 = 0; iTask2 < pResource2->GetTaskCount (); ++iTask2)
                {
                    pTask2 = pResource2->GetTask (iTask2);

                    if (!CompareNames (IDS_ERR_NON_UNIQUE_PROGRAM, pTask1->GetProgram (), pTask2->GetProgram (), TRUE))
                        return (false);

                    if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetName (), pTask2->GetProgram (), TRUE))
                        return (false);

                    if (!CompareNames (IDS_ERR_EQUAL_TASK_AND_PROGRAM_NAME, pTask1->GetProgram (), pTask2->GetName (), TRUE))
                        return (false);
                };
            };
        };
    };

    return (true);
}
예제 #6
0
McoStatus ThermDialog::SetUpTherm(int therm_num)
{

    Rect 		r;
    Handle 		h;
    short 		itemType;
    short 		wi,hi;
    short		ids1[] = THERM_IDs_1;
    short		ids2[] = THERM_IDs_2;
    int 		i;
    Str255		theString;

    Quit = FALSE;

    //if (therm_num == 3)
    for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids2[i];
    //else for (i=0; i<NUM_THERM_IDS; i++) ids[i] = ids1[i];

    GetPort(&olddp);

    dt = (DialogTHndl) GetResource ('DLOG',ids[THERM_DLG]);

    if (! dt) return(MCO_RSRC_ERROR);

    HNoPurge ((Handle) dt);

    r = (**dt).boundsRect;


#define menuHeight 20

    wi = qd.screenBits.bounds.right;
    hi = qd.screenBits.bounds.bottom;

    OffsetRect (&r, -r.left, -r.top);
    OffsetRect (&r, (wi - r.right) / 2,
                (hi - r.bottom - menuHeight) / 3 + menuHeight);
    (**dt).boundsRect = r;

#undef menuHeight


    dp = GetNewDialog (ids[THERM_DLG], nil, (WindowPtr) -1);



    if (! dp)
    {
        HPurge ((Handle) dt);
        return(MCO_RSRC_ERROR);
    }

    GetDItem (dp,ids[THERM_TEXT], &itemType, &h, &r);
    GetIndString(theString,THERM_MESS,therm_num);
    SetIText(h,theString);

    SetPort(dp);

    ShowWindow(dp);
    DrawDialog(dp);

    box_d_item(dp,ids[THERM_BOX]);
    return MCO_SUCCESS;
}
예제 #7
0
CRenderableObjectsManager* CLayerManager::GetLayer(CXMLTreeNode &Node)
{
	return GetResource(Node.GetPszProperty("layer",""));
}
예제 #8
0
void CScreenPlayerSelect::CreateInterface()
{
    CWindow*        pw;
    CEdit*          pe;
    CLabel*         pl;
    CButton*        pb;
    CList*          pli;
    CGroup*         pg;
    Math::Point     pos, ddim;
    std::string     name;

    pos.x = 0.10f;
    pos.y = 0.10f;
    ddim.x = 0.80f;
    ddim.y = 0.80f;
    pw = m_interface->CreateWindows(pos, ddim, 12, EVENT_WINDOW5);
    GetResource(RES_TEXT, RT_TITLE_NAME, name);
    pw->SetName(name);

    pos.x  = 0.10f;
    pos.y  = 0.40f;
    ddim.x = 0.50f;
    ddim.y = 0.50f;
    pw->CreateGroup(pos, ddim, 5, EVENT_INTERFACE_GLINTl);  // orange corner
    pos.x  = 0.40f;
    pos.y  = 0.10f;
    ddim.x = 0.50f;
    ddim.y = 0.50f;
    pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr);  // blue corner

    pos.x =  60.0f/640.0f;
    pos.y = 313.0f/480.0f;
    ddim.x = 120.0f/640.0f;
    ddim.y =  32.0f/480.0f;
    GetResource(RES_EVENT, EVENT_INTERFACE_NLABEL, name);
    pl = pw->CreateLabel(pos, ddim, -1, EVENT_INTERFACE_NLABEL, name);
    pl->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT);

    pos.x = 200.0f/640.0f;
    pos.y = 320.0f/480.0f;
    ddim.x = 160.0f/640.0f;
    ddim.y =  32.0f/480.0f;
    pg = pw->CreateGroup(pos, ddim, 7, EVENT_LABEL1);
    pg->SetState(STATE_SHADOW);

    pos.x = 207.0f/640.0f;
    pos.y = 328.0f/480.0f;
    ddim.x = 144.0f/640.0f;
    ddim.y =  18.0f/480.0f;
    pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_NEDIT);
    pe->SetMaxChar(15);
    if(m_main->GetPlayerProfile() != nullptr)
    {
        name = m_main->GetPlayerProfile()->GetName();
    }
    else
    {
        name = CPlayerProfile::GetLastName();
    }
    pe->SetText(name.c_str());
    pe->SetCursor(name.length(), 0);
    m_interface->SetFocus(pe);

    pos.x = 380.0f/640.0f;
    pos.y = 320.0f/480.0f;
    ddim.x =100.0f/640.0f;
    ddim.y = 32.0f/480.0f;
    pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NOK);
    pb->SetState(STATE_SHADOW);

    pos.x = 380.0f/640.0f;
    pos.y = 250.0f/480.0f;
    ddim.x =100.0f/640.0f;
    ddim.y = 52.0f/480.0f;
    pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_PERSO);
    pb->SetState(STATE_SHADOW);

    pos.x = 200.0f/640.0f;
    pos.y = 150.0f/480.0f;
    ddim.x = 160.0f/640.0f;
    ddim.y = 160.0f/480.0f;
    pli = pw->CreateList(pos, ddim, 0, EVENT_INTERFACE_NLIST);
    pli->SetState(STATE_SHADOW);

    pos.x = 200.0f/640.0f;
    pos.y = 100.0f/480.0f;
    ddim.x = 160.0f/640.0f;
    ddim.y =  32.0f/480.0f;
    pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NDELETE);
    pb->SetState(STATE_SHADOW);

    SetBackground("textures/interface/interface.png");
    CreateVersionDisplay();

    ReadNameList();
    UpdateNameList();
    UpdateNameControl();
}
예제 #9
0
int main(int argc, char** argv)
{
        argc_main = argc;
        argv_main = argv;
	SplashColor paperColor;
	GooString* filename, *password;
	char* spwd;
	FILE* f = NULL;
	bookinfo* bi;
	char buf[1024];
	int i;

	mkdir(CACHEDIR, 0777);
	chmod(CACHEDIR, 0777);

	spwd = GetDeviceKey();

	if (setgid(102) != 0) fprintf(stderr, "warning: cannot set gid\n");
	if (setuid(102) != 0) fprintf(stderr, "warning: cannot set uid\n");

	if (spwd)
	{
		//fprintf(stderr, "password: %s\n", spwd);
		password = new GooString(spwd);
	}
	else
	{
		fprintf(stderr, "warning: cannot read password\n");
		password = NULL;
	}

	OpenScreen();

	signal(SIGFPE, sigfpe_handler);
	signal(SIGSEGV, sigsegv_handler);

	clock_left = GetThemeInt("panel.clockleft", 0);
	bmk_flag = GetResource("bmk_flag", NULL);

	if (argc < 2)
	{
		Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
		return 0;
	}

	OriginalName = FileName = argv[1];
	bi = GetBookInfo(FileName);
	if (bi->title) book_title = strdup(bi->title);

	// read config file
	globalParams = new GlobalParams();

	globalParams->setEnableFreeType("yes");
	globalParams->setAntialias((char*)(ivstate.antialiasing ? "yes" : "no"));
	globalParams->setVectorAntialias("no");

	filename = new GooString(FileName);
	doc = new PDFDoc(filename, NULL, NULL);
	if (!doc->isOk())
	{
		int err = doc->getErrorCode();
		delete doc;
		if (err == 4)   // encrypted file
		{
			filename = new GooString(FileName);
			doc = new PDFDoc(filename, NULL, password);
			if (!doc->isOk())
			{
				delete doc;
				spwd = query_password();
				password = new GooString(spwd);
				filename = new GooString(FileName);
				doc = new PDFDoc(filename, NULL, password);
				if (!doc->isOk())
				{
					Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
					return 0;
				}
			}
		}
		else
		{
			Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
			return 0;
		}
	}

	npages = doc->getNumPages();
	paperColor[0] = 255;
	paperColor[1] = 255;
	paperColor[2] = 255;
	splashOut = new MySplashOutputDev(USE4 ? splashModeMono4 : splashModeMono8, 4, gFalse, paperColor);
	splashOut->startDoc(doc->getXRef());

	Outline* outline = doc->getOutline();
	if (outline && outline->getItems())
	{

		GooList* items = outline->getItems();
		if (items->getLength() == 1)
		{
			OutlineItem* first = (OutlineItem*)items->get(0);
			first->open();
			items = first->getKids();
			update_toc(items, 0);
			first->close();
		}
		else if (items->getLength() > 1)
		{
			update_toc(items, 0);
		}

	}

	DataFile = GetAssociatedFile(FileName, 0);
	f = fopen(DataFile, "rb");
	if (f == NULL || fread(&docstate, 1, sizeof(tdocstate), f) != sizeof(tdocstate) || docstate.magic != 0x9751)
	{
		docstate.magic = 0x9751;
		docstate.page = 1;
		docstate.offx = 0;
		docstate.offy = 0;
		docstate.scale = 100;
		docstate.rscale = 150;
		docstate.orient = 0;
		docstate.nbmk = 0;
	}
	if (f != NULL) fclose(f);

	cpage = docstate.page;
	subpage = docstate.subpage;
	offx = docstate.offx;
	offy = docstate.offy;
	if (docstate.scale == 0)
	{
		scale = get_fit_scale();
		ScaleZoomType = ZoomTypeFitWidth;
	}
	else
	{
		scale = docstate.scale;
	}
	rscale = docstate.rscale;
	reflow_mode = (docstate.orient & 0x80) ? 1 : 0;

	gcfg = GetGlobalConfig();
//	ko = ReadInt(gcfg, "keeporient", 0);
	ko = -1;
	if (GetGlobalOrientation() == -1 || ko == 0)
	{
		orient = GetOrientation();
	}
	else
	{
		orient = docstate.orient & 0x7f;
		SetOrientation(orient);
	}

	if (argc >= 3)
	{
		if (argv[2][0] == '=')
		{
#ifdef USESYNOPSIS
			long long position;
			TSynopsisItem::PositionToLong(argv[2] + 1, &position);
			cpage = position_to_page(position >> 40);
#else
//			cpage = atoi(position_to_page(argv[2] + 1));
			cpage = atoi(argv[2] + 1);
#endif
		}
		else
		{
예제 #10
0
파일: stdfn.c 프로젝트: ahe01/rufus
DWORD GetResourceSize(HMODULE module, char* name, char* type, const char* desc)
{
	DWORD len = 0;
	return (GetResource(module, name, type, desc, &len, FALSE) == NULL)?0:len;
}
예제 #11
0
CEmiterInstance* CEmiterManager::GetEmiter(const string &_szName) const
{
  return GetResource(_szName);
}
예제 #12
0
파일: drive.c 프로젝트: ntamvl/rufus
/*
 * Create a partition table
 * See http://technet.microsoft.com/en-us/library/cc739412.aspx for some background info
 * NB: if you modify the MBR outside of using the Windows API, Windows still uses the cached
 * copy it got from the last IOCTL, and ignores your changes until you replug the drive
 * or issue an IOCTL_DISK_UPDATE_PROPERTIES.
 */
BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL mbr_uefi_marker, uint8_t extra_partitions)
{
	const char* PartitionTypeName[2] = { "MBR", "GPT" };
	unsigned char* buffer;
	CREATE_DISK CreateDisk = {PARTITION_STYLE_RAW, {{0}}};
	DRIVE_LAYOUT_INFORMATION_EX4 DriveLayoutEx = {0};
	BOOL r;
	DWORD i, size, bufsize, pn = 0;
	LONGLONG main_part_size_in_sectors, extra_part_size_in_tracks = 0, ms_efi_size;
	const LONGLONG bytes_per_track = ((LONGLONG)SelectedDrive.Geometry.SectorsPerTrack) * SelectedDrive.Geometry.BytesPerSector;

	PrintInfoDebug(0, MSG_238, PartitionTypeName[partition_style]);

	if ((extra_partitions & XP_UEFI_NTFS) && (uefi_ntfs_size == 0)) {
		uefi_ntfs_size = GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_NTFS), _RT_RCDATA, "uefi-ntfs.img");
		if (uefi_ntfs_size == 0)
			return FALSE;
	}

	// Compute the start offset of our first partition
	if ((partition_style == PARTITION_STYLE_GPT) || (!IsChecked(IDC_EXTRA_PARTITION))) {
		// Go with the MS 1 MB wastage at the beginning...
		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = 1024*1024;
	} else {
		// Align on Cylinder
		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = bytes_per_track;
	}

	// If required, set the MSR partition (GPT only - must be created before the data part)
	if ((partition_style == PARTITION_STYLE_GPT) && (extra_partitions & XP_MSR)) {
		uprintf("Adding MSR partition");
		DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = 128*1024*1024;
		DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_MSFT_RESERVED_GUID;
		IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId));
		// coverity[strcpy_overrun]
		wcscpy(DriveLayoutEx.PartitionEntry[pn].Gpt.Name, L"Microsoft reserved partition");

		// We must zero the beginning of this partition, else we get FAT leftovers and stuff
		if (SetFilePointerEx(hDrive, DriveLayoutEx.PartitionEntry[pn].StartingOffset, NULL, FILE_BEGIN)) {
			bufsize = 65536;	// 64K should be enough for everyone
			buffer = calloc(bufsize, 1);
			if (buffer != NULL) {
				if ((!WriteFile(hDrive, buffer, bufsize, &size, NULL)) || (size != bufsize))
					uprintf("  Could not zero MSR: %s", WindowsErrorString());
				free(buffer);
			}
		}

		pn++;
		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[pn-1].StartingOffset.QuadPart +
				DriveLayoutEx.PartitionEntry[pn-1].PartitionLength.QuadPart;
	}

	// Set our main data partition
	main_part_size_in_sectors = (SelectedDrive.DiskSize - DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart) /
		// Need 33 sectors at the end for secondary GPT
		SelectedDrive.Geometry.BytesPerSector - ((partition_style == PARTITION_STYLE_GPT)?33:0);
	if (main_part_size_in_sectors <= 0)
		return FALSE;

	// Adjust the size according to extra partitions (which we always align to a track)
	if (extra_partitions) {
		uprintf("Adding extra partition");
		if (extra_partitions & XP_EFI) {
			// The size of the EFI partition depends on the minimum size we're able to format in FAT32,
			// which in turn depends on the cluster size used, which in turn depends on the disk sector size.
			if (SelectedDrive.Geometry.BytesPerSector <= 1024)
				ms_efi_size = 100*1024*1024;
			else if (SelectedDrive.Geometry.BytesPerSector <= 4096)
				ms_efi_size = 300*1024*1024;
			else
				ms_efi_size = 1200*1024*1024;	// That'll teach you to have a nonstandard disk!
			extra_part_size_in_tracks = (ms_efi_size + bytes_per_track - 1) / bytes_per_track;
		} else if (extra_partitions & XP_UEFI_NTFS)
			extra_part_size_in_tracks = (MIN_EXTRA_PART_SIZE + bytes_per_track - 1) / bytes_per_track;
		else if (extra_partitions & XP_COMPAT)
			extra_part_size_in_tracks = 1;	// One track for the extra partition
		uprintf("Reserved %" PRIi64" tracks (%s) for extra partition", extra_part_size_in_tracks,
			SizeToHumanReadable(extra_part_size_in_tracks * bytes_per_track, TRUE, FALSE));
		main_part_size_in_sectors = ((main_part_size_in_sectors / SelectedDrive.Geometry.SectorsPerTrack) -
			extra_part_size_in_tracks) * SelectedDrive.Geometry.SectorsPerTrack;
		if (main_part_size_in_sectors <= 0)
			return FALSE;
	}
	DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = main_part_size_in_sectors * SelectedDrive.Geometry.BytesPerSector;
	if (partition_style == PARTITION_STYLE_MBR) {
		DriveLayoutEx.PartitionEntry[pn].Mbr.BootIndicator = IsChecked(IDC_BOOT);
		switch (file_system) {
		case FS_FAT16:
			DriveLayoutEx.PartitionEntry[pn].Mbr.PartitionType = 0x0e;	// FAT16 LBA
			break;
		case FS_NTFS:
		case FS_EXFAT:
		case FS_UDF:
		case FS_REFS:
			DriveLayoutEx.PartitionEntry[pn].Mbr.PartitionType = 0x07;
			break;
		case FS_FAT32:
			DriveLayoutEx.PartitionEntry[pn].Mbr.PartitionType = 0x0c;	// FAT32 LBA
			break;
		default:
			uprintf("Unsupported file system\n");
			return FALSE;
		}
	} else {
		DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = PARTITION_BASIC_DATA_GUID;
		IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId));
		wcscpy(DriveLayoutEx.PartitionEntry[pn].Gpt.Name, L"Microsoft Basic Data");
	}
	pn++;

	// Set the optional extra partition
	if (extra_partitions) {
		// Should end on a track boundary
		DriveLayoutEx.PartitionEntry[pn].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[pn-1].StartingOffset.QuadPart +
			DriveLayoutEx.PartitionEntry[pn-1].PartitionLength.QuadPart;
		DriveLayoutEx.PartitionEntry[pn].PartitionLength.QuadPart = (extra_partitions & XP_UEFI_NTFS)?uefi_ntfs_size:
			extra_part_size_in_tracks * SelectedDrive.Geometry.SectorsPerTrack * SelectedDrive.Geometry.BytesPerSector;
		if (partition_style == PARTITION_STYLE_GPT) {
			DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionType = (extra_partitions & XP_UEFI_NTFS)?
				PARTITION_BASIC_DATA_GUID:PARTITION_SYSTEM_GUID;
			IGNORE_RETVAL(CoCreateGuid(&DriveLayoutEx.PartitionEntry[pn].Gpt.PartitionId));
			wcscpy(DriveLayoutEx.PartitionEntry[pn].Gpt.Name, (extra_partitions & XP_UEFI_NTFS)?L"UEFI:NTFS":L"EFI system partition");
		} else {
			DriveLayoutEx.PartitionEntry[pn].Mbr.PartitionType = (extra_partitions & XP_UEFI_NTFS)?0xef:RUFUS_EXTRA_PARTITION_TYPE;
			if (extra_partitions & XP_COMPAT)
				// Set the one track compatibility partition to be all hidden sectors
				DriveLayoutEx.PartitionEntry[pn].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack;
		}

		// We need to write the UEFI:NTFS partition before we refresh the disk
		if (extra_partitions & XP_UEFI_NTFS) {
			uprintf("Writing UEFI:NTFS partition...");
			if (!SetFilePointerEx(hDrive, DriveLayoutEx.PartitionEntry[pn].StartingOffset, NULL, FILE_BEGIN)) {
				uprintf("Unable to set position");
				return FALSE;
			}
			buffer = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_NTFS), _RT_RCDATA, "uefi-ntfs.img", &bufsize, FALSE);
			if (buffer == NULL) {
				uprintf("Could not access uefi-ntfs.img");
				return FALSE;
			}
			r = WriteFile(hDrive, buffer, bufsize, &size, NULL);
			if ((!r) || (size != bufsize)) {
				if (!r)
					uprintf("Write error: %s", WindowsErrorString());
				else
					uprintf("Write error: Wrote %d bytes, expected %d bytes\n", size, bufsize);
				return FALSE;
			}
		}
		pn++;
	}

	// Initialize the remaining partition data
	for (i = 0; i < pn; i++) {
		DriveLayoutEx.PartitionEntry[i].PartitionNumber = i+1;
		DriveLayoutEx.PartitionEntry[i].PartitionStyle = partition_style;
		DriveLayoutEx.PartitionEntry[i].RewritePartition = TRUE;
	}

	switch (partition_style) {
	case PARTITION_STYLE_MBR:
		CreateDisk.PartitionStyle = PARTITION_STYLE_MBR;
		// If MBR+UEFI is selected, write an UEFI marker in lieu of the regular MBR signature.
		// This helps us reselect the partition scheme option that was used when creating the
		// drive in Rufus. As far as I can tell, Windows doesn't care much if this signature
		// isn't unique for USB drives.
		CreateDisk.Mbr.Signature = mbr_uefi_marker?MBR_UEFI_MARKER:GetTickCount();

		DriveLayoutEx.PartitionStyle = PARTITION_STYLE_MBR;
		DriveLayoutEx.PartitionCount = 4;	// Must be multiple of 4 for MBR
		DriveLayoutEx.Type.Mbr.Signature = CreateDisk.Mbr.Signature;
		// TODO: CHS fixup (32 sectors/track) through a cheat mode, if requested
		// NB: disk geometry is computed by BIOS & co. by finding a match between LBA and CHS value of first partition
		//     ms-sys's write_partition_number_of_heads() and write_partition_start_sector_number() can be used if needed
		break;
	case PARTITION_STYLE_GPT:
		// TODO: (?) As per MSDN: "When specifying a GUID partition table (GPT) as the PARTITION_STYLE of the CREATE_DISK
		// structure, an application should wait for the MSR partition arrival before sending the IOCTL_DISK_SET_DRIVE_LAYOUT_EX
		// control code. For more information about device notification, see RegisterDeviceNotification."

		CreateDisk.PartitionStyle = PARTITION_STYLE_GPT;
		IGNORE_RETVAL(CoCreateGuid(&CreateDisk.Gpt.DiskId));
		CreateDisk.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS;

		DriveLayoutEx.PartitionStyle = PARTITION_STYLE_GPT;
		DriveLayoutEx.PartitionCount = pn;
		// At the very least, a GPT disk has 34 reserved sectors at the beginning and 33 at the end.
		DriveLayoutEx.Type.Gpt.StartingUsableOffset.QuadPart = 34 * SelectedDrive.Geometry.BytesPerSector;
		DriveLayoutEx.Type.Gpt.UsableLength.QuadPart = SelectedDrive.DiskSize - (34+33) * SelectedDrive.Geometry.BytesPerSector;
		DriveLayoutEx.Type.Gpt.MaxPartitionCount = MAX_GPT_PARTITIONS;
		DriveLayoutEx.Type.Gpt.DiskId = CreateDisk.Gpt.DiskId;
		break;
	}

	// If you don't call IOCTL_DISK_CREATE_DISK, the next call will fail
	size = sizeof(CreateDisk);
	r = DeviceIoControl(hDrive, IOCTL_DISK_CREATE_DISK, (BYTE*)&CreateDisk, size, NULL, 0, &size, NULL );
	if (!r) {
		uprintf("Could not reset disk: %s\n", WindowsErrorString());
		return FALSE;
	}

	size = sizeof(DriveLayoutEx) - ((partition_style == PARTITION_STYLE_GPT)?((4-pn)*sizeof(PARTITION_INFORMATION_EX)):0);
	r = DeviceIoControl(hDrive, IOCTL_DISK_SET_DRIVE_LAYOUT_EX, (BYTE*)&DriveLayoutEx, size, NULL, 0, &size, NULL );
	if (!r) {
		uprintf("Could not set drive layout: %s\n", WindowsErrorString());
		return FALSE;
	}

	if (!RefreshDriveLayout(hDrive))
		return FALSE;

	return TRUE;
}
CTrigger* CTriggerManager::GetTrigger(std::string name)
{
	return GetResource(name);
}
예제 #14
0
/**
  In GO SLEEP state (in state ECUM_STATE_GO_SLEEP)
 */
static void in_state_goSleep( void ) {

    /* !req EcuMf0026:
     * The ECU State Manager Fixed module shall put all communication interfaces to standby state and shall arm the
     * wake up source before the ECU State Manager Fixed module may put the ECU into SLEEP state.
     */

    /* We only wait for NvM_WriteAll() for so long */
    if (EcuM_World_go_sleep_state_timeout) {
        EcuM_World_go_sleep_state_timeout--;
#if defined(USE_NVM)
        {
            NvM_RequestResultType nvmResult;

            if((NvM_GetErrorStatus(0, &nvmResult) != E_OK) || (nvmResult != NVM_REQ_PENDING)) {
                /* Done or something is wrong...continue */
                EcuM_World_go_sleep_state_timeout = 0;
            }
        }
#endif
	}

    if( (EcuM_World_go_sleep_state_timeout == 0) ) {
        /*
         * We should go to sleep , enable source that should wake us
         */
        uint32 cMask;
        uint8  source;
        const EcuM_SleepModeType *sleepModePtr;

        /* Get the current sleep mode */

        /* @req EcuM2185 */ /* @req EcuMf2185 */
		sleepModePtr = &EcuM_World.config->EcuMSleepModeConfig[EcuM_World.sleep_mode];

		cMask = sleepModePtr->EcuMWakeupSourceMask;

		/* Loop over the WKSOURCE for this sleep mode */
		/* @req EcuM2389 */
		/* @req EcuM2546 */
		for (; cMask; cMask &= ~(1ul << source)) {
			source = ilog2(cMask);
			/* @req 3.1.5/ECUM2389 */
//			DEBUG_ECUM_CALLOUT_W_ARG("EcuM_EnableWakeupSources","0x%lx",(1ul<< source));
			EcuM_EnableWakeupSources( 1<< source );

		}

		/* Let no one else run */
		(void)GetResource(RES_SCHEDULER);
		SetCurrentState(ECUM_STATE_SLEEP);

	} else if( EcuM_GetPendingWakeupEvents() != 0 ) {
		/* @req EcuM2188 */  /* @req EcuMf2188 */

		/* We have pending wakeup events, need to startup again */
#if defined(USE_NVM)
		NvM_CancelWriteAll();
		SetCurrentState(ECUM_STATE_SLEEP);
#endif
	}
}
예제 #15
0
MOboolean
moResourceManager::Init(
    const moText& p_apppath,
    const moText& p_datapath,
    moConfig&  p_consoleconfig,
    MOint p_render_to_texture_mode,
    MOint p_screen_width,
    MOint p_screen_height,
    MOint p_render_width,
    MOint p_render_height,
    MO_HANDLE p_OpWindowHandle,
    MO_DISPLAY p_Display) {

    if ( GetResourceByType( MO_RESOURCETYPE_DEBUG ) == NULL )
        AddResource( new moDebugManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_NET ) == NULL )
        AddResource( new moNetManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FILE ) == NULL )
        AddResource( new moFileManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FILTER ) == NULL )
        AddResource( new moFilterManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_TIME ) == NULL )
        AddResource( new moTimeManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_DATA ) == NULL )
        AddResource( new moDataManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_MATH ) == NULL )
        AddResource( new moMathManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_SHADER ) == NULL )
        AddResource( new moShaderManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FB )==NULL )
        AddResource( new moFBManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_GL )==NULL )
        AddResource( new moGLManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_DECODER )==NULL )
        AddResource( new moDecoderManager() );


    if ( GetResourceByType( MO_RESOURCETYPE_RENDER )==NULL )
        AddResource( new moRenderManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_TEXTURE )==NULL )
        AddResource( new moTextureManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_SOUND )==NULL )
        AddResource( new moSoundManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_VIDEO )==NULL )
        AddResource( new moVideoManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_MODEL )==NULL )
        AddResource( new mo3dModelManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_FONT )==NULL )
        AddResource( new moFontManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_GUI )==NULL )
        AddResource( new moGUIManager() );

    if ( GetResourceByType( MO_RESOURCETYPE_SCRIPT )==NULL )
        AddResource( new moScriptManager() );

    ///Asigna configname, y labelname a los recursos PREDETERMINADOS en caso de encontrarse en el config
    moText resname;
    moText cfname;
    moText lblname;

    ///TODO: chequear errores...
    moParam& presources(p_consoleconfig.GetParam(moText("resources")));

    presources.FirstValue();

    for(MOuint r=0; r<presources.GetValuesCount(); r++) {

        moResource* pResource = NULL;

        resname = presources[MO_SELECTED][MO_CFG_RESOURCE].Text();
        cfname = presources[MO_SELECTED][MO_CFG_RESOURCE_CONFIG].Text();
        lblname = presources[MO_SELECTED][MO_CFG_RESOURCE_LABEL].Text();

        MOint rid = GetResourceIndex( lblname );

        if(rid>-1) pResource = GetResource(rid);

        if (pResource) {
            pResource->SetConfigName(cfname);
            pResource->SetLabelName(lblname);
            pResource->SetConsoleParamIndex( presources.GetParamDefinition().GetIndex() );
            pResource->SetConsoleValueIndex( r );
        }
        presources.NextValue();
    }

    if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Embedded Resources."));
    MODebugMan = (moDebugManager*) GetResourceByType( MO_RESOURCETYPE_DEBUG );
    if (MODebugMan) {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Debug Man Resource."));
        if (!MODebugMan->Init())
            MODebug2->Error(moText("moResourceManager:: Debug Man. Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Debug Man. Creation Error."));
    }

    MONetMan = (moNetManager*) GetResourceByType( MO_RESOURCETYPE_NET );
    if (MONetMan) {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Net Man Resource."));
        if (!MONetMan->Init())
            MODebug2->Error(moText("moResourceManager:: Net Man. Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Net Man. Creation Error."));
    }

    MOFileMan = (moFileManager*) GetResourceByType( MO_RESOURCETYPE_FILE );
    if (MOFileMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing File Man Resource."));
        if (!MOFileMan->Init())
            MODebug2->Error(moText("moResourceManager:: File Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: File Man Creation Error."));
    }


    MODataMan = (moDataManager*) GetResourceByType( MO_RESOURCETYPE_DATA );
    if (MODataMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Data Man Resource."));
        if (!MODataMan->Init( p_apppath, p_datapath, p_consoleconfig.GetName()))
            MODebug2->Error(moText("moResourceManager:: Data Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Data Man Creation Error."));
    }

    MOFilterMan = (moFilterManager*) GetResourceByType( MO_RESOURCETYPE_FILTER );
    if (MOFilterMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Filter Man Resource."));
        if (!MOFilterMan->Init())
            MODebug2->Error(moText("moResourceManager:: Filter Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Filter Man Creation Error."));
    }

    MOTimeMan = (moTimeManager*) GetResourceByType( MO_RESOURCETYPE_TIME );
    if (MOTimeMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Time Man Resource."));
        if (!MOTimeMan->Init())
            MODebug2->Error(moText("moResourceManager:: Time Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Time Man Creation Error."));
    }

    MOGLMan = (moGLManager*) GetResourceByType( MO_RESOURCETYPE_GL );
    if (MOGLMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing GL Man Resource."));
        if (!MOGLMan->Init())
            MODebug2->Error(moText("moResourceManager:: GL Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: GL Man Creation Error."));
    }

    MOFBMan = (moFBManager*) GetResourceByType( MO_RESOURCETYPE_FB );
    if (MOFBMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing FrameBuffer Man Resource."));
        if (!MOFBMan->Init())
            MODebug2->Error(moText("moResourceManager:: FrameBuffer Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: FrameBuffer Man Creation Error."));
    }

    MOTextureMan = (moTextureManager*)  GetResourceByType( MO_RESOURCETYPE_TEXTURE );
    if (MOTextureMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Texture Man Resource."));
        if (!MOTextureMan->Init())
            MODebug2->Error(moText("moResourceManager:: Texture Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Texture Man Creation Error."));
    }

    MODecoderMan = (moDecoderManager*)  GetResourceByType( MO_RESOURCETYPE_DECODER );
    if (MODecoderMan)  {
        if (MODebug2) MODebug2->Message(moText("moDecoderMan:: Initializing Decoder Manager Resource."));
        if (!MODecoderMan->Init())
            MODebug2->Error(moText("moDecoderMan:: Decoder Manager Initialization Error."));
    } else {
        MODebug2->Error(moText("moDecoderMan:: Decoder Manager Creation Error."));
    }


    MORenderMan = (moRenderManager*) GetResourceByType( MO_RESOURCETYPE_RENDER );
    if (MORenderMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Render Man Resource."));
        if (!MORenderMan->Init( (moRenderManagerMode)p_render_to_texture_mode, p_screen_width, p_screen_height, p_render_width, p_render_height ))
            MODebug2->Error(moText("moResourceManager:: Render Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Render Man Creation Error."));
    }

    MOMathMan = (moMathManager*) GetResourceByType( MO_RESOURCETYPE_MATH );
    if (MOMathMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Math Man Resource."));
        if (!MOMathMan->Init())
            MODebug2->Error(moText("moResourceManager:: Math Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Math Man Creation Error."));
    }

    MOShaderMan = (moShaderManager*) GetResourceByType( MO_RESOURCETYPE_SHADER );
    if (MOShaderMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Shsder Man Resource."));
        if (!MOShaderMan->Init())
            MODebug2->Error(moText("moResourceManager:: Shader Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Shader Man Creation Error."));
    }

    MOFontMan = (moFontManager*) GetResourceByType( MO_RESOURCETYPE_FONT );
    if (MOFontMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Font Man Resource."));
        if (!MOFontMan->Init())
            MODebug2->Error(moText("moResourceManager:: Font Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Font Man Creation Error."));
    }

    MOGuiMan = (moGUIManager*)  GetResourceByType( MO_RESOURCETYPE_GUI );
    if (MOGuiMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing GUI Man Resource."));
        if (!MOGuiMan->Init( p_OpWindowHandle, p_Display ))
            MODebug2->Error(moText("moResourceManager:: GUI Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: GUI Man Creation Error."));
    }

    MOSoundMan = (moSoundManager*)  GetResourceByType( MO_RESOURCETYPE_SOUND );
    if (MOSoundMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Sound Man Resource."));
        if (!MOSoundMan->Init())
            MODebug2->Error(moText("moResourceManager:: Sound Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Sound Man Creation Error."));
    }

    MOVideoMan = (moVideoManager*)  GetResourceByType( MO_RESOURCETYPE_VIDEO );
    if (MOVideoMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Video Man Resource."));
        if (!MOVideoMan->Init()) {
            MODebug2->Error(moText("moResourceManager:: Video Man Initialization Error."));
        }
    } else {
        MODebug2->Error(moText("moResourceManager:: Video Man Creation Error."));
    }

    MOModelMan = (mo3dModelManager*)  GetResourceByType( MO_RESOURCETYPE_MODEL );
    if (MOModelMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Model Man Resource."));
        if (!MOModelMan->Init())
            MODebug2->Error(moText("moResourceManager:: Model Man Initialization Error."));
    } else {
        MODebug2->Error(moText("moResourceManager:: Model Man Creation Error."));
    }

    MOScriptMan = (moScriptManager*)  GetResourceByType( MO_RESOURCETYPE_SCRIPT );
    if (MOScriptMan)  {
        if (MODebug2) MODebug2->Message(moText("moResourceManager:: Initializing Script Man Resource."));
        if (!MOScriptMan->Init()) {
            MODebug2->Error(moText("moResourceManager:: Script Man Initialization Error."));
        }
    } else {
        MODebug2->Error(moText("moResourceManager:: Script Man Creation Error."));
    }

    m_Plugins.Init( 0, NULL);

    m_bInitialized = true;

    if (MODebug2) MODebug2->Message(moText("moResourceManager:: Embedded Resources Ready."));

    return Initialized();
}
예제 #16
0
void CScreenSetupGame::CreateInterface()
{
    CWindow*        pw;
    CLabel*         pl;
    CCheck*         pc;
    CSlider*        psl;
    CList*          pli;
    Math::Point     pos, ddim;
    std::string     name;

    CScreenSetup::CreateInterface();
    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
    if ( pw == nullptr )  return;

    ddim.x = dim.x*6;
    ddim.y = dim.y*0.5f;
    pos.x = ox+sx*3;
    pos.y = 0.65f;

    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOVIES);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SCROLL);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_INVERTX);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_INVERTY);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EFFECT);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_BLOOD);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_AUTOSAVE_ENABLE);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;

    pos.y -= ddim.y;
    ddim.x = dim.x*2.5f;
    psl = pw->CreateSlider(pos, ddim, -1, EVENT_INTERFACE_AUTOSAVE_INTERVAL);
    psl->SetState(STATE_SHADOW);
    psl->SetLimit(1.0f, 30.0f);
    psl->SetArrowStep(1.0f);
    pos.y += ddim.y/2;
    GetResource(RES_EVENT, EVENT_INTERFACE_AUTOSAVE_INTERVAL, name);
    pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
    pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
    pos.y -= ddim.y/2;
    pos.x = ox+sx*3+dim.x*4.0f;
    psl = pw->CreateSlider(pos, ddim, -1, EVENT_INTERFACE_AUTOSAVE_SLOTS);
    psl->SetState(STATE_SHADOW);
    psl->SetLimit(1.0f, 10.0f);
    psl->SetArrowStep(1.0f);
    pos.y += ddim.y/2;
    GetResource(RES_EVENT, EVENT_INTERFACE_AUTOSAVE_SLOTS, name);
    pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
    pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
    pos.y -= ddim.y/2;

    ddim.x = dim.x*6;
    ddim.y = dim.y*0.5f;
    pos.x = ox+sx*10;
    pos.y = 0.65f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_TOOLTIP);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_GLINT);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_RAIN);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_BGPAUSE);
    pc->SetState(STATE_SHADOW);
    pos.y -= 0.048f;
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EDITMODE);
    pc->SetState(STATE_SHADOW);
    if ( m_simulationSetup )
    {
        pc->SetState(STATE_DEAD);
    }
    pos.y -= 0.048f;
    pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_EDITVALUE);
    pc->SetState(STATE_SHADOW);

    ddim.y = dim.y*3.0f;
    pos.y -= ddim.y;
    pli = pw->CreateList(pos, ddim, 0, EVENT_INTERFACE_LANGUAGE);
    pli->SetState(STATE_SHADOW);
    // TODO: Add something like GetSupportedLanguages() and GetLanguageFriendlyName() for this
    pli->SetItemName(1+LANGUAGE_ENV, "[System default]");
    pli->SetItemName(1+LANGUAGE_ENGLISH, "English");
    pli->SetItemName(1+LANGUAGE_FRENCH, "French");
    pli->SetItemName(1+LANGUAGE_GERMAN, "German");
    pli->SetItemName(1+LANGUAGE_POLISH, "Polish");
    pli->SetItemName(1+LANGUAGE_RUSSIAN, "Russian");

    UpdateSetupButtons();
}
예제 #17
0
// will need to read from text file instead
YEARDATAHDL GetYearData(short year)
{
	// IMPORTANT: The calling function should NOT dispose the handle it gets
	YEARDATAHDL		yrHdl=nil;
	short yearMinus1990 = year-1990;
	long i,n,resSize=0;
	
	if(0<= yearMinus1990 && yearMinus1990 <kMAXNUMSAVEDYEARS)
	{
		if(gYearDataHdl1990Plus[yearMinus1990]) return gYearDataHdl1990Plus[yearMinus1990];
	}
	
#ifdef MAC
	Handle r = nil;
	r=GetResource('YEAR',(long)year);
#ifdef SWAP_BINARY	
	resSize = GetMaxResourceSize(r);
	if(resSize > 0 && r) 
	{
		yrHdl = (YEARDATAHDL)_NewHandle(resSize);
		if(yrHdl)
		{
			_HLock(r); // so it can't be purged !!!
			YEARDATAHDL rHdl = (YEARDATAHDL)_NewHandle(resSize);
			DetachResource(r);
			rHdl = (YEARDATAHDL) r;
			// copy and swap the bytes
			n = resSize/sizeof(YEARDATA);
			for(i = 0; i< n; i++)
			{
				YEARDATA yrd  = (YEARDATA)INDEXH(rHdl,i);
				SwapFloat(&yrd.XODE);
				SwapFloat(&yrd.VPU);
				INDEXH(yrHdl,i) = yrd;
			}
			// I don't think we free something gotten from a resource
		}
		ReleaseResource(r);// don't dispose of a resource handle !!!
		r = 0;
	}
#else
	if(r) 
	{
		DetachResource(r);
		yrHdl = (YEARDATAHDL) r;
	}
#endif
#else
	char numStr[32];
	HRSRC hResInfo =0;
	HGLOBAL r = 0;
	sprintf(numStr,"#%ld",year);
	hResInfo = FindResource(hInst,numStr,"YEAR");
	if(hResInfo) 
	{
		// copy the handle so we can be
		// just like the mac
		//
		//also we need to swap the bytes
		//
		// be careful r is a HGLOBAL, not one of our special fake handles
		resSize = SizeofResource(hInst,hResInfo);
		if(resSize > 0) r = LoadResource(hInst,hResInfo);
		if(resSize > 0 && r) 
		{
			yrHdl = (YEARDATAHDL)_NewHandle(resSize);
			if(yrHdl)
			{
				YEARDATAPTR rPtr = (YEARDATAPTR) LockResource(r);
				// copy and swap the bytes
				n = resSize/sizeof(YEARDATA);
				for(i = 0; i< n; i++)
				{
					YEARDATA yrd  = rPtr[i];
					SwapFloat(&yrd.XODE);
					SwapFloat(&yrd.VPU);
					INDEXH(yrHdl,i) = yrd;
				}
				// WIN32 applications do not have to unlock resources locked by LockResource
				// I don't think we free something gotten from a resource
			}
		}
	}
#endif
	
	if(yrHdl && 0<= yearMinus1990 && yearMinus1990 <kMAXNUMSAVEDYEARS)
	{
		gYearDataHdl1990Plus[yearMinus1990] = yrHdl;
	}
	
	return(yrHdl);
}
예제 #18
0
  /* Create a new FT_Face from an SFNT resource, specified by res ID. */
  static FT_Error
  FT_New_Face_From_SFNT( FT_Library  library,
                         ResID       sfnt_id,
                         FT_Long     face_index,
                         FT_Face*    aface )
  {
    Handle     sfnt = NULL;
    FT_Byte*   sfnt_data;
    size_t     sfnt_size;
    FT_Error   error  = FT_Err_Ok;
    FT_Memory  memory = library->memory;
    int        is_cff, is_sfnt_ps;


    sfnt = GetResource( TTAG_sfnt, sfnt_id );
    if ( sfnt == NULL )
      return FT_THROW( Invalid_Handle );

    sfnt_size = (FT_ULong)GetHandleSize( sfnt );
    if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
    {
      ReleaseResource( sfnt );
      return error;
    }

    HLock( sfnt );
    ft_memcpy( sfnt_data, *sfnt, sfnt_size );
    HUnlock( sfnt );
    ReleaseResource( sfnt );

    is_cff     = sfnt_size > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
    is_sfnt_ps = sfnt_size > 4 && !ft_memcmp( sfnt_data, "typ1", 4 );

    if ( is_sfnt_ps )
    {
      FT_Stream  stream;


      if ( FT_NEW( stream ) )
        goto Try_OpenType;

      FT_Stream_OpenMemory( stream, sfnt_data, sfnt_size );
      if ( !open_face_PS_from_sfnt_stream( library,
                                           stream,
                                           face_index,
                                           0, NULL,
                                           aface ) )
      {
        FT_Stream_Close( stream );
        FT_FREE( stream );
        FT_FREE( sfnt_data );
        goto Exit;
      }

      FT_FREE( stream );
    }
  Try_OpenType:
    error = open_face_from_buffer( library,
                                   sfnt_data,
                                   sfnt_size,
                                   face_index,
                                   is_cff ? "cff" : "truetype",
                                   aface );
  Exit:
    return error;
  }
예제 #19
0
MediaDecoderStateMachine*
MP3Decoder::CreateStateMachine() {
  nsRefPtr<MediaDecoderReader> reader =
      new MediaFormatReader(this, new mp3::MP3Demuxer(GetResource()));
  return new MediaDecoderStateMachine(this, reader);
}
예제 #20
0
void CairoRenderer::RenderOperator(const Operator *pOp, const Object **pParams, int nParams)
{
	const char *cstr;
	double x, y;
	double v[6];
	int i, n;
	const Object *pObj;
	const Stream *pStream;
	const Dictionary *pDict;
	cairo_matrix_t matrix;
	int nWidth, nHeight;
	cairo_surface_t *pSurface;

	cstr = pOp->GetValue();

	if (strchr("fFbBW", *cstr) != NULL)
		if (cstr[1] == '\0')
			cairo_set_fill_rule(m_pCairo, CAIRO_FILL_RULE_WINDING);
		else if (cstr[1] == '*')
			cairo_set_fill_rule(m_pCairo, CAIRO_FILL_RULE_EVEN_ODD);

	if (*cstr == 'b')  //close, fill, and stroke
	{
		cairo_close_path(m_pCairo);
		cairo_fill(m_pCairo);
		Stroke();
	}
	else if (strcmp(cstr, "B") == 0 || strcmp(cstr, "B*") == 0)  //fill and stroke
	{
		cairo_fill(m_pCairo);
		Stroke();
	}
	else if (strcmp(cstr, "BDC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "BI") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "BMC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "BT") == 0)
	{
		cairo_save(m_pCairo);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		m_cairo_face = NULL;
	}
	else if (strcmp(cstr, "BX") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "c") == 0)  //curve to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_curve_to(m_pCairo, v[0], v[1], v[2], v[3], v[4], v[5]);
	}
	else if (strcmp(cstr, "cm") == 0)  //concat
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_matrix_init(&matrix, v[0], v[1], v[2], v[3], v[4], v[5]);
		cairo_transform(m_pCairo, &matrix);
	}
	else if (strcmp(cstr, "CS") == 0)  //color space
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "cs") == 0)  //color space
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "d") == 0)  //line dash
		SetDash(pParams[0], pParams[1]);
	else if (strcmp(cstr, "d0") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "d1") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Do") == 0)
	{
		pStream = (const Stream *)GetResource(XOBJECT, ((Name *)pParams[0])->GetValue());
		pDict = pStream->GetDictionary();
		pObj = pDict->GetValue("Subtype");
		if (strcmp(((const Name *)pObj)->GetValue(), "Image") == 0)
		{
			nWidth = ((const Numeric *)pDict->GetValue("Width"))->GetValue();
			nHeight = ((const Numeric *)pDict->GetValue("Height"))->GetValue();
			cairo_matrix_init(&matrix, 1.0 / nWidth, 0.0, 0.0, -1.0 / nHeight, 0.0, 1.0);
			cairo_save(m_pCairo);
			cairo_transform(m_pCairo, &matrix);
			cairo_rectangle(m_pCairo, 0.0, 0.0, nWidth, nHeight);
			cairo_clip(m_pCairo);
			pSurface = CreateImageSurface(pStream, nWidth, nHeight);
			cairo_set_source_surface(m_pCairo, pSurface, 0.0, 0.0);
			cairo_paint(m_pCairo);
			cairo_surface_destroy(pSurface);
			cairo_restore(m_pCairo);
		}
	}
	else if (strcmp(cstr, "DP") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "EI") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "EMC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "ET") == 0)
	{
		cairo_restore(m_pCairo);
		if (m_cairo_face)
		{
			cairo_set_font_face(m_pCairo, NULL);
			cairo_font_face_destroy(m_cairo_face);
		}
	}
	else if (strcmp(cstr, "EX") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (*cstr == 'f' || *cstr == 'F')  //fill
		cairo_fill(m_pCairo);
	else if (strcmp(cstr, "G") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_pStrokeColor[0] = v[0];
		m_pStrokeColor[1] = v[0];
		m_pStrokeColor[2] = v[0];
	}
	else if (strcmp(cstr, "g") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_source_rgba(m_pCairo, v[0], v[0], v[0], 1.0);
	}
	else if (strcmp(cstr, "gs") == 0)  //set graphics state
		SetGraphicsState(((const Name *)pParams[0])->GetValue());
	else if (strcmp(cstr, "h") == 0)  //close subpath
		cairo_close_path(m_pCairo);
	else if (strcmp(cstr, "i") == 0)  //flatness tolerance
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_tolerance(m_pCairo, v[0]);
	}
	else if (strcmp(cstr, "ID") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "j") == 0)  //line join
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_line_join(m_pCairo, (cairo_line_join_t)v[0]);
	}
	else if (strcmp(cstr, "J") == 0)  //line cap
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_line_cap(m_pCairo, (cairo_line_cap_t)v[0]);
	}
	else if (strcmp(cstr, "K") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_pStrokeColor[0] = (1.0 - v[0]) * (1.0 - v[3]);
		m_pStrokeColor[1] = (1.0 - v[1]) * (1.0 - v[3]);
		m_pStrokeColor[2] = (1.0 - v[2]) * (1.0 - v[3]);
	}
	else if (strcmp(cstr, "k") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_source_rgba(m_pCairo, (1.0 - v[0]) * (1.0 - v[3]), (1.0 - v[1]) * (1.0 - v[3]), (1.0 - v[2]) * (1.0 - v[3]), 1.0);
	}
	else if (strcmp(cstr, "l") == 0)  //line to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_line_to(m_pCairo, v[0], v[1]);
	}
	else if (strcmp(cstr, "m") == 0)  //new sub path
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_move_to(m_pCairo, v[0], v[1]);
	}
	else if (strcmp(cstr, "M") == 0)  //miter limit
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_miter_limit(m_pCairo, v[0]);
	}
	else if (strcmp(cstr, "MP") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "n") == 0)  //end path
		cairo_new_path(m_pCairo);
	else if (strcmp(cstr, "q") == 0)  //save graphics state
		cairo_save(m_pCairo);
	else if (strcmp(cstr, "Q") == 0)  //restore graphics state
		cairo_restore(m_pCairo);
	else if (strcmp(cstr, "re") == 0)  //rectangle
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_rectangle(m_pCairo, v[0], v[1], v[2], v[3]);
	}
	else if (strcmp(cstr, "RG") == 0)
	{
		ConvertNumeric(pParams, nParams, m_pStrokeColor);
	}
	else if (strcmp(cstr, "rg") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_source_rgba(m_pCairo, v[0], v[1], v[2], 1.0);
	}
	else if (strcmp(cstr, "ri") == 0)  //color rendering intent
		SetIntent(((const Name *)pParams[0])->GetValue());
	else if (strcmp(cstr, "s") == 0)  //close and stroke
	{
		cairo_close_path(m_pCairo);
		Stroke();
	}
	else if (strcmp(cstr, "S") == 0)  //stroke
		Stroke();
	else if (strcmp(cstr, "SC") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "sc") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "SCN") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "scn") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "sh") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "T*") == 0)
	{
		cairo_translate(m_pCairo, 0.0, -m_dTextLead);
		cairo_move_to(m_pCairo, 0.0, 0.0);
	}
	else if (strcmp(cstr, "Tc") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Td") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_translate(m_pCairo, v[0], v[1]);
		cairo_move_to(m_pCairo, 0.0, 0.0);
	}
	else if (strcmp(cstr, "TD") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_translate(m_pCairo, v[0], v[1]);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		m_dTextLead = -v[1];
	}
	else if (strcmp(cstr, "Tf") == 0)
	{
		ChangeFont(((const Name *)pParams[0])->GetValue());
		SetFontFace(m_pFontData->GetFontFile());

		ConvertNumeric(pParams + 1, nParams - 1, v);
		cairo_matrix_init_scale(m_pFontMatrix, v[0], -v[0]);
		cairo_set_font_matrix(m_pCairo, m_pFontMatrix);
	}
	else if (strcmp(cstr, "Tj") == 0)
		RenderString((const String *)pParams[0]);
	else if (strcmp(cstr, "TJ") == 0)
	{
		n = ((const Array *)pParams[0])->GetSize();
		for (i = 0; i < n; i++)
		{
			pObj = ((const Array *)pParams[0])->GetValue(i);
			if (pObj->GetType() == Object::OBJ_STRING)
				RenderString((const String *)pObj);
			else if (pObj->GetType() == Object::OBJ_NUMERIC)
				cairo_translate(m_pCairo, -((const Numeric *)pObj)->GetValue() / 1000.0, 0.0);
		}
	}
	else if (strcmp(cstr, "TL") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_dTextLead = v[0];
	}
	else if (strcmp(cstr, "Tm") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_matrix_init(&matrix, v[0], v[1], v[2], v[3], v[4], v[5]);
		cairo_matrix_multiply(&matrix, m_pFontMatrix, &matrix);
		cairo_set_font_matrix(m_pCairo, &matrix);
		cairo_move_to(m_pCairo, 0.0, 0.0);
	}
	else if (strcmp(cstr, "Tr") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		m_nTextMode = v[0];
	}
	else if (strcmp(cstr, "Ts") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Tw") == 0)
	{
		NOT_IMPLEMENTED;
	}
	else if (strcmp(cstr, "Tz") == 0)
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_scale(m_pCairo, v[0] / 100.0, 1.0);
	}
	else if (strcmp(cstr, "v") == 0)  //curve to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_get_current_point(m_pCairo, &x, &y);
		cairo_curve_to(m_pCairo, x, y, v[0], v[1], v[2], v[3]);
	}
	else if (strcmp(cstr, "w") == 0)  //line width
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_set_line_width(m_pCairo, v[0] + 0.5);
	}
	else if (*cstr == 'W')  //clipping path
		cairo_clip(m_pCairo);
	else if (strcmp(cstr, "y") == 0)  //curve to
	{
		ConvertNumeric(pParams, nParams, v);
		cairo_curve_to(m_pCairo, v[0], v[1], v[2], v[3], v[2], v[3]);
	}
	else if (strcmp(cstr, "'") == 0)
	{
		cairo_translate(m_pCairo, 0.0, -m_dTextLead);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		RenderString((const String *)pParams[0]);
	}
	else if (strcmp(cstr, "\"") == 0)
	{
		cairo_translate(m_pCairo, 0.0, -m_dTextLead);
		cairo_move_to(m_pCairo, 0.0, 0.0);
		RenderString((const String *)pParams[2]);
	}
	else
	{
		assert(false);
	}
}
예제 #21
0
/*test case:test the reaction of the system called with 
 an activation of a task*/
static void test_t1_instance(void)
{	
	StatusType result_inst_1, result_inst_1_5, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11, result_inst_12, result_inst_13, result_inst_14, result_inst_15, result_inst_16, result_inst_17, result_inst_18, result_inst_19, result_inst_20;
	
	SCHEDULING_CHECK_INIT(1);
	result_inst_1 = GetResource(ResourceA);
	SCHEDULING_CHECK_AND_EQUAL_INT(1 , E_OK, result_inst_1);
	
	SCHEDULING_CHECK_INIT(2);
	result_inst_1_5 = ReleaseResource(ResourceA);
	SCHEDULING_CHECK_AND_EQUAL_INT(2 , E_OK, result_inst_1_5);
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = GetResource(INVALID_RESOURCE);
	SCHEDULING_CHECK_AND_EQUAL_INT(3 , E_OS_ID, result_inst_2);
	
	SCHEDULING_CHECK_INIT(4);
	result_inst_3 = GetResource(source1);
	SCHEDULING_CHECK_AND_EQUAL_INT(4 , E_OK, result_inst_3);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_4 = GetResource(Resource2);
	SCHEDULING_CHECK_AND_EQUAL_INT(5 , E_OK, result_inst_4);
	
	SCHEDULING_CHECK_INIT(6);
	result_inst_5 = GetResource(Resource3);
	SCHEDULING_CHECK_AND_EQUAL_INT(6 , E_OK, result_inst_5);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_6 = GetResource(Resource4);
	SCHEDULING_CHECK_AND_EQUAL_INT(7 , E_OK, result_inst_6);
	
	SCHEDULING_CHECK_INIT(8);
	result_inst_7 = GetResource(Resource5);
	SCHEDULING_CHECK_AND_EQUAL_INT(8 , E_OK, result_inst_7);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_8 = GetResource(Resource6);
	SCHEDULING_CHECK_AND_EQUAL_INT(9 , E_OK, result_inst_8);
	
	SCHEDULING_CHECK_INIT(10);
	result_inst_9 = ReleaseResource(Resource6);
	SCHEDULING_CHECK_AND_EQUAL_INT(10 , E_OK, result_inst_9);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_10 = ReleaseResource(Resource5);
	SCHEDULING_CHECK_AND_EQUAL_INT(11 , E_OK, result_inst_10);
	
	SCHEDULING_CHECK_INIT(12);
	result_inst_11 = ReleaseResource(Resource4);
	SCHEDULING_CHECK_AND_EQUAL_INT(12 , E_OK, result_inst_11);
	
	SCHEDULING_CHECK_INIT(13);
	result_inst_12 = ReleaseResource(Resource3);
	SCHEDULING_CHECK_AND_EQUAL_INT(13 , E_OK, result_inst_12);
	
	SCHEDULING_CHECK_INIT(14);
	result_inst_13 = ReleaseResource(source1);
	SCHEDULING_CHECK_AND_EQUAL_INT(14 , E_OS_NOFUNC, result_inst_13);
	
	SCHEDULING_CHECK_INIT(15);
	result_inst_14 = ReleaseResource(Resource2);
	SCHEDULING_CHECK_AND_EQUAL_INT(15 , E_OK, result_inst_14);
	
	SCHEDULING_CHECK_INIT(16);
	result_inst_15 = GetResource(source1);
	SCHEDULING_CHECK_AND_EQUAL_INT(16 , E_OS_ACCESS, result_inst_15);
	
	SCHEDULING_CHECK_INIT(17);
	result_inst_17 = ReleaseResource(source1);
	SCHEDULING_CHECK_AND_EQUAL_INT(17 , E_OK, result_inst_17);
	
	SCHEDULING_CHECK_INIT(18);
	result_inst_16 = ActivateTask(t2);
	/*force scheduling*/
	SCHEDULING_CHECK_AND_EQUAL_INT(21 , E_OK, result_inst_16);
	
	SCHEDULING_CHECK_INIT(22);
	result_inst_18 = ReleaseResource(INVALID_RESOURCE);
	SCHEDULING_CHECK_AND_EQUAL_INT(22 , E_OS_ID, result_inst_18);
	
	SCHEDULING_CHECK_INIT(23);
	result_inst_19 = ReleaseResource(source1);
	SCHEDULING_CHECK_AND_EQUAL_INT(23 , E_OS_NOFUNC, result_inst_19);
	
	SCHEDULING_CHECK_INIT(24);
	result_inst_20 = ReleaseResource(RES_SCHEDULER);
	SCHEDULING_CHECK_AND_EQUAL_INT(24 , E_OS_NOFUNC, result_inst_20);
	
	
}
예제 #22
0
	Int SoundSource::GetDuration() const {
		if (0 > mID)
			return 0;
		return (GetResource().GetProperties().GetSampleCount() * 1000) /
			GetResource().GetProperties().GetFrequency();
	}
예제 #23
0
pascal Handle SafeGetResource(ResType type, short resNum)
{
	StAcroResourceContext resContext;
	
	return GetResource(type, resNum);
}
예제 #24
0
	Int SoundSource::GetSeekTime() {
		if (mOpenALSourceID)
			alGetSourcei(mOpenALSourceID, AL_SAMPLE_OFFSET, &mSampleOffset);
		return (mSampleOffset * 1000) /
			GetResource().GetProperties().GetFrequency();
	}
/**
 * Creates the project file
 *
 * @param           
 * @return          
 * @exception       -
 * @see             
*/
HRESULT CProjectWizardData::CreateProjectFile()
{
    int i;
    HRESULT hrResult;
    FILE *pProjectFile;
    CString sFilename;


    // Create project file.
    //---------------------

    sFilename.Format (_T ("%s." FILE_EXT_PROJECT), m_strProjectName);

    hrResult = CreateFile (sFilename, &pProjectFile);
    if (hrResult != S_OK)
        return (hrResult);

    CString strProjectGuid;
    hrResult = CreateGuid(&strProjectGuid);


    // Write [Attributes] section (Alias, UserText1, UserText2, UserText3, UserURL)
    //-----------------------------------------------------------------------------------

    fprintf (pProjectFile, "[Attributes]\r\n");
    fprintf (pProjectFile, "GUID=\"%s\"\r\n", strProjectGuid);
    if (!m_strAlias.IsEmpty())
    {
        fprintf (pProjectFile, "Alias=%s\r\n", m_strAlias);
    }
    if (!m_strUserText1.IsEmpty())
    {
        fprintf (pProjectFile, "UserText1=%s\r\n", m_strUserText1);
    }
    if (!m_strUserText2.IsEmpty())
    {
        fprintf (pProjectFile, "UserText2=%s\r\n", m_strUserText2);
    }
    if (!m_strUserText3.IsEmpty())
    {
        fprintf (pProjectFile, "UserText3=%s\r\n", m_strUserText3);
    }
    if (!m_strURL.IsEmpty())
    {
        fprintf (pProjectFile, "UserURL=%s\r\n", m_strURL);
    }
    fprintf(pProjectFile, "\r\n");


    // Write [Format] section (version)
    //---------------------------------

    fprintf (pProjectFile, "[Format]\r\n");
    fprintf (pProjectFile, "version=V2.0\r\n\r\n");


    // Write [Classes.GVLs] section (.gvl file entries)
    //-------------------------------------------------

    fprintf (pProjectFile, "[Classes.GVLs]\r\n");

    for (i = 0; i < GetResourceCount (); ++i)
    {
        fprintf (pProjectFile, "file=%s." FILE_EXT_GLOBAL_VARIABLES "\r\n",
                 GetResource (i)->GetResource ());
    };

    fprintf(pProjectFile,"\r\n");


    // Write [Classes.Configurations] section (configuration .con file entries)
    //-----------------------------------------------------------

    fprintf (pProjectFile, "[Classes.Configurations]\r\n");
    fprintf (pProjectFile, "file=%s.con\r\n", CONFIGURATION_FILE_NAME);
    fprintf (pProjectFile, "\r\n");


    // Write [Classes.Constants] section (constant files)
    //---------------------------------------------------

    fprintf (pProjectFile, "[Classes.Constants]\r\n");

    for (i = 0; i < GetResourceCount (); ++i)
    {
        fprintf (pProjectFile, "file=%s." FILE_EXT_CONSTANTS "\r\n",
                 GetResource (i)->GetResource ());
    };

    fprintf (pProjectFile,"\r\n");


    // Write [Classes.Programs] section (program files)
    //-------------------------------------------------

    fprintf (pProjectFile, "[Classes.Programs]\r\n");

    for (i = 0; i < GetResourceCount (); ++i)
    {
        CProjectWizardResource *pResource;
        int k;

        pResource = GetResource (i);
        ASSERT (pResource != NULL);
        if (pResource== NULL)
            continue;

        for (k = 0; k < pResource->GetTaskCount (); ++k)
        {
            CProjectWizardTask *pTask;

            pTask = pResource->GetTask (k);
            ASSERT (pTask != NULL);
            if (pTask == NULL)
                continue;

            fprintf (pProjectFile, "file=%s\r\n", (LPCTSTR)BuildProgramFileName (pTask));
        };
    };

    fprintf (pProjectFile,"\r\n");


    // Write [Libs] section (library files)
    //-------------------------------------

    fprintf (pProjectFile, "[Libs]\r\n");

    for (i = 0; i < GetLibraryCount (); ++i)
        if (m_Libraries[i].GetSelectFlag ())
            fprintf (pProjectFile, "file=%s\\%s\r\n", _T("$(LIBDIR)"), m_Libraries[i].GetLibraryName ());

    fprintf (pProjectFile,"\r\n");


    // Write [Targets] section (target files)
    //---------------------------------------

    fprintf (pProjectFile,"[Targets]\r\n");

    for (i = 0; i < GetResourceCount (); ++i)
        fprintf (pProjectFile, "file=%s\r\n", BuildTargetFileName (GetResource (i)));

    fprintf (pProjectFile, "\r\n");


    fclose (pProjectFile);

    return (S_OK);
}
예제 #26
0
/*test case:test the reaction of the system called with 
an activation of a task*/
static void test_t1_instance(void)
{
	AlarmBaseType AlarmBaseType_inst_1;
	EventMaskType EventMaskType_inst_1;
	StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11, result_inst_12, result_inst_13, result_inst_14, result_inst_15, result_inst_16, result_inst_17, result_inst_18, result_inst_19;
	TaskStateType TaskStateType_inst_1;
	TaskType TaskType_inst_1;
	TickType TickType_inst_1;
		
	SCHEDULING_CHECK_STEP(1);
	
	SCHEDULING_CHECK_STEP(2);
	SuspendAllInterrupts();
	
	SCHEDULING_CHECK_INIT(3);
	result_inst_2 = ActivateTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OS_DISABLEDINT, result_inst_2);
	
	SCHEDULING_CHECK_INIT(5);
	result_inst_3 = TerminateTask();
	SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OS_DISABLEDINT, result_inst_3);
	
	SCHEDULING_CHECK_INIT(7);
	result_inst_4 = ChainTask(t2);
	SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OS_DISABLEDINT, result_inst_4);
	
	SCHEDULING_CHECK_INIT(9);
	result_inst_5 = Schedule();
	SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OS_DISABLEDINT, result_inst_5);
	
	SCHEDULING_CHECK_INIT(11);
	result_inst_6 = GetTaskID(&TaskType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_DISABLEDINT, result_inst_6);
	
	SCHEDULING_CHECK_INIT(13);
	result_inst_7 = GetTaskState(t2, &TaskStateType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OS_DISABLEDINT, result_inst_7);
	
	SCHEDULING_CHECK_INIT(15);
	result_inst_8 = GetResource(Resource1);
	SCHEDULING_CHECK_AND_EQUAL_INT(16,E_OS_DISABLEDINT, result_inst_8);
	
	SCHEDULING_CHECK_INIT(17);
	result_inst_9 = ReleaseResource(Resource1);
	SCHEDULING_CHECK_AND_EQUAL_INT(18,E_OS_DISABLEDINT, result_inst_9);
	
	SCHEDULING_CHECK_INIT(19);
	result_inst_10 = SetEvent(t2, Event1);
	SCHEDULING_CHECK_AND_EQUAL_INT(20,E_OS_DISABLEDINT, result_inst_10);
	
	SCHEDULING_CHECK_INIT(21);
	result_inst_11 = ClearEvent(Event1);
	SCHEDULING_CHECK_AND_EQUAL_INT(22,E_OS_DISABLEDINT, result_inst_11);
	
	SCHEDULING_CHECK_INIT(23);
	result_inst_12 = GetEvent(t2, &EventMaskType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(24,E_OS_DISABLEDINT, result_inst_12);
	
	SCHEDULING_CHECK_INIT(25);
	result_inst_13 = WaitEvent(Event1);
	SCHEDULING_CHECK_AND_EQUAL_INT(26,E_OS_DISABLEDINT, result_inst_13);
	
	SCHEDULING_CHECK_INIT(27);
	result_inst_14 = GetAlarmBase(Alarm1, &AlarmBaseType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(28,E_OS_DISABLEDINT, result_inst_14);
	
	SCHEDULING_CHECK_INIT(29);
	result_inst_15 = GetAlarm(Alarm1, &TickType_inst_1);
	SCHEDULING_CHECK_AND_EQUAL_INT(30,E_OS_DISABLEDINT, result_inst_15);
	
	SCHEDULING_CHECK_INIT(31);
	result_inst_16 = SetRelAlarm(Alarm1, 1, 0);
	SCHEDULING_CHECK_AND_EQUAL_INT(32,E_OS_DISABLEDINT, result_inst_16);
	
	SCHEDULING_CHECK_INIT(33);
	result_inst_17 = SetAbsAlarm(Alarm1, 1, 0);
	SCHEDULING_CHECK_AND_EQUAL_INT(34,E_OS_DISABLEDINT, result_inst_17);
	
	SCHEDULING_CHECK_INIT(35);
	result_inst_18 = CancelAlarm(Alarm1);
	SCHEDULING_CHECK_AND_EQUAL_INT(36,E_OS_DISABLEDINT, result_inst_18);
	
	SCHEDULING_CHECK_INIT(37);
	result_inst_19 = GetActiveApplicationMode();
	SCHEDULING_CHECK_AND_EQUAL_INT(38,OSDEFAULTAPPMODE, result_inst_19);
	
	SCHEDULING_CHECK_STEP(39);
	ResumeAllInterrupts();
}
예제 #27
0
void CMainDialog::StartPauseMenu()
{
    CWindow*    pw;
    CButton*    pb;
    Math::Point     pos, dim;
    std::string name;

    StartDialog(Math::Point(0.3f, 0.8f), true);
    m_dialogType = DialogType::PauseMenu;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
    if ( pw == nullptr )  return;

    pos.x = 0.35f;
    pos.y = 0.60f;
    dim.x = 0.30f;
    dim.y = 0.30f;
    pw->CreateGroup(pos, dim, 5, EVENT_INTERFACE_GLINTl);  // orange corner
    pos.x = 0.35f;
    pos.y = 0.10f;
    dim.x = 0.30f;
    dim.y = 0.30f;
    pw->CreateGroup(pos, dim, 4, EVENT_INTERFACE_GLINTr);  // blue corner

    pos.x = 0.40f;
    dim.x = 0.20f;
    dim.y = 32.0f/480.0f;

    pos.y = 0.74f;
    pb = pw->CreateButton(pos, dim, -1, EVENT_DIALOG_CANCEL);
    pb->SetState(STATE_SHADOW);
    GetResource(RES_TEXT, RT_DIALOG_CONTINUE, name);
    pb->SetName(name);

    if ( (m_main->GetLevelCategory() == LevelCategory::Missions    ||  // missions ?
         m_main->GetLevelCategory() == LevelCategory::FreeGame     ||  // free games?
         m_main->GetLevelCategory() == LevelCategory::CustomLevels ) &&   // user ?
         m_main->GetMissionType() != MISSION_CODE_BATTLE             )
    {
        pos.y = 0.62f;
        pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_WRITE);
        pb->SetState(STATE_SHADOW);
        if ( m_main->IOIsBusy() )  // current task?
        {
            pb->ClearState(STATE_ENABLE);
        }

        pos.y = 0.53f;
        pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_READ);
        pb->SetState(STATE_SHADOW);
        if ( !m_main->GetPlayerProfile()->HasAnySavedScene() )  // no file to read?
        {
            pb->ClearState(STATE_ENABLE);
        }
        pb->SetState(STATE_WARNING);
    }

    pos.y = 0.39f;
    pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_SETUP);
    pb->SetState(STATE_SHADOW);

    pos.y = 0.25f;
    pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_AGAIN);
    pb->SetState(STATE_SHADOW);
    pb->SetState(STATE_WARNING);

    pos.y = 0.16f;
    pb = pw->CreateButton(pos, dim, -1, EVENT_DIALOG_OK);
    pb->SetState(STATE_SHADOW);
    pb->SetState(STATE_WARNING);
    GetResource(RES_TEXT, RT_DIALOG_ABORT, name);
    pb->SetName(name);
}
예제 #28
0
extern int32_t ciaaModbus_transportOpen(
      int32_t fildes,
      ciaaModbus_transportModeEnum mode)
{
   int32_t hModbusTransport;
   int32_t hModbusLowLayer;

   /* check parameter mode */
   if ( (mode == CIAAMODBUS_TRANSPORT_MODE_ASCII_MASTER) ||
        (mode == CIAAMODBUS_TRANSPORT_MODE_ASCII_SLAVE)  ||
        (mode == CIAAMODBUS_TRANSPORT_MODE_RTU_MASTER)   ||
        (mode == CIAAMODBUS_TRANSPORT_MODE_RTU_SLAVE)    ||
        (mode == CIAAMODBUS_TRANSPORT_MODE_TCP_MASTER)   ||
        (mode == CIAAMODBUS_TRANSPORT_MODE_TCP_SLAVE) )
   {
      /* if valid mode, initialize handler with valid value */
      hModbusTransport = 0;

      /* enter critical section */
      GetResource(MODBUSR);

      /* search a Transport Object not in use */
      while ( (hModbusTransport < CIAA_MODBUS_TOTAL_TRANSPORTS) &&
              (ciaaModbus_transportObj[hModbusTransport].inUse == true) )
      {
         hModbusTransport++;
      }

      /* if object available, use it */
      if (hModbusTransport < CIAA_MODBUS_TOTAL_TRANSPORTS)
      {
         switch (mode)
         {
            case CIAAMODBUS_TRANSPORT_MODE_ASCII_MASTER:
            case CIAAMODBUS_TRANSPORT_MODE_ASCII_SLAVE:
               /* open modbus ascii transport */
               hModbusLowLayer = ciaaModbus_asciiOpen(fildes);
               break;

            case CIAAMODBUS_TRANSPORT_MODE_RTU_MASTER:
            case CIAAMODBUS_TRANSPORT_MODE_RTU_SLAVE:
               /* ciaaModbus_transportObj[hModbusTransport].hModbusLowLayer =
               ciaaModbus_rtuOpen() */
               hModbusLowLayer = -1;
               break;

            case CIAAMODBUS_TRANSPORT_MODE_TCP_MASTER:
            case CIAAMODBUS_TRANSPORT_MODE_TCP_SLAVE:
               /* ciaaModbus_transportObj[hModbusTransport].hModbusLowLayer =
               ciaaModbus_tcpOpen() */
               hModbusLowLayer = -1;
               break;
         }
         /* check if a valid low layer transport */
         if (hModbusLowLayer >= 0)
         {
            /* set low layer transpor */
            ciaaModbus_transportObj[hModbusTransport].hModbusLowLayer = hModbusLowLayer;

            /* set object in use */
            ciaaModbus_transportObj[hModbusTransport].inUse = true;

            /* set low layer mode */
            ciaaModbus_transportObj[hModbusTransport].mode = mode;

            /* Set default response timeout */
            ciaaModbus_transportObj[hModbusTransport].respTimeout = CIAA_MODBUS_TRASNPORT_DEFAULT_TIMEOUT;
         }
         else
         {
            /* if invalid low layer transport, return invalid handler */
            hModbusTransport = -1;
         }
      }
      else
      {
         /* if no object available, return invalid handler */
         hModbusTransport = -1;
      }

      /* exit critical section */
      ReleaseResource(MODBUSR);
   }
   else
   {
      /* if invalid mode, initialize handler with invalid value*/
      hModbusTransport = -1;
   }

   return hModbusTransport;
}
예제 #29
0
void
vsDynamicMaterial::SetDrawMode( vsDrawMode drawMode )
{
	GetResource()->m_drawMode = drawMode;
}
예제 #30
0
void CScreenQuit::CreateInterface()
{
    CWindow*        pw;
    CEdit*          pe;
    CLabel*         pl;
    CButton*        pb;
    Math::Point     pos, ddim;
    std::string     name;

    pos.x  = 0.0f;
    pos.y  = 0.0f;
    ddim.x = 0.0f;
    ddim.y = 0.0f;
    pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5);

    pos.x  =  80.0f/640.0f;
    pos.y  = 190.0f/480.0f;
    ddim.x = 490.0f/640.0f;
    ddim.y = 160.0f/480.0f;
    pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1);
    pe->SetGenericMode(true);
    pe->SetEditCap(false);
    pe->SetHighlightCap(false);
    pe->SetFontType(Gfx::FONT_STUDIO);
    pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
    pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt"));

    pos.x  =  40.0f/640.0f;
    pos.y  =  83.0f/480.0f;
    ddim.x = 246.0f/640.0f;
    ddim.y =  16.0f/480.0f;
    GetResource(RES_TEXT, RT_GENERIC_DEV1, name);
    pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
    pl->SetFontType(Gfx::FONT_STUDIO);
    pl->SetFontSize(Gfx::FONT_SIZE_SMALL);

    pos.y  =  13.0f/480.0f;
    GetResource(RES_TEXT, RT_GENERIC_DEV2, name);
    pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
    pl->SetFontType(Gfx::FONT_STUDIO);
    pl->SetFontSize(Gfx::FONT_SIZE_SMALL);

    pos.x  = 355.0f/640.0f;
    pos.y  =  83.0f/480.0f;
    ddim.x = 246.0f/640.0f;
    ddim.y =  16.0f/480.0f;
    GetResource(RES_TEXT, RT_GENERIC_EDIT1, name);
    pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name);
    pl->SetFontType(Gfx::FONT_STUDIO);
    pl->SetFontSize(Gfx::FONT_SIZE_SMALL);

    pos.y  =  13.0f/480.0f;
    GetResource(RES_TEXT, RT_GENERIC_EDIT2, name);
    pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name);
    pl->SetFontType(Gfx::FONT_STUDIO);
    pl->SetFontSize(Gfx::FONT_SIZE_SMALL);

    pos.x  = 306.0f/640.0f;
    pos.y  =  17.0f/480.0f;
    ddim.x =  30.0f/640.0f;
    ddim.y =  30.0f/480.0f;
    pb = pw->CreateButton(pos, ddim, 49, EVENT_INTERFACE_ABORT);
    pb->SetState(STATE_SHADOW);

    SetBackground("textures/interface/generico.png");
}