Mercurial > mplayer.hg
comparison m_struct.h @ 8169:7c9253521f9c
A struct setter. It allow you to setup struct from some user
settings.
author | albeu |
---|---|
date | Tue, 12 Nov 2002 14:16:30 +0000 |
parents | |
children | 2cc1ce724722 |
comparison
equal
deleted
inserted
replaced
8168:ff6a98628e6c | 8169:7c9253521f9c |
---|---|
1 | |
2 #ifndef NEW_CONFIG | |
3 #warning "Including m_struct.h but NEW_CONFIG is disabled" | |
4 #else | |
5 | |
6 ///////////////////// A struct setter //////////////////////// | |
7 | |
8 struct m_option; | |
9 | |
10 /// Struct definition | |
11 typedef struct m_struct_st { | |
12 char* name; // For error msg and debuging | |
13 unsigned int size; // size of the whole struct | |
14 void* defaults; // Pointer to a struct filled with the default settings | |
15 struct m_option* fields; // settable fields | |
16 } m_struct_t; | |
17 | |
18 // Note : the p field of the m_option_t struct must contain the offset | |
19 // of the member in the struct (use M_ST_OFF macro for this). | |
20 | |
21 // From glib.h (modified ;-) | |
22 #define M_ST_OFF(struct_type, member) \ | |
23 ((void*) &((struct_type*) 0)->member) | |
24 #define M_ST_MB_P(struct_p, struct_offset) \ | |
25 ((void*) (struct_p) + (unsigned long) (struct_offset)) | |
26 #define M_ST_MB(member_type, struct_p, struct_offset) \ | |
27 (*(member_type*) M_STRUCT_MEMBER_P ((struct_p), (struct_offset))) | |
28 | |
29 | |
30 | |
31 /// Allocate the struct and set it to the defaults | |
32 void* | |
33 m_struct_alloc(m_struct_t* st); | |
34 /// Set a field of the struct | |
35 int | |
36 m_struct_set(m_struct_t* st, void* obj, char* field, char* param); | |
37 /// Reset a field (or all if field == NULL) to defaults | |
38 void | |
39 m_struct_reset(m_struct_t* st, void* obj, char* field); | |
40 /// Create a copy of an existing struct | |
41 void* | |
42 m_struct_copy(m_struct_t* st, void* obj); | |
43 /// Free an allocated struct | |
44 void | |
45 m_struct_free(m_struct_t* st, void* obj); | |
46 /// Get a field description | |
47 struct m_option* | |
48 m_struct_get_field(m_struct_t* st,char* f); | |
49 | |
50 #endif |