Beispiel #1
0
/**
 * \brief Procedure called when closing the window.
 * \param event This event occured.
 */
void bf::main_frame::on_close( wxCloseEvent& event )
{
  save_config();

  bool quit = !event.CanVeto();

  if ( !quit )
    {
      quit = true;
      m_animation_edit->validate();

      if ( is_changed() )
        {
          wxMessageDialog dlg
            ( this,
              _("The animation is not saved."
                 " Do you want to save it now?"),
              _("Animation is not saved."), wxYES_NO | wxCANCEL );

          int answer = dlg.ShowModal();

          if ( answer == wxID_CANCEL )
            quit = false;
          else if ( answer == wxID_YES )
            quit = save();
        }
    }

  if ( quit )
    event.Skip();
  else
    event.Veto();
} // main_frame::on_close()
Beispiel #2
0
int main() {
	
	int r=get_rand();
	sigset_t actl, oactl;

	sigemptyset(&actl);
	sigemptyset(&oactl);
	sigaddset(&actl, SIGABRT);

	sigprocmask(SIG_SETMASK, &actl, NULL);

	sigaddset(&actl, SIGALRM);
	if (sigprocmask(r, &actl, NULL) != -1) {
		perror("sigprocmask() did not fail even though invalid how parameter was passed to it.\n");
		return PTS_UNRESOLVED;
	}

	sigprocmask(SIG_SETMASK, NULL, &oactl);

	if (sigismember(&oactl, SIGABRT) != 1) {
		printf("FAIL: signal mask was changed. \n");
		return PTS_FAIL;
	}

	if (is_changed(oactl)) {
		printf("FAIL: signal mask was changed. \n");
		return PTS_FAIL;
	}

	printf("%ssigprocmask_12-1:%s           %sPASSED%s\n", boldOn, boldOff, green, normal);
	return PTS_PASS;
}
Beispiel #3
0
/**
 * \brief Answer to a click on "Open animation".
 * \param event This event occured.
 */
void bf::main_frame::on_open_animation( wxCommandEvent& WXUNUSED(event) )
{
  const wxFileName path(m_animation_file);

  wxFileDialog dlg
    ( this, _("Choose an animation"), path.GetPath(), wxEmptyString,
      _("Animation files (*.anim)|*.anim"), wxFD_OPEN | wxFD_FILE_MUST_EXIST );

  if ( dlg.ShowModal() == wxID_OK )
    {
      std::string w = 
        path_configuration::get_instance().search_workspace
        ( wx_to_std_string(dlg.GetPath()) );
      
      if ( ! w.empty() )
        {
          if ( is_changed() || !m_animation_file.empty() )
            {
              main_frame* frm = new main_frame( workspace_environment(w) );
              frm->load_animation( dlg.GetPath() );
              frm->Show();
            }
          else
            load_animation( dlg.GetPath() );
        }
    }
} // main_frame::on_open_animation()
Beispiel #4
0
void update_leds(char *tty)
{
    char i;
    unsigned char real_status_leds[3] = {K_CAPSLOCK,K_NUMLOCK,K_SCROLLLOCK};
    unsigned char real_status;
    unsigned char leds[3] = {LED_NUM,LED_CAP,LED_SCR};
    for(i=0; i < 3; i++)
    {
        if(led_config[i] == IF_NONE && options & OPT_ALTKBCODE)
        {
            ioctl(ttyfd,KDGKBLED,&real_status);
            if(real_status & real_status_leds[i])
                set_led(TRUE,leds[i]);
            else
                set_led(FALSE,leds[i]);
            continue;
        }
        else if (led_config[i] == IF_ALIVE)
        {
            if (if_info[IF_ALIVE] == 1)
                set_led(TRUE,leds[i]);
            else
                set_led(FALSE,leds[i]);
            continue;
        }
        else if(led_config[i] == IF_NONE)
            continue;
        if(is_changed(led_config[i]))
            set_led(TRUE,leds[i]);
        else
            set_led(FALSE,leds[i]);
    }
    memcpy(&l_if_info,&if_info,sizeof(if_info));
}
Beispiel #5
0
/**
 * \brief Make the title of the window.
 */
