예제 #1
0
// Test failure of open-release-open (can't re-open a game!)
bool open_release_open() {
	SETUP_P(1,1);
	switch(child_num) {
	case 0:
	case 1:
		fd = open(get_node_name(0),O_RDWR);
		ASSERT(fd >= 0);
		ASSERT(!close(fd));
		fd = open(get_node_name(0),O_RDWR);
		ASSERT(fd < 0);
	}
	DESTROY_P();
	return TRUE;
}
예제 #2
0
파일: content.c 프로젝트: AlexSteel/wine
static ContentItem *parse_hhc(HHInfo *info, IStream *str, ContentItem *hhc_root,
        insert_type_t *insert_type)
{
    stream_t stream;
    strbuf_t node, node_name;
    ContentItem *ret = NULL, *prev = NULL;

    *insert_type = INSERT_NEXT;

    strbuf_init(&node);
    strbuf_init(&node_name);

    stream_init(&stream, str);

    while(next_node(&stream, &node)) {
        get_node_name(&node, &node_name);

        TRACE("%s\n", node.buf);

        if(!strcasecmp(node_name.buf, "ul")) {
            ContentItem *item = parse_ul(info, &stream, hhc_root);
            prev = insert_item(prev, item, INSERT_CHILD);
            if(!ret)
                ret = prev;
            *insert_type = INSERT_CHILD;
        }

        strbuf_zero(&node);
    }

    strbuf_free(&node);
    strbuf_free(&node_name);

    return ret;
}
예제 #3
0
파일: index.c 프로젝트: Barrell/wine
/* Parse the object tag corresponding to a list item.
 *
 * At this step we look for all of the "param" child tags, using this information
 * to build up the information about the list item.  When we reach the </object>
 * tag we know that we've finished parsing this list item.
 */
static IndexItem *parse_index_sitemap_object(HHInfo *info, stream_t *stream)
{
    strbuf_t node, node_name;
    IndexItem *item;

    strbuf_init(&node);
    strbuf_init(&node_name);

    item = heap_alloc_zero(sizeof(IndexItem));
    item->nItems = 0;
    item->items = heap_alloc_zero(0);
    item->itemFlags = 0x11;

    while(next_node(stream, &node)) {
        get_node_name(&node, &node_name);

        TRACE("%s\n", node.buf);

        if(!strcasecmp(node_name.buf, "param")) {
            parse_index_obj_node_param(item, node.buf, info->pCHMInfo->codePage);
        }else if(!strcasecmp(node_name.buf, "/object")) {
            break;
        }else {
            WARN("Unhandled tag! %s\n", node_name.buf);
        }

        strbuf_zero(&node);
    }

    strbuf_free(&node);
    strbuf_free(&node_name);

    return item;
}
예제 #4
0
void* games_race_func(void* arg) {
	
	ThreadParam *p = (ThreadParam*)arg;
	
	// Randomize the order of the games
	int game_numbers[GAMES_RACE_T_NUM_GAMES];
	int i;
	for(i=0; i<GAMES_RACE_T_NUM_GAMES; ++i)
		game_numbers[i] = i;
	shuffle_arr(game_numbers,GAMES_RACE_T_NUM_GAMES);
	
	// Try to open a game!
	// First game successfully opened, update it's semaphore and return.
	// If no game opened, update the last semaphore and return.
	for(i=0; i<GAMES_RACE_T_NUM_GAMES; ++i) {
		int file_d = open(get_node_name(game_numbers[i]),O_RDWR);
		if (file_d >= 0) {
			PROG_BUMP();
			sem_post(p->sem_arr+game_numbers[i]);
			close(file_d);
			return NULL;
		}
	}
	PROG_BUMP();
	sem_post(p->sem_arr+GAMES_RACE_T_NUM_GAMES);
	return NULL;
}
예제 #5
0
static 
int join_the_election(zhandle_t *zkhandle, char node[], struct watch_func_para_t *para) 
{
    char buf[512] = {0};
    int ret;

    ret = zoo_create(zkhandle,
                        "/election/ccs-member", 
                        "hello", 
                        5,
                        &ZOO_OPEN_ACL_UNSAFE,  /* a completely open ACL */
                        ZOO_SEQUENCE|ZOO_EPHEMERAL,
                        buf, 
                        sizeof(buf)-1);
    if (ret) {
        fprintf(stderr, "zoo_create error [%d]\n", ret);
        return ret;
    }

    get_node_name(buf, node);

    struct Stat stat;
    memset(&stat, 0, sizeof(stat));
    struct String_vector strings;
    memset(para, 0, sizeof(*para));
    para->zkhandle = zkhandle;
    strcpy(para->node, node);
    ret = zoo_wget_children2(zkhandle, "/election", ccs_children_watcher, para, &strings, &stat);
    if (ret) {
        fprintf(stderr, "zoo_wget_children2 error [%d]\n", ret);
        return ret;
    }

    return ret;
}
예제 #6
0
// Same thing, with threads
void* two_releases_func(void* arg) {
	ThreadParam *tp = (ThreadParam*)arg;
	int fd = open(get_node_name(0),O_RDWR);
	if(fd < 0) sem_post(tp->sem_arr);				// Did I fail to open?
	else if(!close(fd)) sem_post(tp->sem_arr+1);	// If not, did I fail to close?
	else if(close(fd)) sem_post(tp->sem_arr+2);		// If not, can I close again?
	return NULL;
}
예제 #7
0
파일: cluster.c 프로젝트: aspiers/pacemaker
const char *
get_local_node_name(void)
{
    static char *name = NULL;

    if(name) {
        return name;
    }
    name = get_node_name(0);
    return name;
}
예제 #8
0
void* open_race_thread_func(void* arg) {
	ThreadParam *tp = (ThreadParam*)arg;
	int file_d = open(get_node_name(0),O_RDWR);
	if (file_d >= 0)
		sem_wait(tp->sem_arr);
	sem_post(tp->sem_arr+1);	// Signal father
	sem_wait(tp->sem_arr+2);	// Wait for father
	if (file_d >= 0)			// If I've open()ed, now I need to close()
		close(file_d);
	return NULL;
}
예제 #9
0
// Make sure the first one is the white player
bool first_open_is_white() {
	
	// This may sometimes succeed, so try this many times
	//PRINT("in first_open_is_white()\n");
	int i, trials = 50;
	for (i=0; i<trials; ++i) {
		int res;
		//printf("in loop i = %d\n",i);
		UPDATE_PROG(i*100/trials);
		
		SETUP_P(1,1);
		switch(child_num) {
		case 0:
			//printf("case 0\n");
			fd = open(get_node_name(0),O_RDWR);
			//printf("case 0 open succeeded\n");
			ASSERT(fd >= 0);
			res = ioctl(fd,SNAKE_GET_COLOR,NULL);
			//printf("case 0 ioctl res = %d\n", res);
			ASSERT(res == WHITE_COLOR);
			//printf("case 0 after ioctl\n");
			close(fd);
			//printf("end of case 0\n");
			break;
		case 1:
			//printf("case 1\n");
			usleep(10000);	// 10ms, should be enough for father to be first to open
			//printf("case 1 after usleep\n");
			fd = open(get_node_name(0),O_RDWR);
			//printf("case 1 open succeeded\n");
			ASSERT(fd >= 0);
			usleep(10000);	// To prevent closing of a game before the white player can read the color
			PRINT("Son closing\n");
			close(fd);
			break;
		}
		DESTROY_P();
	}
	
	return TRUE;
}
예제 #10
0
// Test simple open and release.
// Make sure two processes do it, otherwise one will be stuck forever...
// calling open() blocks the process
bool open_release_simple() {
	SETUP_P(1,1);
	switch(child_num) {
	case 0:
	case 1:
		fd = open(get_node_name(0),O_RDWR);
		//printf("fd = %d", fd);
		ASSERT(fd >= 0);
		ASSERT(!close(fd));
	}
	DESTROY_P();
	return TRUE;
}
예제 #11
0
파일: content.c 프로젝트: AlexSteel/wine
static ContentItem *parse_sitemap_object(HHInfo *info, stream_t *stream, ContentItem *hhc_root,
        insert_type_t *insert_type)
{
    strbuf_t node, node_name;
    ContentItem *item;

    *insert_type = INSERT_NEXT;

    strbuf_init(&node);
    strbuf_init(&node_name);

    item = heap_alloc_zero(sizeof(ContentItem));

    while(next_node(stream, &node)) {
        get_node_name(&node, &node_name);

        TRACE("%s\n", node.buf);

        if(!strcasecmp(node_name.buf, "/object"))
            break;
        if(!strcasecmp(node_name.buf, "param"))
            parse_obj_node_param(item, hhc_root, node.buf, info->pCHMInfo->codePage);

        strbuf_zero(&node);
    }

    strbuf_free(&node);
    strbuf_free(&node_name);

    if(item->merge.chm_index) {
        IStream *merge_stream;

        merge_stream = GetChmStream(info->pCHMInfo, item->merge.chm_file, &item->merge);
        if(merge_stream) {
            item->child = parse_hhc(info, merge_stream, hhc_root, insert_type);
            IStream_Release(merge_stream);
        }else {
            WARN("Could not get %s::%s stream\n", debugstr_w(item->merge.chm_file),
                 debugstr_w(item->merge.chm_file));

            if(!item->name) {
                free_content_item(item);
                item = NULL;
            }
        }

    }

    return item;
}
예제 #12
0
파일: index.c 프로젝트: Barrell/wine
/* Parse the HTML Help page corresponding to all of the Index items.
 *
 * At this high-level stage we locate out each HTML list item tag.
 * Since there is no end-tag for the <LI> item, we must hope that
 * the <LI> entry is parsed correctly or tags might get lost.
 *
 * Within each entry it is also possible to encounter an additional
 * <UL> tag.  When this occurs the tag indicates that the topics
 * contained within it are related to the parent <LI> topic and
 * should be inset by an indent.
 */
