vlc_probe.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_probe.h: service probing interface
00003  *****************************************************************************
00004  * Copyright (C) 2009 Rémi Denis-Courmont
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2.1 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00019  *****************************************************************************/
00020 
00021 #ifndef VLC_PROBE_H
00022 # define VLC_PROBE_H 1
00023 
00024 # include <stdlib.h>
00025 
00026 /**
00027  * \file
00028  * This file defines functions and structures to run-time probe VLC extensions
00029  */
00030 
00031 # ifdef __cplusplus
00032 extern "C" {
00033 # endif
00034 
00035 void *vlc_probe (vlc_object_t *, const char *, size_t *restrict);
00036 #define vlc_probe(obj, cap, pcount) \
00037         vlc_probe(VLC_OBJECT(obj), cap, pcount)
00038 
00039 struct vlc_probe_t
00040 {
00041     VLC_COMMON_MEMBERS
00042 
00043     void  *list;
00044     size_t count;
00045 };
00046 
00047 typedef struct vlc_probe_t vlc_probe_t;
00048 
00049 static inline int vlc_probe_add(vlc_probe_t *obj, const void *data,
00050                                 size_t len)
00051 {
00052     char *tab = (char *)realloc (obj->list, (obj->count + 1) * len);
00053 
00054     if (unlikely(tab == NULL))
00055         return VLC_ENOMEM;
00056     memcpy(tab + (obj->count * len), data, len);
00057     obj->list = tab;
00058     obj->count++;
00059     return VLC_SUCCESS;
00060 }
00061 
00062 # define VLC_PROBE_CONTINUE VLC_EGENERIC
00063 # define VLC_PROBE_STOP     VLC_SUCCESS
00064 
00065 # ifdef __cplusplus
00066 }
00067 # endif
00068 
00069 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines