getht-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getht-commit] arch commit: getht--mainline--0.1--patch-29


From: Nick
Subject: [Getht-commit] arch commit: getht--mainline--0.1--patch-29
Date: Sat, 26 May 2007 23:19:37 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Revision: getht--mainline--0.1--patch-29
Archive: address@hidden
Creator: Nick White <address@hidden>
Date: Sat May 26 23:18:56 BST 2007
Standard-date: 2007-05-26 22:18:56 GMT
Modified-files: configure.ac doc/getht.man src/config.c
    src/getht.c
New-patches: address@hidden/getht--mainline--0.1--patch-29
Summary: General cleanup, Add alt url config options
Keywords: 

Removed unused & unnecessary findnewestiss
Replaces strcpy with strncpy to eliminate possible buffer overruns
Added a couple of config options to allow use of alternative
toc urls
M  doc/getht.man
M  src/config.c
M  src/getht.c
M  configure.ac

* modified files

--- orig/configure.ac
+++ mod/configure.ac
@@ -22,6 +22,9 @@
 AM_PATH_XML2([2.0.0])
 CFLAGS="$CFLAGS $XML_CPPFLAGS"
 LIBS="$LIBS $XML_LIBS"
+#PKG_CHECK_MODULES(libxml-2.0)
+#AC_SUBST(XML_CPPFLAGS)
+#AC_SUBST(XML_LIBS)
 
 dnl check for libcurl
 LIBCURL_CHECK_CONFIG([yes], [7.7.2])


--- orig/doc/getht.man
+++ mod/doc/getht.man
@@ -110,6 +110,16 @@
 time the GetHT is executed. \fB1\fR = yes, \fB0\fR = no
 The default setting is \fB0\fR
 .TP
+.B toc_url
+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:


--- orig/src/config.c
+++ mod/src/config.c
@@ -30,6 +30,8 @@
 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
@@ -56,6 +58,10 @@
                        strncpy(issue_path, parameter, STR_MAX);
                else if(!strcmp(option, "startup_check"))
                        *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"))
@@ -117,6 +123,10 @@
                fprintf(config_file, "%s = %s\n", "issuepath", issue_path);
        if(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)


--- orig/src/getht.c
+++ mod/src/getht.c
@@ -39,6 +39,7 @@
 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];
 CURL *main_curl_handle; 
 
 int main(int argc, char *argv[])
@@ -61,6 +62,9 @@
        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;
@@ -78,7 +82,7 @@
        proxy_pass[0] = '\0';
 
        if(loadconfig(getht_path, &save_path, &update) != 0)
-               writefreshconfig(getht_path, &save_path, &update);
+               writefreshconfig(getht_path, &save_path, &update, &issue_url, 
&media_url);
 
        if(!opendir(save_path))
                if(mkdir(save_path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | 
S_IXOTH))
@@ -148,12 +152,10 @@
                                option = 1;
                                break;
                        case 't':
-                               strcpy(issue_xml, strdup(optarg));
-                               option = 1;
+                               strncpy(issue_xml, strdup(optarg), STR_MAX);
                                break;
                        case 'x':
-                               strcpy(media_xml, strdup(optarg));
-                               option = 1;
+                               strncpy(media_xml, strdup(optarg), STR_MAX);
                                break;
                        case 'h':
                                showusage();
@@ -277,7 +279,7 @@
 int update_contents_files()
 /* Returns 0 on success, 1 on failure */
 {
-       if(save_file(NULL, XML_TOC_URL, issue_xml))
+       if(save_file(NULL, issue_url, issue_xml))
                return 1;
        
        char isstitle[STR_MAX];
@@ -295,7 +297,7 @@
 
        if(media_accounted_for(media_xml, &date))
        {
-               if(save_file(NULL, MEDIA_TOC_URL, media_rev))
+               if(save_file(NULL, media_url, media_rev))
                        return 1;
        
                med ** temp_med;
@@ -310,29 +312,3 @@
 
        return 0;
 }
-
-int findnewestiss(iss ** issue, int no_of_issues)
-/*     returns newest issue indice */
-{
-       iss * tmp_issue; issdates newest;
-       int new_iss;
-
-       new_iss = -1;
-       newest.year = 0; newest.firstmonth = 0; newest.lastmonth = 0;
-
-       int i;
-
-       for(i = 0; i <= no_of_issues; i++)
-       {
-               if(issue[i]->date.year > newest.year ||
-                       (issue[i]->date.year == newest.year && 
issue[i]->date.firstmonth > newest.firstmonth))
-               {
-                       newest.year = issue[i]->date.year;
-                       newest.firstmonth = issue[i]->date.firstmonth;
-                       newest.lastmonth = issue[i]->date.lastmonth;
-                       new_iss = i;
-               }
-       }
-
-       return new_iss;
-}



Attachment: pgpdbtkFDCGz5.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]