]> Sergey Matveev's repositories - tofuproxy.git/blob - fifos/add.go
Download link for 0.6.0 release
[tofuproxy.git] / fifos / add.go
1 // tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
2 //              manager, WARC/geminispace browser
3 // Copyright (C) 2021-2024 Sergey Matveev <stargrave@stargrave.org>
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, version 3 of the License.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 package fifos
18
19 import (
20         "bufio"
21         "log"
22         "os"
23 )
24
25 func readLinesFromFIFO(p string) []string {
26         fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0666))
27         if err != nil {
28                 log.Fatalln(err)
29         }
30         var lines []string
31         scanner := bufio.NewScanner(fd)
32         for scanner.Scan() {
33                 t := scanner.Text()
34                 if len(t) > 0 {
35                         lines = append(lines, t)
36                 }
37         }
38         fd.Close()
39         return lines
40 }