void litehtml::el_td::parse_styles(bool is_reparse) { const wchar_t* str = get_attr(L"width"); if(str) { m_style.add_property(L"width", str, 0); } str = get_attr(L"background"); if(str) { std::wstring url = L"url('"; url += str; url += L"')"; m_style.add_property(L"background-image", url.c_str(), 0); } str = get_attr(L"align"); if(str) { m_style.add_property(L"text-align", str, 0); } str = get_attr(L"valign"); if(str) { m_style.add_property(L"vertical-align", str, 0); } element::parse_styles(is_reparse); }
void litehtml::el_td::parse_attributes() { const tchar_t* str = get_attr(_t("width")); if(str) { m_style.add_property(_t("width"), str, 0, false); } str = get_attr(_t("background")); if(str) { tstring url = _t("url('"); url += str; url += _t("')"); m_style.add_property(_t("background-image"), url.c_str(), 0, false); } str = get_attr(_t("align")); if(str) { m_style.add_property(_t("text-align"), str, 0, false); } str = get_attr(_t("bgcolor")); if (str) { m_style.add_property(_t("background-color"), str, 0, false); } str = get_attr(_t("valign")); if(str) { m_style.add_property(_t("vertical-align"), str, 0, false); } html_tag::parse_attributes(); }
void litehtml::el_link::parse_attributes() { bool processed = false; const tchar_t* rel = get_attr(_t("rel")); if(rel && !t_strcmp(rel, _t("stylesheet"))) { const tchar_t* media = get_attr(_t("media")); const tchar_t* href = get_attr(_t("href")); if(href && href[0]) { tstring css_text; tstring css_baseurl; m_doc->container()->import_css(css_text, href, css_baseurl); if(!css_text.empty()) { m_doc->add_stylesheet(css_text.c_str(), css_baseurl.c_str(), media); processed = true; } } } if(!processed) { m_doc->container()->link(m_doc, this); } }
static gboolean set_c_ll ( const char **attr ) { if ( (c_slat = get_attr ( attr, "lat" )) && (c_slon = get_attr ( attr, "lon" )) ) { c_ll.lat = g_ascii_strtod(c_slat, NULL); c_ll.lon = g_ascii_strtod(c_slon, NULL); return TRUE; } return FALSE; }
/*-----------------------------------------------------------------------------------------------------------------------*/ static int32_t load_transport_protocol(FIXProtocolDescr* prot, xmlNode* parentRoot, char const* parentFile, FIXError** error) { int32_t res = FIX_SUCCESS; xmlDoc* doc = NULL; char const* transpFile = get_attr(parentRoot, "transport", parentFile); if(!strcmp(transpFile, parentFile)) // transport is the same as protocol { prot->transportVersion = _strdup(prot->version); goto ok; } char path[PATH_MAX] = {}; if (FIX_FAILED == fix_utils_make_path(parentFile, transpFile, path, PATH_MAX)) { goto err; } doc = xmlParseFile(path); if (!doc) { *error = fix_error_create(FIX_ERROR_PROTOCOL_XML_LOAD_FAILED, xmlGetLastError()->message); goto err; } if (xml_validate(doc, error) == FIX_FAILED) { goto err; } xmlNode* root = xmlDocGetRootElement(doc); prot->transportVersion = _strdup(get_attr(root, "version", NULL)); if (!strcmp(prot->version, prot->transportVersion)) // versions are the same, no need to process transport protocol { goto ok; } if (!root) { *error = fix_error_create(FIX_ERROR_PROTOCOL_XML_LOAD_FAILED, xmlGetLastError()->message); goto err; } if (load_field_types(&prot->transport_field_types, root, error) == FIX_FAILED) { goto err; } if (load_messages(prot, &prot->transport_field_types, root, error) == FIX_FAILED) { goto err; } goto ok; err: res = FIX_FAILED; ok: if (doc) { xmlFreeDoc(doc); } return res; }
static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page) { const char *ptr; LPWSTR *param, merge; int len; ptr = get_attr(text, "name", &len); if(!ptr) { WARN("name attr not found\n"); return; } if(!strncasecmp("name", ptr, len)) { param = &item->name; }else if(!strncasecmp("merge", ptr, len)) { param = &merge; }else if(!strncasecmp("local", ptr, len)) { param = &item->local; }else { WARN("unhandled param %s\n", debugstr_an(ptr, len)); return; } ptr = get_attr(text, "value", &len); if(!ptr) { WARN("value attr not found\n"); return; } /* * "merge" parameter data (referencing another CHM file) can be incorporated into the "local" parameter * by specifying the filename in the format: * MS-ITS:file.chm::/local_path.htm */ if(param == &item->local && strstr(ptr, "::")) { const char *local = strstr(ptr, "::")+2; int local_len = len-(local-ptr); item->local = decode_html(local, local_len, code_page); param = &merge; } *param = decode_html(ptr, len, code_page); if(param == &merge) { SetChmPath(&item->merge, hhc_root->merge.chm_file, merge); heap_free(merge); } }
void litehtml::el_image::parse_attributes() { m_src = get_attr(_t("src"), _t("")); const tchar_t* attr_height = get_attr(_t("height")); if(attr_height) { m_style.add_property(_t("height"), attr_height, 0, false); } const tchar_t* attr_width = get_attr(_t("width")); if(attr_width) { m_style.add_property(_t("width"), attr_width, 0, false); } }
void litehtml::el_table::parse_attributes() { const tchar_t* str = get_attr(_t("width")); if(str) { m_style.add_property(_t("width"), str, 0, false); } str = get_attr(_t("align")); if(str) { int align = value_index(str, _t("left;center;right")); switch(align) { case 1: m_style.add_property(_t("margin-left"), _t("auto"), 0, false); m_style.add_property(_t("margin-right"), _t("auto"), 0, false); break; case 2: m_style.add_property(_t("margin-left"), _t("auto"), 0, false); m_style.add_property(_t("margin-right"), _t("0"), 0, false); break; } } str = get_attr(_t("cellspacing")); if(str) { tstring val = str; val += _t(" "); val += str; m_style.add_property(_t("border-spacing"), val.c_str(), 0, false); } str = get_attr(_t("border")); if(str) { m_style.add_property(_t("border-width"), str, 0, false); } str = get_attr(_t("bgcolor")); if (str) { m_style.add_property(_t("background-color"), str, 0, false); } html_tag::parse_attributes(); }
bool DieHolder::get_operand(int const attr, ea_t const rel_addr, Dwarf_Small const atom, Dwarf_Unsigned *operand, bool only_locblock) { Dwarf_Attribute attrib = get_attr(attr); Dwarf_Locdesc **llbuf = NULL; Dwarf_Locdesc *locdesc = NULL; Dwarf_Signed count = 0; Dwarf_Error err = NULL; DwarfDealloc dealloc(m_dbg); bool found = false; bool ret = false; CHECK_DWERR2(attrib == NULL, NULL, "retrieving an operand implies finding the attribute..."); CHECK_DWERR(dwarf_loclist_n(attrib, &llbuf, &count, &err), err, "cannot get location descriptions"); dealloc.add(llbuf, DW_DLA_LIST); for(Dwarf_Signed idx = 0; idx < count; ++idx) { locdesc = llbuf[idx]; // handle deallocation too dealloc.add(llbuf[idx], DW_DLA_LOCDESC); dealloc.add(llbuf[idx]->ld_s, DW_DLA_LOC_BLOCK); if(!found) { // from a location block? if(!locdesc->ld_from_loclist) { // no need to check the address found = true; } // this loc desc is from a location list else if(!only_locblock && (locdesc->ld_lopc <= rel_addr && locdesc->ld_hipc > rel_addr)) { found = true; } } } if(found) { CHECK_DWERR2(locdesc->ld_cents != 1, NULL, "only 1 location in a location description is supported"); Dwarf_Loc *loc = &locdesc->ld_s[0]; if(loc->lr_atom == atom) { *operand = loc->lr_number; ret = true; } } return ret; }
char __xmlcontext::get_char(const char *name, char def) const { const char *val = get_attr(name); if (val == NULL) return def; return *val; }
PUBLIC L4_msg_tag Vlog::kinvoke(L4_obj_ref ref, Mword rights, Syscall_frame *f, Utcb const *r_msg, Utcb *s_msg) { L4_msg_tag const t = f->tag(); if (t.proto() == L4_msg_tag::Label_irq) return Icu_h<Vlog>::icu_invoke(ref, rights, f, r_msg, s_msg); else if (t.proto() != L4_msg_tag::Label_log) return commit_result(-L4_err::EBadproto); switch (r_msg->values[0]) { case 0: log_string(f, r_msg); return no_reply(); case 2: // set attr return set_attr(rights, f, r_msg); case 3: // get attr return get_attr(rights, f, s_msg); default: return get_input(rights, f, s_msg); } }
t_scene *get_scene(int fd, char *buffer) { t_scene *scene; int error; if ((error = check_balise(buffer, "scene")) < 0) return (NULL); scene = malloc(sizeof(*scene)); scene->attr = get_attr(buffer, scene); buffer = get_cam(fd, &(scene->cam), scene); if (scene->cam == NULL) return (NULL); if ((error = check_balise(buffer, "object")) == ERROR_NO_DEF_NAME && check_balise(buffer, "light") == ERROR_NO_DEF_NAME) return (NULL); buffer = get_object(fd, &(scene->obj), scene); if (scene->obj == NULL) return (NULL); buffer = get_next_line(fd); if ((error = check_balise(buffer, "light")) == ERROR_NO_DEF_NAME) return (NULL); buffer = get_light(fd, &(scene->light), scene); if (scene->light == NULL) return (NULL); return (scene); }
std::string __xmlcontext::get_string(const char *name, const char *def) const { const char *val = get_attr(name); if (val == NULL) return def == NULL ? std::string() : std::string(def); return std::string(val); }
void litehtml::el_para::parse_styles(bool is_reparse /*= false*/) { const wchar_t* str = get_attr(L"align"); if (str) { m_style.add_property(L"text-align", str, 0); } element::parse_styles(is_reparse); }
double __xmlcontext::get_double(const char *name, double def) const { const char *val = get_attr(name); if (val == NULL) return def; double d = strtod(val, NULL); return d; }
long long __xmlcontext::get_llong(const char *name, long long def) const { const char *val = get_attr(name); if (val == NULL) return def; long long d = strtoll(val, NULL, 0); return d; }
int __xmlcontext::get_int(const char *name, int def) const { const char *val = get_attr(name); if (val == NULL) return def; long d = strtol(val, NULL, 0); return d; }
bool copy(const wchar_t* path, const wchar_t* dest) noexcept { auto attr = get_attr(path); if (fsys::is_valid(attr) && fsys::is_link(attr)) return fsys::is_dir(attr) ? pvt::copy_dir_link(path, dest) : pvt::copy_file_link(path, dest); return false; }
int main(int argc, char **argv) { int input=-1; printf("\n===============WELCOME TO THE TEST INTERFACE TO VERIFY THE IPC================\n"); //list_receiver(1); while(1) { printf("\n -----Available Operations--- \n"); printf("\n 1. MESSAGE QUEUE Creation \n"); //this calls to the mq_open printf(" 2. Register Sender in the queue \n"); //this calls the msender system call printf(" 3. Register Receiver in the queue \n"); //this call the mreceiver system call printf(" 4. Send a message using the system call mq_send \n"); // This calls the mq_send system call printf(" 5. Clear and Close Message Queue\n"); //This calls the mq_close system call printf(" 6. Get Attributes of the message queue \n"); printf(" 7. Set Attributes of the message queue \n");//this calls to the mq_getattr system call printf(" 8. Notify system call \n"); printf(" 0. Exit the Program \n"); printf("Choose the operation you want to perform \t "); scanf(" %d",&input); switch(input) { case 1: list_queue(); break; case 2: list_sender(); break; case 3: list_receiver(0); break; case 4: mess_send(); //sender can be created dynamically also. break; case 5: message_clean(); break; case 6: get_attr(); break; case 7: set_attr(); break; case 8 : reqnotify(); break; case 0: exit(0); break; default : printf("\nIncorrect input. Try again. \n"); break; } } }
static void _startElement(void *ctx, const xmlChar *name, const xmlChar **attrs) { dprintf("START ELEMENT name='%s'\n", name); if ( strcmp((char *) name, "document") == 0 ) { CTX(ctx)->state = OCR_STATE_READ; CTX(ctx)->addr = strtoul(get_attr((xmlChar **) attrs, "id"), NULL, 16); CTX(ctx)->box = frame_geometry_null; CTX(ctx)->text.len = 0; } else if ( CTX(ctx)->state == OCR_STATE_READ ) { char *geometry = get_attr((xmlChar **) attrs, "geometry"); frame_geometry_t g = frame_geometry_null; /* Get element geometry attribute (if any) */ if ( (geometry != NULL) && (*geometry != '\0') ) { frame_geometry_parse(geometry, &g); dprintf(" geometry=\"%s\"=%ux%u+%d+%d\n", geometry, g.width, g.height, g.x, g.y); } if ( strcmp((char *) name, "line") == 0 ) { CTX(ctx)->box = g; CTX(ctx)->text.len = 0; } else { /* Ignore delirious line boundaries */ if ( (CTX(ctx)->box.width > 0) && (CTX(ctx)->box.height > 0) ) { if ( strcmp((char *) name, "box") == 0 ) { char *value = get_attr((xmlChar **) attrs, "value"); if ( strlen(value) == 1 ) { /* Ignore leading unknown characters */ if ( (CTX(ctx)->text.len > 0) || (*value != '_' ) ) ocr_text_append(CTX(ctx), *value, &g); } } else if ( strcmp((char *) name, "space") == 0 ) { /* Ignore leading space characters */ if ( CTX(ctx)->text.len > 0 ) { ocr_text_append(CTX(ctx), ' ', &g); } } } } } }
/* * def m(self): return self.f + 1 */ pyobj D_m(pyobj self) { pyobj f = get_attr(self, "f"); int i = project_int(f); #ifdef TAGGING return inject_int(i+1); #else return create_int(i+1); #endif }
void litehtml::el_div::parse_attributes() { const tchar_t* str = get_attr(_t("align")); if(str) { m_style.add_property(_t("text-align"), str, 0, false); } html_tag::parse_attributes(); }
/*-----------------------------------------------------------------------------------------------------------------------*/ static FIXMsgDescr* load_message(xmlNode const* msg_node, xmlNode const* root, FIXFieldType* (*ftypes)[FIELD_TYPE_CNT], FIXError** error) { FIXMsgDescr* msg = (FIXMsgDescr*)calloc(1, sizeof(FIXMsgDescr)); msg->name = _strdup(get_attr(msg_node, "name", NULL)); msg->type = _strdup(get_attr(msg_node, "type", NULL)); msg->field_count = count_msg_fields(msg_node, get_first(root, "components")); msg->fields = (FIXFieldDescr*)calloc(msg->field_count, sizeof(FIXFieldDescr)); uint32_t count = 0; if (FIX_FAILED == load_fields(msg->fields, &count, msg_node, get_first(root, "components"), ftypes, error)) { return NULL; } assert(count == msg->field_count); msg->field_index = (FIXFieldDescr**)calloc(FIELD_DESCR_CNT, sizeof(FIXFieldDescr*)); build_index(msg->fields, msg->field_count, msg->field_index); return msg; }
static void xmpp_failure_text(proto_tree *tree, tvbuff_t *tvb, element_t *element) { attr_t *lang = get_attr(element,"xml:lang"); proto_tree_add_text(tree, tvb, element->offset, element->length, "TEXT%s: %s", lang?ep_strdup_printf("(%s)",lang->value):"", element->data?element->data->value:""); }
/* Parse the attributes correspond to a list item, including sub-topics. * * Each list item has, at minimum, a param of type "keyword" and two * parameters corresponding to a "sub-topic." For each sub-topic there * must be a "name" param and a "local" param, if there is only one * sub-topic then there isn't really a sub-topic, the index will jump * directly to the requested item. */ static void parse_index_obj_node_param(IndexItem *item, const char *text, UINT code_page) { const char *ptr; LPWSTR *param; int len; ptr = get_attr(text, "name", &len); if(!ptr) { WARN("name attr not found\n"); return; } /* Allocate a new sub-item, either on the first run or whenever a * sub-topic has filled out both the "name" and "local" params. */ if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len))) item_realloc(item, item->nItems+1); if(!strncasecmp("keyword", ptr, len)) { param = &item->keyword; }else if(!item->keyword && !strncasecmp("name", ptr, len)) { /* Some HTML Help index files use an additional "name" parameter * rather than the "keyword" parameter. In this case, the first * occurrence of the "name" parameter is the keyword. */ param = &item->keyword; }else if(!strncasecmp("name", ptr, len)) { item->itemFlags |= 0x01; param = &item->items[item->nItems-1].name; }else if(!strncasecmp("local", ptr, len)) { item->itemFlags |= 0x10; param = &item->items[item->nItems-1].local; }else { WARN("unhandled param %s\n", debugstr_an(ptr, len)); return; } ptr = get_attr(text, "value", &len); if(!ptr) { WARN("value attr not found\n"); return; } *param = decode_html(ptr, len, code_page); }
void DieHolder::get_frame_base_offsets(OffsetAreas &offset_areas) { Dwarf_Attribute attrib = get_attr(DW_AT_frame_base); Dwarf_Locdesc **llbuf = NULL; Dwarf_Locdesc *locdesc = NULL; Dwarf_Signed count = 0; Dwarf_Error err = NULL; DwarfDealloc dealloc(m_dbg); CHECK_DWERR2(attrib == NULL, NULL, "retrieving an operand implies finding the attribute..."); CHECK_DWERR(dwarf_loclist_n(attrib, &llbuf, &count, &err), err, "cannot get location descriptions"); dealloc.add(llbuf, DW_DLA_LIST); for(Dwarf_Signed idx = 0; idx < count; ++idx) { ea_t low_pc = 0; ea_t high_pc = 0; locdesc = llbuf[idx]; // handle deallocation too dealloc.add(llbuf[idx], DW_DLA_LOCDESC); dealloc.add(llbuf[idx]->ld_s, DW_DLA_LOC_BLOCK); // only 1 location in a location description is supported if(locdesc->ld_cents == 1) { Dwarf_Loc *loc = &locdesc->ld_s[0]; Dwarf_Small const atom = loc->lr_atom; // from a location block? if(!locdesc->ld_from_loclist) { low_pc = BADADDR; high_pc = BADADDR; } // this loc desc is from a location list else { low_pc = static_cast<ea_t>(locdesc->ld_lopc); high_pc = static_cast<ea_t>(locdesc->ld_hipc); } // is it the right atom to get the offset from? if(atom == DW_OP_breg4 || atom == DW_OP_breg5) { offset_areas.push_back(OffsetArea(low_pc, high_pc, // operand is unsigned, but should be signed... static_cast<sval_t>(loc->lr_number), (atom == DW_OP_breg5))); } } } }
void litehtml::el_break::parse_attributes() { const tchar_t* attr_clear = get_attr(_t("clear")); if(attr_clear) { m_style.add_property(_t("clear"), attr_clear, 0, false); } html_tag::parse_attributes(); }
void litehtml::el_tr::parse_attributes() { const tchar_t* str = get_attr(_t("align")); if(str) { m_style.add_property(_t("text-align"), str, 0, false); } str = get_attr(_t("valign")); if(str) { m_style.add_property(_t("vertical-align"), str, 0, false); } str = get_attr(_t("bgcolor")); if (str) { m_style.add_property(_t("background-color"), str, 0, false); } html_tag::parse_attributes(); }
bool __xmlcontext::get_bool(const char *name, bool def) const { const char *val = get_attr(name); if (val == NULL) return def; if (isdigit(*val)) return strtol(val, NULL, 0) != 0; if (*val == 't' || *val == 'T' || *val == 'y' || *val == 'Y') return true; return false; }
/*-----------------------------------------------------------------------------------------------------------------------*/ static FIXErrCode load_field_types(FIXFieldType* (*ftypes)[FIELD_TYPE_CNT], xmlNode const* root, FIXError** error) { xmlNode const* field = get_first(get_first(root, "fields"), "field"); while(field) { if (field->type == XML_ELEMENT_NODE && !strcmp((char const*)field->name, "field")) { if (fix_protocol_get_field_type(ftypes, get_attr(field, "name", NULL))) { *error = fix_error_create(FIX_ERROR_FIELD_TYPE_EXISTS, "FIXFieldType '%s' already exists", (char const*)field->name); return FIX_FAILED; } FIXFieldType* fld = (FIXFieldType*)calloc(1, sizeof(FIXFieldType)); fld->tag = atoi(get_attr(field, "number", NULL)); fld->name = _strdup(get_attr(field, "name", NULL)); fld->valueType = str2FIXFieldValueType(get_attr(field, "type", NULL)); xmlNode const* value = get_first(field, "value"); if (value) { fld->values = (FIXFieldValue**)calloc(FIELD_VALUE_CNT, sizeof(FIXFieldValue*)); while(value) { if (value->type == XML_ELEMENT_NODE && !strcmp((char const*)value->name, "value")) { FIXFieldValue* val = (FIXFieldValue*)calloc(1, sizeof(FIXFieldValue)); val->value = strdup(get_attr(value, "enum", NULL)); uint32_t idx = fix_utils_hash_string(val->value, strlen(val->value)) % FIELD_VALUE_CNT; val->next = fld->values[idx]; fld->values[idx] = val; } value = value->next; } } uint32_t idx = fix_utils_hash_string(fld->name, strlen(fld->name)) % FIELD_TYPE_CNT; fld->next = (*ftypes)[idx]; (*ftypes)[idx] = fld; } field = field->next; } return FIX_SUCCESS; }