void bf::main_frame::make_title()
{
  if ( m_animation_file.empty() )
    SetTitle( wxT("Bear Factory - Animation editor") );
  else
    SetTitle( wxFileName(m_animation_file).GetName() );

  if ( is_changed() )
    SetTitle( GetTitle() + wxT("*") );
} // main_frame::make_title()
Beispiel #6
0
void RawLocation::write_changes(int index) {
  // write any changes to memory
  if (is_changed()) {
    // get the value for this location
    Value value(this, index);
    // mark the location as being cached (do this before store_local to avoid
    // recursion when handling x86 floats). 
    mark_as_cached();
    // write the value into memory
    code_generator()->store_to_location(value, index);
  }
}
Beispiel #7
0
static bool settings_write_config(const char* filename, int options)
{
    int i;
    int fd;
    char value[MAX_PATH];
    fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY, 0666);
    if (fd < 0)
        return false;
    fdprintf(fd, "# .cfg file created by rockbox %s - "
                 "http://www.rockbox.org\r\n\r\n", rbversion);
    for(i=0; i<nb_settings; i++)
    {
        if (settings[i].cfg_name == NULL)
            continue;
        value[0] = '\0';
        if (settings[i].flags & F_DEPRECATED)
            continue;
        
        switch (options)
        {
            case SETTINGS_SAVE_CHANGED:
                if (!is_changed(i))
                    continue;
                break;
            case SETTINGS_SAVE_SOUND:
                if ((settings[i].flags&F_SOUNDSETTING) == 0)
                    continue;
                break;
            case SETTINGS_SAVE_THEME:
                if ((settings[i].flags&F_THEMESETTING) == 0)
                    continue;
                break;
#ifdef HAVE_RECORDING
            case SETTINGS_SAVE_RECPRESETS:
                if ((settings[i].flags&F_RECSETTING) == 0)
                    continue;
                break;
#endif
#if CONFIG_CODEC == SWCODEC
            case SETTINGS_SAVE_EQPRESET:
                if ((settings[i].flags&F_EQSETTING) == 0)
                    continue;
                break;
#endif
        }

        cfg_to_string(i, value, MAX_PATH);
        fdprintf(fd,"%s: %s\r\n",settings[i].cfg_name,value);
    } /* for(...) */
    close(fd);
    return true;
}
Beispiel #8
0
int main() {
	sigset_t actl, oactl;

	sigemptyset(&actl);
	sigemptyset(&oactl);

	sigaddset(&actl, SIGABRT);

	sigprocmask(SIG_SETMASK, &actl, NULL);
	sigprocmask(SIG_BLOCK, NULL, &oactl);
	
	if (is_changed(oactl, SIGABRT)) {
		return PTS_FAIL;
	}
	printf("PASS: signal mask was not changed.\n");
	return PTS_PASS;
}
Beispiel #9
0
int main() {
	sigset_t actl, oactl;

	sigemptyset(&actl);
	sigemptyset(&oactl);

	sigaddset(&actl, SIGABRT);

	sigprocmask(SIG_SETMASK, &actl, NULL);
	sigprocmask(SIG_BLOCK, NULL, &oactl);
	
	if (is_changed(oactl, SIGABRT)) {
		return PTS_FAIL;
	}
	printf("%ssigprocmask_8-1:%s            %sPASSED%s\n", boldOn, boldOff, green, normal);
	return PTS_PASS;
}
Beispiel #10
0
Datei: 8-2.c Projekt: 8l/rose
void *a_thread_func() {
	sigset_t actl, oactl;

	sigemptyset(&actl);
	sigemptyset(&oactl);

	sigaddset(&actl, SIGABRT);

	pthread_sigmask(SIG_SETMASK, &actl, NULL);
	pthread_sigmask(SIG_SETMASK, NULL, &oactl);
	
	if (is_changed(oactl, SIGABRT)) {
		pthread_exit((void*)-1);
	}
	printf("PASS: signal mask was not changed.\n");
	pthread_exit((void*)0);

        /* To please some compilers */
	return NULL;
}
Beispiel #11
0
void *a_thread_func(void *arg) {

	int r=get_rand();
	sigset_t actl, oactl;
/*
	printf("SIG_SETMASK=%d\n", SIG_SETMASK);
	printf("SIG_BLOCK=%d\n", SIG_BLOCK);
	printf("SIG_UNBLOCK=%d\n", SIG_UNBLOCK);
	printf("r=%d\n", r);
*/
	sigemptyset(&actl);
	sigemptyset(&oactl);
	sigaddset(&actl, SIGABRT);

	pthread_sigmask(SIG_SETMASK, &actl, NULL);

	sigaddset(&actl, SIGALRM);
	if (pthread_sigmask(r, &actl, NULL) != EINVAL) {
		perror("pthread_sigmask() did not fail even though invalid how parameter was passed to it.\n");
		pthread_exit((void*)1);
	}

	pthread_sigmask(SIG_SETMASK, NULL, &oactl);

	if (is_changed(oactl, SIGABRT)) {
		printf("FAIL: signal mask was changed. \n");
		pthread_exit((void*)-1);
	}

/*
	printf("sigismember(SIGABRT)=%d\n", sigismember(&oactl, SIGABRT));
	printf("sigismember(SIGALRM)=%d\n", sigismember(&oactl, SIGALRM));
*/

	printf("PASS: signal mask was not changed.\n");
	pthread_exit((void*)0);

        /* To please some compilers */
	return NULL;
}
Beispiel #12
0
 void write_changes(const Assembler::Register reg, const int index) {
   if (is_changed() && in_register() && uses_register(reg)) {
     write_changes(index);
   }
 }
