mmp

The mini music player, an alternative to MPD

git clone https://git.8pit.net/mmp.git

 1import ctypes
 2
 3class MPDExpr(ctypes.Structure):
 4    pass
 5
 6class MPDExprOP(ctypes.Union):
 7    pass
 8
 9MPDExprOP._fields_ = [('str', ctypes.c_char_p),
10                      ('expr', ctypes.POINTER(MPDExpr))]
11
12MPDExpr._fields_ = [('name', ctypes.c_char_p),
13                    ('op', ctypes.c_uint),
14                    ('o1', MPDExprOP),
15                    ('next', ctypes.POINTER(MPDExpr))]
16
17class MPDRange(ctypes.Structure):
18    _fields_ = [('start', ctypes.c_size_t),
19                ('end', ctypes.c_ssize_t)]
20
21class MPDCmd(ctypes.Structure):
22    pass
23
24class MPDValue(ctypes.Union):
25    _fields_ = [('ival', ctypes.c_int),
26                ('uval', ctypes.c_uint),
27                ('sval', ctypes.c_char_p),
28                ('fval', ctypes.c_float),
29                ('bval', ctypes.c_bool),
30                ('rval', MPDRange),
31                ('eval', ctypes.POINTER(MPDExpr)),
32                ('cmdval', ctypes.POINTER(MPDCmd))]
33
34class MPDArg(ctypes.Structure):
35    _fields_ = [('type', ctypes.c_uint),
36                ('v', MPDValue)]
37
38MPDCmd._fields_ = [('name', ctypes.c_char_p),
39                   ('argc', ctypes.c_size_t),
40                   ('argv', ctypes.POINTER(ctypes.POINTER(MPDArg)))]
41
42# TODO: Use python3 enum
43class MPDVal(object):
44    INT   = 0
45    UINT  = 1
46    STR   = 2
47    FLOAT = 3
48    BOOL  = 4
49    RANGE = 5
50    EXPR  = 6
51    CMD   = 7