unsigned long guide_client_get_snapshot(unsigned char ** presult, unsigned char ** ptimestamp, unsigned long * psize, const char * address, const char * cur_timestamp) { struct snapshot_data data; char url[512]; struct hc * hc; memset(&data, 0, sizeof data); data.firsttime = 1; data.status = -1; sprintf(url, "http://%s/http_replay_guide-get_snapshot?" "guide_file_name=%s&serial_no=RTV4080K0000000000", address, cur_timestamp); hc = hc_start_request(url); if (!hc) { perror("Error: guide_client_get_snapshot(): hc_start_request()"); goto exit; } hc_send_request(hc); hc_read_pieces(hc, get_snapshot_callback, &data); hc_free(hc); *ptimestamp = (unsigned char*)data.timestamp; *presult = (unsigned char*)data.buf; *psize = data.filesize; exit: return data.status; }
// // 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); }