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