コード例 #1
0
ファイル: report_gui.c プロジェクト: testfarm/testfarm
static void report_gui_build(report_gui_t *rg, int browse)
{
  char *argv[] = {NULL, NULL, NULL};

  /* Only once... */
  if ( rg->builder != NULL )
    return;

  /* Check output file presence */
  if ( access(rg->out->file->name, R_OK) != 0 ) {
    eprintf("Test Output file not found:\n%s", rg->out->file->name);
    return;
  }

  rg->build_then_browse = browse;

  /* Build HTML document */
  argv[0] = "testfarm-report";
  argv[1] = rg->out->file->name;

  rg->builder = child_spawn(argv, -1, -1, -1, (child_handler_t *) report_gui_build_terminated, rg);
  if ( rg->builder == NULL ) {
    status_mesg("Cannot execute report generator \"%s\"", argv[0]);
  }
  else {
    gtk_widget_set_sensitive(rg->rtv_build, 0);
    gtk_widget_set_sensitive(rg->rtv_view, 0);
    gtk_widget_set_sensitive(rg->rtv_view2, 0);
  }
}
コード例 #2
0
ファイル: report_gui.c プロジェクト: testfarm/testfarm
static void report_gui_build_completed(report_gui_t *rg, int fd, GdkInputCondition condition)
{
  int status;

  /* Read child process termination status */
  read(fd, &status, sizeof(status));
  //fprintf(stderr, "Test Report completed with status %d\n", status);

  /* Write message to status bar */
  if ( status == 0 ) {
    status_mesg("Test report \"%s\" written", rg->report_name);
  }
  else {
    eprintf("Error building Test Report\n\"%s\"\nfrom Test Output\n\"%s\"", rg->report_name, rg->out->file->name);
  }

  /* Restore buttons sensitivity */
  gtk_widget_set_sensitive(rg->rtv_build, 1);
  gtk_widget_set_sensitive(rg->rtv_view, 1);
  gtk_widget_set_sensitive(rg->rtv_view2, 1);

  /* Call Test Report viewer if requested */
  if ( (status == 0) && (rg->build_then_browse) ) {
    rg->build_then_browse = 0;
    report_gui_view(rg);
  }
}
コード例 #3
0
ファイル: report_gui.c プロジェクト: testfarm/testfarm
static void report_gui_proc_spawn(report_gui_proc_t *proc, char *argv[])
{
  int stdin_pipe[2];

  /* Ensure everything is closed */
  report_gui_proc_terminated(0, proc);

  /* Create command pipe */
  if ( pipe(stdin_pipe) ) {
    fprintf(stderr, "Unable to create pipe for \"%s\": %s", argv[0], strerror(errno));
    return;
  }

  fcntl(stdin_pipe[0], F_SETFD, 0);          /* Disable close-on-exec mode on read endpoint */
  fcntl(stdin_pipe[1], F_SETFD, FD_CLOEXEC); /* Enable close-on-exec mode on write endpoint */

  proc->child = child_spawn(argv, stdin_pipe[0], -1 /* stdout */, -1 /* stderr */,
			    (child_handler_t *) report_gui_proc_terminated, proc);

  /* Close now useless pipe endpoint */
  close(stdin_pipe[0]);

  if ( proc->child == NULL ) {
    close(stdin_pipe[1]);
    status_mesg("Cannot execute process \"%s\"", argv[0]);
  }
  else {
    proc->stdin = stdin_pipe[1];
  }
}
コード例 #4
0
ファイル: apoint.c プロジェクト: dunecn/calcurse
/* Delete an item from the appointment list. */
void
apoint_delete (struct conf *conf, unsigned *nb_events, unsigned *nb_apoints)
{
  char *choices = "[y/n] ";
  char *del_app_str = _("Do you really want to delete this item ?");
  long date;
  int nb_items = *nb_apoints + *nb_events;
  unsigned go_for_deletion = 0;
  int to_be_removed = 0;
  int answer = 0;
  int deleted_item_type = 0;

  date = calendar_get_slctd_day_sec ();

  if (conf->confirm_delete)
    {
      status_mesg (del_app_str, choices);
      answer = wgetch (win[STA].p);
      if ((answer == 'y') && (nb_items != 0))
        go_for_deletion = 1;
      else
        {
          wins_erase_status_bar ();
          return;
        }
    }
  else if (nb_items != 0)
    go_for_deletion = 1;

  if (go_for_deletion)
    {
      if (nb_items != 0)
        {
          deleted_item_type = day_erase_item (date, hilt, ERASE_DONT_FORCE);
          if (deleted_item_type == EVNT || deleted_item_type == RECUR_EVNT)
            {
              (*nb_events)--;
              to_be_removed = 1;
            }
          else if (deleted_item_type == APPT || deleted_item_type == RECUR_APPT)
            {
              (*nb_apoints)--;
              to_be_removed = 3;
            }
          else if (deleted_item_type == 0)
            return;
          else
            EXIT (_("no such type"));
          /* NOTREACHED */

          if (hilt > 1)
            hilt--;
          if (apad.first_onscreen >= to_be_removed)
            apad.first_onscreen = apad.first_onscreen - to_be_removed;
          if (nb_items == 1)
            hilt = 0;
        }
    }
}
コード例 #5
0
ファイル: report_gui.c プロジェクト: testfarm/testfarm
static void report_gui_view(report_gui_t *rg)
{
  static int null_stdout = -1;
  static int null_stderr = -1;
  char *argv[] = {NULL, NULL, NULL};
  char *url;
  int size;

  /* Open /dev/null if not already done */
  if (null_stdout < 0) {
	  null_stdout = open("/dev/null", O_WRONLY);
	  if (null_stdout < 0) {
		  perror("Cannot open '/dev/null' for stdout redirection");
	  }
  }

  if (null_stdout >= 0) {
	  fprintf(stderr, "Browser stdout redirected to /dev/null (fd=%d)\n", null_stdout);
  }

  if (null_stderr < 0) {
	  null_stderr = open("/dev/null", O_WRONLY);
	  if (null_stderr < 0) {
		  perror("Cannot open '/dev/null' for stderr redirection");
	  }
  }

  if (null_stderr >= 0) {
	  fprintf(stderr, "Browser stderr redirected to /dev/null (fd=%d)\n", null_stderr);
  }

  /* Build URL */
  size = strlen(rg->report_name) + 6;
  url = (char *) malloc(size);
  snprintf(url, size, "file:%s", rg->report_name);

  /* Spawn HTML browser */
  argv[0] = get_browser();
  argv[1] = url;
  fprintf(stderr, "Start Test Report viewer: %s %s\n", argv[0], argv[1]);

  if (child_spawn(argv, -1 /* stdin */, null_stdout /* stdout */, null_stderr /* stderr */,
		  (child_handler_t *) NULL, NULL) == NULL) {
	  status_mesg("Cannot execute browser \"%s\"", argv[0]);
  }

  free(url);
}
コード例 #6
0
ファイル: apoint.c プロジェクト: dunecn/calcurse
/*
 * Add an item in either the appointment or the event list,
 * depending if the start time is entered or not.
 */
