fixes for latest zig
This commit is contained in:
parent
6afa1f1f3a
commit
7d1b87d8df
2 changed files with 12 additions and 8 deletions
|
@ -6,13 +6,13 @@ pub fn build(b: *Builder) void {
|
|||
exe.setBuildMode(mode);
|
||||
exe.linkSystemLibrary("c");
|
||||
|
||||
const source_files = [][]const u8{"src/journal/main.c"};
|
||||
const source_files = [_][]const u8{"src/journal/main.c"};
|
||||
|
||||
for (source_files) |source| {
|
||||
exe.addCSourceFile(source, [][]const u8{"-W -O"});
|
||||
exe.addCSourceFile(source, [_][]const u8{"-W -O"});
|
||||
}
|
||||
|
||||
const zig_sources = [][]const u8{"src/journal/journal.zig"};
|
||||
const zig_sources = [_][]const u8{"src/journal/journal.zig"};
|
||||
|
||||
for (zig_sources) |source| {
|
||||
const obj = b.addObject("journal", source);
|
||||
|
|
|
@ -14,6 +14,10 @@ fn alloc_str(size: c_ulong) [*c]u8 {
|
|||
return @ptrCast([*c]u8, @alignCast(@alignOf(u8), c.malloc(c_ulong(size))));
|
||||
}
|
||||
|
||||
fn free_str(ptr: [*c]u8) void {
|
||||
c.free(@ptrCast(?*c_void, ptr));
|
||||
}
|
||||
|
||||
export fn journal_open(topic: [*c]u8) [*c](c.FILE) {
|
||||
var home_path: [*c]const u8 = c.getenv(c"HOME");
|
||||
|
||||
|
@ -22,7 +26,7 @@ export fn journal_open(topic: [*c]u8) [*c](c.FILE) {
|
|||
|
||||
_ = c.snprintf(journal_dir, c_ulong(512), c"%s/.lunabot", home_path);
|
||||
|
||||
warn("uwu journal_dir = '{}'", journal_dir.*);
|
||||
warn("uwu journal_dir = '{}'\n", journal_dir.*);
|
||||
|
||||
//c.mkdir(journal_dir, c.S_IRWXU | c.S_IRGRP | c.S_IROTH);
|
||||
|
||||
|
@ -31,12 +35,12 @@ export fn journal_open(topic: [*c]u8) [*c](c.FILE) {
|
|||
|
||||
_ = c.snprintf(journal_path, c_ulong(1024), c"%s/%s", journal_dir, topic);
|
||||
|
||||
warn("journal_path = {}", journal_path.*);
|
||||
warn("journal_path = {}\n", journal_path.*);
|
||||
|
||||
var res: [*c](c.FILE) = c.fopen(journal_path, c"a");
|
||||
|
||||
c.free(@ptrCast(?*c_void, journal_path));
|
||||
c.free(@ptrCast(?*c_void, journal_dir));
|
||||
free_str(journal_path);
|
||||
free_str(journal_dir);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -60,7 +64,7 @@ export fn journal_write_topic(journal: *c.FILE, topic: [*c]u8, message: [*c]u8)
|
|||
_ = c.strftime(tstamp, usize(128), c"%c", cur_time);
|
||||
_ = c.sprintf(fmt_msg, c"[%s] [%s]: %s\n", tstamp, topic, message);
|
||||
|
||||
c.free(@ptrCast(?*c_void, tstamp));
|
||||
free_str(tstamp);
|
||||
|
||||
journal_write(journal, fmt_msg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue