Example #1
0
// Return index of possible display start; -1 if none
int possible_begin_of_display (string gdb_answer, GDBAgent *gdb)
{
    int index = -1;

    if (index == -1)
	index = display_index(gdb_answer, gdb);

    if (index == -1)
    {
	gdb_answer += "a";
	index = display_index(gdb_answer, gdb);
    }

    if (index == -1)
    {
	gdb_answer.at ("a", -1) = " a";
	index = display_index(gdb_answer, gdb);
    }

    if (index == -1)
    {
	gdb_answer.at (" a", -1) = ": a";
	index = display_index(gdb_answer, gdb);
    }

    return index;
}
Example #2
0
static void new_osc_sample(const measure_data_t* data)
{
  int channel = ch_generic2internal(data->ch);
  int i;

  xSemaphoreTake(lcdLock, portMAX_DELAY);
  interrupt_off();

  /* first we clear the old line */
  GLCD_setTextColor(White);
  for(i=0;i<CONFIG_SAMPLE_BUFFER_SIZE;i++)
  {
    display_show_analog(
        (display_buffer_index[channel]+i) % DISPLAY_BUFF_SIZE,
        display_buffer[(display_buffer_index[channel]+i) % DISPLAY_BUFF_SIZE][channel]);
  }

  GLCD_setTextColor(osc_color[channel]);
  for(i=0;i<CONFIG_SAMPLE_BUFFER_SIZE;i++)
  {
    display_show_analog(display_index(channel), data->data[i]);

    // Update buffer
    display_buffer[display_index(channel)][channel] = data->data[i];
    display_buffer_index[channel]++;


  }

  interrupt_on();
  xSemaphoreGive(lcdLock);
}
Example #3
0
static void display_index (Epdf_Document *document, Eina_List *children, int n)
{
  Epdf_Index_Item *item;
  Eina_List       *l;

  if (!children)
    return;

  EINA_LIST_FOREACH(children, l, item) {
    char *buf;
    char  buf2[64];
    int page;
    Eina_List *c;

    buf = (char *)malloc (sizeof (char) * 2 * n + 1);
    memset (buf, ' ', 2 * n);
    buf[2 * n] = '\0';
    page = epdf_index_item_page_get (document, item);
    if (page == -1)
      snprintf (buf2, 64, "no dest. page");
    else
      snprintf (buf2, 64, "page %d", page);
    printf ("%s%s (%s)\n", buf, epdf_index_item_title_get (item), buf2);
    free (buf);
    c = epdf_index_item_children_get (item);
    if (c)
      display_index (document, c, n + 1);
  }
Example #4
0
void DispBuffer::filter (string& answer)
{
    int index;

    // Fetch and buffer displays, return remainder
    switch (already_read) {
    case DisplayPart:
	answer.prepend (answer_buffer);
	answer_buffer = "";
	already_read = Null;
	// FALL THROUGH

    case Null:
	index = display_index(answer, gdb);

	if (index == 0) {
	    // We only have displays
	    display_buffer = answer;
	    already_read = DisplayFound;

	    answer = "";
	}
	else if (index > 0) {
	    // Displays are a part of the answer
	    display_buffer = answer.from(index);
	    already_read = DisplayFound;

	    answer = answer.before(index);
	}
	else {
	    // Maybe there is a display part at the end of the answer?
	    index = possible_begin_of_display (answer, gdb);

	    if (index == -1) {
		// nothing found -> answer remains unchanged
	    }
	    else {
		answer_buffer = answer.from(index);
		already_read = DisplayPart;

		answer = answer.before(index);
	    }
	}
	break;

    case DisplayFound:
	display_buffer += answer;

	answer = "";
	break;

    default:
	assert(0);		// This can't happen.
	::abort();
	break;
    }

    // std::clog << "Display buffer = " << quote(display_buffer) << "\n";
}
Example #5
0
static void
resize (int sig)
{
  finish_index ();
  endwin ();
  refresh ();
  initscr ();

  keypad (stdscr, TRUE);        /* enable keypad for use of arrow keys */
  nonl ();                      /* tell curses not to do NL->CR/NL on output */
  cbreak ();                    /* take input chars immediately */
  noecho ();

  init_index (data_path);
  display_index ();
  refresh ();
}
Example #6
0
int main(void) {
	int result = OK;

	/* get the arguments passed in the URL */
	process_cgivars();

	/* reset internal variables */
	reset_cgi_vars();

	document_header();

	/* validate arguments in URL */
	result = validate_arguments();
	if(result == ERROR) {
		document_footer();
		return ERROR;
		}

	/* read the CGI configuration file */
	result = read_cgi_config_file(get_cgi_config_location());
	if(result == ERROR) {
		printf("<P>Error: Could not open CGI configuration file '%s' for reading!</P>\n", get_cgi_config_location());
		document_footer();
		return ERROR;
		}

	/* read the main configuration file */
	result = read_main_config_file(main_config_file);
	if(result == ERROR) {
		printf("<P>Error: Could not open main configuration file '%s' for reading!</P>\n", main_config_file);
		document_footer();
		return ERROR;
		}

	/* read all object configuration data */
	result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
	if(result == ERROR) {
		printf("<P>Error: Could not read some or all object configuration data!</P>\n");
		document_footer();
		return ERROR;
		}

	/* read all status data */
	result = read_all_status_data(get_cgi_config_location(), READ_ALL_STATUS_DATA);
	if(result == ERROR) {
		printf("<P>Error: Could not read host and service status information!</P>\n");
		document_footer();
		free_memory();
		return ERROR;
		}

	/* get authentication information */
	get_authentication_information(&current_authdata);

	/* decide what to display to the user */
	if(display_type == DISPLAY_HOST && host_style == DISPLAY_HOST_SERVICES)
		display_host_services();
	else if(display_type == DISPLAY_HOST)
		display_host();
	else if(display_type == DISPLAY_SERVICE)
		display_service();
	else if(display_type == DISPLAY_HOSTGROUP && hostgroup_style == DISPLAY_HOSTGROUP_OVERVIEW)
		display_hostgroup_overview();
	else if(display_type == DISPLAY_HOSTGROUP && hostgroup_style == DISPLAY_HOSTGROUP_SUMMARY)
		display_hostgroup_summary();
	else if(display_type == DISPLAY_PING)
		display_ping();
	else if(display_type == DISPLAY_TRACEROUTE)
		display_traceroute();
	else if(display_type == DISPLAY_QUICKSTATS)
		display_quick_stats();
	else if(display_type == DISPLAY_PROCESS)
		display_process();
	else if(display_type == DISPLAY_ALL_PROBLEMS || display_type == DISPLAY_UNHANDLED_PROBLEMS)
		display_problems();
	else
		display_index();

	document_footer();

	/* free all allocated memory */
	free_memory();

	return OK;
	}
Example #7
0
// True if GDB_ANSWER contains some display
bool contains_display (const string& gdb_answer, GDBAgent *gdb)
{
    return display_index(gdb_answer, gdb) >= 0;
}
Example #8
0
int
main (int argc, char *argv[])
{
  vc_component *v = NULL;
  fpos_t *fpos = NULL;
  long pos = 0;
  FILE *fp = NULL;
  ITEM *it = NULL;
  int entry_number = 0;

  bool done = FALSE;
  int win_state = WINDOW_INDEX;
  int command = 0;

  set_defaults ();
  process_command_line_args (argc, argv);
  /*
   * process_environment_variables(); 
   * process_configuration_file(); 
   */

  signal (SIGINT, finish);      /* catch interrupt for exiting */
  signal (SIGWINCH, resize);    /* catch interrupt for resizing */
  initscr ();

  keypad (stdscr, TRUE);        /* enable keypad for use of arrow keys */
  nonl ();                      /* tell curses not to do NL->CR/NL on output */
  cbreak ();                    /* take input chars immediately */
  noecho ();

  init_index (data_path);
  set_index_help_fcn (show_index_help);
  init_view ();
  set_view_help_fcn (show_view_help);
  init_edit ();
  set_edit_help_fcn (show_edit_help);
  init_help ();

  while (!done)
    {
      switch (win_state)
        {
        case WINDOW_INDEX:

      /*-------------------
         display the index
        -------------------*/

          display_index ();
          command = process_index_commands ();

          switch (command)
            {
            case INDEX_COMMAND_VIEW:
              win_state = WINDOW_VIEW;
              break;
            case INDEX_COMMAND_RAW_VIEW:
              win_state = WINDOW_RAW_VIEW;
              break;
            case INDEX_COMMAND_EDIT:
              win_state = WINDOW_EDIT;
              break;
            case INDEX_COMMAND_ADD:
              win_state = WINDOW_ADD;
              break;
            case INDEX_COMMAND_DELETE:
              win_state = WINDOW_DELETE;
              break;
            case INDEX_COMMAND_QUIT:
              done = TRUE;
              break;
            default:
              break;
            }

          break;

        case WINDOW_RAW_VIEW:

      /*-------------------------------------------------
         view the currently selected item with the pager
        -------------------------------------------------*/

          it = get_current_item ();

          /* only display if there is an item that is selected */
          if (NULL == it)
            {
              v = NULL;
            }
          else
            {
              fpos = (fpos_t *) item_userptr (it);

              fp = fopen (data_path, "r");
              fsetpos (fp, fpos);
              v = parse_vcard_file (fp);
              fclose (fp);
            }

          if (v != NULL)
            {
              raw_view (v);
              vc_delete_deep (v);
              v = NULL;
            }

          win_state = WINDOW_INDEX;

          break;

        case WINDOW_VIEW:

      /*----------------------------------
         view the currently selected item
        ----------------------------------*/

          it = get_current_item ();

          /* only display if there is an item that is selected */
          if (NULL == it)
            {
              v = NULL;
            }
          else
            {
              fpos = (fpos_t *) item_userptr (it);

              fp = fopen (data_path, "r");
              fsetpos (fp, fpos);
              v = parse_vcard_file (fp);
              fclose (fp);
            }

          if (v != NULL)
            {
              entry_number = get_entry_number (it);
              view_vcard (entry_number, v);
              command = process_view_commands ();

              switch (command)
                {
                case VIEW_COMMAND_EDIT:
                  win_state = WINDOW_EDIT;
                  break;
                case VIEW_COMMAND_INDEX:
                  win_state = WINDOW_INDEX;
                  break;
                case VIEW_COMMAND_PREVIOUS:
                  select_previous_item ();
                  win_state = WINDOW_VIEW;
                  break;
                case VIEW_COMMAND_NEXT:
                  select_next_item ();
                  win_state = WINDOW_VIEW;
                  break;
                default:
                  break;
                }
            }
          else
            {
              win_state = WINDOW_INDEX;
            }

          vc_delete_deep (v);
          v = NULL;

          break;

        case WINDOW_EDIT:

      /*--------------
         edit a vcard
        --------------*/

          it = get_current_item ();

          /* only display if there is an item that is selected */
          if (NULL != it)
            {
              fpos = (fpos_t *) item_userptr (it);

              fp = fopen (data_path, "r");
              fsetpos (fp, fpos);
              pos = ftell (fp);
              fclose (fp);
              fp = NULL;

              if (EDIT_SUCCESSFUL == edit_entry (data_path, pos))
                {
                  refresh_index ();
                }
            }

          win_state = WINDOW_INDEX;
          break;

        case WINDOW_ADD:
          if (ADD_SUCCESSFUL == add_entry (data_path))
            {
              refresh_index ();
            }

          win_state = WINDOW_INDEX;
          break;
        case WINDOW_DELETE:

          it = get_current_item ();

          /* only delete if there is an item that is selected */
          if (NULL != it)
            {
              fpos = (fpos_t *) item_userptr (it);

              fp = fopen (data_path, "r");
              fsetpos (fp, fpos);
              pos = ftell (fp);
              fclose (fp);
              fp = NULL;

              if (DELETE_SUCCESSFUL == delete_entry (data_path, pos))
                {
                  refresh_index ();
                }
            }

          win_state = WINDOW_INDEX;
          break;
        default:
          break;
        }
    }

  finish (0);
  exit (EXIT_SUCCESS);
  return (0);
}