Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef3ef0950f | |||
| 78bdf578bf | |||
| cd3f296fc5 | |||
| ea527a2065 |
5
Makefile
5
Makefile
@@ -6,7 +6,7 @@ HAREFLAGS=
|
||||
DESTDIR=
|
||||
PREFIX=/usr/local
|
||||
BINDIR=$(PREFIX)/bin
|
||||
MANDIR=$(PREFIX)/share/man
|
||||
MANDIR=$(PREFIX)/man
|
||||
|
||||
all: bulb
|
||||
|
||||
@@ -22,9 +22,10 @@ clean:
|
||||
install:
|
||||
mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
|
||||
install -Dm755 bulb $(DESTDIR)$(BINDIR)/bulb
|
||||
install -Dm755 doc/*.1 $(DESTDIR)$(MANDIR)/man1
|
||||
install -Dm755 doc/bulb.1 $(DESTDIR)$(MANDIR)/man1
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(BINDIR)/bulb
|
||||
rm -f $(DESTDIR)$(MANDIR)/man1/bulb.1
|
||||
|
||||
.PHONY: all check clean install uninstall
|
||||
|
||||
@@ -32,7 +32,8 @@ export fn main() void = {
|
||||
let post = false;
|
||||
let anonymous = false;
|
||||
|
||||
for (let opt .. cmd.opts) {
|
||||
for (let index = 0z; index < len(cmd.opts); index += 1) {
|
||||
let opt = cmd.opts[index];
|
||||
switch (opt.0) {
|
||||
case 'b' =>
|
||||
board = opt.1;
|
||||
|
||||
@@ -6,6 +6,7 @@ use io;
|
||||
use os;
|
||||
use path;
|
||||
use strings;
|
||||
use types;
|
||||
|
||||
// TODO
|
||||
// two issues:
|
||||
@@ -44,7 +45,7 @@ export fn read(output: io::handle, board: str, number: int) (void | error) = {
|
||||
|
||||
static let output_wbuf: [os::BUFSZ]u8 = [0...];
|
||||
let output = bufio::init(output, [], output_wbuf);
|
||||
let file = bufio::newscanner(file);
|
||||
let file = bufio::newscanner(file, types::SIZE_MAX);
|
||||
defer bufio::finish(&file);
|
||||
|
||||
let saw_escape = false;
|
||||
@@ -87,7 +88,7 @@ export fn post(input: io::handle, board: str, user_name: (str | void)) (void | e
|
||||
|
||||
static let file_wbuf: [os::BUFSZ]u8 = [0...];
|
||||
let file = bufio::init(file, [], file_wbuf);
|
||||
let input = bufio::newscanner(input);
|
||||
let input = bufio::newscanner(input, types::SIZE_MAX);
|
||||
defer bufio::finish(&input);
|
||||
|
||||
let saw_break = false;
|
||||
@@ -116,14 +117,16 @@ export fn post(input: io::handle, board: str, user_name: (str | void)) (void | e
|
||||
};
|
||||
|
||||
export fn list(output: io::handle) (void | error) = {
|
||||
for (let directory .. bulb_path) list_boards_in(output, directory)?;
|
||||
for (let index = 0z; index < len(bulb_path); index += 1) {
|
||||
list_boards_in(output, bulb_path[index])?;
|
||||
};
|
||||
};
|
||||
|
||||
export fn look_up_board(board: str) (str | no_such_board | invalid_board) = {
|
||||
validate_board_name(board)?;
|
||||
static let buf = path::buffer { ... };
|
||||
for (let directory .. bulb_path) {
|
||||
let location = path::set(&buf, directory, board)!;
|
||||
for (let index = 0z; index < len(bulb_path); index += 1) {
|
||||
let location = path::set(&buf, bulb_path[index], board)!;
|
||||
match (os::stat(location)) {
|
||||
case fs::filestat => return location;
|
||||
case => void;
|
||||
@@ -150,8 +153,8 @@ export fn validate_board_name(board: str) (void | invalid_board) = {
|
||||
fn list_boards_in(output: io:: handle, directory: str) (void | error) = {
|
||||
let entries = os::readdir(directory)?;
|
||||
defer fs::dirents_free(entries);
|
||||
for (let entry .. entries) {
|
||||
fmt::fprintln(output, entry.name)?;
|
||||
for (let index = 0z; index < len(entries); index += 1) {
|
||||
fmt::fprintln(output, entries[index].name)?;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user