static void filelist_parser_package_start (FilelistSAXContext *ctx, const char *name, const char **attrs) { SAXContext *sctx = &ctx->sctx; Package *p = sctx->current_package; int i; const char *attr; const char *value; g_assert (p != NULL); sctx->want_text = TRUE; if (!strcmp (name, "version")) { parse_version_info(attrs, p); } else if (!strcmp (name, "file")) { ctx->current_file = package_file_new (); for (i = 0; attrs && attrs[i]; i++) { attr = attrs[i]; value = attrs[++i]; if (!strcmp (attr, "type")) ctx->current_file->type = g_string_chunk_insert_const (p->chunk, value); } } }
static void other_parser_package_start (OtherSAXContext *ctx, const char *name, const char **attrs) { SAXContext *sctx = &ctx->sctx; Package *p = sctx->current_package; int i; const char *attr; const char *value; g_assert (p != NULL); sctx->want_text = TRUE; if (!strcmp (name, "version")) { parse_version_info(attrs, p); } else if (!strcmp (name, "changelog")) { ctx->current_entry = changelog_entry_new (); for (i = 0; attrs && attrs[i]; i++) { attr = attrs[i]; value = attrs[++i]; if (!strcmp (attr, "author")) ctx->current_entry->author = g_string_chunk_insert_const (p->chunk, value); else if (!strcmp (attr, "date")) ctx->current_entry->date = strtol(value, NULL, 10); } } }
// // rtv_get_device_info // returns pointer to replaytv device. // int rtv_get_device_info(const char *address, char *queryStr, rtv_device_t **device_p) { char url[512]; struct hc *hc; int rc, new_entry; rtv_device_t *rtv; rtv_device_info_t *devinfo; RTV_DBGLOG(RTVLOG_DSCVR, "%s: Enter: address=%s: current_rtv_cnt=%d\n", __FUNCTION__, address, rtv_devices.num_rtvs); *device_p = NULL; rtv = rtv_get_device_struct(address, &new_entry); devinfo = &(rtv->device); if ( !(new_entry) ) { RTV_DBGLOG(RTVLOG_DSCVR, "%s: address=%s already exists in device struct. Decrement count.\n", __FUNCTION__, address); rtv_devices.num_rtvs--; } rtv_free_device_info(devinfo); devinfo->ipaddr = malloc(strlen(address) + 1); strcpy(devinfo->ipaddr, address); parser = XML_ParserCreate("US-ASCII"); XML_SetElementHandler(parser, devinfo_xml_start, devinfo_xml_end); XML_SetCharacterDataHandler(parser, devinfo_xml_charhndlr); XML_SetDefaultHandler(parser, devinfo_default_handler); XML_SetUserData(parser, devinfo); if ( queryStr == NULL ) { sprintf(url, "http://%s/Device_Descr.xml", address); RTV_DBGLOG(RTVLOG_DSCVR, "%s: Build default query str: %s\n", __FUNCTION__, url); } else { strncpy(url, queryStr, 511); RTV_DBGLOG(RTVLOG_DSCVR, "%s: Use supplied query str: %s\n", __FUNCTION__, url); } hc = hc_start_request(url); if (!hc) { RTV_ERRLOG("%s: hc_start_request(): %d=>%s\n", __FUNCTION__, errno, strerror(errno)); rtv_free_device_info(devinfo); return(-EPROTO); } hc_send_request(hc, NULL); rc = hc_read_pieces(hc, get_deviceinfo_callback, NULL, 0); hc_free(hc); if ( rc != 0 ) { RTV_ERRLOG("%s: hc_read_pieces call failed: rc=%d\n", __FUNCTION__, rc); rtv_free_device_info(devinfo); return(rc); } if ( (devinfo->status & RTV_EXPECTED_FIELDS) != RTV_EXPECTED_FIELDS ) { RTV_ERRLOG("%s: Missing XML Fields exp=%08X got=%08lX\n", __FUNCTION__, RTV_EXPECTED_FIELDS, devinfo->status); rtv_free_device_info(devinfo); return(-EBADE); } if ( (rc = parse_version_info(devinfo)) != 0 ) { } *device_p = rtv; rtv_devices.num_rtvs++; if ( RTVLOG_DSCVR ) { rtv_print_device_info(devinfo); } return (rc); }
static void primary_parser_package_start (PrimarySAXContext *ctx, const char *name, const char **attrs) { SAXContext *sctx = &ctx->sctx; Package *p = sctx->current_package; int i; const char *attr; const char *value; g_assert (p != NULL); sctx->want_text = TRUE; if (!strcmp (name, "format")) { ctx->state = PRIMARY_PARSER_FORMAT; } else if (!strcmp (name, "version")) { parse_version_info(attrs, p); } else if (!strcmp (name, "checksum")) { for (i = 0; attrs && attrs[i]; i++) { attr = attrs[i]; value = attrs[++i]; if (!strcmp (attr, "type")) p->checksum_type = g_string_chunk_insert (p->chunk, value); } } else if (!strcmp (name, "time")) { for (i = 0; attrs && attrs[i]; i++) { attr = attrs[i]; value = attrs[++i]; if (!strcmp (attr, "file")) p->time_file = strtol(value, NULL, 10); else if (!strcmp (attr, "build")) p->time_build = strtol(value, NULL, 10); } } else if (!strcmp (name, "size")) { for (i = 0; attrs && attrs[i]; i++) { attr = attrs[i]; value = attrs[++i]; if (!strcmp (attr, "package")) p->size_package = strtoll(value, NULL, 10); else if (!strcmp (attr, "installed")) p->size_installed = strtoll(value, NULL, 10); else if (!strcmp (attr, "archive")) p->size_archive = strtoll(value, NULL, 10); } } else if (!strcmp (name, "location")) { for (i = 0; attrs && attrs[i]; i++) { attr = attrs[i]; value = attrs[++i]; if (!strcmp (attr, "href")) p->location_href = g_string_chunk_insert (p->chunk, value); else if (!strcmp (attr, "xml:base")) p->location_base = g_string_chunk_insert (p->chunk, value); } } }