forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filecheck.h
66 lines (52 loc) · 1.72 KB
/
filecheck.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
55
56
57
58
59
60
61
62
63
64
65
66
/**
* @file
*
* @brief Header for filecheck plugin
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#ifndef ELEKTRA_PLUGIN_FILECHECK_H
#define ELEKTRA_PLUGIN_FILECHECK_H
#include <kdbplugin.h>
#define LF_BYTE 0x0A
#define CR_BYTE 0x0D
#define CHAR_BYTES_MAX 4
#define LINE_BYTES 1024
#define INTERNAL_BOM_DELIMITER 0xAA
#define BOM_COUNT 14
#define BOM_SIZE_MAX 5
const uint8_t BOMS[BOM_COUNT][BOM_SIZE_MAX] = {
{ 0xEF, 0xBB, 0xBF, INTERNAL_BOM_DELIMITER, 0x00 }, { 0xFE, 0xFF, INTERNAL_BOM_DELIMITER, 0x00, 0x00 },
{ 0xFF, 0xFE, INTERNAL_BOM_DELIMITER, 0x00, 0x00 }, { 0x00, 0x00, 0xFE, 0xFF, INTERNAL_BOM_DELIMITER },
{ 0xFE, 0xFF, 0x00, 0x00, INTERNAL_BOM_DELIMITER }, { 0x2B, 0x2F, 0x76, 0x38, INTERNAL_BOM_DELIMITER },
{ 0x2B, 0x2F, 0x76, 0x39, INTERNAL_BOM_DELIMITER }, { 0x2B, 0x2F, 0x76, 0x2B, INTERNAL_BOM_DELIMITER },
{ 0x2B, 0x2F, 0x76, 0x2F, INTERNAL_BOM_DELIMITER }, { 0xF7, 0x64, 0x4C, INTERNAL_BOM_DELIMITER, 0x00 },
{ 0xDD, 0x73, 0x66, 0x73, INTERNAL_BOM_DELIMITER }, { 0x0E, 0xFE, 0xFF, INTERNAL_BOM_DELIMITER, 0x00 },
{ 0xFB, 0xEE, 0x28, INTERNAL_BOM_DELIMITER, 0x00 }, { 0x84, 0x31, 0x95, 0x33, INTERNAL_BOM_DELIMITER }
};
typedef enum
{
NA,
CR,
LF,
CRLF,
LFCR,
NUM_TYPES
} Lineending;
typedef struct
{
short checkLineEnding;
Lineending validLE;
short rejectNullByte;
short checkEncoding;
char * encoding;
short rejectBom;
short rejectUnprintable;
} checkStruct;
int elektraFilecheckOpen (Plugin * handle, Key * errorKey);
int elektraFilecheckClose (Plugin * handle, Key * errorKey);
int elektraFilecheckGet (Plugin * handle, KeySet * ks, Key * parentKey);
int elektraFilecheckSet (Plugin * handle, KeySet * ks, Key * parentKey);
Plugin * ELEKTRA_PLUGIN_EXPORT;
#endif