| 1 |
# Copyright(c) 2000-2016 Richard Mortier <[email protected]> |
| 2 |
# |
| 3 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 |
# of this software and associated documentation files(the "Software"), to deal |
| 5 |
# in the Software without restriction, including without limitation the rights |
| 6 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 |
# copies of the Software, and to permit persons to whom the Software is |
| 8 |
# furnished to do so, subject to the following conditions: |
| 9 |
# |
| 10 |
# The above copyright notice and this permission notice shall be included in all |
| 11 |
# copies or substantial portions of the Software. |
| 12 |
# |
| 13 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 |
# SOFTWARE. |
| 20 |
|
| 21 |
BEGIN { |
| 22 |
FS="[.] "; RS="\n\n"; |
| 23 |
|
| 24 |
printf("% This file auto-generated from rfc-index.txt by rfc2bib.awk\n"); |
| 25 |
printf("% by Richard Mortier <[email protected]>.\n"); |
| 26 |
printf("%\n"); |
| 27 |
printf("% Date: %s\n", strftime()); |
| 28 |
printf("\n"); |
| 29 |
printf("@string{ietf=\"{IETF}\"}\n\n"); |
| 30 |
} |
| 31 |
|
| 32 |
/^[0-9][0-9][0-9][0-9] Not Issued./ { |
| 33 |
number = substr($1, 0, 4); |
| 34 |
gsub(/^0+/, "", number); |
| 35 |
|
| 36 |
printf("@TechReport{rfc:%s,\n", number); |
| 37 |
printf(" key = {RFC%s},\n", number); |
| 38 |
printf(" author = {N/A},\n"); |
| 39 |
printf(" title = {{Not Issued}},\n"); |
| 40 |
printf(" institution = ietf,\n"); |
| 41 |
printf(" type = {{RFC}},\n"); |
| 42 |
printf(" year = {N/A},\n"); |
| 43 |
printf("}\n\n"); |
| 44 |
next; |
| 45 |
} |
| 46 |
|
| 47 |
/^[0-9][0-9][0-9][0-9] /{ |
| 48 |
gsub(/[\n]/, "", $0); |
| 49 |
gsub(/[ ]+/, " ", $0); |
| 50 |
|
| 51 |
# guard '$', '_', '#' from BibTeX/LaTeX in all fields |
| 52 |
gsub(/\$/, "\\$", $0 ); # "); |
| 53 |
gsub(/_/, "\\_", $0 ); # "); |
| 54 |
gsub(/#/, "\\" "#", $0 ); # "); |
| 55 |
|
| 56 |
number = substr($1, 0, 4); |
| 57 |
gsub(/^0+/, "", number); |
| 58 |
printf("@TechReport{rfc:%s,\n", number); |
| 59 |
printf(" key = {RFC%s},\n", number); |
| 60 |
|
| 61 |
# authors are all the fields "in the middle"; can be separated by |
| 62 |
# commas or ampersands |
| 63 |
authors = $2; |
| 64 |
for(i=3; i < NF-1; i++) |
| 65 |
{ |
| 66 |
if(length( $(i) ) > 1) |
| 67 |
{ |
| 68 |
authors =( authors ".~" $(i) ); |
| 69 |
} |
| 70 |
else |
| 71 |
{ |
| 72 |
authors =( authors "." $(i) ); |
| 73 |
} |
| 74 |
} |
| 75 |
gsub(/,| &/, " and", authors); |
| 76 |
gsub(/^ /, "", authors); |
| 77 |
if(length(authors) == 0) |
| 78 |
{ |
| 79 |
authors = "author list not available"; |
| 80 |
} |
| 81 |
printf(" author = {%s},\n", authors ); |
| 82 |
|
| 83 |
# guard capitals and '&' in the title |
| 84 |
tmp = substr($1, 6); |
| 85 |
title = gensub(/([A-Z])/, "{\\1}", "g", tmp); |
| 86 |
gsub(/&/, "\\" "\\&", title ); # "); |
| 87 |
gsub(/ - /, " -- ", title ); # "); |
| 88 |
printf(" title = {%s},\n", title); |
| 89 |
|
| 90 |
# just let the institution be the IETF for now |
| 91 |
printf(" institution = ietf,\n"); |
| 92 |
|
| 93 |
y_fld = $(NF-1); |
| 94 |
y_pos = length(y_fld) - 3; |
| 95 |
year = substr(y_fld, y_pos, 4); |
| 96 |
if(length(year) == 0) |
| 97 |
{ |
| 98 |
year = "{year not available}"; |
| 99 |
} |
| 100 |
printf(" year = %s,\n", year); |
| 101 |
|
| 102 |
printf(" type = {RFC},\n"); |
| 103 |
printf(" number = %s,\n", number); |
| 104 |
|
| 105 |
# early RFCs: mmm-dd-yyyy; later RFCs: month yyyy |
| 106 |
m_fld = $(NF-1); |
| 107 |
gsub(/-| |\n|[0-9]/, "", m_fld); |
| 108 |
month = substr(tolower(m_fld), 0, 3); |
| 109 |
if(length(month) == 0) |
| 110 |
{ |
| 111 |
month = "{month not available}"; |
| 112 |
} |
| 113 |
printf(" month = %s,\n", month); |
| 114 |
|
| 115 |
printf(" annote = {%s},\n", $NF); |
| 116 |
printf("}\n\n"); |
| 117 |
} |