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