Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 1 | // Copyright (c) 2014, Google Inc. |
| 2 | // |
| 3 | // Permission to use, copy, modify, and/or distribute this software for any |
| 4 | // purpose with or without fee is hereby granted, provided that the above |
| 5 | // copyright notice and this permission notice appear in all copies. |
| 6 | // |
| 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
David Benjamin | 0d1b096 | 2016-08-01 09:50:57 -0400 | [diff] [blame] | 13 | // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 14 | |
| 15 | package main |
| 16 | |
| 17 | import ( |
| 18 | "bufio" |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 19 | "errors" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 20 | "flag" |
| 21 | "fmt" |
| 22 | "io" |
| 23 | "os" |
| 24 | "path/filepath" |
| 25 | "sort" |
| 26 | "strconv" |
| 27 | "strings" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 28 | ) |
| 29 | |
David Benjamin | 2e52121 | 2014-07-16 14:37:51 -0400 | [diff] [blame] | 30 | // ssl.h reserves values 1000 and above for error codes corresponding to |
| 31 | // alerts. If automatically assigned reason codes exceed this value, this script |
| 32 | // will error. This must be kept in sync with SSL_AD_REASON_OFFSET in ssl.h. |
| 33 | const reservedReasonCode = 1000 |
| 34 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 35 | var resetFlag *bool = flag.Bool("reset", false, "If true, ignore current assignments and reassign from scratch") |
| 36 | |
| 37 | func makeErrors(reset bool) error { |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 38 | topLevelPath, err := findToplevel() |
| 39 | if err != nil { |
| 40 | return err |
| 41 | } |
| 42 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 43 | dirName, err := os.Getwd() |
| 44 | if err != nil { |
| 45 | return err |
| 46 | } |
| 47 | |
| 48 | lib := filepath.Base(dirName) |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 49 | headerPath := filepath.Join(topLevelPath, "include", "openssl", lib+".h") |
| 50 | errDir := filepath.Join(topLevelPath, "crypto", "err") |
| 51 | dataPath := filepath.Join(errDir, lib+".errordata") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 52 | |
| 53 | headerFile, err := os.Open(headerPath) |
| 54 | if err != nil { |
| 55 | if os.IsNotExist(err) { |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 56 | return fmt.Errorf("No header %s. Run in the right directory or touch the file.", headerPath) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | return err |
| 60 | } |
| 61 | |
| 62 | prefix := strings.ToUpper(lib) |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 63 | reasons, err := parseHeader(prefix, headerFile) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 64 | headerFile.Close() |
| 65 | |
| 66 | if reset { |
| 67 | err = nil |
David Benjamin | 2e52121 | 2014-07-16 14:37:51 -0400 | [diff] [blame] | 68 | // Retain any reason codes above reservedReasonCode. |
| 69 | newReasons := make(map[string]int) |
| 70 | for key, value := range reasons { |
| 71 | if value >= reservedReasonCode { |
| 72 | newReasons[key] = value |
| 73 | } |
| 74 | } |
| 75 | reasons = newReasons |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | if err != nil { |
| 79 | return err |
| 80 | } |
| 81 | |
| 82 | dir, err := os.Open(".") |
| 83 | if err != nil { |
| 84 | return err |
| 85 | } |
| 86 | defer dir.Close() |
| 87 | |
| 88 | filenames, err := dir.Readdirnames(-1) |
| 89 | if err != nil { |
| 90 | return err |
| 91 | } |
| 92 | |
David Benjamin | 616c4c2 | 2017-05-03 15:51:56 -0400 | [diff] [blame] | 93 | if filepath.Base(filepath.Dir(dirName)) == "fipsmodule" { |
| 94 | // Search the non-FIPS half of library for error codes as well. |
| 95 | extraPath := filepath.Join(topLevelPath, "crypto", lib+"_extra") |
| 96 | extraDir, err := os.Open(extraPath) |
| 97 | if err != nil && !os.IsNotExist(err) { |
| 98 | return err |
| 99 | } |
| 100 | if err == nil { |
| 101 | defer extraDir.Close() |
| 102 | extraFilenames, err := extraDir.Readdirnames(-1) |
| 103 | if err != nil { |
| 104 | return err |
| 105 | } |
| 106 | for _, extraFilename := range extraFilenames { |
| 107 | filenames = append(filenames, filepath.Join(extraPath, extraFilename)) |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 112 | for _, name := range filenames { |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 113 | if !strings.HasSuffix(name, ".c") { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 114 | continue |
| 115 | } |
| 116 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 117 | if err := addReasons(reasons, name, prefix); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 118 | return err |
| 119 | } |
| 120 | } |
| 121 | |
David Benjamin | 2e52121 | 2014-07-16 14:37:51 -0400 | [diff] [blame] | 122 | assignNewValues(reasons, reservedReasonCode) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 123 | |
| 124 | headerFile, err = os.Open(headerPath) |
| 125 | if err != nil { |
| 126 | return err |
| 127 | } |
| 128 | defer headerFile.Close() |
| 129 | |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 130 | newHeaderFile, err := os.OpenFile(headerPath+".tmp", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 131 | if err != nil { |
| 132 | return err |
| 133 | } |
| 134 | defer newHeaderFile.Close() |
| 135 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 136 | if err := writeHeaderFile(newHeaderFile, headerFile, prefix, reasons); err != nil { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 137 | return err |
| 138 | } |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 139 | os.Rename(headerPath+".tmp", headerPath) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 140 | |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 141 | dataFile, err := os.OpenFile(dataPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 142 | if err != nil { |
| 143 | return err |
| 144 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 145 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 146 | outputStrings(dataFile, lib, reasons) |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 147 | dataFile.Close() |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 148 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 149 | return nil |
| 150 | } |
| 151 | |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 152 | func findToplevel() (path string, err error) { |
| 153 | path = ".." |
David Benjamin | 95aaf4a | 2015-09-03 12:09:36 -0400 | [diff] [blame] | 154 | buildingPath := filepath.Join(path, "BUILDING.md") |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 155 | |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 156 | _, err = os.Stat(buildingPath) |
David Benjamin | 616c4c2 | 2017-05-03 15:51:56 -0400 | [diff] [blame] | 157 | for i := 0; i < 2 && err != nil && os.IsNotExist(err); i++ { |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 158 | path = filepath.Join("..", path) |
David Benjamin | 95aaf4a | 2015-09-03 12:09:36 -0400 | [diff] [blame] | 159 | buildingPath = filepath.Join(path, "BUILDING.md") |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 160 | _, err = os.Stat(buildingPath) |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 161 | } |
| 162 | if err != nil { |
David Benjamin | 95aaf4a | 2015-09-03 12:09:36 -0400 | [diff] [blame] | 163 | return "", errors.New("Cannot find BUILDING.md file at the top-level") |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 164 | } |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 165 | return path, nil |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 168 | type assignment struct { |
| 169 | key string |
| 170 | value int |
| 171 | } |
| 172 | |
| 173 | type assignmentsSlice []assignment |
| 174 | |
| 175 | func (a assignmentsSlice) Len() int { |
| 176 | return len(a) |
| 177 | } |
| 178 | |
| 179 | func (a assignmentsSlice) Less(i, j int) bool { |
| 180 | return a[i].value < a[j].value |
| 181 | } |
| 182 | |
| 183 | func (a assignmentsSlice) Swap(i, j int) { |
| 184 | a[i], a[j] = a[j], a[i] |
| 185 | } |
| 186 | |
| 187 | func outputAssignments(w io.Writer, assignments map[string]int) { |
| 188 | var sorted assignmentsSlice |
| 189 | |
| 190 | for key, value := range assignments { |
| 191 | sorted = append(sorted, assignment{key, value}) |
| 192 | } |
| 193 | |
| 194 | sort.Sort(sorted) |
| 195 | |
| 196 | for _, assignment := range sorted { |
| 197 | fmt.Fprintf(w, "#define %s %d\n", assignment.key, assignment.value) |
| 198 | } |
| 199 | } |
| 200 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 201 | func parseDefineLine(line, lib string) (key string, value int, ok bool) { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 202 | if !strings.HasPrefix(line, "#define ") { |
| 203 | return |
| 204 | } |
| 205 | |
| 206 | fields := strings.Fields(line) |
| 207 | if len(fields) != 3 { |
| 208 | return |
| 209 | } |
| 210 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 211 | key = fields[1] |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 212 | if !strings.HasPrefix(key, lib+"_R_") { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 213 | return |
| 214 | } |
| 215 | |
| 216 | var err error |
| 217 | if value, err = strconv.Atoi(fields[2]); err != nil { |
| 218 | return |
| 219 | } |
| 220 | |
| 221 | ok = true |
| 222 | return |
| 223 | } |
| 224 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 225 | func writeHeaderFile(w io.Writer, headerFile io.Reader, lib string, reasons map[string]int) error { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 226 | var last []byte |
| 227 | var haveLast, sawDefine bool |
| 228 | newLine := []byte("\n") |
| 229 | |
| 230 | scanner := bufio.NewScanner(headerFile) |
| 231 | for scanner.Scan() { |
| 232 | line := scanner.Text() |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 233 | _, _, ok := parseDefineLine(line, lib) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 234 | if ok { |
| 235 | sawDefine = true |
| 236 | continue |
| 237 | } |
| 238 | |
| 239 | if haveLast { |
| 240 | w.Write(last) |
| 241 | w.Write(newLine) |
| 242 | } |
| 243 | |
| 244 | if len(line) > 0 || !sawDefine { |
| 245 | last = []byte(line) |
| 246 | haveLast = true |
| 247 | } else { |
| 248 | haveLast = false |
| 249 | } |
| 250 | sawDefine = false |
| 251 | } |
| 252 | |
| 253 | if err := scanner.Err(); err != nil { |
| 254 | return err |
| 255 | } |
| 256 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 257 | outputAssignments(w, reasons) |
| 258 | w.Write(newLine) |
| 259 | |
| 260 | if haveLast { |
| 261 | w.Write(last) |
| 262 | w.Write(newLine) |
| 263 | } |
| 264 | |
| 265 | return nil |
| 266 | } |
| 267 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 268 | func outputStrings(w io.Writer, lib string, assignments map[string]int) { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 269 | lib = strings.ToUpper(lib) |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 270 | prefixLen := len(lib + "_R_") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 271 | |
| 272 | keys := make([]string, 0, len(assignments)) |
| 273 | for key := range assignments { |
| 274 | keys = append(keys, key) |
| 275 | } |
| 276 | sort.Strings(keys) |
| 277 | |
| 278 | for _, key := range keys { |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 279 | fmt.Fprintf(w, "%s,%d,%s\n", lib, assignments[key], key[prefixLen:]) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
David Benjamin | 2e52121 | 2014-07-16 14:37:51 -0400 | [diff] [blame] | 283 | func assignNewValues(assignments map[string]int, reserved int) { |
Adam Langley | 29b1867 | 2015-02-06 11:52:16 -0800 | [diff] [blame] | 284 | // Needs to be in sync with the reason limit in |
| 285 | // |ERR_reason_error_string|. |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 286 | max := 99 |
| 287 | |
| 288 | for _, value := range assignments { |
David Benjamin | 2e52121 | 2014-07-16 14:37:51 -0400 | [diff] [blame] | 289 | if reserved >= 0 && value >= reserved { |
| 290 | continue |
| 291 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 292 | if value > max { |
| 293 | max = value |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | max++ |
| 298 | |
David Benjamin | fc23396 | 2015-02-09 21:30:53 -0500 | [diff] [blame] | 299 | // Sort the keys, so this script is reproducible. |
| 300 | keys := make([]string, 0, len(assignments)) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 301 | for key, value := range assignments { |
| 302 | if value == -1 { |
David Benjamin | fc23396 | 2015-02-09 21:30:53 -0500 | [diff] [blame] | 303 | keys = append(keys, key) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 304 | } |
| 305 | } |
David Benjamin | fc23396 | 2015-02-09 21:30:53 -0500 | [diff] [blame] | 306 | sort.Strings(keys) |
| 307 | |
| 308 | for _, key := range keys { |
| 309 | if reserved >= 0 && max >= reserved { |
| 310 | // If this happens, try passing -reset. Otherwise bump |
| 311 | // up reservedReasonCode. |
| 312 | panic("Automatically-assigned values exceeded limit!") |
| 313 | } |
| 314 | assignments[key] = max |
| 315 | max++ |
| 316 | } |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | func handleDeclareMacro(line, join, macroName string, m map[string]int) { |
| 320 | if i := strings.Index(line, macroName); i >= 0 { |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 321 | contents := line[i+len(macroName):] |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 322 | if i := strings.Index(contents, ")"); i >= 0 { |
| 323 | contents = contents[:i] |
| 324 | args := strings.Split(contents, ",") |
| 325 | for i := range args { |
| 326 | args[i] = strings.TrimSpace(args[i]) |
| 327 | } |
| 328 | if len(args) != 2 { |
| 329 | panic("Bad macro line: " + line) |
| 330 | } |
| 331 | token := args[0] + join + args[1] |
| 332 | if _, ok := m[token]; !ok { |
| 333 | m[token] = -1 |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 339 | func addReasons(reasons map[string]int, filename, prefix string) error { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 340 | file, err := os.Open(filename) |
| 341 | if err != nil { |
| 342 | return err |
| 343 | } |
| 344 | defer file.Close() |
| 345 | |
David Benjamin | 96396b3 | 2015-02-11 15:53:03 -0500 | [diff] [blame] | 346 | reasonPrefix := prefix + "_R_" |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 347 | |
| 348 | scanner := bufio.NewScanner(file) |
| 349 | for scanner.Scan() { |
| 350 | line := scanner.Text() |
| 351 | |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 352 | handleDeclareMacro(line, "_R_", "OPENSSL_DECLARE_ERROR_REASON(", reasons) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 353 | |
| 354 | for len(line) > 0 { |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 355 | i := strings.Index(line, prefix+"_") |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 356 | if i == -1 { |
| 357 | break |
| 358 | } |
| 359 | |
| 360 | line = line[i:] |
| 361 | end := strings.IndexFunc(line, func(r rune) bool { |
| 362 | return !(r == '_' || (r >= 'A' && r <= 'Z') || (r >= '0' && r <= '9')) |
| 363 | }) |
| 364 | if end == -1 { |
| 365 | end = len(line) |
| 366 | } |
| 367 | |
| 368 | var token string |
| 369 | token, line = line[:end], line[end:] |
| 370 | |
| 371 | switch { |
| 372 | case strings.HasPrefix(token, reasonPrefix): |
| 373 | if _, ok := reasons[token]; !ok { |
| 374 | reasons[token] = -1 |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | return scanner.Err() |
| 381 | } |
| 382 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 383 | func parseHeader(lib string, file io.Reader) (reasons map[string]int, err error) { |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 384 | reasons = make(map[string]int) |
| 385 | |
| 386 | scanner := bufio.NewScanner(file) |
| 387 | for scanner.Scan() { |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 388 | key, value, ok := parseDefineLine(scanner.Text(), lib) |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 389 | if !ok { |
| 390 | continue |
| 391 | } |
| 392 | |
David Benjamin | 34248d4 | 2015-06-28 23:36:21 -0400 | [diff] [blame] | 393 | reasons[key] = value |
Adam Langley | 95c29f3 | 2014-06-20 12:00:00 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | err = scanner.Err() |
| 397 | return |
| 398 | } |
| 399 | |
| 400 | func main() { |
| 401 | flag.Parse() |
| 402 | |
| 403 | if err := makeErrors(*resetFlag); err != nil { |
| 404 | fmt.Fprintf(os.Stderr, "%s\n", err) |
| 405 | os.Exit(1) |
| 406 | } |
| 407 | } |