예제 #1
0
/*************createlist**************/
void CreateList(FILE *fp, My402List *List)
{
    char buf[1027];

    while(fgets(buf, sizeof(buf), fp) != NULL)
     {
        //printf("%d\n",num_line);
        /* buf may contain '\n' */
        //check length
        if(strlen(buf) > 1024)
            ExitAll(" format err: the line is too long",0);//exit
        //create new node~(success not sure)

        AddNewNode(buf, List);

        //My402ListElem *test;
        //test = My402ListLast(List);

        //printf("%s%d%s%s\n", ((My402ListElemObj*)test->obj)->TSign,((My402ListElemObj*)test->obj)->TTime,((My402ListElemObj*)test->obj)->TAm,((My402ListElemObj*)test->obj)->TDesc);

        //printf("the length of my402list is %d\n", My402ListLength(List));
        //printf("it is empty? %d\n", My402ListEmpty(List));
        //printf("%s", buf);
    }
}
예제 #2
0
파일: manager.cpp 프로젝트: CyberShadow/FAR
void Manager::ExitMainLoop(int Ask)
{
	if (Global->CloseFAR)
	{
		Global->CloseFARMenu=TRUE;
	};

	if (!Ask || !Global->Opt->Confirm.Exit || !Message(0,2,MSG(MQuit),MSG(MAskQuit),MSG(MYes),MSG(MNo)))
	{
		/* $ 29.12.2000 IS
		   + Проверяем, сохранены ли все измененные файлы. Если нет, то не выходим
		     из фара.
		*/
		if (ExitAll() || Global->CloseFAR)
		{
			FilePanels *cp;

			if (!(cp = CtrlObject->Cp())
			        || (!cp->LeftPanel->ProcessPluginEvent(FE_CLOSE,nullptr) && !cp->RightPanel->ProcessPluginEvent(FE_CLOSE,nullptr)))
				EndLoop=TRUE;
		}
		else
		{
			Global->CloseFARMenu=FALSE;
		}
	}
}
예제 #3
0
static void Quit(void)
{
	// Exit PowerPC emulation
	exit_emul_ppc();

	// Stop 60Hz thread
	if (tick_thread_active) {
		tick_thread_cancel = true;
		wait_thread(tick_thread);
	}

	// Stop NVRAM watchdog thread
	if (nvram_thread_active) {
		nvram_thread_cancel = true;
		wait_thread(nvram_thread);
	}

	// Deinitialize everything
	ExitAll();

	// Delete SheepShaver globals
	SheepMem::Exit();

	// Delete RAM area
	if (ram_area_mapped)
		vm_mac_release(RAMBase, RAMSize);

	// Delete ROM area
	if (rom_area_mapped)
		vm_mac_release(ROMBase, ROM_AREA_SIZE);

	// Delete DR cache areas
	if (dr_emulator_area_mapped)
		vm_mac_release(DR_EMULATOR_BASE, DR_EMULATOR_SIZE);
	if (dr_cache_area_mapped)
		vm_mac_release(DR_CACHE_BASE, DR_CACHE_SIZE);

	// Delete Kernel Data area
	kernel_data_exit();

	// Exit system routines
	SysExit();

	// Exit preferences
	PrefsExit();

	// Release win32 libraries
	KernelExit();

#ifdef ENABLE_MON
	// Exit mon
	mon_exit();
#endif

	exit(0);
}
예제 #4
0
/*------------------------------------------------------------------------------*/
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow )
{
	HWND hWnd;
	WCHAR ClsName[] = L"RemoteJoyLiteWindow";

	if ( hPreInst == NULL ){
		WNDCLASS WndCls;

		WndCls.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
		WndCls.lpfnWndProc   = WndProc;
		WndCls.cbClsExtra    = 0;
		WndCls.cbWndExtra    = 0;
		WndCls.hInstance     = hInstance;
		WndCls.hIcon         = LoadIcon( hInstance, L"REMOTEJOYLITE_ICON" );
		WndCls.hCursor       = LoadCursor( NULL, IDC_ARROW );
		WndCls.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
		WndCls.lpszMenuName  = NULL;
		WndCls.lpszClassName = ClsName;
		if ( RegisterClass(&WndCls) == FALSE ){ return( FALSE ); }
	}

	SettingLoad();
	MacroLoad();
	if ( SettingData.DispRot & 1 ){
		SCREEN_W = 272;
		SCREEN_H = 480;
	} else {
		SCREEN_W = 480;
		SCREEN_H = 272;
	}
	RECT rect = { 0, 0, SCREEN_W, SCREEN_H };

	AdjustWindowRect( &rect, WS_OVERLAPPEDWINDOW, FALSE );

	hWnd = CreateWindow( ClsName,
						 L"RemoteJoyLite Ver0.19",
						 WS_OVERLAPPEDWINDOW,
						 CW_USEDEFAULT,
						 CW_USEDEFAULT,
						 rect.right - rect.left,
						 rect.bottom - rect.top,
						 NULL,
						 NULL,
						 hInstance,
						 NULL );

	hWndMain = hWnd;

	pAkindDI = std::unique_ptr<AkindDI>(new AkindDI());
	pAkindD3D = std::unique_ptr<AkindD3D>(new AkindD3D(hWnd));
	pAkindD3D->addCreateEventHandler(RemoteJoyLiteInit);
	pAkindD3D->addReleaseEventHandler(RemoteJoyLiteExit);
	pAkindD3D->addCreateEventHandler(DebugFontInit);
	pAkindD3D->addReleaseEventHandler(DebugFontExit);
	pAkindD3D->addReleaseEventHandler(ImageFilterLanczos4::release);
	pAkindD3D->addReleaseEventHandler(ImageFilterSpline36::release);

	if ( InitAll( hWnd, hInstance ) == FALSE ){
		ExitAll();
		return( FALSE );
	}

	CreateDirectory( L".\\Capture", NULL );
	CreateDirectory( L".\\Macro", NULL );

	UpdateWindow( hWnd );
	InitWindowSize( hWnd );

	MSG msg;
	while ( LoopFlag != FALSE ){
		MainSync( hWnd );
		while ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ){
			GetMessage( &msg, NULL, 0, 0 );
			if ( SettingMessage( &msg, FullScreen, *pAkindD3D ) != FALSE ){ continue; }
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
	}
	ExitAll();
	return( msg.wParam );
}
예제 #5
0
void AddNewNode(char *buf, My402List *List){
    num_line++;
    My402ListElemObj *NewObj;
    NewObj = (My402ListElemObj*)malloc(sizeof(My402ListElemObj));
   /*parse & judge the context of buf*/
   //parsing text input
   char *start_ptr=buf;
   //char *ptr_addr[4];
   char *tab_ptr = strchr(start_ptr, '\t');
   //int countT=0;
   //ptr_addr[countT] = buf;
   char *toomanyfield;

   if(tab_ptr!=NULL)
   {
        *tab_ptr++= '\0';
        //countT++;
        //if(countT>3)
        //    ExitAll("format of this line is incorrect",0);//exit
        //ptr_addr[countT] = tab_ptr;
        NewObj->TSign = (char *)malloc(sizeof(char)*2);
        strncpy(NewObj->TSign,start_ptr,1);

        if(*(NewObj->TSign) !='-' && *(NewObj->TSign) !='+')
            ExitAll(" cannot caculate with wrong symbol ",num_line);

        //printf("%s",NewObj->TSign);

        start_ptr=tab_ptr;//can delete
        tab_ptr = strchr(start_ptr, '\t');
    }
    else
    {
        ExitAll(" the format is wrong ",num_line);
    }
    if(tab_ptr!=NULL)
    {
        *tab_ptr++= '\0';
        //countT++;
        //if(countT>3)
        //    ExitAll("format of this line is incorrect",0);//exit
        //ptr_addr[countT] = tab_ptr;
        NewObj->TTime = atol(start_ptr);

        if(NewObj->TTime > time(NULL))
            ExitAll(" time is over the current time ",num_line);
        //printf("%d\n",NewObj->TTime);

        start_ptr=tab_ptr;//can delete
        tab_ptr = strchr(start_ptr, '\t');
    }
    else
    {
        ExitAll(" the format is wrong ",num_line);
    }
    if(tab_ptr!=NULL)
    {
        *tab_ptr++= '\0';
        //countT++;
        //if(countT>3)
        //    ExitAll("format of this line is incorrect",0);//exit
        //ptr_addr[countT] = tab_ptr;
        char *toomanydecimal = strchr(start_ptr,'.');
        if(strlen(toomanydecimal)>3)
        {
            ExitAll(" too many decimal ",num_line);
        }
        NewObj->TAm =(char *)malloc(sizeof(char)*11);
        strncpy(NewObj->TAm,start_ptr,10);

        //printf("%s\n",NewObj->TAm);

        start_ptr=tab_ptr;//can delete
        tab_ptr = strchr(start_ptr, '\n');
        toomanyfield=strchr(start_ptr, '\t');
    }
    else
    {
        ExitAll(" the format is wrong ",num_line);
    }
    if(toomanyfield!=NULL)
    {
        ExitAll(" too many field ",num_line);
    }
    if(tab_ptr!=NULL)
    {
        *tab_ptr= '\0';
        while(*start_ptr == ' ')
        {
            start_ptr++;
        }
        //countT++;
        //if(countT>3)
        //    ExitAll("format of this line is incorrect",0);//exit
        //ptr_addr[countT] = tab_ptr;
        NewObj->TDesc = (char *)malloc(sizeof(char)*25);
        strncpy(NewObj->TDesc,start_ptr,24);

        //printf("%s\n", NewObj->TDesc);

        //start_ptr=tab_ptr;//can delete
        //tab_ptr = strchr(start_ptr, '\t');
    }
    else
    {
        ExitAll(" the format is wrong ",num_line);
    }

    /*check every part*/

   /*add new obj*/
   //malloc & initial new node
   //NewObj = (My402ListElemObj*)malloc(sizeof(My402ListElemObj));
   //strcpy(NewObj->TSign,ptr_addr[0]);
   //NewObj->TTime = atol(ptr_addr[1]);
   //strcpy(NewObj->TAm,ptr_addr[2]);
   //strcpy(NewObj->TDesc,ptr_addr[3]);
   //add new node to list
   int ToF;
   ToF = My402ListAppend(List, NewObj); //void* with My402ListElemObj*
   if(ToF == 0)
    ExitAll("A node cannot be added when initial the list",0);//exit~
}
예제 #6
0
/*****************sort***************************************/
void SortMyList(My402List *List)
{
    /*test the list
    My402ListElem *test;
    test = My402ListFirst(List);
    if(test == List->anchor.next)
    printf("%s\n","good1");
    while(test != NULL)
    {
        if(test->next==My402ListNext(List,test))
        {
            printf("%s\n","good2");

        }
        printf("%d\n",((My402ListElemObj*)test->obj)->TTime);
        //if(test == NULL)
        //printf("%s","good3");
        test = My402ListNext(List,test);

    }
    if(List->anchor.prev == My402ListLast(List))
    printf("%s","good");
    */

    My402ListElemObj *temp1, *temp2;
    My402ListElem *elem1, *elem2;
    //if(My402ListEmpty(List))
        //exit~
    elem1=My402ListFirst(List);
    while(elem1 != NULL)
    {
        elem2 = My402ListNext(List, elem1);
        while(elem2 != NULL)
        {
            temp1 = (My402ListElemObj*)elem1->obj;
            temp2 = (My402ListElemObj*)elem2->obj;
            if(temp1->TTime > temp2->TTime)
            {
                elem1->obj = temp2;
                elem2->obj = temp1;
            }
            if(temp1->TTime == temp2->TTime)
                ExitAll(" there are 2 time with the same value ",0);
            //exit~
            elem2 = My402ListNext(List, elem2);
            //if(elem2 != NULL)
            //printf("%d\n", ((My402ListElemObj*)elem2->obj)->TTime);
        }
        elem1 = My402ListNext(List, elem1);
    }

    /*//test
    My402ListElem *test = My402ListFirst(List);
    while(test != NULL)
    {
        printf("%d\n", ((My402ListElemObj*)test->obj)->TTime);
        test=My402ListNext(List,test);
    }
    */

}
예제 #7
0
int main(int argc, char **argv)
{
    // Print banner
    printf(
        "SIDPlayer Version 4.4\n\n"
        "Copyright (C) 1996-2004 Christian Bauer\n"
        "E-mail: [email protected]\n"
        "http://www.uni-mainz.de/~bauec002/\n\n"
        "This is free software with ABSOLUTELY NO WARRANTY.\n"
        "You are welcome to redistribute it under certain conditions.\n"
        "For details, see the file COPYING.\n\n"
    );

    // Initialize everything
    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
        fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError());
        exit(1);
    }
    atexit(quit);
    InitAll(argc, argv);
    int32 speed = PrefsFindInt32("speed");

    // Parse non-option arguments
    const char *file_name = NULL;
    int song = 0;
    int i;
    for (i=1; i<argc; i++) {
        if (strcmp(argv[i], "--help") == 0)
            usage(argv[0]);
        else if (argv[i][0] == '-') {
            fprintf(stderr, "Unrecognized option '%s'\n", argv[i]);
            usage(argv[0]);
        } else {
            if (file_name == NULL)
                file_name = argv[i];  // First non-option argument is file name
            else
                song = atoi(argv[i]); // Second non-option argument is song number
        }
    }
    if (file_name == NULL)
        usage(argv[0]);

    // Load given PSID file
    if (!LoadPSIDFile(file_name)) {
        fprintf(stderr, "Couldn't load '%s' (not a PSID file?)\n", file_name);
        exit(1);
    }

    // Select song
    if (song > 0) {
        if (song > number_of_songs)
            song = number_of_songs;
        SelectSong(song - 1);
    }

    SIDAdjustSpeed(speed); // SelectSong and LoadPSIDFile() reset this to 100%

    // Print file information
    printf("Module Name: %s\n", module_name);
    printf("Author     : %s\n", author_name);
    printf("Copyright  : %s\n\n", copyright_info);
    printf("Playing song %d/%d\n", current_song + 1, number_of_songs);

    // Start replay and enter main loop
    SDL_PauseAudio(false);
    while (true) {
        SDL_Event e;
        if (SDL_WaitEvent(&e)) {
            if (e.type == SDL_QUIT)
                break;
        }
    }

    ExitAll();
    return 0;
}
예제 #8
0
static void quit()
{
    ExitAll();
    SDL_Quit();
}