Logo Search packages:      
Sourcecode: libwfut version File versions  Download package

WFUTError WFUT::WFUTClient::getChannelList ( const std::string &  url,
ChannelList &  channels 
)

This function directly download and parses a channel listings file from the specified URL. This function will block until complete. This is the file that lists all the channels that are available at a that location.

Definition at line 79 of file WFUT.cpp.

                                                                                {
  assert (m_initialised == true);

  FILE *fp = os_create_tmpfile();
  if (!fp) {
    return WFUT_GENERAL_ERROR;
  }

  if (m_io->downloadFile(fp, url, 0)) {
    // error
    fprintf(stderr, "Error downloading file list\n");
    os_free_tmpfile(fp);
    return WFUT_DOWNLOAD_ERROR;
  }

  std::string xml;
  // Pre-allocate string memory
  xml.reserve(ftell(fp));
  rewind(fp);
  char buf[1024];
  size_t n;
  while ((n = fread(buf, sizeof(char), 1024, fp) ) > 0) {
    xml.append(buf, n);  
  }

  os_free_tmpfile(fp);

  if (parseChannelListXML(xml, channels)) {
    // Error
    fprintf(stderr, "Error parsing file list\n");
    return WFUT_PARSE_ERROR;
  }

  return WFUT_NO_ERROR;
}


Generated by  Doxygen 1.6.0   Back to index