Update README
This commit is contained in:
1 parent
958a79ad73
commit
78b05690e7
1 file changed
+38
-1
@@ -331,7 +331,44 @@ the minimum information of its interface needed.
|
||||
|
||||
We can also see in this example so the container ARRAY provides also
|
||||
a macro to define the oplist of the array itself. This is true for
|
||||
all containers and this allows to define proper recursive container.
|
||||
all containers and this allows to define proper recursive container like in this example:
|
||||
|
||||
#include <stdio.h>
|
||||
#include "m-array.h"
|
||||
#include "m-tuple.h"
|
||||
#include "m-dict.h"
|
||||
#include "m-string.h"
|
||||
|
||||
TUPLE_DEF2(symbol, (offset, long), (value, long))
|
||||
#define M_OPL_symbol_t() TUPLE_OPLIST(symbol, M_DEFAULT_OPLIST, M_DEFAULT_OPLIST)
|
||||
|
||||
ARRAY_DEF(array_symbol, symbol_t)
|
||||
#define M_OPL_array_symbol_t() ARRAY_OPLIST(array_symbol, M_OPL_symbol_t())
|
||||
|
||||
DICT_DEF2(sections, string_t, array_symbol_t)
|
||||
#define M_OPL_sections_t() DICT_OPLIST(sections, STRING_OPLIST, M_OPL_array_symbol_t())
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
if (argc < 2) abort();
|
||||
FILE *f = fopen(argv[1], "rt");
|
||||
if (!f) abort();
|
||||
M_LET(sc, sections_t) {
|
||||
sections_in_str(sc, f);
|
||||
array_symbol_t *a = sections_get(sc, STRING_CTE(".text"));
|
||||
if (a == NULL) {
|
||||
printf("There is no .text section.");
|
||||
} else {
|
||||
printf("Section .text is :");
|
||||
array_symbol_out_str(stdout, *a);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
This example reads the data from a file
|
||||
and outputs the .text section if it finds it on the terminal.
|
||||
|
||||
Other examples are available in the example folder.
|
||||
|
||||
|
||||
Reference in new issue
Block a user