2019-09-08 14:55:17 +00:00
|
|
|
const std = @import("std");
|
2022-04-27 23:01:09 +00:00
|
|
|
const log = std.log.scoped(.scritcher_bmp);
|
2019-09-08 14:55:17 +00:00
|
|
|
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) {
|
2022-04-27 23:01:09 +00:00
|
|
|
log.debug("\tINVALID HEADER: '{s}'\n", .{magic});
|
2019-09-08 14:55:17 +00:00
|
|
|
return BMPValidError.InvalidMagic;
|
|
|
|
}
|
|
|
|
}
|