Пример #1
0
//--------------------------------------------------------------------------
bool idaapi menu_callback(void *ud)
{
  graph_viewer_t *gv = (graph_viewer_t *)ud;
  mutable_graph_t *g = get_viewer_graph(gv);
  int code = askbuttons_c("Circle", "Tree", "Digraph", 1, "Please select layout type");
  bgcolor_t c = 0x44FF55;
  set_node_info(g->gid, 7, &c, NULL, "Hello from plugin!");
  g->current_layout = code + 2;
  g->circle_center = point_t(200, 200);
  g->circle_radius = 200;
  g->redo_layout();
  refresh_viewer(gv);
  return true;
}
Пример #2
0
static void
getNodeList(PGconn *conn)
{
	int ii;
	PGresult *res;

	/* SQL Statement */
	static const char *STMT_GET_NODE_INFO = "SELECT NODE_NAME, NODE_TYPE, NODE_PORT, NODE_HOST FROM PGXC_NODE;";

	res = PQexec(conn, STMT_GET_NODE_INFO);
	if (res == NULL || PQresultStatus(res) != PGRES_TUPLES_OK)
	{
		fprintf(stderr, "Could not obtain node list.\n");
		PQclear(res);
		exit (1);
	}
	pgxc_clean_node_count = PQntuples(res);
	pgxc_clean_node_info = (node_info *)calloc(pgxc_clean_node_count, sizeof(node_info));
	if (pgxc_clean_node_info == NULL)
	{
		fprintf(stderr, "No more memory.\n");
		exit(1);
	}

	for (ii = 0; ii < pgxc_clean_node_count; ii++)
	{
		char *node_name;
		char *node_type_c;
		NODE_TYPE node_type;
		int  port;
		char *host;

		node_name = strdup(PQgetvalue(res, ii, 0));
		node_type_c = strdup(PQgetvalue(res, ii, 1));
		switch (node_type_c[0])
		{
			case 'C':
				/* pgxc_clean has to connect to the Coordinator */
				node_type = NODE_TYPE_COORD;
				if (strcmp(node_name, my_nodename) == 0)
					my_nodeidx = ii;
				break;
			case 'D':
				node_type = NODE_TYPE_DATANODE;
				break;
			default:
				fprintf(stderr, "Invalid catalog data (node_type), node_name: %s, node_type: %s\n", node_name, node_type_c);
				exit(1);
		}
		port = atoi(PQgetvalue(res, ii, 2));
		host = strdup(PQgetvalue(res, ii, 3));
		set_node_info(node_name, port, host, node_type, ii);

		if (node_name)
			free(node_name);
		if (node_type_c)
			free(node_type_c);
		if (host)
			free(host);
	}
	/* Check if local Coordinator has been found */
	if (my_nodeidx == -1)
	{
		fprintf(stderr, "Failed to identify the coordinator which %s is connecting to.  ", progname);
		fprintf(stderr, "Connecting to a wrong node.\n");
		exit(1);
	}
}