/usr/include/kodi/xbmc_addon_cpp_dll.h is in kodi-addons-dev 2:17.1+dfsg1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | #pragma once
/*
* Copyright (C) 2005-2015 Team Kodi
* http://kodi.tv
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kodi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "xbmc_addon_types.h"
#include <vector>
#include <string.h>
#include <stdlib.h>
class DllSetting
{
public:
enum SETTING_TYPE { NONE=0, CHECK, SPIN };
DllSetting(SETTING_TYPE t, const char *n, const char *l)
{
id = NULL;
label = NULL;
if (n)
{
id = new char[strlen(n)+1];
strcpy(id, n);
}
if (l)
{
label = new char[strlen(l)+1];
strcpy(label, l);
}
current = 0;
type = t;
}
DllSetting(const DllSetting &rhs) // copy constructor
{
id = NULL;
label = NULL;
if (rhs.id)
{
id = new char[strlen(rhs.id)+1];
strcpy(id, rhs.id);
}
if (rhs.label)
{
label = new char[strlen(rhs.label)+1];
strcpy(label, rhs.label);
}
current = rhs.current;
type = rhs.type;
for (unsigned int i = 0; i < rhs.entry.size(); i++)
{
char *lab = new char[strlen(rhs.entry[i]) + 1];
strcpy(lab, rhs.entry[i]);
entry.push_back(lab);
}
}
~DllSetting()
{
delete[] id;
delete[] label;
for (unsigned int i=0; i < entry.size(); i++)
delete[] entry[i];
}
void AddEntry(const char *label)
{
if (!label || type != SPIN) return;
char *lab = new char[strlen(label) + 1];
strcpy(lab, label);
entry.push_back(lab);
}
// data members
SETTING_TYPE type;
char* id;
char* label;
int current;
std::vector<const char *> entry;
};
class DllUtils
{
public:
static unsigned int VecToStruct(const std::vector<DllSetting> &vecSet, ADDON_StructSetting*** sSet)
{
*sSet = NULL;
if (vecSet.empty())
return 0;
unsigned int uiElements=0;
*sSet = (ADDON_StructSetting**)malloc(vecSet.size()*sizeof(ADDON_StructSetting*));
for(unsigned int i=0;i<vecSet.size();i++)
{
(*sSet)[i] = NULL;
(*sSet)[i] = (ADDON_StructSetting*)malloc(sizeof(ADDON_StructSetting));
(*sSet)[i]->id = NULL;
(*sSet)[i]->label = NULL;
uiElements++;
if (vecSet[i].id && vecSet[i].label)
{
(*sSet)[i]->id = strdup(vecSet[i].id);
(*sSet)[i]->label = strdup(vecSet[i].label);
(*sSet)[i]->type = vecSet[i].type;
(*sSet)[i]->current = vecSet[i].current;
(*sSet)[i]->entry_elements = 0;
(*sSet)[i]->entry = NULL;
if(vecSet[i].type == DllSetting::SPIN && !vecSet[i].entry.empty())
{
(*sSet)[i]->entry = (char**)malloc(vecSet[i].entry.size()*sizeof(char**));
for(unsigned int j=0;j<vecSet[i].entry.size();j++)
{
if(strlen(vecSet[i].entry[j]) > 0)
{
(*sSet)[i]->entry[j] = strdup(vecSet[i].entry[j]);
(*sSet)[i]->entry_elements++;
}
}
}
}
}
return uiElements;
}
static void StructToVec(unsigned int iElements, ADDON_StructSetting*** sSet, std::vector<DllSetting> *vecSet)
{
if(iElements == 0)
return;
vecSet->clear();
for(unsigned int i=0;i<iElements;i++)
{
DllSetting vSet((DllSetting::SETTING_TYPE)(*sSet)[i]->type, (*sSet)[i]->id, (*sSet)[i]->label);
if((*sSet)[i]->type == DllSetting::SPIN)
{
for(unsigned int j=0;j<(*sSet)[i]->entry_elements;j++)
{
vSet.AddEntry((*sSet)[i]->entry[j]);
}
}
vSet.current = (*sSet)[i]->current;
vecSet->push_back(vSet);
}
}
static void FreeStruct(unsigned int iElements, ADDON_StructSetting*** sSet)
{
if(iElements == 0)
return;
for(unsigned int i=0;i<iElements;i++)
{
if((*sSet)[i]->type == DllSetting::SPIN)
{
for(unsigned int j=0;j<(*sSet)[i]->entry_elements;j++)
{
free((*sSet)[i]->entry[j]);
}
free((*sSet)[i]->entry);
}
free((*sSet)[i]->id);
free((*sSet)[i]->label);
free((*sSet)[i]);
}
free(*sSet);
}
};
|