From f811c2d4823f95d7e90f25e0e7a98e5c5abcf3e2 Mon Sep 17 00:00:00 2001 From: Nick White Date: Thu, 3 May 2007 00:31:22 +0000 Subject: Added Autotools, changed dir structure, added docs Added (perhaps somewhat shaky) autotools support Added tagging rules to junkify files generated by autotools Added a directory structure Updated README & INSTALL files to reflect changes Wrote a man page Changed version numbers in preparation for a release git-archimport-id: getht@sv.gnu.org/getht--mainline--0.1--patch-23 --- AUTHOR | 3 - AUTHORS | 3 + INSTALL | 41 +++--- Makefile | 37 ------ Makefile.am | 13 ++ NEWS | 0 README | 51 ++++---- config.c | 168 ------------------------ configure.in | 47 +++++++ doc/Makefile.am | 2 + doc/getht.man | 167 ++++++++++++++++++++++++ download.c | 228 -------------------------------- getht.c | 394 -------------------------------------------------------- getht.h | 47 ------- issue.h | 77 ----------- issuemem.c | 174 ------------------------- mediarev.c | 150 --------------------- mediaxml.c | 246 ----------------------------------- src/Makefile.am | 7 + src/config.c | 168 ++++++++++++++++++++++++ src/download.c | 228 ++++++++++++++++++++++++++++++++ src/getht.c | 394 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/getht.h | 47 +++++++ src/issue.h | 77 +++++++++++ src/issuemem.c | 174 +++++++++++++++++++++++++ src/mediarev.c | 150 +++++++++++++++++++++ src/mediaxml.c | 246 +++++++++++++++++++++++++++++++++++ src/tocxml.c | 264 +++++++++++++++++++++++++++++++++++++ src/version.h | 22 ++++ src/xml.c | 62 +++++++++ tocxml.c | 264 ------------------------------------- version.h | 22 ---- xml.c | 62 --------- 33 files changed, 2123 insertions(+), 1912 deletions(-) delete mode 100644 AUTHOR create mode 100644 AUTHORS delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 NEWS delete mode 100644 config.c create mode 100644 configure.in create mode 100644 doc/Makefile.am create mode 100644 doc/getht.man delete mode 100644 download.c delete mode 100644 getht.c delete mode 100644 getht.h delete mode 100644 issue.h delete mode 100644 issuemem.c delete mode 100644 mediarev.c delete mode 100644 mediaxml.c create mode 100644 src/Makefile.am create mode 100644 src/config.c create mode 100644 src/download.c create mode 100644 src/getht.c create mode 100644 src/getht.h create mode 100644 src/issue.h create mode 100644 src/issuemem.c create mode 100644 src/mediarev.c create mode 100644 src/mediaxml.c create mode 100644 src/tocxml.c create mode 100644 src/version.h create mode 100644 src/xml.c delete mode 100644 tocxml.c delete mode 100644 version.h delete mode 100644 xml.c diff --git a/AUTHOR b/AUTHOR deleted file mode 100644 index a476016..0000000 --- a/AUTHOR +++ /dev/null @@ -1,3 +0,0 @@ -Main program code and maintainer: -Nick White - http://www.njw.me.uk diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..a476016 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,3 @@ +Main program code and maintainer: +Nick White + http://www.njw.me.uk diff --git a/INSTALL b/INSTALL index 1167673..12a7728 100644 --- a/INSTALL +++ b/INSTALL @@ -1,21 +1,32 @@ -At the moment this project uses a custom (but very basic) makefile -to make and install. This will soon be changed to autotools, but at -present this way works well enough. +To install this package, simply follow the following steps: -For a default install all that is needed is the following: +1. Decompress & untar the archive + $ tar -xjf getht-.tar.bz2 -1. Decompress/archive the project file: - tar -xzf getht-.tar.gz -or - tar -xyf getht-.tar.bz2 +2. Change to the source directory + $ cd getht- -2. Change to hdte directory: - cd getht- +4. Prepare the software for your system + $ ./configure -3. Run make to compile the source: - make + 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. Use make again to install it (you'll need to have root privilages): - make install +4. Build the software + $ make -For further build options, see the output of "make help" +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 deleted file mode 100644 index 34a02db..0000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -PREFIX=/usr -DOCS=AUTHOR COPYING CREDITS ChangeLog INSTALL README TODO -CFLAGS+=-g `curl-config --cflags` `xml2-config --cflags` -LDFLAGS+=`curl-config --libs` `xml2-config --libs` - -all: getht - -getht: download.o config.o issuemem.o tocxml.o mediarev.o mediaxml.o xml.o - -tocxml.o mediaxml.o: xml.o - -static: - CFLAGS="$(CFLAGS) -s -static" - @echo "Not implemented yet, sorry." - -clean: - rm -rf *.o - -install: - cp getht $(PREFIX)/bin - mkdir -p $(PREFIX)/doc/getht - cp $(DOCS) $(PREFIX)/doc/getht - -uninstall: - rm $(PREFIX)/bin/getht - rm -r $(PREFIX)/doc/getht - -help: - @echo -e "Make targets:" - @echo -e "make (all)\tBuilds GetHT with default settings" - @echo -e "make install\tInstalls GetHT" - @echo -e "make uninstall\tRemoves GetHT" - @echo -e "make clean\tRemoves all object files" - @echo -e "make static\tBuilds a statically linked GetHT binary" - @echo -e "make help\tPrint this help message" - -.PHONY: all clean install uninstall help diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..8f2b81f --- /dev/null +++ b/Makefile.am @@ -0,0 +1,13 @@ +## 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 new file mode 100644 index 0000000..e69de29 diff --git a/README b/README index 0097953..8f294b2 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ -GetHT - The Free Hinduism Today Digital Edition Fetcher +GetHT - The Free Hinduism Today Digital Edition Downloader -Summary: +-Summary The nice people at Hinduism Today have recently begun freely distributing their magazine in pdf format, so that anybody may read a copy for free. @@ -13,36 +13,37 @@ unable to download the new issues. This program is written to change all that. -License: -htde is released under the GPL, see the file COPYING for details. +-License +GetHT is released under the GPL, see the file COPYING for details. Basically this means that you are free to study the program, modify it, and redistribute it however you see fit, provided you extend the same freedom to others by releasing derivatives with the same license. -Proxy Support: +-Dependancies +libxml2 2.0.0+ Compiled with zlib support +libcurl 7.7.2+ + +-Install +For details on how to install GetHT see the INSTALL file. + +-Proxy Support GetHT supports HTTP, SOCKS4 & SOCKS5 proxys (though they haven't been thoroughly tested - let me know if there are any problems). Environmental variables (e.g. http_proxy) are used, but may be overridden with the following lines in the config.ini file. Any lines which are not needed (for example the authentication lines) should just be omitted. The format of the options is: -proxy_type (http, socks4 or socks5) -proxy_address
-proxy_port -proxy_auth (none, basic, digest or ntlm) -proxy_user -proxy_pass - -Dependancies: -libxml2 To parse the contents and media files; ensure to compile - with zlib support -libcurl 7.7.2+ To download the necessary issues and periphery -Unless compiled with "make nogui": -fltk 2.0+ To draw and control the windows - -Install: -The project is too small to warrent autoconf or anything else complex, -so simply use the makefile provided to compile and install the software -from source. - -For more details see the included INSTALL file. + proxy_type (http, socks4 or socks5) + proxy_address
+ proxy_port + proxy_auth (none, basic, digest or ntlm) + proxy_user + proxy_pass + +-Bugs / Problems +This software is very new, so there will undoubtedly be some bugs lingering, +or parts of the program which don't work as expected. +If you encounter problems, there are several ways to get help: + Mailing List : http://lists.nongnu.org/mailman/listinfo/getht-general + Support Tracker : http://savannah.nongnu.org/support/?group=getht + Bug Tracker : http://savannah.nongnu.org/bugs/?group=getht diff --git a/config.c b/config.c deleted file mode 100644 index 57807b1..0000000 --- a/config.c +++ /dev/null @@ -1,168 +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 -#include - -#include "getht.h" - -extern proxytype proxy_type; -extern char proxy_addr[STR_MAX]; -extern long proxy_port; -extern proxyauth proxy_auth; -extern char proxy_user[STR_MAX]; -extern char proxy_pass[STR_MAX]; - -int loadconfig(char * htde_path, char * issue_path, int * update) -/* Loads variables from config file to extern and passed - * variables. */ -{ - FILE * config_file; - char filepath[STR_MAX]; - - snprintf(filepath, STR_MAX, "%s/config.ini", htde_path); - - if((config_file = fopen(filepath,"r")) == NULL) - { - fprintf(stderr,"Cannot open file %s for reading.\n",filepath); - return 1; - } - - char parameter[80], option[80]; - while(!feof(config_file)) - { - fscanf(config_file, "%s = %s", option, parameter); - - if(option[0] == '#'); /* ignore lines beginning with a hash */ - else if(!strcmp(option, "issuepath")) - strncpy(issue_path, parameter, STR_MAX); - else if(!strcmp(option, "startup_check")) - *update = atoi(parameter); - else if(!strcmp(option, "proxy_type")) - { - if(!strcmp(parameter, "http")) - proxy_type = HTTP; - else if(!strcmp(parameter, "socks4")) - proxy_type = SOCKS4; - else if(!strcmp(parameter, "socks5")) - proxy_type = SOCKS5; - else - fprintf(stderr, - "Proxy type %s not known, please use either http, socks4 or socks5", - parameter); - } - else if(!strcmp(option, "proxy_address")) - strncpy(proxy_addr, parameter, STR_MAX); - else if(!strcmp(option, "proxy_port")) - proxy_port = (long) atoi(parameter); - else if(!strcmp(option, "proxy_auth")) - { - if(!strcmp(parameter, "basic")) - proxy_auth = BASIC; - else if(!strcmp(parameter, "digest")) - proxy_auth = DIGEST; - else if(!strcmp(parameter, "ntlm")) - proxy_auth = NTLM; - else - fprintf(stderr, - "Proxy authentication method %s not known, please use basic, digest or ntlm", - parameter); - } - else if(!strcmp(option, "proxy_user")) - strncpy(proxy_user, parameter, STR_MAX); - else if(!strcmp(option, "proxy_pass")) - strncpy(proxy_pass, parameter, STR_MAX); - else - fprintf(stderr, "Option '%s' not recognised, ignoring\n", option); - } - - return 0; -} - -int writefreshconfig(char * htde_path, char * issue_path, int * update) -/* Write a new config file according to extern and passed variables. */ -{ - FILE * config_file; - char filepath[STR_MAX]; - - snprintf(filepath, STR_MAX, "%s/config.ini", htde_path); - - if((config_file = fopen(filepath,"w")) == NULL) - { - fprintf(stderr,"Cannot open file %s for writing.\n",filepath); - return 1; - } - else - fprintf(stdout,"Writing a fresh config file to %s.\n",filepath); - - if(issue_path[0]) - fprintf(config_file, "%s = %s\n", "issuepath", issue_path); - if(update) - fprintf(config_file, "%s = %i\n", "startup_check", *update); - if(proxy_type != NONE) - { - if(proxy_type = HTTP) - fprintf(config_file, "%s = %s\n", "proxy_type", "http"); - else if(proxy_type = SOCKS4) - fprintf(config_file, "%s = %s\n", "proxy_type", "socks4"); - else if(proxy_type = SOCKS5) - fprintf(config_file, "%s = %s\n", "proxy_type", "socks5"); - } - if(proxy_addr[0]) - fprintf(config_file, "%s = %s\n", "proxy_address", proxy_addr); - if(proxy_port) - fprintf(config_file, "%s = %i\n", "proxy_port", proxy_port); - if(proxy_auth != NOAUTH) - { - if(proxy_auth = BASIC) - fprintf(config_file, "%s = %s\n", "proxy_auth", "basic"); - else if(proxy_auth = DIGEST) - fprintf(config_file, "%s = %s\n", "proxy_auth", "digest"); - else if(proxy_auth = NTLM) - fprintf(config_file, "%s = %s\n", "proxy_auth", "ntlm"); - } - if(proxy_user[0]) - fprintf(config_file, "%s = %s\n", "proxy_user", proxy_user); - if(proxy_pass[0]) - fprintf(config_file, "%s = %s\n", "proxy_pass", proxy_pass); - - return 0; -} - -int updateconfig(char * htde_path, char * issue_path, int * update) -/* Read existing config file, and rewrite any variables which differ - * in memory. */ -{ - FILE * config_file; - char filepath[STR_MAX]; - - snprintf(filepath, STR_MAX, "%s/config.ini", htde_path); - - if((config_file = fopen(filepath,"rw")) == NULL) - { - fprintf(stderr,"Cannot open file %s for reading/writing.\n",filepath); - return 1; - } - - fprintf(stderr,"Not yet implemented.\n"); - - return 1; -} diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..306a49b --- /dev/null +++ b/configure.in @@ -0,0 +1,47 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT(getht, 0.0.1) +AC_CONFIG_SRCDIR([src/]) +AC_CONFIG_AUX_DIR([config]) +AC_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE(AC_PACKAGE_NAME,AC_PACKAGE_VERSION) +AC_LANG([C]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL + +# Checks for libraries. + +dnl check for zlib +CHECK_ZLIB() + +dnl check for libxml2 +AM_PATH_XML2([2.0.0]) +CFLAGS="$CFLAGS $XML_CPPFLAGS" +LIBS="$LIBS $XML_LIBS" + +dnl check for libcurl +LIBCURL_CHECK_CONFIG([yes], [7.7.2]) +CFLAGS="$CFLAGS $LIBCURL_CPPFLAGS" +LIBS="$LIBS $LIBCURL" + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdlib.h string.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +# Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([mkdir strdup]) + +AC_CONFIG_FILES([Makefile + doc/Makefile + src/Makefile]) +AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..5ab40eb --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,2 @@ +man1_MANS = getht.man +##doc_DATA = *.txt diff --git a/doc/getht.man b/doc/getht.man new file mode 100644 index 0000000..3b6bfef --- /dev/null +++ b/doc/getht.man @@ -0,0 +1,167 @@ +.\" Copyright 2007 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 2 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, write to the Free Software +.\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +.TH GETHT 1 +.SH NAME +.B GetHT +\- The Free Hinduism Today Digital Edition Downloader +.SH SYNOPSIS +.TP 5 +\fBgetht +\fI[-uadmnfvh] [-t tocfile] [-m medtocfile]\fR + +.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. + +.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-latest +Download only the latest issue of Hinduism Today. +.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 \-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 +.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