static void parse_hhindex(HHInfo *info, IStream *str, IndexItem *item)
{
    stream_t stream;
    strbuf_t node, node_name;
    int indent_level = -1;

    strbuf_init(&node);
    strbuf_init(&node_name);

    stream_init(&stream, str);

    while(next_node(&stream, &node)) {
        get_node_name(&node, &node_name);

        TRACE("%s\n", node.buf);

        if(!strcasecmp(node_name.buf, "li")) {
            IndexItem *new_item;

            new_item = parse_li(info, &stream);
            if(new_item && item->keyword && strcmpW(new_item->keyword, item->keyword) == 0) {
                int num_items = item->nItems;

                item_realloc(item, num_items+1);
                memcpy(&item->items[num_items], &new_item->items[0], sizeof(IndexSubItem));
                heap_free(new_item->keyword);
                heap_free(new_item->items);
                heap_free(new_item);
            } else if(new_item) {
                item->next = new_item;
                item->next->merge = item->merge;
                item = item->next;
                item->indentLevel = indent_level;
            }
        }else if(!strcasecmp(node_name.buf, "ul")) {
            indent_level++;
        }else if(!strcasecmp(node_name.buf, "/ul")) {
            indent_level--;
        }else {
            WARN("Unhandled tag! %s\n", node_name.buf);
        }

        strbuf_zero(&node);
    }

    strbuf_free(&node);
    strbuf_free(&node_name);
}
예제 #13
0
bool games_race_processes() {
	
	
	int j;
	for(j=0; j<GAMES_RACE_NUM_TRIES; ++j) {
		
		UPDATE_PROG(j*100/GAMES_RACE_NUM_TRIES);
		
		SETUP_P(GAMES_RACE_T_NUM_GAMES,GAMES_RACE_T_NUM_PROCS);
		if (child_num) {
		
			// Randomize the order of the games
			int game_numbers[GAMES_RACE_T_NUM_GAMES];
			int i;
			for(i=0; i<GAMES_RACE_T_NUM_GAMES; ++i)
				game_numbers[i] = i;
			shuffle_arr(game_numbers,GAMES_RACE_T_NUM_GAMES);
			
			// Try to open a game!
			// First game successfully opened, exit() with it's index.
			// If no game opened, exit() with the last index.
			for(i=0; i<GAMES_RACE_T_NUM_GAMES; ++i) {
				int file_d = open(get_node_name(game_numbers[i]),O_RDWR);
				if (file_d >= 0) {
					close(file_d);
					exit(game_numbers[i]);
				}
			}
			exit(GAMES_RACE_T_NUM_GAMES);
		}
		else {
			int status, results[GAMES_RACE_T_NUM_GAMES+1] = { 0 };
			while(wait(&status) != -1) {
				results[WEXITSTATUS(status)]++;
			}
			int i;
			for (i=0; i<GAMES_RACE_T_NUM_GAMES; ++i)
				ASSERT(results[i] == 2);
			ASSERT(results[GAMES_RACE_T_NUM_GAMES] == GAMES_RACE_T_NUM_PROCS-2*GAMES_RACE_T_NUM_GAMES);
		}
		DESTROY_P();
	}
	return TRUE;
}
예제 #14
0
파일: content.c 프로젝트: AlexSteel/wine
static ContentItem *parse_ul(HHInfo *info, stream_t *stream, ContentItem *hhc_root)
{
    strbuf_t node, node_name;
    ContentItem *ret = NULL, *prev = NULL, *new_item = NULL;
    insert_type_t it;

    strbuf_init(&node);
    strbuf_init(&node_name);

    while(next_node(stream, &node)) {
        get_node_name(&node, &node_name);

        TRACE("%s\n", node.buf);

        if(!strcasecmp(node_name.buf, "object")) {
            const char *ptr;
            int len;

            static const char sz_text_sitemap[] = "text/sitemap";

            ptr = get_attr(node.buf, "type", &len);

            if(ptr && len == sizeof(sz_text_sitemap)-1
               && !memcmp(ptr, sz_text_sitemap, len)) {
                new_item = parse_sitemap_object(info, stream, hhc_root, &it);
                prev = insert_item(prev, new_item, it);
                if(!ret)
                    ret = prev;
            }
        }else if(!strcasecmp(node_name.buf, "ul")) {
            new_item = parse_ul(info, stream, hhc_root);
            insert_item(prev, new_item, INSERT_CHILD);
        }else if(!strcasecmp(node_name.buf, "/ul")) {
            break;
        }

        strbuf_zero(&node);
    }

    strbuf_free(&node);
    strbuf_free(&node_name);

    return ret;
}
예제 #15
0
gboolean
init_cs_connection_once(crm_cluster_t * cluster)
{
    const char *uuid = NULL;
    crm_node_t *peer = NULL;
    enum cluster_type_e stack = get_cluster_type();

    crm_peer_init();

    /* Here we just initialize comms */
    if (stack != pcmk_cluster_corosync) {
        crm_err("Invalid cluster type: %s (%d)", name_for_cluster_type(stack), stack);
        return FALSE;
    }

    if (cluster_connect_cpg(cluster) == FALSE) {
        return FALSE;
    }
    crm_info("Connection to '%s': established", name_for_cluster_type(stack));

    cluster->nodeid = get_local_nodeid(0);
    if(cluster->nodeid == 0) {
        crm_err("Could not establish local nodeid");
        return FALSE;
    }

    cluster->uname = get_node_name(0);
    if(cluster->uname == NULL) {
        crm_err("Could not establish local node name");
        return FALSE;
    }

    /* Ensure the local node always exists */
    peer = crm_get_peer(cluster->nodeid, cluster->uname);
    uuid = get_corosync_uuid(peer);

    if(uuid) {
        cluster->uuid = strdup(uuid);
    }

    return TRUE;
}
예제 #16
0
파일: index.c 프로젝트: Barrell/wine
/* Parse the HTML list item node corresponding to a specific help entry.
 *
 * At this stage we look for the only child tag we expect to find under
 * the list item: the <OBJECT> tag.  We also only expect to find object
 * tags with the "type" attribute set to "text/sitemap".
 */
