vlc_probe.h 1.97 KB
Newer Older
1 2 3 4 5
/*****************************************************************************
 * vlc_probe.h: service probing interface
 *****************************************************************************
 * Copyright (C) 2009 Rémi Denis-Courmont
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
6 7
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
8 9 10 11 12
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
13 14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
15 16
 *
 * You should have received a copy of the GNU Lesser General Public License
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
17 18
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 *****************************************************************************/

#ifndef VLC_PROBE_H
# define VLC_PROBE_H 1

# include <stdlib.h>

/**
 * \file
 * This file defines functions and structures to run-time probe VLC extensions
 */

# ifdef __cplusplus
extern "C" {
# endif

35
void *vlc_probe (vlc_object_t *, const char *, size_t *);
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#define vlc_probe(obj, cap, pcount) \
        vlc_probe(VLC_OBJECT(obj), cap, pcount)

struct vlc_probe_t
{
    VLC_COMMON_MEMBERS

    void  *list;
    size_t count;
};

typedef struct vlc_probe_t vlc_probe_t;

static inline int vlc_probe_add(vlc_probe_t *obj, const void *data,
                                size_t len)
{
    char *tab = (char *)realloc (obj->list, (obj->count + 1) * len);

    if (unlikely(tab == NULL))
        return VLC_ENOMEM;
    memcpy(tab + (obj->count * len), data, len);
    obj->list = tab;
    obj->count++;
    return VLC_SUCCESS;
}

# define VLC_PROBE_CONTINUE VLC_EGENERIC
# define VLC_PROBE_STOP     VLC_SUCCESS

# ifdef __cplusplus
}
# endif

#endif