Re: [Morphix-cvs] SF.net SVN: morphix: [2471] trunk/mmaker

"Brendan M. Sleight" <[email protected]> Fri, 6 Apr 2007 19:27:57 +0100
Newsgroups gmane.linux.morphix.devel
Message-ID <[email protected]>
Hi All,

I have had a re-think on the patch I submitted. It works for examples such as:-
 <retrieve>
    <from>http://foo.com/bar.deb</from>
    <to>/tmp/</to>
 </retrieve>

However, it will not work for examples such as:-
 <retrieve>
    <from>http://foo.com/bar.txt</from>
    <to>/tmp/foo.txt</to>
 </retrieve>

Below is another improved patch. However my c skills are very, very
rusty. I can not remember the last time I did some c. Please can
someone review my 1337 coding, before it is submitted to the svn
repository.

Regards,
Brendan


Index: makemodule.c
===================================================================
--- makemodule.c        (revision 2471)
+++ makemodule.c        (working copy)
@@ -550,7 +550,17 @@
                        gchar *http_s = "http://";

                        if (strncmp(r->from,http_s,strlen(http_s)) == 0) {
-                               gchar *cmdline = g_strdup_printf("wget
-P %s/%s %s",module->dirname,r->to,r->from);
+                               #If the last charactor of r->from is a
/ then we need wget -P else wget -O
+                               char * pch;
+                               char  wgetopt;
+                               pch=strrchr(r->from,'/');
+                               if (pch-r->from == strlen(r->from)-1) {
+                                       wgetopt='P';
+                               }
+                               else {
+                                       wgetopt='O';
+                               }
+                               gchar *cmdline = g_strdup_printf("wget
-%c %s/%s %s",wgetopt,module->dirname,r->to,r->from);
                                if (!ExecuteCommand(cmdline)) {
                                        fprintf(stderr,"Warning:
unable to execute retrieval: %s\n",r->from);
                                }

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV