summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h33
1 files changed, 13 insertions, 20 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h
index 271df98..43e3022 100644
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h
@@ -1,24 +1,13 @@
1#pragma once
2/* 1/*
3 * Copyright (C) 2005-2013 Team XBMC 2 * Copyright (C) 2005-2018 Team Kodi
4 * http://kodi.tv 3 * This file is part of Kodi - https://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 * 4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
20 */ 7 */
21 8
9#pragma once
10
22#include <string> 11#include <string>
23#include <vector> 12#include <vector>
24#include <string.h> 13#include <string.h>
@@ -195,7 +184,7 @@ namespace ADDON
195 m_Callbacks = (KodiAPI::AddOn::CB_AddOnLib*)m_Handle->AddOnLib_RegisterMe(m_Handle->addonData); 184 m_Callbacks = (KodiAPI::AddOn::CB_AddOnLib*)m_Handle->AddOnLib_RegisterMe(m_Handle->addonData);
196 if (!m_Callbacks) 185 if (!m_Callbacks)
197 fprintf(stderr, "libXBMC_addon-ERROR: AddOnLib_RegisterMe can't get callback table from Kodi !!!\n"); 186 fprintf(stderr, "libXBMC_addon-ERROR: AddOnLib_RegisterMe can't get callback table from Kodi !!!\n");
198 187
199 return m_Callbacks != nullptr; 188 return m_Callbacks != nullptr;
200 } 189 }
201 190
@@ -203,14 +192,18 @@ namespace ADDON
203 * @brief Add a message to XBMC's log. 192 * @brief Add a message to XBMC's log.
204 * @param loglevel The log level of the message. 193 * @param loglevel The log level of the message.
205 * @param format The format of the message to pass to XBMC. 194 * @param format The format of the message to pass to XBMC.
195 * @note This method uses limited buffer (16k) for the formatted output.
196 * So data, which will not fit into it, will be silently discarded.
206 */ 197 */
207 void Log(const addon_log_t loglevel, const char *format, ... ) 198 void Log(const addon_log_t loglevel, const char *format, ... )
208 { 199 {
209 char buffer[16384]; 200 char buffer[16384];
201 static constexpr size_t len = sizeof (buffer) - 1;
210 va_list args; 202 va_list args;
211 va_start (args, format); 203 va_start (args, format);
212 vsprintf (buffer, format, args); 204 vsnprintf (buffer, len, format, args);
213 va_end (args); 205 va_end (args);
206 buffer[len] = '\0'; // to be sure it's null-terminated
214 m_Callbacks->Log(m_Handle->addonData, loglevel, buffer); 207 m_Callbacks->Log(m_Handle->addonData, loglevel, buffer);
215 } 208 }
216 209
@@ -297,7 +290,7 @@ namespace ADDON
297 { 290 {
298 m_Callbacks->FreeString(m_Handle->addonData, str); 291 m_Callbacks->FreeString(m_Handle->addonData, str);
299 } 292 }
300 293
301 /*! 294 /*!
302 * @brief Free the memory used by arr including its elements 295 * @brief Free the memory used by arr including its elements
303 * @param arr The string array to free 296 * @param arr The string array to free