From e91ec0d87aa31cb465fe8cf934d405ad56342eba Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 19 May 2010 17:15:41 +0100 Subject: Switched to simpler build system, and fixed bugs Now there's a proper build system in place, which is actually simple enough to understand. I also fixed plenty of warnings about the code (reminding me how badly I knew C when I wrote this). Hinduism today aren't indexing their new issues using the index file I was sourcing any more, so I don't expect to fix any more bugs or improve this much. --- .gitignore | 14 +-- AUTHORS | 3 - BUGS | 0 COPYING | 4 + CREDITS | 6 -- ChangeLog | 0 INSTALL | 32 ------- Makefile | 40 ++++++++ Makefile.am | 13 --- NEWS | 0 README | 2 +- cli.c | 65 +++++++++++++ config.mk | 24 +++++ configure.ac | 34 ------- doc/Makefile.am | 2 - doc/RELEASING | 45 --------- doc/getht.man | 163 ------------------------------- download.c | 265 ++++++++++++++++++++++++++++++++++++++++++++++++++ getht.1 | 143 +++++++++++++++++++++++++++ getht.c | 210 ++++++++++++++++++++++++++++++++++++++++ getht.h | 92 ++++++++++++++++++ issuemem.c | 135 ++++++++++++++++++++++++++ parseconfig.c | 160 +++++++++++++++++++++++++++++++ prepare-release.sh | 64 ------------- src/.gitignore | 5 - src/Makefile.am | 7 -- src/cli.c | 79 --------------- src/config.c | 172 --------------------------------- src/download.c | 276 ----------------------------------------------------- src/getht.c | 223 ------------------------------------------- src/getht.h | 52 ---------- src/issue.h | 59 ------------ src/issuemem.c | 148 ---------------------------- src/tocxml.c | 259 ------------------------------------------------- src/xml.c | 60 ------------ tocxml.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++ xml.c | 46 +++++++++ 37 files changed, 1427 insertions(+), 1716 deletions(-) delete mode 100644 AUTHORS delete mode 100644 BUGS delete mode 100644 CREDITS delete mode 100644 ChangeLog delete mode 100644 INSTALL create mode 100644 Makefile delete mode 100644 Makefile.am delete mode 100644 NEWS create mode 100644 cli.c create mode 100644 config.mk delete mode 100644 configure.ac delete mode 100644 doc/Makefile.am delete mode 100644 doc/RELEASING delete mode 100644 doc/getht.man create mode 100644 download.c create mode 100644 getht.1 create mode 100644 getht.c create mode 100644 getht.h create mode 100644 issuemem.c create mode 100644 parseconfig.c delete mode 100755 prepare-release.sh delete mode 100644 src/.gitignore delete mode 100644 src/Makefile.am delete mode 100644 src/cli.c delete mode 100644 src/config.c delete mode 100644 src/download.c delete mode 100644 src/getht.c delete mode 100644 src/getht.h delete mode 100644 src/issue.h delete mode 100644 src/issuemem.c delete mode 100644 src/tocxml.c delete mode 100644 src/xml.c create mode 100644 tocxml.c create mode 100644 xml.c diff --git a/.gitignore b/.gitignore index 42255fb..afee52f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1 @@ -# ignore auto-generated autoconf files -Makefile -Makefile.in -aclocal.m4 -stamp-h1 -config.h -config.h.in -config.h.log -config.log -config.status -config -configure -autom4te.cache +getht diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index fbf808e..0000000 --- a/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -Main program code and maintainer: -Nick White - http://www.njw.me.uk diff --git a/BUGS b/BUGS deleted file mode 100644 index e69de29..0000000 diff --git a/COPYING b/COPYING index 94a9ed0..cb6e900 100644 --- a/COPYING +++ b/COPYING @@ -1,3 +1,7 @@ +GetHT is Copyright 2006,2008,2010 Nick White. It is licensed under the +GNU General Public License version 3, or any later version. + + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/CREDITS b/CREDITS deleted file mode 100644 index d4ebfc5..0000000 --- a/CREDITS +++ /dev/null @@ -1,6 +0,0 @@ -So far this program has been written entirely by me, Nick White. -Many thanks to Bridget Cady for her patient testing. - -If you'd like to contribute suggestions, bug reports, or anything -else you believe would be useful, I would be delighted, and your -name would be mentioned here. diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e69de29..0000000 diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 12a7728..0000000 --- a/INSTALL +++ /dev/null @@ -1,32 +0,0 @@ -To install this package, simply follow the following steps: - -1. Decompress & untar the archive - $ tar -xjf getht-.tar.bz2 - -2. Change to the source directory - $ cd getht- - -4. Prepare the software for your system - $ ./configure - - Note that there are several options which can be applied - here, such as prefix and locations of libraries. - For more information run: - $ ./configure --help - -4. Build the software - $ make - -5. Install the software (ensure that you have superuser - privilages if installing outside of your home directory) - $ make install - - -You can then run the package by typing the following -command into a terminal: -$ getht - -Note that the AutoTools scripts to build and install GetHT are -quite simple, and have not been thoroughly tested. -If you encounter any problems building please let me know, using -one of the methods suggested in the README file. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9a9847c --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +# See COPYING file for copyright, license and warranty details. + +include config.mk + +TARGET = getht +SRC = $(shell find . -name '*.c') +OBJ = $(SRC:.c=.o) +MAN = $(TARGET:=.1) +DOC = README + +all: $(TARGET) + +$(TARGET:=.o): $(SRC) + cc -c $(SRC) $(CFLAGS) + +$(TARGET): $(OBJ) + cc -o $@ $(OBJ) $(LDFLAGS) + +clean: + rm -f -- $(TARGET) $(OBJ) + +install: + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f $(TARGET) $(DESTDIR)$(PREFIX)/bin + mkdir -p $(DESTDIR)$(MANPREFIX)/man1 + cp -f $(MAN) $(DESTDIR)$(MANPREFIX)/man1 + +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/$(TARGET) + rm -f $(DESTDIR)$(MANPREFIX)/man1/$(MAN) + +dist: clean + mkdir -p getht-$(VERSION) + cp -R $(SRC) $(DOC) getht-$(VERSION) + sed "s/VERSION/$(VERSION)/g" < $(MAN) > getht-$(VERSION)/$(MAN) + tar -c getht-$(VERSION) > getht-$(VERSION).tar + bzip2 < getht-$(VERSION).tar > getht-$(VERSION).tar.bz2 + rm -rf getht-$(VERSION).tar getht-$(VERSION) + gpg -b < getht-$(VERSION).tar.bz2 > getht-$(VERSION).tar.bz2.sig + sha1sum < getht-$(VERSION).tar.bz2 > getht-$(VERSION).tar.bz2.sha1 diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 8f2b81f..0000000 --- a/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -## A simple file to process with Automake, to produce Makefile.in - -SUBDIRS = src doc - -doc_DATA = \ - AUTHORS \ - BUGS \ - ChangeLog \ - COPYING \ - CREDITS \ - INSTALL \ - NEWS \ - README diff --git a/NEWS b/NEWS deleted file mode 100644 index e69de29..0000000 diff --git a/README b/README index 6c36bb6..0c96f05 100644 --- a/README +++ b/README @@ -24,7 +24,7 @@ libxml2 2.0.0+ libcurl 7.7.2+ -Install -For details on how to install GetHT see the INSTALL file. +make && make install -Proxy Support GetHT supports HTTP, SOCKS4 & SOCKS5 proxys (though they haven't been diff --git a/cli.c b/cli.c new file mode 100644 index 0000000..156ff0b --- /dev/null +++ b/cli.c @@ -0,0 +1,65 @@ +/* + * This file is part of GetHT + * + * See COPYING file for copyright, license and warranty details. + * + */ + +#include +#include + +#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("%2i: %s\n", iss_no, 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); + if(verbose >= 1) + { + for(sec_no=0; sec_no<=issue[iss_no]->no_of_sections; sec_no++) + { + printf(" %2i: %s\n", issue[iss_no]->section[sec_no]->number, + issue[iss_no]->section[sec_no]->title); + printf(" %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(" pp %2i - %2i: %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 showusage() +{ + printf("Usage: getht [options] -a\n"); + printf(" or: getht [options] -d issno [-s secno]\n"); + printf(" or: getht [options] -l\n"); + printf("Downloads issue(s) of Hinduism Today\n\n"); + printf("Download options:\n"); + printf(" -a, --download-all Download all issues\n"); + printf(" -d, --download-issue issno Download issue number issno\n"); + printf(" -s, --download-section secno Download section number secno\n"); + printf(" -f, --force Force re-download of existing files\n"); + printf("Discovery options:\n"); + printf(" -l, --list-issues List available issues\n"); + printf(" -u, --update Update contents files\n"); + printf("Global options:\n"); + printf(" -q, --quiet Make output less verbose\n"); + printf(" -v, --verbose Make output more verbose\n"); + printf("Other options:\n"); + printf(" -h, --help Print this help message\n"); + printf(" -V, --version Print version information\n"); +} diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..3251293 --- /dev/null +++ b/config.mk @@ -0,0 +1,24 @@ +# See COPYING file for copyright, license and warranty details. + +VERSION = 0.2 + +# paths +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +# includes and libs +INCS = -I. -I/usr/include +LIBS = -L/usr/lib -lc + +CURLINC = $(shell pkg-config --cflags libcurl) +CURLLIB = $(shell pkg-config --libs libcurl) +XMLINC = $(shell pkg-config --cflags libxml-2.0) +XMLLIB = $(shell pkg-config --libs libxml-2.0) + +# flags +#CFLAGS = -pedantic -Wall -Werror ${INCS} ${CURLINC} ${XMLINC} -DVERSION=\"${VERSION}\" +CFLAGS = -std=c99 -Wall -Werror ${INCS} ${CURLINC} ${XMLINC} -DVERSION=\"${VERSION}\" +LDFLAGS = ${LIBS} ${CURLLIB} ${XMLLIB} + +# compiler and linker +CC = cc diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 6111c42..0000000 --- a/configure.ac +++ /dev/null @@ -1,34 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.63]) -AC_INIT([getht], [0.2]) -AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE([-Wall -Werror]) - -# Checks for programs. -AC_PROG_CC -AC_PROG_AWK -AC_PROG_MAKE_SET - -# Checks for libraries. -PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.0.0]) -PKG_CHECK_MODULES([LIBCURL], [libcurl >= 7.7.2]) -LIBS="$LIBXML2_LIBS $LIBCURL_LIBS $LIBS" -CFLAGS="$LIBXML2_CFLAGS $LIBCURL_CFLAGS $CFLAGS" - -# Checks for header files. -AC_CHECK_HEADERS([stdlib.h string.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_MALLOC -AC_FUNC_REALLOC -AC_CHECK_FUNCS([mkdir]) - -AC_CONFIG_FILES([Makefile - doc/Makefile - src/Makefile]) -AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 5ab40eb..0000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -man1_MANS = getht.man -##doc_DATA = *.txt diff --git a/doc/RELEASING b/doc/RELEASING deleted file mode 100644 index 6260e96..0000000 --- a/doc/RELEASING +++ /dev/null @@ -1,45 +0,0 @@ -== PROCEDURE FOR MAKING A NEW RELEASE == - -- Version Number - -1. Set version number in build system - configure.ac -2. Tag current commit in git - git-tag -s vX.X - git-push --tags - -- Source Tarball - -1. Create a clean tarball, and sign & checksum it - ./prepare-release.sh -2. Upload tarball & related files - scp getht-*.tar.bz2* @dl.sv.nongnu.org:/releases/getht/ - -- Webpages - -1. Get downloads webpage - wget http://download.savannah.gnu.org/releases/getht/ -2. Add new version information -3. Upload updated webpage - scp index.html @dl.sv.nongnu.org:/releases/getht/ -4. Take screenshot of new version -5. Upload new screenshot - cvs commit - -- Infrastructure - -1. Add to new version option to bug tracker - https://savannah.nongnu.org/bugs/admin/field_values.php?group_id=9005&list_value=1&field=release_id - -- Announcement - -1. Post news to mailing list - getht-general@nongnu -2. Post news to Savannah - https://savannah.nongnu.org/news/submit.php?group=getht -3. Post new version to the following directories: - Freshmeat: http://freshmeat.net/add-release/64475/ - IceWalkers: http://www.icewalkers.com/submit.php?ID=3035 - SourceWell: http://sourcewell.berlios.de/updapp.php?id=3655 - -- Clean up - -1. Delete local copy of release files - rm index.html getht-*.tar.bz2* - -- Packaging - -1. Update packages maintained diff --git a/doc/getht.man b/doc/getht.man deleted file mode 100644 index 4c4b5a7..0000000 --- a/doc/getht.man +++ /dev/null @@ -1,163 +0,0 @@ -.\" Copyright 2007,2008 Nick White -.\" -.\" This file is part of GetHT -.\" -.\" This is free documentation; 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 3 of the License, or -.\" (at your option) any later version. -.\" -.\" The GNU General Public License's references to "object code" -.\" and "executables" are to be interpreted as the output of any -.\" document formatting or typesetting system, including -.\" intermediate and printed output. -.\" -.\" This manual 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 this program. If not, see . -.TH GETHT 1 -.SH NAME -.B GetHT -\- The Free Hinduism Today Digital Edition Downloader -.SH SYNOPSIS -.TP 5 -\fBgetht -\fI[-ualmofVvh] [-d issno] [-n medno] [-t tocfile] [-m medtocfile]\fR - -.SH DESCRIPTION -.PP -.I GetHT -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. - -.SH OPTIONS -.TP -.B \-u, \-\-update -Update the Hinduism Today contents files. -.TP -.B \-a, \-\-download-all -Download all issues of Hinduism Today. -.TP -.B \-d, \-\-download-issue issno -Download the issue numbered issno (use \fI-l\fR to find -issue numbers). -.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 \-t, \-\-tocfile tocfile -Use a different contents file, as specified by tocfile. -.TP -.B \-h, \-\-help -Print a brief usage message. -.TP -.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 -All of the settings for GetHT are stored in the -configuration file, which normally resides in -\fB~/.getht/config.ini\fR. - -The format of this file is very simple: -\fB