[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getht-commit] arch commit: getht--mainline--0.1--patch-24
From: |
Nick |
Subject: |
[Getht-commit] arch commit: getht--mainline--0.1--patch-24 |
Date: |
Thu, 3 May 2007 18:52:46 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Revision: getht--mainline--0.1--patch-24
Archive: address@hidden
Creator: Nick White <address@hidden>
Date: Thu May 3 18:51:44 BST 2007
Standard-date: 2007-05-03 17:51:44 GMT
New-files: .arch-ids/prepare-package.sh.id
prepare-package.sh src/.arch-ids/cli.c.id src/cli.c
Modified-files: doc/getht.man src/Makefile.am src/getht.c
src/issue.h src/tocxml.c src/version.h
New-patches: address@hidden/getht--mainline--0.1--patch-24
Summary: Added a script to ease releases, improved cli interface
Keywords:
Added the script prepare-release.sh
Modified and added options to allow easy downloading of single
issues and media files
Moved functions outputting to the command line to cli.c
Added a verbose flag
A .arch-ids/prepare-package.sh.id
A prepare-package.sh
A src/.arch-ids/cli.c.id
A src/cli.c
M doc/getht.man
M src/getht.c
M src/issue.h
M src/tocxml.c
M src/version.h
M src/Makefile.am
* modified files
--- orig/doc/getht.man
+++ mod/doc/getht.man
@@ -27,7 +27,7 @@
.SH SYNOPSIS
.TP 5
\fBgetht
-\fI[-uadmnfvh] [-t tocfile] [-m medtocfile]\fR
+\fI[-ualmofVvh] [-d issno] [-n medno] [-t tocfile] [-m medtocfile]\fR
.SH DESCRIPTION
.PP
@@ -47,22 +47,31 @@
.B \-a, \-\-download-all
Download all issues of Hinduism Today.
.TP
-.B \-d, \-\-download-latest
-Download only the latest issue of Hinduism Today.
+.B \-d, \-\-download-issue issno
+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 \-n, \-\-download-latest-media
-Download only the multimedia files from the latest
-issue of Hinduism Today.
-.TP
.B \-f, \-\-force
Force getht to download files, even if they have
already been downloaded. This is useful if a download
has been corrupted or interrupted.
.TP
+.B \-l, \-\-list-issues
+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
@@ -73,7 +82,11 @@
.B \-h, \-\-help
Print a brief usage message.
.TP
-.B \-v, \-\-version
+.B \-v, \-\-verbose
+Make the output from \fI-l\fR and \fI-m\fR more verbose.
+May be used twice to make output yet more verbose.
+.TP
+.B \-V, \-\-version
Display the version number.
.SH CONFIGURATION FILE
--- orig/src/Makefile.am
+++ mod/src/Makefile.am
@@ -2,6 +2,6 @@
bin_PROGRAMS = getht
-getht_SOURCES = config.c download.c getht.c issuemem.c \
+getht_SOURCES = config.c cli.c download.c getht.c issuemem.c \
mediarev.c mediaxml.c tocxml.c xml.c \
getht.h issue.h version.h
--- orig/src/getht.c
+++ mod/src/getht.c
@@ -35,10 +35,6 @@
med * findnewestmed(iss ** issue, int no_of_issues);
-void show_iss_struct(iss ** issue, int no_of_issues);
-
-void showusage();
-
proxytype proxy_type; char proxy_addr[STR_MAX]; long proxy_port;
proxyauth proxy_auth;
char proxy_user[STR_MAX]; char proxy_pass[STR_MAX];
@@ -67,11 +63,12 @@
snprintf(save_path,STR_MAX,"%s/hinduism_today",getenv("HOME"));
- int downall = 0, downlatest = 0;
- int downallmedia = 0, downlatestmedia = 0;
- int downissue = 0, downmedia = 0;
- int force = 0, update = 0, showstr = 0;
- int option = 0;
+ int downall = 0, downallmedia = 0;
+ int downissue = 0, downissueno = -1;
+ int downmedia = 0, downmediano = -1;
+ int listissues = 0, listmedia = 0;
+ int force = 0, update = 0;
+ int verbose = 0, option = 0;
proxy_type = NONE;
proxy_port = 0;
@@ -98,18 +95,21 @@
static struct option long_opts[] =
{
{"download-all", no_argument, 0, 'a'},
- {"download-latest", no_argument, 0, 'd'},
- {"download-all-media", no_argument, 0, 'm'},
- {"download-latest-media", no_argument, 0, 'n'},
+ {"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'},
- {"version", no_argument, 0, 'v'},
+ {"verbose", no_argument, 0, 'v'},
+ {"version", no_argument, 0, 'V'},
{0, 0, 0, 0}
};
- while((c = getopt_long(argc, argv, "adfhmnsuvx:t:", long_opts, NULL))
!= -1) {
+ while((c = getopt_long(argc, argv, "ad:fhlmn:osuvVx:t:", long_opts,
NULL)) != -1) {
switch(c) {
case 'a':
downall = 1;
@@ -117,18 +117,26 @@
option = 1;
break;
case 'd':
- downlatest = 1;
downissue = 1;
+ downissueno = atoi(optarg);
+ option = 1;
+ break;
+ case 'l':
+ listissues = 1;
option = 1;
break;
case 'm':
+ listmedia = 1;
+ option = 1;
+ break;
+ case 'o':
downallmedia = 1;
downmedia = 1;
option = 1;
break;
case 'n':
- downlatestmedia = 1;
downmedia = 1;
+ downmediano = atoi(optarg);
option = 1;
break;
case 'f':
@@ -139,10 +147,6 @@
update = 1;
option = 1;
break;
- case 's':
- showstr = 1;
- option = 1;
- break;
case 't':
strcpy(issue_xml, strdup(optarg));
option = 1;
@@ -156,6 +160,10 @@
return 0;
break;
case 'v':
+ verbose++;
+ option = 1;
+ break;
+ case 'V':
printf("GetHT version: %s\n",VERSION);
option = 1;
return 0;
@@ -181,12 +189,11 @@
iss **issue;
int no_of_issues = -1;
- int latest_index = -1;
int i;
- if(downissue || showstr)
+ if(downissue || listissues)
{
- issue = parsetoc(issue_xml, &no_of_issues, &latest_index);
+ issue = parsetoc(issue_xml, &no_of_issues);
if(!issue)
{
@@ -195,7 +202,7 @@
printf("Cannot open contents file, trying to
update contents\n");
if(update_contents_files())
return 1;
- issue = parsetoc(issue_xml, &no_of_issues,
&latest_index);
+ issue = parsetoc(issue_xml, &no_of_issues);
}
else
{
@@ -204,24 +211,16 @@
}
}
- if(latest_index == -1)
- {
- fprintf(stderr, "Error: Cannot ascertain latest issue.
");
- fprintf(stderr, "Defaulting to first issue in contents
file\n");
- latest_index = 0;
- }
-
if(downall)
{
for(i = 0; i < no_of_issues; i++)
downloadissue(NULL, save_path, issue[i], force);
}
-
- if(downlatest)
- downloadissue(NULL, save_path, issue[latest_index],
force);
+ else if(downissueno >= 0 && downissueno <= no_of_issues)
+ downloadissue(NULL, save_path, issue[downissueno],
force);
}
- if(downmedia || showstr)
+ if(downmedia || listmedia)
{
int newest;
@@ -243,13 +242,6 @@
}
}
- if(downlatestmedia)
- {
- newest = findnewestiss(issue, no_of_issues);
- for(i = 0; i <= issue[newest]->no_of_media; i++)
- downloadmedia(NULL, save_path,
issue[newest]->media[i], force);
- }
-
if(downallmedia)
{
for(i = 0; i <= no_of_issues; i++)
@@ -258,10 +250,23 @@
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(showstr)
- show_iss_struct(issue, no_of_issues);
+ 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);
@@ -306,52 +311,6 @@
return 0;
}
-void show_iss_struct(iss ** issue, int no_of_issues)
-/* Prints issue information */
-{
- int iss_no, sec_no, med_no, it_no;
- printf("%i Issues\n",no_of_issues);
- for(iss_no=0;iss_no<=no_of_issues;iss_no++)
- {
- printf("-Issue %i-\n", (iss_no+1));
- printf("Title:\t'%s'\n", issue[iss_no]->title);
- printf("Preview URI:\t'%s'\n", issue[iss_no]->preview_uri);
- printf("Months:\t'%i' -
'%i'\n",issue[iss_no]->date.firstmonth,issue[iss_no]->date.lastmonth);
- printf("Year:\t'%i'\n",issue[iss_no]->date.year);
- printf("Number of
Sections:\t'%i'\n",issue[iss_no]->no_of_sections);
-
- for(sec_no=0; sec_no <= (issue[iss_no]->no_of_sections);
sec_no++)
- {
- printf("\t-Section %i-\n", (sec_no));
- printf("\tTitle:\t'%s'\n",
issue[iss_no]->section[sec_no]->title);
- printf("\tURI:\t'%s'\n",
issue[iss_no]->section[sec_no]->uri);
- printf("\tNo. of Items:\t'%i'\n",
issue[iss_no]->section[sec_no]->no_of_items);
-
- for(it_no=0; it_no <=
issue[iss_no]->section[sec_no]->no_of_items; it_no++)
- {
- printf("\t\t-Item-\n");
-
printf("\t\tTitle:\t'%s'\n",issue[iss_no]->section[sec_no]->item[it_no]->title);
- printf("\t\tFirst
page:\t'%i'",issue[iss_no]->section[sec_no]->item[it_no]->firstpage);
- printf("\tLast
page:\t'%i'\n",issue[iss_no]->section[sec_no]->item[it_no]->lastpage);
- }
- it_no = 0;
- }
- sec_no = 0;
-
- printf("Number of Media:\t'%i'\n",issue[iss_no]->no_of_media);
-
- for(med_no=0; med_no <= (issue[iss_no]->no_of_media); med_no++)
- {
- printf("\t-Media %i-\n", (med_no));
- printf("\tTitle:\t'%s'\n",
issue[iss_no]->media[med_no]->title);
- printf("\tURI:\t'%s'\n",
issue[iss_no]->media[med_no]->uri);
- printf("\tComment:\t'%s'\n",
issue[iss_no]->media[med_no]->comment);
- printf("\tPreview URI:\t'%s'\n",
issue[iss_no]->media[med_no]->preview_uri);
- }
- med_no = 0;
- }
-}
-
int findnewestiss(iss ** issue, int no_of_issues)
/* returns newest issue indice */
{
@@ -377,18 +336,3 @@
return new_iss;
}
-
-void showusage()
-{
- printf("Usage: getht -u -a -d -m -n -f [-t tocfile] -h -v\n");
- printf("-u | --update Update contents files\n");
- printf("-a | --download-all Download all issues\n");
- printf("-d | --download-latest Download latest issue\n");
- printf("-m | --download-all-media Download all media\n");
- printf("-n | --download-latest-media Download latest issue's media\n");
- printf("-f | --force Force re-download of existing
files\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 | --version Print version information\n");
-}
--- orig/src/issue.h
+++ mod/src/issue.h
@@ -66,7 +66,7 @@
int no_of_media;
} iss;
-iss ** parsetoc(char *filepath, int * iss_no, int * latest);
+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);
--- orig/src/tocxml.c
+++ mod/src/tocxml.c
@@ -28,15 +28,15 @@
#include "issue.h"
#include "getht.h"
-iss ** parsetoc(char *filepath, int * iss_no, int * latest);
-int parseissue(xmlDocPtr file, xmlNodePtr node, iss * cur_issue, int * latest);
+iss ** parsetoc(char *filepath, int * iss_no);
+int parseissue(xmlDocPtr file, xmlNodePtr node, iss * cur_issue);
void parsesection(xmlDocPtr file, xmlNodePtr node, sec * cur_section);
void tokenise_hyphons(char to_token[10], int * first, int * last);
int no_of_issues;
-iss ** parsetoc(char *filepath, int * iss_no, int * latest)
+iss ** parsetoc(char *filepath, int * iss_no)
/* starts parsing of xml to issue structure */
{
xmlDocPtr file;
@@ -78,7 +78,7 @@
&(issue[no_of_issues]->date.lastmonth));
/* parse the issue */
- parseissue(file, cnode,
issue[no_of_issues], latest);
+ parseissue(file, cnode,
issue[no_of_issues]);
}
cnode = cnode->next;
}
@@ -95,15 +95,12 @@
return issue;
}
-int parseissue(xmlDocPtr file, xmlNodePtr node, iss * cur_issue, int * latest)
+int parseissue(xmlDocPtr file, xmlNodePtr node, iss * cur_issue)
/* parses issue from xml, saving in cur_issue structure */
{
strncpy(cur_issue->title, (char *) xmlGetProp(node, "title"), STR_MAX);
strncpy(cur_issue->preview_uri, (char *) xmlGetProp(node, "coverlink"),
STR_MAX);
- if(xmlGetProp(node, "current") && *latest==-1)
- *latest = no_of_issues;
-
node = node->xmlChildrenNode;
while(node != NULL){
--- orig/src/version.h
+++ mod/src/version.h
@@ -19,4 +19,4 @@
*
*/
-#define VERSION "0.0.1"
+#define VERSION "pre_release"
* added files
--- /dev/null
+++
/home/nick/programming/c/getht/getht-mainline/,,address@hidden/new-files-archive/./.arch-ids/prepare-package.sh.id
@@ -0,0 +1 @@
+Nick White <address@hidden> Thu May 3 15:21:05 2007 12700.0
--- /dev/null
+++
/home/nick/programming/c/getht/getht-mainline/,,address@hidden/new-files-archive/./prepare-package.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# 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
+
+TMPDIR="/tmp"
+ORIGDIR=$(pwd)
+
+VERSION=$(gawk -F \" '{print $2}' src/version.h | \
+ sed -e ':a;N;$!ba;s/\n//g')
+
+echo Packaging GetHT version $VERSION
+
+echo Copying sources to a temporary directory
+rm -rf $TMPDIR/getht-$VERSION && \
+mkdir $TMPDIR/getht-$VERSION && \
+cp -R * $TMPDIR/getht-$VERSION && \
+cd $TMPDIR/getht-$VERSION
+
+echo Removing Arch metadata
+rm -rf \{arch\}
+rm -rf .arch_ids
+rm -f ++log.getht*
+
+# ensure version number in configure.in is set correctly
+sed -i "s|^AC_INIT(getht, .*)$|AC_INIT(getht, $VERSION)|" configure.in
+
+echo Building necessary autotools parts
+autoreconf -i
+
+echo Cleaning make environment
+make clean
+
+echo Cleaning up working directory
+rm -rf autom4te.cache
+rm prepare-package.sh
+
+echo Packaging into a tarball
+cd ..
+tar -cjf getht-$VERSION.tar.bz2 getht-$VERSION
+
+echo Removing temporary directory
+rm -rf getht-$VERSION
+
+cd $ORIGDIR
+mv $TMPDIR/getht-$VERSION.tar.bz2 .
+
+echo "Packaging of GetHT $VERSION complete."
+echo "The tarball resides at ./getht-$VERSION.tar.bz2"
--- /dev/null
+++
/home/nick/programming/c/getht/getht-mainline/,,address@hidden/new-files-archive/./src/.arch-ids/cli.c.id
@@ -0,0 +1 @@
+Nick White <address@hidden> Thu May 3 17:57:09 2007 26612.0
--- /dev/null
+++
/home/nick/programming/c/getht/getht-mainline/,,address@hidden/new-files-archive/./src/cli.c
@@ -0,0 +1,99 @@
+/*
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include "issue.h"
+#include "getht.h"
+
+void list_issues(iss ** issue, int no_of_issues, int verbose)
+{
+ int iss_no, sec_no, it_no;
+ for(iss_no=0;iss_no<=no_of_issues;iss_no++)
+ {
+ printf("[%i]\t", iss_no);
+ printf("%s\n", issue[iss_no]->title);
+ if(verbose >= 1)
+ {
+ for(sec_no=0; sec_no<=issue[iss_no]->no_of_sections;
sec_no++)
+ {
+ printf("\t%i: %s\n",
issue[iss_no]->section[sec_no]->number,
+ issue[iss_no]->section[sec_no]->title);
+ printf("\t%s\n",
issue[iss_no]->section[sec_no]->uri);
+ if(verbose >= 2)
+ {
+ for(it_no=0;
+
it_no<=issue[iss_no]->section[sec_no]->no_of_items;
+ it_no++)
+ {
+ printf("\t\tpp %i - %i: %s\n",
+
issue[iss_no]->section[sec_no]->item[it_no]->firstpage,
+
issue[iss_no]->section[sec_no]->item[it_no]->lastpage,
+
issue[iss_no]->section[sec_no]->item[it_no]->title);
+ }
+ }
+ }
+ }
+ }
+}
+
+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);
+ 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 &&
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");
+}
pgp3uVbmSqUKE.pgp
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getht-commit] arch commit: getht--mainline--0.1--patch-24,
Nick <=