static IndexItem *parse_li(HHInfo *info, stream_t *stream)
{
    strbuf_t node, node_name;
    IndexItem *ret = NULL;

    strbuf_init(&node);
    strbuf_init(&node_name);

    while(next_node(stream, &node)) {
        get_node_name(&node, &node_name);

        TRACE("%s\n", node.buf);

        if(!strcasecmp(node_name.buf, "object")) {
            const char *ptr;
            int len;

            static const char sz_text_sitemap[] = "text/sitemap";

            ptr = get_attr(node.buf, "type", &len);

            if(ptr && len == sizeof(sz_text_sitemap)-1
               && !memcmp(ptr, sz_text_sitemap, len)) {
                ret = parse_index_sitemap_object(info, stream);
                break;
            }
        }else {
            WARN("Unhandled tag! %s\n", node_name.buf);
        }

        strbuf_zero(&node);
    }
    if(!ret)
        FIXME("Failed to parse <li> tag!\n");

    strbuf_free(&node);
    strbuf_free(&node_name);

    return ret;
}
예제 #17
0
파일: runtime.c 프로젝트: stonegao/mirb
rt_value rt_eval(rt_value self, const char *input, const char *filename)
{
	struct compiler *compiler = compiler_create(input, filename);

	struct node* expression = parse_main(compiler);

	if(compiler->err_count != 0)
		return RT_NIL;

	extern rt_value get_node_name(struct node *node);

	#ifdef DEBUG
		printf("Tree: %s\n", rt_string_to_cstr(get_node_name(expression)));
	#endif

	struct block *code_block = gen_block(expression);

	rt_compiled_block_t compiled_block = compile_block(code_block);

	compiler_destroy(compiler);

	return compiled_block(self, RT_NIL, 0, 0);
}
예제 #18
0
/*!
 * \internal
 * \brief Respond to a client peer-remove request (i.e. propagate to all peers)
 *
 * \param[in] client_name Name of client that made request (for log messages)
 * \param[in] xml         Root of request XML
 *
 * \return void
 */
void
attrd_client_peer_remove(const char *client_name, xmlNode *xml)
{
    // Host and ID are not used in combination, rather host has precedence
    const char *host = crm_element_value(xml, F_ATTRD_HOST);
    char *host_alloc = NULL;

    if (host == NULL) {
        int nodeid;

        crm_element_value_int(xml, F_ATTRD_HOST_ID, &nodeid);
        if (nodeid > 0) {
            crm_node_t *node = crm_find_peer(nodeid, NULL);
            char *host_alloc = NULL;

            if (node && node->uname) {
                // Use cached name if available
                host = node->uname;
            } else {
                // Otherwise ask cluster layer
                host_alloc = get_node_name(nodeid);
                host = host_alloc;
            }
            crm_xml_add(xml, F_ATTRD_HOST, host);
        }
    }

    if (host) {
        crm_info("Client %s is requesting all values for %s be removed",
                 client_name, host);
        send_attrd_message(NULL, xml); /* ends up at attrd_peer_message() */
        free(host_alloc);
    } else {
        crm_info("Ignoring request by client %s to remove all peer values without specifying peer",
                 client_name);
    }
}
예제 #19
0
파일: workfile.c 프로젝트: andreiw/polaris
/*
 * Do a depth-first walk of a device tree and
 * return the first node with the matching model.
 */
static Prom_node *
dev_find_node_by_compat(Prom_node *root, char *compat)
{
	Prom_node	*node;
	char		*compatible;
	char		*name;

	if (root == NULL)
		return (NULL);

	if (compat == NULL)
		return (NULL);

	name = get_node_name(root);
	if (name == NULL)
		name = "";

	compatible = (char *)get_prop_val(find_prop(root, "compatible"));

	if (compatible == NULL)
	    return (NULL);

	if ((strcmp(name, "pci") == 0) && (compatible != NULL) &&
	    (strcmp(compatible, compat) == 0)) {
		return (root); /* found a match */
	}

	/* look at your children first */
	if ((node = dev_find_node_by_compat(root->child, compat)) != NULL)
	    return (node);

	/* now look at your siblings */
	if ((node = dev_find_node_by_compat(root->sibling, compat)) != NULL)
	    return (node);

	return (NULL);  /* not found */
}
예제 #20
0
// draws the tree in OpenGL trying to spread the nodes over the screen
void Node::draw_subtree(GLfloat parent_x, GLfloat parent_y, int number_children,
                        GLfloat parent_space) {
  GLfloat separation = parent_space / (number_children);

  // std::cout << "depth:   " << depth_ << "    separation:   " << separation
  //           << "    parent space:   " << parent_space
  //           << "    number of children:   " << number_children << std::endl;

  GLfloat x = (GLfloat)(
      parent_x +
      (((GLfloat)children_number_) - ((GLfloat)number_children - 1) / 2) *
          separation);

  GLfloat y = (GLfloat)(parent_y - SPACE_HEIGHT);

  draw_node(x, y, this->get_node_type());
  draw_connector(parent_x, parent_y, x, y);
  draw_status(x, y, node_status_);
  draw_string(x - CURSOR_WIDTH, y + 2.1 * CURSOR_WIDTH,
              get_node_name().c_str());

  if (this->get_node_type() == ACTION)
    draw_string(x - CURSOR_WIDTH, y + 2.2 * NODE_WIDTH,
                get_ros_node_name().c_str());

  if (highlighted_)
    draw_cursor(x, y);

  if (number_children_ > 0) {
    first_child_->draw_subtree(x, y, number_children_, separation);
  }
  if (next_brother_ != NULL) {
    next_brother_->draw_subtree(parent_x, parent_y, number_children,
                                parent_space);
  }
}
예제 #21
0
int zkServer::zkCreate(const char *data, char *path_buffer, int path_buffer_len)
{
    int ret = 0;
    if(NULL == zkhandle)
    {
        ERROR_PRINT(" zkhandle is NULL ", "");
        return -1;
    }

    DEBUG_PRINT("root:%s server_name:%s prefix:%s ", root.c_str(), server_name.c_str(),prefix.c_str());
    ret = zoo_create(zkhandle, std::string(root + server_name + prefix).c_str(), data, strlen(data), 
            &ZOO_OPEN_ACL_UNSAFE, 
            ZOO_EPHEMERAL|ZOO_SEQUENCE, 
            path_buffer, 
            path_buffer_len);

    if (ret) {
        ERROR_PRINT(" error %d of %s ", ret, "create node");
	return -2;
    }
    else 
    {
        char node[PATH_BUFFER_LEN] = {0};
        get_node_name(path_buffer, node);
        node_name = std::string(node);
        DEBUG_PRINT("path_buffer:%s, node_name:%s", path_buffer, node_name.c_str());
        
        /* get data from znode */
        char node_value[PATH_BUFFER_LEN] = {0};
        int value_len = PATH_BUFFER_LEN;
        ret = zoo_get(zkhandle, path_buffer, 0, node_value, &value_len, NULL);
        DEBUG_PRINT("node data:%s node_name:%s", node_value, node_name.c_str());
    }

    return ret;
}
예제 #22
0
/* Search the CHM storage stream (an HTML file) for the requested text.
 *
 * Before searching the HTML file all HTML tags are removed so that only
 * the content of the document is scanned.  If the search string is found
 * then the title of the document is returned.
 */
