summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <arch@njw.me.uk>2008-04-03 00:42:00 +0000
committerNick White <arch@njw.me.uk>2008-04-03 00:42:00 +0000
commitf85c3b947985ad0cdaec0197dea8e077c9d5f6d7 (patch)
treef23d297e2265505f4aa53ae07ca3008d9b36d256
parentb37c74e3fa320ffd23e31c10954243280f7d127d (diff)
Removed all media handling code
This patch has no new features. It just removes all of the media handling code. It was proving too hard to maintain, and lots of it is now available at the website anyway. git-archimport-id: getht@sv.gnu.org/getht--mainline--0.1--patch-34
-rw-r--r--BUGS82
-rw-r--r--doc/getht.man32
-rw-r--r--src/Makefile.am2
-rw-r--r--src/cli.c32
-rw-r--r--src/config.c5
-rw-r--r--src/download.c45
-rw-r--r--src/getht.c111
-rw-r--r--src/getht.h6
-rw-r--r--src/issue.h15
-rw-r--r--src/issuemem.c24
-rw-r--r--src/mediarev.c178
-rw-r--r--src/mediaxml.c249
-rw-r--r--src/tocxml.c1
13 files changed, 14 insertions, 768 deletions
diff --git a/BUGS b/BUGS
index cd7345a..e69de29 100644
--- a/BUGS
+++ b/BUGS
@@ -1,82 +0,0 @@
-
-!! BIG BUG !!
-read media xml crashes, as cannot find any issue info, so sets issue & leaves an item with all blank fields
-a few things to fix with this:
-
- read rev:
- at the moment looks for
- set the filename of player \"player1\" to \"%s\"
- set the filename of player \"player1\" to \"
- however, "player1" has now been changed to "PubDesk"
- therefore change scanning routine to along the lines of
- set the filename of player \"*\" to \"%s\"
- more complex but worthwhile
- -also-
- if no url is found inside a "on mouseUp" clause, do not keep a blank media entry
- best way to do this would be to:
- dealloc the media item,
- realloc the pointer array,
- and -1 to no_of_media
-
-
-further progress:
-- main obstacle is that "on mouseUp" no longer necessarily follows a newline - file now less organised still
- therefore we'll have to scan each line (except when already in useful clause (check this)) char by char for the occurance
- best way to do this would be to scan char by char, and if one worthwhile is found to copy from this point to a new string for parsing
- worth spending a few minutes checking if there's a library function out there to do this, if not create a simple generic one, using pointers, roughly of the form:
- int containstring(char * toparse, char * match), returning 1 if found and 0 otherwise
-- change of scanning routine has been done, but is untested
- consider changing for an improved getquote which can take the nth quote
- this is due to it being best not to rely on end of lines at end of bit we're interested in
-- 2nd clause of above (if no url is found) is very important now, as majority are unuseful
-
-
-currently (16/08/2007):
-
-the strcontains does not appear to be working correctly; appears to accept any line as a match
-this then creates a bunch of structures, which eventually become confused
- this may point to some niggling bug in the memory management, but for the moment focus on correct basic rev parsing
-
-currently (28/11/2007):
-
-strcontains works mostly - check the TODO
-the sscanf for extracting uri isn't working - best to just have a slightly more sophisticated getquote function
-next actions:
- /no_of_media strangely changes where it's pointing to to be "out of bounds" half way through
- / always gets stuck on 'Geometry'
- / must have an overflow, prob in strcontains (only happens when it's used lots)
- / rewrite strcontains using array arithmetic - easier to maintain
- /ensure whole lines are always parsed (not just first parts thereof) [should now be done]
- / to test search output for 1st reference to Publisher, and see if a few lines above is a successful on mouseUp recognition
- / get rid of ugly & unnecessary extra checks, which are put there just to ensure nothing bad happens in the delicate phase
-
-currently (09/12/2007)
-
-strcontains has been rewritten to use friendly arrays; appears to work fine (though not heavily tested)
-getting a str has been rewritten into a function: gzgetstr ; appears to work fine thouth also not well tested
-
-note - arch changes they've made:
-only one regular media item (in form of earlier)
-now a new "songs" section, with neat urls following "SongsURLs" (when not in on mouseUp section)
- song titles follow, again on separate neat lines, but without any easy delimiter to hook on to
-there is also a video section in a "on menupick pItem" clause
- different syntax to traditional
- has to work out url using quality choices from pItem (high, med, low; given below)
- won't be too hard, just be somewhat tricky to get the different options (start with them hardcoded, i.e. on "put tSize & '.mov' after tURL" just make 3 items with high, med, & low qualities
-there is also an interviews section, which looks very similar to Songs (InterviewsURLs)
- note that interview names are encased in html
-there are also thumbnail jpgs, but they needn't be handled for a while
-
-next actions:
- improve getquote to point where sscanf line is replaced [e.g. allow to only return quote n (and ignore prev)]
- only include stack if it has a uri attached (otherwise throw away)
-
-18/12/07
-
-getquote has been rewritten to extract an arbitrary quote n
-empty uri strings are ignored
-
-TODO w/bugs
-generally:
-
-we should be able to read rev.gz / xml from hd, to save time & server hitting with testing
diff --git a/doc/getht.man b/doc/getht.man
index 2fcde22..5a34819 100644
--- a/doc/getht.man
+++ b/doc/getht.man
@@ -32,9 +32,9 @@
.SH DESCRIPTION
.PP
.I GetHT
-is a program which downloads multimedia and pdf files
-from Hinduism Today. It has good proxy support, and
-is small, fast, and simple.
+is a program which downloads pdf files from Hinduism
+Today. It has good proxy support, and is small, fast,
+and simple.
.I GetHT
is not endorsed by or affiliated with Hinduism Today.
@@ -51,14 +51,6 @@ Download all issues of Hinduism Today.
Download the issue numbered issno (use \fI-l\fR to find
issue numbers).
.TP
-.B \-n, \-\-download-media medno
-Download the multimedia file numbered medno (use \fI-m\fR
-to find media numbers).
-.TP
-.B \-m, \-\-download-all-media
-Download all multimedia files distributed by Hinduism
-Today.
-.TP
.B \-f, \-\-force
Force getht to download files, even if they have
already been downloaded. This is useful if a download
@@ -68,17 +60,9 @@ has been corrupted or interrupted.
List the issues of Hinduism Today, with issue numbers,
sorted by date.
.TP
-.B \m, \-\-list-media
-List the multimedia files associated with Hinduism
-today, with media numbers, sorted by issue date.
-.TP
.B \-t, \-\-tocfile tocfile
Use a different contents file, as specified by tocfile.
.TP
-.B \-x, \-\-mediatocfile mediatocfile
-Use a different media contents file, as specified by
-mediatocfile.
-.TP
.B \-h, \-\-help
Print a brief usage message.
.TP
@@ -101,9 +85,8 @@ with commented lines starting with a #
The following options may be set.
.TP
.B issuepath
-Stores the path in which all issues and multimedia
-files will be saved. The default setting is
-\fB~/hinduism_today/\fR
+Stores the path in which all issues will be saved
+The default setting is \fB~/hinduism_today/\fR
.TP
.B startup_check
Whether to automatically check for new issues each
@@ -115,11 +98,6 @@ A url to the xml file containing the table of contents
for the publication.
Default: \fBhttp://www.hinduismtoday.com/digital/htde_toc.xml\fR
.TP
-.B mediatoc_url
-A url to the rev.gz file listing the media included with
-the publication.
-Default: \fBhttp://www.hinduismtoday.com/digital/htde_media-player.rev.gz\fR
-.TP
.B proxy_type
The type of proxy (if any) through which GetHT is to
pass. GetHT currently supports the following options:
diff --git a/src/Makefile.am b/src/Makefile.am
index 79f8673..e6b2bc1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,5 +3,5 @@
bin_PROGRAMS = getht
getht_SOURCES = config.c cli.c download.c getht.c issuemem.c \
- mediarev.c mediaxml.c tocxml.c xml.c \
+ tocxml.c xml.c \
getht.h issue.h version.h
diff --git a/src/cli.c b/src/cli.c
index 56ccc9d..b085d02 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -59,47 +59,15 @@ void list_issues(iss ** issue, int no_of_issues, int verbose)
}
}
-void list_media(iss ** issue, int no_of_issues, int verbose)
-{
- int iss_no, med_no, med_global;
- for(iss_no=0, med_global=0;iss_no<=no_of_issues;iss_no++)
- {
- if(issue[iss_no]->no_of_media >= 0)
- {
- printf("%s\n", issue[iss_no]->title);
- if(verbose >= 2)
- printf("Year: %i; Months: %i - %i\n",issue[iss_no]->date.year,issue[iss_no]->date.firstmonth,issue[iss_no]->date.lastmonth);
- for(med_no=0; med_no <= (issue[iss_no]->no_of_media); med_no++, med_global++)
- {
- printf("[%i]\t", med_global);
- printf("%s\n", issue[iss_no]->media[med_no]->title);
- if(verbose >= 1)
- {
- printf("\t%s\n", issue[iss_no]->media[med_no]->uri);
- if(verbose >=2)
- {
- if(issue[iss_no]->media[med_no]->comment[0]!='\0')
- printf("\t%s\n", issue[iss_no]->media[med_no]->comment);
- }
- }
- }
- }
- }
-}
-
void showusage()
{
printf("Usage: getht [-ualmofhv] [-d issno] [-n medno] [-t tocfile]\n");
printf("-u | --update Update contents files\n");
printf("-a | --download-all Download all issues\n");
printf("-d | --download-issue issno Download issue number issno\n");
- printf("-n | --download-media medno Download media number n\n");
- printf("-o | --download-all-media Download all media\n");
printf("-f | --force Force re-download of existing files\n");
printf("-l | --list-issues List available issues\n");
- printf("-m | --list-media List available media\n");
printf("-t | --tocfile file Use alternative contents xml file\n");
- printf("-x | --mediatocfile file Use alternative media contents xml file\n");
printf("-h | --help Print this help message\n");
printf("-v | --verbose Make output more verbose\n");
printf("-V | --version Print version information\n");
diff --git a/src/config.c b/src/config.c
index a963cc7..23c2926 100644
--- a/src/config.c
+++ b/src/config.c
@@ -31,7 +31,6 @@ extern proxyauth proxy_auth;
extern char proxy_user[STR_MAX];
extern char proxy_pass[STR_MAX];
extern char issue_url[STR_MAX];
-extern char media_url[STR_MAX];
int loadconfig(char * htde_path, char * issue_path, int * update)
/* Loads variables from config file to extern and passed
@@ -60,8 +59,6 @@ int loadconfig(char * htde_path, char * issue_path, int * update)
*update = atoi(parameter);
else if(!strcmp(option, "toc_url"))
strncpy(issue_url, parameter, STR_MAX);
- else if(!strcmp(option, "mediatoc_url"))
- strncpy(media_url, parameter, STR_MAX);
else if(!strcmp(option, "proxy_type"))
{
if(!strcmp(parameter, "http"))
@@ -125,8 +122,6 @@ int writefreshconfig(char * htde_path, char * issue_path, int * update)
fprintf(config_file, "%s = %i\n", "startup_check", *update);
if(issue_url[0])
fprintf(config_file, "%s = %s\n", "toc_url", issue_url);
- if(media_url[0])
- fprintf(config_file, "%s = %s\n", "mediatoc_url", media_url);
if(proxy_type != NONE)
{
if(proxy_type = HTTP)
diff --git a/src/download.c b/src/download.c
index cddf0de..a1853f5 100644
--- a/src/download.c
+++ b/src/download.c
@@ -184,48 +184,3 @@ void downloadissue(CURL *curl_handle, char * directory, iss * issue, int force)
save_file(curl_handle, cur_section->uri, filename);
}
}
-
-void downloadmedia(CURL * curl_handle, char * directory, med * media, int force)
-/* Download media pointed to. */
-{
- char newdir[STR_MAX], filename[STR_MAX], fn[STR_MAX];
- FILE * testfile;
-
- /* for the moment just save to down/media, in future save to issue directories
- * (regardless of if they're occupied) */
- snprintf(newdir,STR_MAX,"%s/%s",directory,"media");
-
- if(!opendir(newdir))
- if(mkdir(newdir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH))
- {
- printf("Please enter the path of a directory to save media in: ");
- scanf("%s", newdir); /* TODO: incorporate GETTEXT */
- }
-
- /* get the position of the final forwardslash of the uri */
- int slashpos;
- for(slashpos=strlen(media->uri);
- slashpos>=0 && media->uri[slashpos] != '/';
- slashpos--);
-
- /* copy from there to fn */
- int tmp;
- for(tmp=0, slashpos++; media->uri[slashpos]; tmp++, slashpos++)
- fn[tmp] = media->uri[slashpos];
- fn[tmp] = '\0';
-
- snprintf(filename,STR_MAX,"%s/%s", newdir, fn);
-
- if(!force){
- testfile = fopen(filename, "r");
- if(!testfile)
- save_file(curl_handle, media->uri, filename);
- else
- {
- fclose(testfile);
- printf("Skipping download of media item %s\n", media->title);
- }
- }
- else
- save_file(curl_handle, media->uri, filename);
-}
diff --git a/src/getht.c b/src/getht.c
index a00df27..26737d7 100644
--- a/src/getht.c
+++ b/src/getht.c
@@ -33,13 +33,11 @@
int update_contents_files();
-med * findnewestmed(iss ** issue, int no_of_issues);
-
proxytype proxy_type; char proxy_addr[STR_MAX]; long proxy_port;
proxyauth proxy_auth;
char proxy_user[STR_MAX]; char proxy_pass[STR_MAX];
-char issue_xml[STR_MAX]; char media_xml[STR_MAX]; char media_rev[STR_MAX];
-char issue_url[STR_MAX]; char media_url[STR_MAX];
+char issue_xml[STR_MAX];
+char issue_url[STR_MAX];
CURL *main_curl_handle;
int main(int argc, char *argv[])
@@ -59,18 +57,14 @@ int main(int argc, char *argv[])
}
snprintf(issue_xml,STR_MAX,"%s/%s",getht_path,ISS_XML_FILE);
- snprintf(media_xml,STR_MAX, "%s/%s", getht_path, MED_XML_FILE);
- snprintf(media_rev,STR_MAX,"%s/%s",getht_path,MED_REVGZ_FILE);
strncpy(issue_url,XML_TOC_URL,STR_MAX);
- strncpy(media_url,MEDIA_TOC_URL,STR_MAX);
snprintf(save_path,STR_MAX,"%s/hinduism_today",getenv("HOME"));
- int downall = 0, downallmedia = 0;
+ int downall = 0;
int downissue = 0, downissueno = -1;
- int downmedia = 0, downmediano = -1;
- int listissues = 0, listmedia = 0;
+ int listissues = 0;
int force = 0, update = 0;
int verbose = 0, option = 0;
@@ -82,7 +76,7 @@ int main(int argc, char *argv[])
proxy_pass[0] = '\0';
if(loadconfig(getht_path, &save_path, &update) != 0)
- writefreshconfig(getht_path, &save_path, &update, &issue_url, &media_url);
+ writefreshconfig(getht_path, &save_path, &update, &issue_url);
if(!opendir(save_path))
if(mkdir(save_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH))
@@ -100,14 +94,10 @@ int main(int argc, char *argv[])
{
{"download-all", no_argument, 0, 'a'},
{"download-issue", required_argument, 0, 'd'},
- {"download-media", required_argument, 0, 'n'},
- {"download-all-media", no_argument, 0, 'o'},
{"force", no_argument, 0, 'f'},
{"list-issues", no_argument, 0, 'l'},
- {"list-media", no_argument, 0, 'm'},
{"update", no_argument, 0, 'u'},
{"tocfile", required_argument, 0, 't'},
- {"mediatocfile", required_argument, 0, 'x'},
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
@@ -129,20 +119,6 @@ int main(int argc, char *argv[])
listissues = 1;
option = 1;
break;
- case 'm':
- listmedia = 1;
- option = 1;
- break;
- case 'o':
- downallmedia = 1;
- downmedia = 1;
- option = 1;
- break;
- case 'n':
- downmedia = 1;
- downmediano = atoi(optarg);
- option = 1;
- break;
case 'f':
force = 1;
option = 1;
@@ -154,9 +130,6 @@ int main(int argc, char *argv[])
case 't':
strncpy(issue_xml, strdup(optarg), STR_MAX);
break;
- case 'x':
- strncpy(media_xml, strdup(optarg), STR_MAX);
- break;
case 'h':
showusage();
return 0;
@@ -222,54 +195,10 @@ int main(int argc, char *argv[])
downloadissue(NULL, save_path, issue[downissueno], force);
}
- if(downmedia || listmedia)
- {
- int newest;
-
- issue = parsemedia(media_xml, issue, &no_of_issues);
-
- if(!issue)
- {
- if(!update)
- {
- printf("Cannot open media contents file, trying to update contents\n");
- if(update_contents_files())
- return 1;
- issue = parsemedia(media_xml, issue, &no_of_issues);
- }
- else
- {
- printf("Cannot open contents file, try running `getht --update`\n");
- return 1;
- }
- }
-
- if(downallmedia)
- {
- for(i = 0; i <= no_of_issues; i++)
- {
- for(newest = 0; newest <= issue[i]->no_of_media; newest++)
- downloadmedia(NULL, save_path, issue[i]->media[newest], force);
- }
- }
- else if(downmediano >= 0)
- {
- int med_global, med_no;
-
- for(i=0,med_global=0; i<=no_of_issues; i++)
- if(issue[i]->no_of_media >= 0)
- for(med_no=0; med_no <= (issue[i]->no_of_media); med_no++,med_global++)
- if(med_global == downmediano)
- downloadmedia(NULL, save_path, issue[i]->media[med_no], force);
- }
- }
if(listissues)
list_issues(issue, no_of_issues, verbose);
- if(listmedia)
- list_media(issue, no_of_issues, verbose);
-
/* Ensure curl cleans itself up */
curl_easy_cleanup(main_curl_handle);
@@ -281,34 +210,6 @@ int update_contents_files()
{
if(save_file(NULL, issue_url, issue_xml))
return 1;
-
- char isstitle[STR_MAX];
- issdates date;
-
- /* see if current issue's media toc has already
- been written to the xml, if not do so */
- if(access(issue_xml, R_OK) == 0)
- {
- if(cur_identifiers(issue_xml, isstitle, &date))
- return 1;
- }
else
- return 1;
-
- if(media_accounted_for(media_xml, &date))
- {
- if(save_file(NULL, media_url, media_rev))
- return 1;
-
- med ** temp_med;
- int med_no = -1;
-
- temp_med = parsemediagz(media_rev, &med_no);
-
- unlink(media_rev);
-
- addmediaissue(media_xml, isstitle, &date, temp_med, med_no);
- }
-
- return 0;
+ return 0;
}
diff --git a/src/getht.h b/src/getht.h
index df2b1b2..ba138ff 100644
--- a/src/getht.h
+++ b/src/getht.h
@@ -20,16 +20,14 @@
*/
#define XML_TOC_URL "http://www.hinduismtoday.com/digital/htde_toc.xml"
+
+/* currently unused - see 0.1 patch-30 for latest version parsing media */
#define MEDIA_TOC_URL "http://www.hinduismtoday.com/digital/htde_media-player.rev.gz"
-#define MED_XML_FILE "media_toc.xml"
#define ISS_XML_FILE "htde_toc.xml"
-#define MED_REVGZ_FILE "htde_media-player.rev.gz"
#define STR_MAX 512
-#define MAX_ISS 10
-
typedef enum
{
NONE,
diff --git a/src/issue.h b/src/issue.h
index 22499b5..e3fef70 100644
--- a/src/issue.h
+++ b/src/issue.h
@@ -47,31 +47,16 @@ typedef struct
typedef struct
{
- char uri[512];
- char title[512];
- char comment[512];
- char preview_uri[512];
- int size;
-} med;
-
-typedef struct
-{
char preview_uri[512];
char title[512];
int size;
issdates date;
sec ** section;
int no_of_sections;
- med ** media;
- int no_of_media;
} iss;
iss ** parsetoc(char *filepath, int * iss_no);
-iss ** parsemedia(char * filepath, iss ** issue, int * no_of_issues);
-
-med ** parsemediagz(char * media_path, int * no_of_media);
iss ** assignnew_iss(iss ** issue, int *no_of_issues);
sec ** assignnew_sec(sec ** section, int * no_of_sections);
it ** assignnew_it(it ** item, int * no_of_items);
-med ** assignnew_med(med ** media, int * no_of_media);
diff --git a/src/issuemem.c b/src/issuemem.c
index 63fe5b4..d4f922f 100644
--- a/src/issuemem.c
+++ b/src/issuemem.c
@@ -107,30 +107,6 @@ it ** assignnew_it(it ** item, int * no_of_items)
return tmp;
}
-med ** assignnew_med(med ** media, int * no_of_media)
-{
- med ** tmp = NULL;
-
- if(*no_of_media < 0)
- { /* make **section a new array of section pointers */
- if( (tmp = malloc(sizeof(med *))) == NULL )
- nogo_mem();
- }
- else
- { /* add a new pointer to media pointer list */
- if( (tmp = realloc(media, sizeof(med *) + (((*no_of_media)+1) * sizeof(med *)))) == NULL )
- nogo_mem();
- }
-
- (*no_of_media)++;
-
- /* make new array item a pointer to issue */
- if( ( tmp[*no_of_media] = malloc(sizeof(med)) ) == NULL )
- nogo_mem();
-
- return tmp;
-}
-
int issuesort(iss ** issue, int no_of_issues)
/* does a basic bubble sort, by date, returning sorted issue */
{
diff --git a/src/mediarev.c b/src/mediarev.c
deleted file mode 100644
index 975c971..0000000
--- a/src/mediarev.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2006 Nick White
- *
- * This mediagz is part of GetHT
- *
- * GetHT is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GetHT is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GetHT; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <zlib.h>
-
-#include "getht.h"
-#include "issue.h"
-
-int gzgetstr(char * newstr, gzFile * gzfile);
-int getquote(char * input, char * quote, int number);
-int strcontains(char * source, char * comparison);
-
-med ** parsemediagz(char * media_path, int * no_of_media)
-/* Parses gzipped adobe pagemaker files for media urls and metadata,
- * filling media with the information. */
-{
- char c;
- char cur_line[STR_MAX];
- gzFile mediagz;
-
- *no_of_media = -1;
-
- med ** media = NULL;
-
- strcpy(cur_line,""); /* reset cur_line */
-
- mediagz = gzopen(media_path, "r");
-
- med * cur_media;
-
- while(gzeof(mediagz)==0)
- {
- gzgetstr(cur_line, mediagz);
-
- if(strcontains(cur_line,"on mouseUp") == 0)
- {
- /* assign memory for the new media */
- media = assignnew_med(media, no_of_media);
-
- cur_media = media[*no_of_media];
-
- /* setup media globals */
- cur_media->uri[0] = '\0';
- cur_media->title[0] = '\0';
- cur_media->comment[0] = '\0';
- cur_media->preview_uri[0] = '\0';
- cur_media->size = 0;
-
- /* process rev file */
- while(strcontains(cur_line,"end mouseUp") && gzeof(mediagz)==0)
- {
- strcpy(cur_line,""); /* reset cur_line */
- gzgetstr(cur_line, mediagz);
-
- if(!strcontains(cur_line,"set the filename of player \"") && strcontains(cur_line,"empty"))
- getquote(cur_line, cur_media->uri, 2);
- else if(!strcontains(cur_line,"set the label of this stack to"))
- getquote(cur_line, cur_media->title, 1);
- else if(!strcontains(cur_line,"statusMsg\(\"") || !strcontains(cur_line,"StatusMsg \(\""))
- getquote(cur_line, cur_media->comment, 1);
- }
-
- /* if it turns out that there was nothing useful there, remove the new media */
- if(cur_media->uri[0] == '\0')
- (*no_of_media)--;
- }
- strcpy(cur_line,""); /* reset cur_line */
- }
-
- return media;
-}
-
-int getquote(char * input, char * quote, int number)
-/* assigns quote string from a line of the format:
- * 'something "quote" something' */
-{
- int curnum;
-
- /* advance past earlier quotes */
- for(curnum=0; curnum < ((number*2)-2); curnum++)
- {
- /* advance until " character is reached */
- while(*input != '"' && *input)
- input++;
- input++;
- }
-
- /* advance until " character is reached */
- while(*input != '"' && *input)
- input++;
-
- input++;
-
- /* copy characters in until next '"' */
- while(*input != '"')
- {
- /* if end is found without closing bracket,
- * exit with error */
- if(! *input)
- return 1;
- *quote = *input;
- quote++;
- input++;
- }
-
- *quote = '\0';
-
- return 0;
-}
-
-int strcontains(char * source, char * comparison)
-{
- int srcpos = 0; /* position in source string */
- int compos = 0; /* position in comparison string */
-
- while(srcpos < strlen(source) && srcpos < STR_MAX)
- {
- /* if the chars match, move to the next in comparison,
- * otherwise only advance the source */
- if(source[srcpos] == comparison[compos])
- compos++;
- else
- compos = 0;
-
- /* if we got to the end of comparison, there's a match */
- if(compos == strlen(comparison))
- return 0;
-
- srcpos++;
- }
-
- /* if we got all the way through the source, there's no match */
- return 1;
-}
-
-int gzgetstr(char * newstr, gzFile * gzfile)
-/* a reimplementation of gzgetstr, which doesn't choke at odd characters
- */
-{
- strcpy(newstr,""); /* reset cur_line */
- char c;
-
- while((c = gzgetc(gzfile)) != -1)
- {
- if(c == '\n')
- break;
-
- /* append the char if there's room in the str */
- if(strlen(newstr)+1 < STR_MAX)
- strncat(newstr,&c,1);
- /* if the line is too long just break to pick up the 2nd half on next pass,
- * not perfect (will miss strs cut into 2 sections), but good enough for now */
- else
- break;
- }
-
- return 0;
-}
diff --git a/src/mediaxml.c b/src/mediaxml.c
deleted file mode 100644
index 54ed3ae..0000000
--- a/src/mediaxml.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 2006 Nick White
- *
- * This file is part of GetHT
- *
- * GetHT is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GetHT is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GetHT; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-
-#include "getht.h"
-#include "issue.h"
-
-int media_accounted_for(char * filepath, issdates * date)
-/* checks if media for issue is found */
-{
- xmlDocPtr media_file;
- xmlNodePtr node;
-
- if(ready_xml(filepath, "media", &media_file, &node))
- return 1;
-
- *node = *node->xmlChildrenNode;
-
- issdates curdate;
- int found = 1;
-
- while (node != NULL)
- {
- if(!xmlStrcmp(node->name,(char *) "issue"))
- {
- curdate.year = atoi( (char *) xmlGetProp(node, "year"));
- curdate.firstmonth = atoi( (char *) xmlGetProp(node, "firstmonth"));
- curdate.lastmonth = atoi( (char *) xmlGetProp(node, "lastmonth"));
- }
-
- if( curdate.year == date->year &&
- curdate.firstmonth == date->firstmonth &&
- curdate.lastmonth == date->lastmonth )
- {
- found = 0;
- break;
- }
-
- node = node->next;
- }
-
- xmlFreeDoc(media_file);
-
- return found;
-}
-
-int addmediaissue(char * filepath, char * title, issdates * date, med ** media, int med_no)
-/* Appends data from media structures to xml file. */
-{
- xmlDocPtr media_file;
- xmlNodePtr node;
-
- /* if xml file doesn't exist */
- if(ready_xml(filepath, "media", &media_file, &node))
- {
- /* set up fresh xml file */
- media_file = xmlNewDoc(NULL);
- node = xmlNewNode(NULL, "media");
- xmlDocSetRootElement(media_file, node);
- }
-
- xmlNodePtr curissue;
- char tmp[5];
-
- /* set up issue node */
- curissue = xmlNewTextChild(node, NULL, "issue", NULL);
-
- xmlNewProp(curissue, "title", title);
-
- snprintf(tmp,5,"%i", date->year);
- xmlNewProp(curissue, "year", tmp);
-
- snprintf(tmp,5,"%i",date->firstmonth);
- xmlNewProp(curissue, "firstmonth", tmp);
-
- snprintf(tmp,5,"%i",date->lastmonth);
- xmlNewProp(curissue, "lastmonth", tmp);
-
- xmlNodePtr curitem;
-
- int count;
- for(count = 0; count <= med_no; count++)
- {
- curitem = xmlNewTextChild(curissue, NULL, "item", media[count]->title);
-
- xmlNewProp(curitem, "uri", media[count]->uri);
-
- if(media[count]->comment)
- xmlNewProp(curitem, "comment", media[count]->comment);
- if(media[count]->preview_uri)
- xmlNewProp(curitem, "preview_uri", media[count]->preview_uri);
- }
-
- xmlKeepBlanksDefault(0);
-
- xmlSaveFormatFile(filepath, media_file, 1);
-
- xmlFreeDoc(media_file);
-
- return 0;
-}
-
-iss ** parsemedia(char * filepath, iss ** issue, int * no_of_issues)
-/* Fills issues with relevant info from media xml, creating new
- ones where necessary. */
-{
- issdates tmpdate;
-
- iss * cur_issue; med * cur_media;
-
- xmlDocPtr media_file;
- xmlNodePtr node, itnode;
-
- if(ready_xml(filepath, "media", &media_file, &node))
- return NULL;
-
- *node = *node->xmlChildrenNode;
-
- int issue_there = 0;
-
- char title[STR_MAX];
- issdates curdate;
- int tmp;
-
- while (node != NULL)
- {
- if(!xmlStrcmp(node->name,(char *) "issue"))
- {
- /* check if issue with title already exists */
- for(tmp = 0; tmp < *no_of_issues; tmp++)
- {
- curdate.year = atoi( (char *) xmlGetProp(node, "year"));
- curdate.firstmonth = atoi( (char *) xmlGetProp(node, "firstmonth"));
- curdate.lastmonth = atoi( (char *) xmlGetProp(node, "lastmonth"));
-
- if( curdate.year == issue[tmp]->date.year &&
- curdate.firstmonth == issue[tmp]->date.firstmonth &&
- curdate.lastmonth == issue[tmp]->date.lastmonth )
- {
- issue_there = 1;
- break;
- }
- }
-
- if(!issue_there)
- { /* advance to the next free issue */
- iss ** tmpiss = NULL;
- if(*no_of_issues == -1)
- { /* make issue** a new array of issue pointers */
- if( (tmpiss = malloc(sizeof(iss *))) == NULL )
- nogo_mem();
- }
- else
- { /* add a new pointer to issue pointer list */
- if( (tmpiss = realloc(issue, sizeof(iss *) + (*no_of_issues * sizeof(iss *)))) == NULL )
- nogo_mem();
- }
-
- (*no_of_issues)++;
-
- /* make new array item a pointer to issue */
- if( (tmpiss[*no_of_issues] = malloc(sizeof(iss))) == NULL )
- nogo_mem();
-
- issue = tmpiss;
-
- issue[*no_of_issues]->date.year = atoi( (char *) xmlGetProp(node, "year"));
- issue[*no_of_issues]->date.firstmonth = atoi( (char *) xmlGetProp(node, "firstmonth"));
- issue[*no_of_issues]->date.lastmonth = atoi( (char *) xmlGetProp(node, "lastmonth"));
-
- strncpy(issue[*no_of_issues]->title, (char *) xmlGetProp(node, "title"), STR_MAX);
-
- tmp = *no_of_issues;
- }
-
- iss * cur_issue = issue[tmp];
-
- issue[tmp]->no_of_media = -1;
-
- itnode = node->xmlChildrenNode;
-
- while (itnode != NULL)
- {
-
- if(!xmlStrcmp(itnode->name,(char *) "item"))
- {
- /* assign memory for the new media */
- cur_issue->media = assignnew_med(cur_issue->media, &(cur_issue->no_of_media));
-
- /* setup media globals */
- cur_media = cur_issue->media[cur_issue->no_of_media];
-
- cur_media->uri[0] = '\0';
- cur_media->title[0] = '\0';
- cur_media->comment[0] = '\0';
- cur_media->preview_uri[0] = '\0';
- cur_media->size = 0;
-
- /* add media info to cur_media */
- if(xmlGetProp(itnode, "uri"))
- strncpy(cur_media->uri, (char *) xmlGetProp(itnode, "uri"), STR_MAX);
-
- if(xmlGetProp(itnode, "comment"))
- strncpy(cur_media->comment, (char *) xmlGetProp(itnode, "comment"), STR_MAX);
-
- if(xmlGetProp(itnode, "preview"))
- strncpy(cur_media->preview_uri, (char *) xmlGetProp(itnode, "preview_uri"), STR_MAX);
-
- if((char *) xmlNodeListGetString(media_file, itnode->xmlChildrenNode, 1))
- strncpy(cur_media->title, (char *) xmlNodeListGetString(media_file, itnode->xmlChildrenNode, 1), STR_MAX);
- else
- strncpy(cur_media->title, "untitled", STR_MAX);
- }
-
- itnode = itnode->next;
- }
- }
-
- node = node->next;
- }
-
- xmlFreeDoc(media_file);
-
- issuesort(issue, *no_of_issues);
-
- return issue;
-}
diff --git a/src/tocxml.c b/src/tocxml.c
index 08ca12b..dc2bddb 100644
--- a/src/tocxml.c
+++ b/src/tocxml.c
@@ -68,7 +68,6 @@ iss ** parsetoc(char *filepath, int * iss_no)
issue = assignnew_iss(issue, &no_of_issues);
/* setup issue globals */
- issue[no_of_issues]->no_of_media = -1;
issue[no_of_issues]->no_of_sections = -1;
issue[no_of_issues]->date.year =
atoi( (const char *)(xmlStrsub(node->name,5,4)) );