Remove building with NOCRYPTO option
[minix.git] / minix / lib / libmagicrt / magic_ds.c
bloba2947c4d5614ea111749929e1e1714d06e3bc64e
1 #include <minix/syslib.h>
2 #include <minix/sysutil.h>
3 #include <minix/com.h>
5 #include <minix/type.h>
6 #include <minix/ds.h>
7 #include "ds/store.h"
9 #include <magic_analysis.h>
10 #include <st/state_transfer.h>
12 const char* sef_sf_typename_keys[] = { "dsi_u", NULL };
13 #define dsi_u_idx 0
15 /*===========================================================================*
16 * sef_cb_sf_transfer_dsi_u *
17 *===========================================================================*/
18 static int sef_cb_sf_transfer_dsi_u(_magic_selement_t *selement, _magic_sel_analyzed_t *sel_analyzed, _magic_sel_stats_t *sel_stats, struct st_cb_info *cb_info) {
19 static struct dsi_mem noxfer_dsi_mem_stub;
20 static const struct _magic_type* _magic_dsi_mem_type = NULL;
21 struct data_store* dsp;
22 _magic_selement_t parent_selement;
23 int ret = EGENERIC;
24 VOLATILE int keep_stubs = (int)&noxfer_dsi_mem_stub;
25 assert(keep_stubs);
27 if(magic_selement_get_parent(selement, &parent_selement) == NULL) {
28 ST_CB_PRINT(ST_CB_ERR, "sef_cb_sf_transfer_dsi_u: magic_selement_get_parent failed", selement, sel_analyzed, sel_stats, cb_info);
29 return EINVAL;
31 dsp = (struct data_store*) parent_selement.address;
32 if(!(dsp->flags & DSF_IN_USE)) {
33 /* Skip when unused. */
34 return MAGIC_SENTRY_ANALYZE_SKIP_PATH;
36 switch(dsp->flags & DSF_MASK_TYPE) {
37 case DSF_TYPE_U32:
38 case DSF_TYPE_LABEL:
39 /* Identity transfer when no ptr is involved. */
40 ret = st_cb_transfer_identity(selement, sel_analyzed, sel_stats, cb_info);
41 break;
42 case DSF_TYPE_STR:
43 case DSF_TYPE_MEM:
44 /* Transfer as dsp->u.mem struct. */
45 if(!_magic_dsi_mem_type && !(_magic_dsi_mem_type = magic_type_lookup_by_name("dsi_mem"))) {
46 ST_CB_PRINT(ST_CB_ERR, "sef_cb_sf_transfer_dsi_u: type dsi_mem not found", selement, sel_analyzed, sel_stats, cb_info);
47 return ENOENT;
49 st_cb_selement_type_cast(_magic_dsi_mem_type, _magic_dsi_mem_type, selement, sel_analyzed, sel_stats, cb_info);
50 ret = st_cb_transfer_selement_generic(selement, sel_analyzed, sel_stats, cb_info);
51 break;
52 default:
53 /* Unknown? Report error. */
54 ST_CB_PRINT(ST_CB_ERR, "sef_cb_sf_transfer_dsi_u: bad flags", selement, sel_analyzed, sel_stats, cb_info);
55 ret = EFAULT;
56 break;
58 return ret;
61 /*===========================================================================*
62 * sef_cb_sf_transfer_typename *
63 *===========================================================================*/
64 static int sef_cb_sf_transfer_typename(_magic_selement_t *selement, _magic_sel_analyzed_t *sel_analyzed, _magic_sel_stats_t *sel_stats, struct st_cb_info *cb_info) {
65 const char *typename_key = ST_TYPE_NAME_KEY(selement->type);
66 if(ST_TYPE_NAME_MATCH(sef_sf_typename_keys[dsi_u_idx],typename_key))
68 return sef_cb_sf_transfer_dsi_u(selement, sel_analyzed, sel_stats, cb_info);
71 return ST_CB_NOT_PROCESSED;
74 /*===========================================================================*
75 * _magic_ds_st_init *
76 *===========================================================================*/
77 void _magic_ds_st_init(void)
79 st_register_typename_keys(sef_sf_typename_keys);
80 st_setcb_selement_transfer(sef_cb_sf_transfer_typename, ST_CB_TYPE_TYPENAME);