-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfield.h
More file actions
62 lines (54 loc) · 1.56 KB
/
Copy pathfield.h
File metadata and controls
62 lines (54 loc) · 1.56 KB
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
/*
* Copyright (C) 2009-2011 CompuLab, Ltd.
* Authors: Nikita Kiryanov <nikita@compulab.co.il>
* Igor Grinberg <grinberg@compulab.co.il>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _FIELD_
#define _FIELD_
#include <stdbool.h>
enum field_type {
FIELD_BINARY,
FIELD_REVERSED,
FIELD_VERSION,
FIELD_ASCII,
FIELD_MAC,
FIELD_DATE,
FIELD_RESERVED,
FIELD_RAW,
};
enum print_format {
FORMAT_DEFAULT,
FORMAT_DUMP,
};
struct field {
char *name;
char *short_name;
int data_size;
enum field_type type;
unsigned char *data;
struct field_ops *ops;
};
struct field_ops {
int (*get_data_size)(const struct field *field);
bool (*is_named)(const struct field *field, const char *str);
void (*print_value)(const struct field *field);
void (*print)(const struct field *field);
int (*update)(struct field *field, char *value);
void (*clear)(struct field *field);
};
void init_field(struct field *field, unsigned char *data,
enum print_format print_format);
#endif