scritcher/src/bmp_valid.zig

27 lines
488 B
Zig
Raw Normal View History

2019-09-08 14:55:17 +00:00
const std = @import("std");
pub const BMPValidError = error{InvalidMagic};
const VALID_MAGICS = [_][]const u8{
"BM",
"BA",
"CI",
"CP",
"IC",
"PT",
};
pub fn magicValid(magic: []const u8) !void {
var valid = false;
for (VALID_MAGICS) |valid_magic| {
if (std.mem.eql(u8, magic, valid_magic)) valid = true;
}
if (!valid) {
2021-04-04 01:16:04 +00:00
std.debug.warn("\tINVALID HEADER: '{s}'\n", .{magic});
2019-09-08 14:55:17 +00:00
return BMPValidError.InvalidMagic;
}
}