char * Downloader::GetResponseText (const char *partname, gint64 *size) { LOG_DOWNLOADER ("Downloader::GetResponseText (%s, %p)\n", partname, size); TextStream *stream; char buffer[4096]; GByteArray *buf; struct stat st; ssize_t nread; char *data; char *path; if (!(path = GetDownloadedFilename (partname))) return NULL; if (g_stat (path, &st) == -1) { g_free (path); return NULL; } if (st.st_size > 0) { stream = new TextStream (); if (!stream->OpenFile (path, true)) { delete stream; g_free (path); return NULL; } g_free (path); buf = g_byte_array_new (); while ((nread = stream->Read (buffer, sizeof (buffer))) > 0) g_byte_array_append (buf, (const guint8 *) buffer, nread); *size = buf->len; g_byte_array_append (buf, (const guint8 *) "", 1); data = (char *) buf->data; g_byte_array_free (buf, false); delete stream; } else { data = g_strdup (""); *size = 0; } return data; }
int main (int argc, const char* argv[]) { if (argc != 2) { printf ("pass in an ASX file to parse.\n"); return -1; } TextStream *ts = new TextStream (); printf ("opening the file: %s\n", argv [1]); ts->OpenFile (argv [1], true); AsxParserInternal *asx = new AsxParserInternal (ts); asx->run (); }