~ubuntu-dev/mplayer/ubuntu-feisty

1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
1
#ifndef _M_STRUCT_H
2
#define _M_STRUCT_H
3
2 by Reinhard Tartler
upgrade to pre8
4
/// \defgroup OptionsStruct Options struct
5
/// \ingroup Options
6
/// An API to manipulate structs using m_option.
7
///@{
8
9
/// \file m_struct.h
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
10
11
struct m_option;
12
13
/// Struct definition
14
typedef struct m_struct_st {
2 by Reinhard Tartler
upgrade to pre8
15
  /// For error messages and debugging
2.6.1 by William Grant
Update to 1.0rc1.
16
  const char* name;
2 by Reinhard Tartler
upgrade to pre8
17
  /// size of the whole struct
18
  unsigned int size;
19
  /// Pointer to a struct filled with the default settings
20
  void* defaults;
21
  /// Field list.
22
  /** The p field of the \ref m_option struct must contain the offset
23
   *  of the member in the struct (use M_ST_OFF macro for this).
24
   */
25
  struct m_option* fields;
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
26
} m_struct_t;
27
28
29
// From glib.h (modified ;-)
2 by Reinhard Tartler
upgrade to pre8
30
31
/// Get the offset of a struct field.
32
/** \param struct_type Struct type.
33
 *  \param member Name of the field.
34
 *  \return The offset of the field in bytes.
35
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
36
#define M_ST_OFF(struct_type, member)    \
37
    ((void*) &((struct_type*) 0)->member)
2 by Reinhard Tartler
upgrade to pre8
38
39
/// Get a pointer to a struct field.
40
/** \param struct_p Pointer to the struct.
41
 *  \param struct_offset Offset of the field in the struct.
42
 *  \return Pointer to the struct field.
43
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
44
#define M_ST_MB_P(struct_p, struct_offset)   \
45
    ((void*) (struct_p) + (unsigned long) (struct_offset))
2 by Reinhard Tartler
upgrade to pre8
46
47
/// Acces a struct field at a given offset.
48
/** \param member_type Type of the field.
49
 *  \param struct_p Pointer to the struct.
50
 *  \param struct_offset Offset of the field in the struct.
51
 *  \return The struct field at the given offset.
52
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
53
#define M_ST_MB(member_type, struct_p, struct_offset)   \
54
    (*(member_type*) M_ST_MB_P ((struct_p), (struct_offset)))
55
56
57
2 by Reinhard Tartler
upgrade to pre8
58
/// Allocate the struct and set it to the defaults.
59
/** \param st Struct definition.
60
 *  \return The newly allocated object set to default.
61
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
62
void*
63
m_struct_alloc(m_struct_t* st);
2 by Reinhard Tartler
upgrade to pre8
64
65
/// Set a field of the struct.
66
/** \param st Struct definition.
67
 *  \param obj Pointer to the struct to set.
68
 *  \param field Name of the field to set.
69
 *  \param param New value of the field.
70
 *  \return 0 on error, 1 on success.
71
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
72
int
73
m_struct_set(m_struct_t* st, void* obj, char* field, char* param);
2 by Reinhard Tartler
upgrade to pre8
74
75
/// Reset a field (or all if field == NULL) to defaults.
76
/** \param st Struct definiton.
77
 *  \param obj Pointer to the struct to set.
78
 *  \param field Name of the field to reset, if NULL all fields are reseted.
79
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
80
void
2.6.1 by William Grant
Update to 1.0rc1.
81
m_struct_reset(m_struct_t* st, void* obj, const char* field);
2 by Reinhard Tartler
upgrade to pre8
82
83
/// Create a copy of an existing struct.
84
/** \param st Struct definiton.
85
 *  \param obj Pointer to the struct to copy.
86
 *  \return Newly allocated copy of obj.
87
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
88
void*
89
m_struct_copy(m_struct_t* st, void* obj);
2 by Reinhard Tartler
upgrade to pre8
90
91
/// Free an allocated struct.
92
/** \param st Struct definiton.
93
 *  \param obj Pointer to the struct to copy.
94
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
95
void
96
m_struct_free(m_struct_t* st, void* obj);
2 by Reinhard Tartler
upgrade to pre8
97
98
/// Get a field description.
99
/** \param st Struct definiton.
100
 *  \param f Name of the field.
101
 *  \return The \ref m_option struct describing the field or NULL if not found.
102
 */
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
103
struct m_option*
2.6.1 by William Grant
Update to 1.0rc1.
104
m_struct_get_field(m_struct_t* st,const char* f);
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
105
2 by Reinhard Tartler
upgrade to pre8
106
///@}
107
1 by Reinhard Tartler
imported mplayer_0.99+1.0pre7try2+cvs20060117
108
#endif /* _M_STRUCT_H */