void
apoint_add (void)
{
#define LTIME 6
  char *mesg_1 =
    _("Enter start time ([hh:mm] or [h:mm]), "
      "leave blank for an all-day event : ");
  char *mesg_2 =
    _("Enter end time ([hh:mm] or [h:mm]) or duration (in minutes) : ");
  char *mesg_3 = _("Enter description :");
  char *format_message_1 =
    _("You entered an invalid start time, should be [h:mm] or [hh:mm]");
  char *format_message_2 =
    _("You entered an invalid end time, should be [h:mm] or [hh:mm] or [mm]");
  char *enter_str = _("Press [Enter] to continue");
  int Id = 1;
  char item_time[LTIME] = "";
  char item_mesg[BUFSIZ] = "";
  long apoint_duration = 0, apoint_start;
  unsigned heures, minutes;
  unsigned end_h, end_m;
  int is_appointment = 1;

  /* Get the starting time */
  do
    {
      status_mesg (mesg_1, "");
      if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_ESC)
        {
          if (strlen (item_time) == 0)
            {
              is_appointment = 0;
              break;
            }
          else if (check_time (item_time) != 1)
            {
              status_mesg (format_message_1, enter_str);
              (void)wgetch (win[STA].p);
            }
          else
            (void)sscanf (item_time, "%u:%u", &heures, &minutes);
        }
      else
        return;
    }
  while (check_time (item_time) != 1);

  /*
   * Check if an event or appointment is entered,
   * depending on the starting time, and record the
   * corresponding item.
   */
  if (is_appointment)
    {				/* Get the appointment duration */
      item_time[0] = '\0';
      do
        {
          status_mesg (mesg_2, "");
          if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_VALID)
            return;		//nothing entered, cancel adding of event
          else if (check_time (item_time) == 0)
            {
              status_mesg (format_message_2, enter_str);
              (void)wgetch (win[STA].p);
            }
          else
            {
              if (check_time (item_time) == 2)
                apoint_duration = atoi (item_time);
              else if (check_time (item_time) == 1)
                {
                  (void)sscanf (item_time, "%u:%u", &end_h, &end_m);
                  if (end_h < heures || ((end_h == heures) && (end_m < minutes)))
                    {
                      apoint_duration = MININSEC - minutes + end_m
                        + (24 + end_h - (heures + 1)) * MININSEC;
                    }
                  else
                    {
                      apoint_duration = MININSEC - minutes
                        + end_m + (end_h - (heures + 1)) * MININSEC;
                    }
                }
            }
        }
      while (check_time (item_time) == 0);
    }
  else				/* Insert the event Id */
    Id = 1;

  status_mesg (mesg_3, "");
  if (getstring (win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID)
    {
      if (is_appointment)
        {
          apoint_start = date2sec (*calendar_get_slctd_day (), heures, minutes);
          (void)apoint_new (item_mesg, 0L, apoint_start,
                            min2sec (apoint_duration), 0L);
          if (notify_bar ())
            notify_check_added (item_mesg, apoint_start, 0L);
        }
      else
        (void)event_new (item_mesg, 0L,
                         date2sec (*calendar_get_slctd_day (), 12, 0), Id);

      if (hilt == 0)
        hilt++;
    }
  wins_erase_status_bar ();
}