fix bug when bmovl can't read the whole pic at once
[mplayer/glamo.git] / m_struct.h
blobe698dca211c442efb119b293d021e6bf6d4a0b44
1 #ifndef _M_STRUCT_H
2 #define _M_STRUCT_H
4 ///////////////////// A struct setter ////////////////////////
6 struct m_option;
8 /// Struct definition
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
14 } m_struct_t;
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
30 void*
31 m_struct_alloc(m_struct_t* st);
32 /// Set a field of the struct
33 int
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
36 void
37 m_struct_reset(m_struct_t* st, void* obj, char* field);
38 /// Create a copy of an existing struct
39 void*
40 m_struct_copy(m_struct_t* st, void* obj);
41 /// Free an allocated struct
42 void
43 m_struct_free(m_struct_t* st, void* obj);
44 /// Get a field description
45 struct m_option*
46 m_struct_get_field(m_struct_t* st,char* f);
48 #endif /* _M_STRUCT_H */