-
Notifications
You must be signed in to change notification settings - Fork 2
/
label.h
128 lines (108 loc) · 5.22 KB
/
label.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸
¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯
__/¯\____ ___/\__ _/\__ _/\_ _/\__ _/\___ ___/\__ __/\_ _/\__
\_ ____/_> ____ \_/ _ \_ \ < /_ \_/ _>> ____ \_ > \_/ _ \_
_> ___/ ¯>__> <<__// __ _/ |> ></ _/> </ ¯ \\__> <<__// /\ // __ _/
_> \7 <__/:. \__/:. \> \_/ L/ _____/. 7> .\_/:. \__/ <_/ </:. \> \_
|:::::::::::::::::::::::/:::::::::::::>::::::::/::::::::::::::::::::::::/:::::|
|¯¯\::::/\:/¯\::::/¯¯¯¯<::::/\::/¯¯\:/¯¯¯¯¯¯\::\::/¯¯\::::/¯¯\::::/¯¯¯¯<::::/¯|
|__ |¯¯| T _ |¯¯¯| ___ |¯¯| |¯| _ T ______ |¯¯¯¯| _ |¯¯¯| _ |¯¯¯| ___ |¯¯| _|
\|__|/\|/ \|___|/ \|__|/\|_|/ \|/ \| |/ \|___|/ \|___|/dNo\|__|/
¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸
¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯
This file is part of Etripator,
copyright (c) 2009--2023 Vincent Cruz.
Etripator 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 3 of the License, or
(at your option) any later version.
Etripator 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 Etripator. If not, see <http://www.gnu.org/licenses/>.
¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸
¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯
*/
#ifndef ETRIPATOR_LABEL_H
#define ETRIPATOR_LABEL_H
#include "config.h"
/**
* Label.
*/
typedef struct {
char* name; /**< Offset in the repository name buffer */
uint16_t logical; /**< Logical address */
uint8_t page; /**< Memory page */
char* description; /**< Description (optional) */
} label_t;
typedef struct label_repository_impl label_repository_t;
/**
* Create label repository.
* \return A pointer to a label repository or NULL if an error occured.
*/
label_repository_t* label_repository_create();
/**
* Release label repository resources.
* \param [in,out] repository Label repository.
*/
void label_repository_destroy(label_repository_t* repository);
/**
* Add label (or inline description) to repository.
* \param [in,out] repository Label repository.
* \param [in] name Name. If the name is NULL, then this label is an inline description.
* \param [in] logical Logical address.
* \param [in] page Memory page.
* \param [in] description Description (optional if name is set, mandatory otherwise).
*/
int label_repository_add(label_repository_t* repository, const char* name, uint16_t logical, uint8_t page, const char *description);
/**
* Find a label by its address.
* \param [in] repository Label repository.
* \param [in] logical Logical address.
* \param [in] page Memory page.
* \param [out] out Associated label (if any).
* \return 1 if a label was found, 0 otherwise.
*/
int label_repository_find(label_repository_t* repository, uint16_t logical, uint8_t page, label_t *out);
/**
* Get the number of labels stored in the repository.
* \param [in] repository Label repository.
* \return Label count.
*/
int label_repository_size(label_repository_t* repository);
/**
* Retrieve the label at the specified index.
* \param [in] repository Label repository.
* \param [in] index Label index.
* \param [out] out Label (if any).
* \return 1 if a label exists for the specified index, 0 otherwise.
*/
int label_repository_get(label_repository_t* repository, int index, label_t *out);
/**
* Delete labels
* \param [in] repository Label repository.
* \param [in] first Start of the logical address range.
* \param [in] end End of the logical address range.
* \param [in] page Memory page.
*/
int label_repository_delete(label_repository_t* repository, uint16_t first, uint16_t end, uint8_t page);
/**
* Load labels from file.
* \param [in] filename Input filename.
* \param [out] repository Label repository.
* \return 1 if the labels contained in the file was succesfully added to the repository.
* 0 if an error occured.
*/
int label_repository_load(const char* filename, label_repository_t* repository);
/**
* Save labels to file.
* \param [in] filename Configuration file.
* \param [in] reposity Label repository.
* \return 1 if the labels in the repository were succesfully written to the file.
* 0 if an error occured.
*/
int label_repository_save(const char* filename, label_repository_t* repository);
#endif // ETRIPATOR_LABEL_H