#!/bin/awk -f
# $Revision$, $Date$
+# TODO: "SourceXDownload" support (use given URLs if present instead of cut-down SourceX URLs)
+
function fixedsub(s1,s2,t, ind) {
# substitutes fixed strings (not regexps)
if (ind = index(t,s1)) {
if (tolower(odp) ~ /<frame[ \t]/) {
match(tolower(odp),/<frame[ \t][^>]*>/)
ramka=substr(odp,RSTART,RLENGTH)
- odp=substr(odp,RSTART+RLENGTH)
- sub(/[sS][rR][cC]=[ \t]+/,"src=",ramka);
- match(tolower(ramka),/src="[^"]+"/)
+ odp=substr(odp,1,RSTART) substr(odp,RSTART+RLENGTH)
+ sub(/[sS][rR][cC]=[ \t]*/,"src=",ramka);
+ match(ramka,/src="[^"]+"/)
newurl=substr(ramka,RSTART+5,RLENGTH-6)
if (DEBUG) print "Ramka: " newurl
if (newurl !~ /\//) {
if (DEBUG) print "Ramka->: " newurl
}
retval=(retval " " get_links(newurl))
- } else if (tolower(odp) ~ /href=[ \t]*"[^"]+"/) {
- sub(/[hH][rR][eE][fF]=[ \t]+/,"href=",odp)
- match(tolower(odp),/href="[^"]+"/)
+ } else if (tolower(odp) ~ /href=[ \t]*"[^"]*"/) {
+ sub(/[hH][rR][eE][fF]=[ \t]*"/,"href=\"",odp)
+ match(odp,/href="[^"]*"/)
+ link=substr(odp,RSTART,RLENGTH)
+ odp=substr(odp,1,RSTART) substr(odp,RSTART+RLENGTH)
+ link=substr(link,7,length(link)-7)
+ retval=(retval " " link)
+ if (DEBUG) print "href(\"\"): " link
+ } else if (tolower(odp) ~ /href=[ \t]*'[^']*'/) {
+ sub(/[hH][rR][eE][fF]=[ \t]*'/,"href='",odp)
+ match(odp,/href='[^']*'/)
link=substr(odp,RSTART,RLENGTH)
- odp=substr(odp,RSTART+RLENGTH)
+ odp=substr(odp,1,RSTART) substr(odp,RSTART+RLENGTH)
link=substr(link,7,length(link)-7)
retval=(retval " " link)
- } else if (tolower(odp) ~ /href=[ \t]*[^ \t>]+/) {
- sub(/[hH][rR][eE][fF]=[ \t]+/,"href=",odp)
- match(tolower(odp),/href=[^ \t>]+/)
+ if (DEBUG) print "href(''): " link
+ } else if (tolower(odp) ~ /href=[ \t]*[^ \t>]*/) {
+ sub(/[hH][rR][eE][fF]=[ \t]*/,"href=",odp)
+ match(odp,/href=[^ \t>]*/)
link=substr(odp,RSTART,RLENGTH)
- odp=substr(odp,RSTART+RLENGTH)
+ odp=substr(odp,1,RSTART) substr(odp,RSTART+RLENGTH)
link=substr(link,6,length(link)-5)
retval=(retval " " link)
+ if (DEBUG) print "href(): " link
} else {
retval=(retval " INTERNAL_ERROR")
break
if (prefix==origin){
if ( DEBUG ) print "Mirror znaleziony na " mname
close("mirrors")
- return mirror substr(url,length(origin))
+ return mirror substr(url,length(origin)+1)
}
}
}
newfilename=fixedsub(prever,"",newfilename)
newfilename=fixedsub(postver,"",newfilename)
if (DEBUG) print "Wersja: " newfilename
- if (newfilename ~ /\.(pkg|bin|binary)$/) continue
+ if (newfilename ~ /\.(pkg|bin|binary|built)$/) continue
if (NUMERIC) {
if ( compare_ver_dec(version, newfilename)==1 ) {
if (DEBUG) print "Tak, jest nowa"