static WCHAR *SearchCHM_File(IStorage *pStorage, const WCHAR *file, const char *needle)
{
    char *buffer = heap_alloc(BLOCK_SIZE);
    strbuf_t content, node, node_name;
    IStream *temp_stream = NULL;
    DWORD i, buffer_size = 0;
    WCHAR *title = NULL;
    BOOL found = FALSE;
    stream_t stream;
    HRESULT hres;

    hres = IStorage_OpenStream(pStorage, file, NULL, STGM_READ, 0, &temp_stream);
    if(FAILED(hres)) {
        FIXME("Could not open '%s' stream: %08x\n", debugstr_w(file), hres);
        goto cleanup;
    }

    strbuf_init(&node);
    strbuf_init(&content);
    strbuf_init(&node_name);

    stream_init(&stream, temp_stream);

    /* Remove all HTML formatting and record the title */
    while(next_node(&stream, &node)) {
        get_node_name(&node, &node_name);

        if(next_content(&stream, &content) && content.len > 1)
        {
            char *text = &content.buf[1];
            int textlen = content.len-1;

            if(!strcasecmp(node_name.buf, "title"))
            {
                int wlen = MultiByteToWideChar(CP_ACP, 0, text, textlen, NULL, 0);
                title = heap_alloc((wlen+1)*sizeof(WCHAR));
                MultiByteToWideChar(CP_ACP, 0, text, textlen, title, wlen);
                title[wlen] = 0;
            }

            buffer = heap_realloc(buffer, buffer_size + textlen + 1);
            memcpy(&buffer[buffer_size], text, textlen);
            buffer[buffer_size + textlen] = '\0';
            buffer_size += textlen;
        }

        strbuf_zero(&node);
        strbuf_zero(&content);
    }

    /* Convert the buffer to lower case for comparison against the
     * requested text (already in lower case).
     */
    for(i=0;i<buffer_size;i++)
        buffer[i] = tolower(buffer[i]);

    /* Search the decoded buffer for the requested text */
    if(strstr(buffer, needle))
        found = TRUE;

    strbuf_free(&node);
    strbuf_free(&content);
    strbuf_free(&node_name);

cleanup:
    heap_free(buffer);
    if(temp_stream)
        IStream_Release(temp_stream);
    if(!found)
    {
        heap_free(title);
        return NULL;
    }
    return title;
}
예제 #23
0
파일: ugraph.cpp 프로젝트: nealey/vera
//--------------------------------------------------------------------------
static int idaapi callback(void *, int code, va_list va)
{
  int result = 0;
  switch ( code )
  {
    case grcode_calculating_layout:
                              // calculating user-defined graph layout
                              // in: mutable_graph_t *g
                              // out: 0-not implemented
                              //      1-graph layout calculated by the plugin
      msg("calculating graph layout...\n");
      break;

    case grcode_changed_current:
                              // a new graph node became the current node
                              // in:  graph_viewer_t *gv
                              //      int curnode
                              // out: 0-ok, 1-forbid to change the current node
     {
       graph_viewer_t *v = va_arg(va, graph_viewer_t *);
       int curnode       = va_argi(va, int);
       msg("%p: current node becomes %d\n", v, curnode);
     }
     break;

    case grcode_clicked:      // a graph has been clicked
                              // in:  graph_viewer_t *gv
                              //      selection_item_t *current_item
                              // out: 0-ok, 1-ignore click
     {
       /*graph_viewer_t *v   =*/ va_arg(va, graph_viewer_t *);
       va_arg(va, selection_item_t *);
       graph_item_t *m = va_arg(va, graph_item_t *);
       msg("clicked on ");
       switch ( m->type )
       {
         case git_none:
           msg("background\n");
           break;
         case git_edge:
           msg("edge (%d, %d)\n", m->e.src, m->e.dst);
           break;
         case git_node:
           msg("node %d\n", m->n);
           break;
         case git_tool:
           msg("toolbutton %d\n", m->b);
           break;
         case git_text:
           msg("text (x,y)=(%d,%d)\n", m->p.x, m->p.y);
           break;
         case git_elp:
           msg("edge layout point (%d, %d) #%d\n", m->elp.e.src, m->elp.e.dst, m->elp.pidx);
           break;
       }
     }
     break;

    case grcode_dblclicked:   // a graph node has been double clicked
                              // in:  graph_viewer_t *gv
                              //      selection_item_t *current_item
                              // out: 0-ok, 1-ignore click
     {
       graph_viewer_t *v   = va_arg(va, graph_viewer_t *);
       selection_item_t *s = va_arg(va, selection_item_t *);
       msg("%p: %sclicked on ", v, code == grcode_clicked ? "" : "dbl");
       if ( s == NULL )
         msg("background\n");
       else if ( s->is_node )
         msg("node %d\n", s->node);
       else
         msg("edge (%d, %d) layout point #%d\n", s->elp.e.src, s->elp.e.dst, s->elp.pidx);
     }
     break;

    case grcode_creating_group:
                              // a group is being created
                              // in:  mutable_graph_t *g
                              //      intset_t *nodes
                              // out: 0-ok, 1-forbid group creation
     {
       mutable_graph_t *g = va_arg(va, mutable_graph_t *);
       intset_t &nodes    = *va_arg(va, intset_t *);
       msg("%p: creating group", g);
       for ( intset_t::iterator p=nodes.begin(); p != nodes.end(); ++p )
         msg(" %d", *p);
       msg("...\n");
     }
     break;

    case grcode_deleting_group:
                              // a group is being deleted
                              // in:  mutable_graph_t *g
                              //      int old_group
                              // out: 0-ok, 1-forbid group deletion
     {
       mutable_graph_t *g = va_arg(va, mutable_graph_t *);
       int group          = va_argi(va, int);
       msg("%p: deleting group %d\n", g, group);
     }
     break;

    case grcode_group_visibility:
                              // a group is being collapsed/uncollapsed
                              // in:  mutable_graph_t *g
                              //      int group
                              //      bool expand
                              // out: 0-ok, 1-forbid group modification
     {
       mutable_graph_t *g = va_arg(va, mutable_graph_t *);
       int group          = va_argi(va, int);
       bool expand        = va_argi(va, bool);
       msg("%p: %scollapsing group %d\n", g, expand ? "un" : "", group);
     }
     break;

    case grcode_gotfocus:     // a graph viewer got focus
                              // in:  graph_viewer_t *gv
                              // out: must return 0
     {
       graph_viewer_t *g = va_arg(va, graph_viewer_t *);
       msg("%p: got focus\n", g);
     }
     break;

    case grcode_lostfocus:    // a graph viewer lost focus
                              // in:  graph_viewer_t *gv
                              // out: must return 0
     {
       graph_viewer_t *g = va_arg(va, graph_viewer_t *);
       msg("%p: lost focus\n", g);
     }
     break;

    case grcode_user_refresh: // refresh user-defined graph nodes and edges
                              // in:  mutable_graph_t *g
                              // out: success
     {
       mutable_graph_t *g = va_arg(va, mutable_graph_t *);
       msg("%p: refresh\n", g);
       // our graph is like this:
       //  0 -> 1 -> 2
       //       \-> 3 -> 4 -> 5 -> 6
       //           ^        /
       //           \-------/
       if ( g->empty() )
         g->resize(7);
       g->add_edge(0, 1, NULL);
       g->add_edge(1, 2, NULL);
       g->add_edge(1, 3, NULL);
       g->add_edge(3, 4, NULL);
       g->add_edge(4, 5, NULL);
       g->add_edge(5, 3, NULL);
       g->add_edge(5, 6, NULL);
       result = true;
     }
     break;

    case grcode_user_gentext: // generate text for user-defined graph nodes
                              // in:  mutable_graph_t *g
                              // out: must return 0
     {
       mutable_graph_t *g = va_arg(va, mutable_graph_t *);
       msg("%p: generate text for graph nodes\n", g);
       graph_text.resize(g->size());
       for ( node_iterator p=g->begin(); p != g->end(); ++p )
       {
         int n = *p;
         graph_text[n] = get_node_name(n);
       }
       result = true;
     }
     break;

    case grcode_user_text:    // retrieve text for user-defined graph node
                              // in:  mutable_graph_t *g
                              //      int node
                              //      const char **result
                              //      bgcolor_t *bg_color (maybe NULL)
                              // out: must return 0, result must be filled
                              // NB: do not use anything calling GDI!
     {
       mutable_graph_t *g = va_arg(va, mutable_graph_t *);
       int node           = va_arg(va, int);
       const char **text  = va_arg(va, const char **);
       bgcolor_t *bgcolor = va_arg(va, bgcolor_t *);
       *text = graph_text[node].c_str();
       if ( bgcolor != NULL )
         *bgcolor = DEFCOLOR;
       result = true;
       qnotused(g);
     }
     break;


    case grcode_user_size:    // calculate node size for user-defined graph
                              // in:  mutable_graph_t *g
                              //      int node
                              //      int *cx
                              //      int *cy
                              // out: 0-did not calculate, ida will use node text size
                              //      1-calculated. ida will add node title to the size
     msg("calc node size - not implemented\n");
     // ida will calculate the node size based on the node text
     break;

    case grcode_user_title:   // render node title of a user-defined graph
                              // in:  mutable_graph_t *g
                              //      int node
                              //      rect_t *title_rect
                              //      int title_bg_color
                              //      HDC dc
                              // out: 0-did not render, ida will fill it with title_bg_color
                              //      1-rendered node title
     // ida will draw the node title itself
     break;

    case grcode_user_draw:    // render node of a user-defined graph
                              // in:  mutable_graph_t *g
                              //      int node
                              //      rect_t *node_rect
                              //      HDC dc
                              // out: 0-not rendered, 1-rendered
                              // NB: draw only on the specified DC and nowhere else!
     // ida will draw the node text itself
     break;

    case grcode_user_hint:    // retrieve hint for the user-defined graph
                              // in:  mutable_graph_t *g
                              //      int mousenode
                              //      int mouseedge_src
                              //      int mouseedge_dst
                              //      char **hint
                              // 'hint' must be allocated by qalloc() or qstrdup()
                              // out: 0-use default hint, 1-use proposed hint
     {
       mutable_graph_t *g = va_arg(va, mutable_graph_t *);
       int mousenode      = va_argi(va, int);
       int mouseedge_src  = va_argi(va, int);
       int mouseedge_dst  = va_argi(va, int);
       char **hint        = va_arg(va, char **);
       char buf[MAXSTR];
       buf[0] = '\0';
       if ( mousenode != -1 )
         qsnprintf(buf, sizeof(buf), "My fancy hint for node %d", mousenode);
       else if ( mouseedge_src != -1 )
         qsnprintf(buf, sizeof(buf), "Hovering on (%d,%d)", mouseedge_src, mouseedge_dst);
       if ( buf[0] != '\0' )
         *hint = qstrdup(buf);
       result = true; // use our hint
       qnotused(g);
     }
     break;
  }
  return result;
}
예제 #24
0
CL_DomString CL_DomElement::get_tag_name() const
{
	return get_node_name();
}
예제 #25
0
void
llvm_stmt(Printer& p, T const* s)
{
    error(s->location(), "codegen for {} not implemneted", get_node_name(s));
}
예제 #26
0
/*
 * display_pci
 * Display all the PCI IO cards on this board.
 */
