diff options
author | Nick White <arch@njw.me.uk> | 2008-04-03 00:42:00 +0000 |
---|---|---|
committer | Nick White <arch@njw.me.uk> | 2008-04-03 00:42:00 +0000 |
commit | f85c3b947985ad0cdaec0197dea8e077c9d5f6d7 (patch) | |
tree | f23d297e2265505f4aa53ae07ca3008d9b36d256 /src | |
parent | b37c74e3fa320ffd23e31c10954243280f7d127d (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
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/cli.c | 32 | ||||
-rw-r--r-- | src/config.c | 5 | ||||
-rw-r--r-- | src/download.c | 45 | ||||
-rw-r--r-- | src/getht.c | 111 | ||||
-rw-r--r-- | src/getht.h | 6 | ||||
-rw-r--r-- | src/issue.h | 15 | ||||
-rw-r--r-- | src/issuemem.c | 24 | ||||
-rw-r--r-- | src/mediarev.c | 178 | ||||
-rw-r--r-- | src/mediaxml.c | 249 | ||||
-rw-r--r-- | src/tocxml.c | 1 |
11 files changed, 9 insertions, 659 deletions
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 @@ -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)) ); |