2
# $Id: rfc,v 1.2 2004/02/06 00:31:05 ianb-guest Exp $
3
# elvis: rfc -- Search RFCs (internet standards documents)
4
# ianb@nessie.mcc.ac.uk 20031220
8
def SURFRAW_rfc_search all
9
def SURFRAW_rfc_field all
10
def SURFRAW_rfc_results $SURFRAW_results
11
def SURFRAW_rfc_output txt
12
defyn SURFRAW_rfc_matchexact no
13
defyn SURFRAW_rfc_showabs no
14
defyn SURFRAW_rfc_showkw no
15
defyn SURFRAW_rfc_reverse no
16
defyn SURFRAW_rfc_ftp no
17
defyn SURFRAW_rfc_nodirect no
23
Usage: $w3_argv0 [options] [search words]...
25
Surfraw search the RFC (Request For Comments) internet standards.
27
-results=NUM Number of search results returned
28
Default: $SURFRAW_rfc_results
29
Environment: SURFRAW_rfc_results
30
-pdf Return files as PDF (Default: text)
31
-rev Reverse order of results
32
-exact Match exact words (instead of prefixes)
34
-keywords Show keywords
35
-nodirect Don't try and go direct to RFC (Tries when
36
arg is numeric and -search/-field not used)
37
-ftp Retrieve RFCs via FTP instead of HTTP
38
-field= Which field to search
44
Default: if args are numeric, "number",
46
Environment: SURFRAW_rfc_field
47
-search= Collection to search
49
rfc | Requests For Comments
51
bcp | Best Current Practices
52
fyi Informational (For Your Information)
53
Default: $SURFRAW_rfc_search
54
Environment: SURFRAW_rfc_search
59
w3_parse_option_hook () {
63
-res*=*) setopt SURFRAW_rfc_results $optarg ;;
64
-pdf*) setopt SURFRAW_rfc_output pdf ;;
65
-rev*) setoptyn SURFRAW_rfc_reverse yes ;;
66
-ex*) setoptyn SURFRAW_rfc_matchexact yes ;;
67
-abs*) setoptyn SURFRAW_rfc_showabs yes ;;
68
-k*) setoptyn SURFRAW_rfc_showkw yes ;;
69
-ftp*) setoptyn SURFRAW_rfc_ftp yes ;;
70
-no*) setoptyn SURFRAW_rfc_nodirect yes ;;
71
-se*=*) setopt SURFRAW_rfc_search $optarg ;;
72
-fi*=*) setopt SURFRAW_rfc_field $optarg ; searchset=1 ;;
80
# w3_args now contains a list of arguments
81
if test -z "$w3_args"; then
82
w3_browse_url "http://www.rfc-editor.org/rfcsearch.html"
84
escaped_args=`w3_url_of_arg $w3_args`
88
if echo "$escaped_args" |grep '^[0-9]*$' &>/dev/null
91
if ifyes SURFRAW_rfc_nodirect
99
# Do we want to go direct to rfc?
100
if [ $isnum -eq 1 -a $searchset -eq 0 -a $nodirect -eq 0 ]
103
if [ "$SURFRAW_rfc_output" = "txt" ]
106
case "$SURFRAW_rfc_search" in
107
all) fileprefix="rfc";;
108
rfc) fileprefix="rfc";;
109
std) fileprefix="std"; subdir="/std";;
110
bcp) fileprefix="bcp"; subdir="/bcp";;
111
fyi) fileprefix="fyi"; subdir="/fyi";;
112
*) echo "Unknown search: $SURFRAW_rfc_search"; exit;;
114
if ifyes SURFRAW_rfc_ftp
116
url="ftp://ftp.rfc-editor.org/in-notes${subdir}/${fileprefix}${escaped_args}.txt"
118
url="http://www.rfc-editor.org/rfc${subdir}/${fileprefix}${escaped_args}.txt"
121
case "$SURFRAW_rfc_search" in
124
*) echo "Only RFCs available as PDF files, not STDs, BCPs or FYIs. Try without -pdf";
127
# pdfs only available through ftp
128
url="ftp://ftp.rfc-editor.org/in-notes/pdfrfc/rfc${escaped_args}.txt.pdf"
133
# not direct to rfc, construct url from options
134
url="http://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=${escaped_args}"
136
if [ $isnum -eq 1 -a $searchset -eq 0 ]
138
url="$url&opt=Number"
140
case "$SURFRAW_rfc_field" in
141
all*) url="$url&opt=All+Fields";;
142
num*) url="$url&opt=Number";;
143
tit*) url="$url&opt=Title";;
144
auth*) url="$url&opt=Author";;
145
key*) url="$url&opt=Keywords";;
146
kw*) url="$url&opt=Keywords";;
147
*) url="$url&opt=All+Fields";;
151
url="$url&num=$SURFRAW_rfc_results"
152
url="$url&filefmt=$SURFRAW_rfc_output"
153
url="$url&search_doc=search_$SURFRAW_rfc_search"
155
if ifyes SURFRAW_rfc_matchexact
157
url="$url&match_method=entire"
159
url="$url&match_method=prefix"
162
if ifyes SURFRAW_rfc_showabs
164
url="$url&abstract=abson"
166
url="$url&abstract=absoff"
169
if ifyes SURFRAW_rfc_showkw
171
url="$url&keywords=keyon"
173
url="$url&keywords=keyoff"
176
if ifyes SURFRAW_rfc_reverse
178
url="$url&sort_method=older"
180
url="$url&sort_method=newer"
183
if ifyes SURFRAW_rfc_ftp
185
url="$url&format=ftp"
187
url="$url&format=http"