void
display_pci(Board_node *board)
{
	struct io_card *card_list = NULL;
	struct io_card card;
	void *value;
	Prom_node *pci;
	Prom_node *card_node;
	Prom_node *pci_bridge_node = NULL;
	char	*slot_name_arr[MAX_SLOTS_PER_IO_BD] = {NULL};
	char	*slot_name = NULL;
	int	slot_name_bits;
	int	slot_name_offset = 0;
	char	*child_name;
	char	*name, *type;
	char	buf[MAXSTRLEN];
	int	*int_val;
	int	pci_bus;
	int	pci_bridge = 0;
	int	pci_bridge_dev_no;
	int	child_dev_no;
	int	i;
	int	portid;
	int	version, *pversion;

	if (board == NULL)
		return;

	/* Initialize all the common information */
	card.display = TRUE;
	card.board = board->board_num;
	card.node_id = board->node_id;

	/*
	 * Search for each schizo, then find/display all nodes under
	 * each schizo node found.  Since the model property "SUNW,schizo"
	 * is not supported on Starcat, we must match on the compatible
	 * property "pci108e,8001".
	 */
	for (pci = dev_find_node_by_compatible(board->nodes, SCHIZO_COMPATIBLE);
	    pci != NULL;
	    pci = dev_next_node_by_compatible(pci, SCHIZO_COMPATIBLE)) {

		/* set max freq for this board */
		board_bus_max_freq = DEFAULT_MAX_FREQ;
		/*
		 * Find out if this is a PCI or cPCI IO Board.
		 * If "enum-impl" property exists in pci node => cPCI.
		 */
		value = get_prop_val(find_prop(pci, "enum-impl"));
		if (value == NULL) {
			(void) sprintf(card.bus_type, "PCI");
		} else {
			(void) sprintf(card.bus_type, "cPCI");
		}

		if (strstr((char *)get_prop_val(
		    find_prop(pci, "compatible")), XMITS_COMPATIBLE)) {
			sprintf(card.notes, "%s", XMITS_COMPATIBLE);
			/*
			 * With XMITS 3.X and PCI-X mode, the bus speed
			 * can be higher than 66MHZ.
			 */
			value = (int *)get_prop_val
			    (find_prop(pci, "module-revision#"));
			if (value) {
				pversion = (int *)value;
				version = *pversion;
				if (version >= 4)
					board_bus_max_freq = PCIX_MAX_FREQ;
			}
		} else if (strstr((char *)get_prop_val(
		    find_prop(pci, "compatible")), SCHIZO_COMPATIBLE))
			sprintf(card.notes, "%s", SCHIZO_COMPATIBLE);
		else
			sprintf(card.notes, " ");

		/*
		 * Get slot-names property from parent node and
		 * store the individual slot names in an array.
		 * This is more general than Starcat requires, but
		 * it is correct, according to the slot-names property.
		 */
		value = (char *)get_prop_val(find_prop(pci, "slot-names"));
		if (value == NULL) {
			/*
			 * No slot_names property.  This could be an Xmits
			 * card, so check the child node for slot-names property
			 */
			value = (char *)get_prop_val(
			    find_prop(pci->child, "slot-names"));
		}

		if (value != NULL) {
			/* Get the 4 byte bitmask and pointer to first name */
			slot_name_bits = *(int *)value;
			if (slot_name_bits > 0)
				slot_name_offset = slot_name_bits - 1;
			slot_name = (char *)value + sizeof (int);

			for (i = 0; i < MAX_SLOTS_PER_IO_BD; i++) {
				if (! (slot_name_bits & (1 << i))) {
					slot_name_arr[i] = (char *)NULL;
					continue;
				}

				/*
				 * Save the name pointer into the array
				 * and advance it past the end of this
				 * slot name
				 */
				slot_name_arr[i] = slot_name;
				slot_name += strlen(slot_name) + 1;
			}
			slot_name = (char *)NULL;
		}

		/*
		 * Search for Children of this node ie. Cards.
		 * Note: any of these cards can be a pci-bridge
		 *	that itself has children. If we find a
		 *	pci-bridge we need to handle it specially.
		 */
		card_node = pci->child;
		while (card_node != NULL) {
			pci_bridge = 0;

			/* If it doesn't have a name, skip it */
			name = (char *)get_prop_val(
			    find_prop(card_node, "name"));
			if (name == NULL) {
				card_node = card_node->sibling;
				continue;
			}

			/*
			 * get dev# and func# for this card from the
			 * 'reg' property.
			 */
			int_val = (int *)get_prop_val(
			    find_prop(card_node, "reg"));
			if (int_val != NULL) {
				card.dev_no = (((*int_val) & 0xF800) >> 11);
				card.func_no = (((*int_val) & 0x700) >> 8);
			} else {
				card.dev_no = -1;
				card.func_no = -1;
			}

			/*
			 * If this is a pci-bridge, then store it's dev#
			 * as its children nodes need this to get their slot#.
			 * We set the pci_bridge flag so that we know we are
			 * looking at a pci-bridge node. This flag gets reset
			 * every time we enter this while loop.
			 */

			/*
			 * Check for a PCI-PCI Bridge for PCI and cPCI
			 * IO Boards using the name and type properties.
			 */
			type = (char *)get_prop_val(
			    find_prop(card_node, "device_type"));
			if ((type != NULL) &&
			    (strncmp(name, "pci", 3) == 0) &&
			    (strcmp(type, "pci") == 0)) {
				pci_bridge_dev_no = card.dev_no;
				pci_bridge_node = card_node;
				pci_bridge = TRUE;
			}

			/*
			 * Get slot-names property from slot_names_arr.
			 * If we are the child of a pci_bridge we use the
			 * dev# of the pci_bridge as an index to get
			 * the slot number. We know that we are a child of
			 * a pci-bridge if our parent is the same as the last
			 * pci_bridge node found above.
			 */
			if (card.dev_no != -1) {
				/*
				 * We compare this card's parent node with the
				 * pci_bridge_node to see if it's a child.
				 */
				if (card_node->parent == pci_bridge_node) {
					/* use dev_no of pci_bridge */
					child_dev_no = pci_bridge_dev_no - 1;
				} else {
					/* use card's own dev_no */
					child_dev_no = card.dev_no - 1;
				}

				if (child_dev_no < MAX_SLOTS_PER_IO_BD &&
				    child_dev_no >= 0 &&
				    slot_name_arr
				    [child_dev_no + slot_name_offset] != NULL) {

					slot_name = slot_name_arr[
					    child_dev_no + slot_name_offset];
				} else
					slot_name = (char *)NULL;

				if (slot_name != NULL && slot_name[0] != '\0') {
					(void) sprintf(card.slot_str, "%s",
					    slot_name);
				} else {
					(void) sprintf(card.slot_str, "-");
				}
			} else {
				(void) sprintf(card.slot_str, "%c", '-');
			}

			/*
			 * Get the portid of the schizo that this card
			 * lives under.
			 */
			portid = -1;
			value = get_prop_val(find_prop(pci, "portid"));
			if (value != NULL) {
				portid = *(int *)value;
			}
			card.schizo_portid = portid;

#ifdef	DEBUG
			(void) sprintf(card.notes, "%s portid [%d]"
			    " dev_no [%d] slot_name[%s] name_bits[%#x]",
			    card.notes, portid, card.dev_no,
			    ((slot_name != NULL) ? slot_name : "NULL"),
			    slot_name_bits);
#endif	/* DEBUG */

			/*
			 * Find out whether this is PCI bus A or B
			 * using the 'reg' property.
			 */
			int_val = (int *)get_prop_val
			    (find_prop(pci, "reg"));

			if (int_val != NULL) {
				int_val ++; /* skip over first integer */
				pci_bus = ((*int_val) & 0x7f0000);
				if (pci_bus == 0x600000)
					card.pci_bus = 'A';
				else if (pci_bus == 0x700000)
					card.pci_bus = 'B';
				else
					card.pci_bus = '-';
			} else {
				card.pci_bus = '-';
			}


			/*
			 * Check for failed status.
			 */
			if (node_failed(card_node))
				strcpy(card.status, "fail");
			else
				strcpy(card.status, "ok");

			/* Get the model of this card */
			value = get_prop_val(find_prop(card_node, "model"));
			if (value == NULL)
				card.model[0] = '\0';
			else {
				(void) sprintf(card.model, "%s", (char *)value);
				/*
				 * If we wish to exclude onboard devices
				 * (such as SBBC) then this is the place
				 * and here is how to do it:
				 *
				 * if (strcmp(card.model, "SUNW,sbbc") == 0) {
				 *	card_node = card_node->sibling;
				 *	continue;
				 * }
				 */
			}

			/*
			 * The card may have a "clock-frequency" but we
			 * are not interested in that. Instead we get the
			 * "clock-frequency" of the PCI Bus that the card
			 * resides on. PCI-A can operate at 33Mhz or 66Mhz
			 * depending on what card is plugged into the Bus.
			 * PCI-B always operates at 33Mhz.
			 *
			 */
			int_val = get_prop_val(find_prop(pci,
			    "clock-frequency"));
			if (int_val != NULL) {
				card.freq = HZ_TO_MHZ(*int_val);
			} else {
				card.freq = -1;
			}

			/*
			 * Figure out how we want to display the name
			 */
			value = get_prop_val(find_prop(card_node,
			    "compatible"));
			if (value != NULL) {
				/* use 'name'-'compatible' */
				(void) sprintf(buf, "%s-%s", name,
				    (char *)value);
			} else {
				/* just use 'name' */
				(void) sprintf(buf, "%s", name);
			}
			name = buf;

			/*
			 * If this node has children, add the device_type
			 * of the child to the name value of this card.
			 */
			child_name = (char *)get_node_name(card_node->child);
			if ((card_node->child != NULL) &&
			    (child_name != NULL)) {
				value = get_prop_val(find_prop(card_node->child,
				    "device_type"));
				if (value != NULL) {
					/* add device_type of child to name */
					(void) sprintf(card.name, "%s/%s (%s)",
					    name, child_name,
					    (char *)value);
				} else {
					/* just add child's name */
					(void) sprintf(card.name, "%s/%s",
					    name, child_name);
				}
			} else {
				/* childless, just the card's name */
				(void) sprintf(card.name, "%s", (char *)name);
			}

			/*
			 * If this is a pci-bridge, then add the word
			 * 'pci-bridge' to its model.
			 */
			if (pci_bridge) {
				if (card.model[0] == '\0')
					(void) sprintf(card.model,
					    "%s", "pci-bridge");
				else
					(void) strcat(card.model,
					    "/pci-bridge");
			}

			/* insert this card in the list to be displayed later */
			card_list = insert_io_card(card_list, &card);

			/*
			 * If we are dealing with a pci-bridge, we need to move
			 * down to the children of this bridge, if there are
			 * any, otherwise its siblings.
			 *
			 * If not a bridge, we are either dealing with a regular
			 * card (in which case we move onto the sibling of this
			 * card) or we are dealing with a child of a pci-bridge
			 * (in which case we move onto the child's siblings or
			 * if there are no more siblings for this child, we
			 * move onto the parent's siblings).  I hope you're
			 * getting all this, there will be an exam later.
			 */
			if (pci_bridge) {
				if (card_node->child != NULL)
					card_node = card_node->child;
				else
					card_node = card_node->sibling;
			} else {
				/*
				 * If our parent is a pci-bridge but there
				 * are no more of its children to process we
				 * move back up to our parent's sibling,
				 * otherwise we move onto our own sibling.
				 */
				if ((card_node->parent == pci_bridge_node) &&
				    (card_node->sibling == NULL))
					card_node =
					    pci_bridge_node->sibling;
				else
					card_node = card_node->sibling;
			}

		} /* end while (card_node ...) loop */
예제 #27
0
int
main(int argc, char **argv)
{
    cib_t *the_cib = NULL;
    int rc = pcmk_ok;

    int cib_opts = cib_sync_call;
    int argerr = 0;
    int flag;

    int option_index = 0;
    int is_remote_node = 0;

    crm_log_cli_init("crm_attribute");
    crm_set_options(NULL, "command -n attribute [options]", long_options,
                    "Manage node's attributes and cluster options."
                    "\n\nAllows node attributes and cluster options to be queried, modified and deleted.\n");

    if (argc < 2) {
        crm_help('?', EX_USAGE);
    }

    while (1) {
        flag = crm_get_option(argc, argv, &option_index);
        if (flag == -1)
            break;

        switch (flag) {
            case 'V':
                crm_bump_log_level(argc, argv);
                break;
            case '$':
            case '?':
                crm_help(flag, EX_OK);
                break;
            case 'D':
            case 'G':
            case 'v':
                command = flag;
                attr_value = optarg;
                break;
            case 'q':
            case 'Q':
                BE_QUIET = TRUE;
                break;
            case 'U':
            case 'N':
                dest_uname = strdup(optarg);
                break;
            case 'u':
                dest_node = strdup(optarg);
                break;
            case 's':
                set_name = strdup(optarg);
                break;
            case 'l':
            case 't':
                type = optarg;
                break;
            case 'z':
                type = XML_CIB_TAG_NODES;
                set_type = XML_TAG_UTILIZATION;
                break;
            case 'n':
                attr_name = strdup(optarg);
                break;
            case 'i':
                attr_id = strdup(optarg);
                break;
            case 'r':
                rsc_id = optarg;
                break;
            case 'd':
                attr_default = optarg;
                break;
            case '!':
                crm_warn("Inhibiting notifications for this update");
                cib_opts |= cib_inhibit_notify;
                break;
            default:
                printf("Argument code 0%o (%c) is not (?yet?) supported\n", flag, flag);
                ++argerr;
                break;
        }
    }

    if (optind < argc) {
        printf("non-option ARGV-elements: ");
        while (optind < argc)
            printf("%s ", argv[optind++]);
        printf("\n");
    }

    if (optind > argc) {
        ++argerr;
    }

    if (argerr) {
        crm_help('?', EX_USAGE);
    }

    the_cib = cib_new();
    rc = the_cib->cmds->signon(the_cib, crm_system_name, cib_command);

    if (rc != pcmk_ok) {
        fprintf(stderr, "Error signing on to the CIB service: %s\n", pcmk_strerror(rc));
        return crm_exit(rc);
    }

    if (type == NULL && dest_uname != NULL) {
	    type = "forever";
    }

    if (safe_str_eq(type, "reboot")) {
        type = XML_CIB_TAG_STATUS;

    } else if (safe_str_eq(type, "forever")) {
        type = XML_CIB_TAG_NODES;
    }

    if (type == NULL && dest_uname == NULL) {
        /* we're updating cluster options - dont populate dest_node */
        type = XML_CIB_TAG_CRMCONFIG;

    } else if (safe_str_neq(type, XML_CIB_TAG_TICKETS)) {
        if (dest_uname == NULL) {
            dest_uname = get_node_name(0);
        }

        rc = query_node_uuid(the_cib, dest_uname, &dest_node, &is_remote_node);
        if (pcmk_ok != rc) {
            fprintf(stderr, "Could not map name=%s to a UUID\n", dest_uname);
            the_cib->cmds->signoff(the_cib);
            cib_delete(the_cib);
            return crm_exit(rc);
        }
    }

    if (attr_name == NULL && command == 'D') {
        fprintf(stderr, "Error during deletion, no attribute name specified.\n");
        return crm_exit(1);
    }

    if ((command == 'v' || command == 'D')
        && safe_str_eq(type, XML_CIB_TAG_STATUS)
        && pcmk_ok == attrd_update_delegate(NULL, command, dest_uname, attr_name, attr_value, type, set_name,
                                 NULL, NULL, is_remote_node)) {
        crm_info("Update %s=%s sent via attrd", attr_name, command == 'D' ? "<none>" : attr_value);

    } else if (command == 'D') {
        rc = delete_attr_delegate(the_cib, cib_opts, type, dest_node, set_type, set_name,
                                  attr_id, attr_name, attr_value, TRUE, NULL);

        if (rc == -ENXIO) {
            /* Nothing to delete...
             * which means its not there...
             * which is what the admin wanted
             */
            rc = pcmk_ok;
        } else if (rc != -EINVAL && safe_str_eq(crm_system_name, "crm_failcount")) {
            char *now_s = NULL;
            time_t now = time(NULL);

            now_s = crm_itoa(now);
            update_attr_delegate(the_cib, cib_sync_call, XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL,
                                 NULL, "last-lrm-refresh", now_s, TRUE, NULL, NULL);
            free(now_s);
        }

    } else if (command == 'v') {
        CRM_LOG_ASSERT(type != NULL);
        CRM_LOG_ASSERT(attr_name != NULL);
        CRM_LOG_ASSERT(attr_value != NULL);

        rc = update_attr_delegate(the_cib, cib_opts, type, dest_node, set_type, set_name,
                                  attr_id, attr_name, attr_value, TRUE, NULL, is_remote_node ? "remote" : NULL);

    } else {                    /* query */

        char *read_value = NULL;

        rc = read_attr_delegate(the_cib, type, dest_node, set_type, set_name,
                                attr_id, attr_name, &read_value, TRUE, NULL);

        if (rc == -ENXIO && attr_default) {
            read_value = strdup(attr_default);
            rc = pcmk_ok;
        }

        crm_info("Read %s=%s %s%s",
                 attr_name, crm_str(read_value), set_name ? "in " : "", set_name ? set_name : "");

        if (rc == -EINVAL) {
            rc = pcmk_ok;

        } else if (BE_QUIET == FALSE) {
            fprintf(stdout, "%s%s %s%s %s%s value=%s\n",
                    type ? "scope=" : "", type ? type : "",
                    attr_id ? "id=" : "", attr_id ? attr_id : "",
                    attr_name ? "name=" : "", attr_name ? attr_name : "",
                    read_value ? read_value : "(null)");

        } else if (read_value != NULL) {
            fprintf(stdout, "%s\n", read_value);
        }
        free(read_value);
    }

    if (rc == -EINVAL) {
        printf("Please choose from one of the matches above and suppy the 'id' with --attr-id\n");

    } else if (rc != pcmk_ok) {
        fprintf(stderr, "Error performing operation: %s\n", pcmk_strerror(rc));
    }

    the_cib->cmds->signoff(the_cib);
    cib_delete(the_cib);
    return crm_exit(rc);
}