-
Notifications
You must be signed in to change notification settings - Fork 0
/
magicfix.h
54 lines (44 loc) · 1.65 KB
/
magicfix.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef MAGICFIX_H
#define MAGICFIX_H
// Magicfix Metadata
#define MAGICFIX_VERSION "v1.0.0"
#define MAGICFIX_GITHUB "https://github.com/Stridsvagn69420/magicfix"
#define MAGICFIX_AUTHOR "Stridsvagn69420"
#define MAGICFIX_LICENSE "EUPL-1.2"
// C Standard Library
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
// Matcher function
typedef bool (*Matcher)(const uint8_t* buf);
// File Database Entry
struct FileTypeData {
Matcher match; // Buffer Matcher
const uint8_t minbuf; // Minimum Buffer Size
const uint8_t *extv; // Primary (Video) File Extension
const uint8_t *exta; // Secondary (Video) File Extension
};
// File Database
#define FILEDBLEN 35 // File Database Length
#define MAXREQBUFSIZE 36 // Maximum required buffer size
extern const struct FileTypeData magicfix_database[FILEDBLEN];
/// @brief File Header Matcher
/// @param filedata File Data (Must be at least MAXREQBUFSIZE large)
/// @return Position in magicfix_database, -1 if not found.
int magicfix_match(const uint8_t* filedata);
/// @brief File Matcher Wrapper
/// @param path String
/// @return Position in magicfix_database, -1 if not found, -2 if stream error, -3 if file could not be opened.
int magicfix_matchfile(const char* path);
/// @brief Extension Replacer
/// @param fpath File Path to be modified
/// @param ext New File Extension (Must start with a dot)
/// @return
void magicfix_extrep(char* fpath, const char* ext);
/// @brief File Extension Rename Wrapper
/// @param oldpath Path to File
/// @param ext New File Extension (Must start with a dot)
/// @return Result of rename()
int magicfix_rename(const char* oldpath, const char* ext);
#endif