static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface) { xmlwriter *This = impl_from_IXmlWriter(iface); struct element *element; TRACE("%p\n", This); switch (This->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_Ready: case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; default: ; } element = pop_element(This); if (!element) return WR_E_INVALIDACTION; /* write full end tag */ write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); write_output_buffer(This->output, element->qname, element->len); write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); This->starttagopen = FALSE; return S_OK; }
static HRESULT WINAPI xmlwriter_WriteEndElement(IXmlWriter *iface) { xmlwriter *This = impl_from_IXmlWriter(iface); struct element *element; TRACE("%p\n", This); element = pop_element(This); if (!element) return WR_E_INVALIDACTION; if (This->starttagopen) { static WCHAR closetagW[] = {' ','/','>'}; write_output_buffer(This->output, closetagW, ARRAY_SIZE(closetagW)); This->starttagopen = FALSE; } else { /* write full end tag */ write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); write_output_buffer(This->output, element->qname, element->len); write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); } return S_OK; }
/* * Function id3_get_content (frame) * * Expand content type string of frame and return it. Return NULL * upon error. * */ char *id3_get_content(struct id3_frame *frame) { GSList *list; char **str_array, *ret; int len; g_return_val_if_fail(frame->fr_desc->fd_id == ID3_TCON, NULL); /* Check if frame is compressed */ if (id3_decompress_frame(frame) == -1) return NULL; if (frame->fr_owner->id3_version == 3) list = id3_get_content_v23(frame); else list = id3_get_content_v24(frame); len = g_slist_length(list); if (len == 0) return g_strdup(""); str_array = g_malloc0(sizeof (char *) * (len + 1)); while (len-- && list) str_array[len] = pop_element(&list); if (len != -1 || list) g_warning("len: %d; list: %p", len, list); ret = g_strjoinv(", ", str_array); g_strfreev(str_array); return ret; }
t_op *pop_op(t_op *ops, char *nick) { t_op *tmp; while (ops != NULL && strcmp(ops->nick, nick) != 0) ops = ops->next; if (ops != NULL) { tmp = ops; ops = pop_element(ops, tmp); free_op(tmp); } return (first_op(ops)); }
void xml_topology_generate(const char *filename, int nnodes, float min_band, float max_band, int seed ){ float band; char hostname[20]; int c = 0; int event; int node_added = 0; long_vector_t elemstack = long_vector_create(1); FILE *fp = std_fopen(filename, "w"); srand(seed); push_element(fp, XML_TOPOLOGY_TAG_CLUSTER, elemstack, -2.0, NULL); push_element(fp, XML_TOPOLOGY_TAG_SWITCH, elemstack, -2.0, NULL); while(long_vector_size(elemstack)){ event = rand() % 3; /* kinda ad-hoc */ switch(event){ case 0: /* new host */ if(c == nnodes) continue; sprintf(hostname, "NODE:%d", c ++); band = (float)rand() / RAND_MAX * (max_band - min_band) + min_band; push_element(fp, XML_TOPOLOGY_TAG_NODE, elemstack, band, hostname); node_added = 1; break; case 1: /* new switch */ if(c == nnodes) continue; band = (float)rand() / RAND_MAX * (max_band - min_band) + min_band; push_element(fp, XML_TOPOLOGY_TAG_SWITCH, elemstack, band, "SWITCH"); node_added = 0; break; case 2: /* close switch */ if(node_added == 0) continue; if(long_vector_size(elemstack) <= 2 && c < nnodes) continue; pop_element(fp, elemstack); break; } } long_vector_destroy(elemstack); }
void fill_lava(int r, int c, int l) { push_element(r, c, l); while(front <= rear) { Q temp; int i, j,k; temp = pop_element(); i = temp.r; j = temp.c; k = temp.level; push_element(i+1, j, k+1); push_element(i-1, j, k+1); push_element(i, j+1, k+1); push_element(i, j-1, k+1); } }
static HRESULT WINAPI xmlwriter_WriteFullEndElement(IXmlWriter *iface) { xmlwriter *This = impl_from_IXmlWriter(iface); struct element *element; TRACE("%p\n", This); switch (This->state) { case XmlWriterState_Initial: return E_UNEXPECTED; case XmlWriterState_Ready: case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; default: ; } element = pop_element(This); if (!element) return WR_E_INVALIDACTION; writer_close_starttag(This); writer_dec_indent(This); /* don't force full end tag to the next line */ if (This->state == XmlWriterState_ElemStarted) This->state = XmlWriterState_Content; else write_node_indent(This); /* write full end tag */ write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); write_output_buffer(This->output, element->qname, element->len); write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); return S_OK; }
void free_liste_element (liste_element * l) { while( ! liste_vide(*l) ) pop_element(l); }