4 ///////////////////// A struct setter ////////////////////////
9 typedef struct m_struct_st
{
10 char* name
; // For error msg and debuging
11 unsigned int size
; // size of the whole struct
12 void* defaults
; // Pointer to a struct filled with the default settings
13 struct m_option
* fields
; // settable fields
16 // Note : the p field of the m_option_t struct must contain the offset
17 // of the member in the struct (use M_ST_OFF macro for this).
19 // From glib.h (modified ;-)
20 #define M_ST_OFF(struct_type, member) \
21 ((void*) &((struct_type*) 0)->member)
22 #define M_ST_MB_P(struct_p, struct_offset) \
23 ((void*) (struct_p) + (unsigned long) (struct_offset))
24 #define M_ST_MB(member_type, struct_p, struct_offset) \
25 (*(member_type*) M_ST_MB_P ((struct_p), (struct_offset)))
29 /// Allocate the struct and set it to the defaults
31 m_struct_alloc(m_struct_t
* st
);
32 /// Set a field of the struct
34 m_struct_set(m_struct_t
* st
, void* obj
, char* field
, char* param
);
35 /// Reset a field (or all if field == NULL) to defaults
37 m_struct_reset(m_struct_t
* st
, void* obj
, char* field
);
38 /// Create a copy of an existing struct
40 m_struct_copy(m_struct_t
* st
, void* obj
);
41 /// Free an allocated struct
43 m_struct_free(m_struct_t
* st
, void* obj
);
44 /// Get a field description
46 m_struct_get_field(m_struct_t
* st
,char* f
);
48 #endif /* _M_STRUCT_H */