Beispiel #13
0
int main()
{
	pid_t pid;
	pid = fork();

	if (pid == 0) {
		/* child */

		sigset_t tempmask, originalmask, currentmask;

		struct sigaction act;

		act.sa_handler = handler;
		act.sa_flags = 0;
		sigemptyset(&act.sa_mask);

		sigemptyset(&tempmask);
		sigaddset(&tempmask, SIGUSR2);

		if (sigaction(SIGUSR1, &act, 0) == -1) {
			perror
			    ("Unexpected error while attempting to pre-conditions");
			return PTS_UNRESOLVED;
		}

		sigemptyset(&originalmask);
		sigaddset(&originalmask, SIGUSR1);
		sigprocmask(SIG_SETMASK, &originalmask, NULL);

		printf("suspending child\n");
		if (sigsuspend(&tempmask) != -1)
			perror("sigsuspend error");

		printf("returned from suspend\n");

		sigprocmask(SIG_SETMASK, NULL, &currentmask);

		if (is_changed(currentmask, SIGUSR1) != 0) {
			printf
			    ("signal mask was not restored properly after sigsuspend returned\n");
			return 1;
		}
		return 0;

	} else {
		int s;
		int exit_status;

		/* parent */
		sleep(1);

		printf("parent sending child a SIGUSR1 signal\n");
		kill(pid, SIGUSR1);

		if (wait(&s) == -1) {
			perror("Unexpected error while setting up test "
			       "pre-conditions");
			return PTS_UNRESOLVED;
		}

		if (!WIFEXITED(s)) {
			printf("Test FAILED: Did not exit normally\n");
			return PTS_FAIL;
		}

		exit_status = WEXITSTATUS(s);

		printf("Exit status from child is %d\n", exit_status);

		if (exit_status == 1) {
			return PTS_FAIL;
		}

		printf("Test PASSED\n");
		return PTS_PASS;
	}
}