summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2007-06-17 18:00:00 +0200
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2007-06-17 18:00:00 +0200
commitb1e4da3be6552f58f3890bf2ad48879823d2e130 (patch)
treecf42a1e6b296956b82a2820948c7b90dbcddf26e /tools.c
parentb9b9ace9a8d2d1c0beda1dc0a2ebc6be9b47c305 (diff)
downloadvdr-patch-lnbsharing-b1e4da3be6552f58f3890bf2ad48879823d2e130.tar.gz
vdr-patch-lnbsharing-b1e4da3be6552f58f3890bf2ad48879823d2e130.tar.bz2
Version 1.5.4vdr-1.5.4
- Increased APIVERSION (forgot to do that in 1.5.2 and 1.5.3). - Fixed a crash in i18n character set conversion (thanks to Alexander Riedel, Jose Alberto Reguero and Christian Wieninger for patches that cured part of the problem). - Adjusted the 'skincurses' plugin to UTF-8 handling. - Using nl_langinfo(CODESET) to determine the local codeset to use (thanks to Thomas Günther). The codeset names in 'libsi/si.c' have been changed to the canonical spelling with '-' (thanks to Ludwig Nussel for pointing this out). - Modified handling invalid characters in VFAT mode. - Replaced strn0cpy() with Utf8Strn0Cpy() where necessary. - Now using 'fontconfig' to determine which fonts to use (thanks to Anssi Hannula for code and hints on how to do this). - If no fonts are installed, VDR now uses a dummy font that doesn't actually draw any text, and logs an error message. - The new function cFont::CreateFont() can be used by plugins to create and use fonts of their own, independent of VDR's standard fonts. - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). - Changed the parameter "OSD font" to "Default font" in "Setup/OSD" (suggested by Rolf Ahrenberg). - Fixed handling detached processes in SystemExec() (thanks to Udo Richter). - The info.vdr file now also stores the name of the channel, and the new function cRecordingInfo::ChannelName() returns this information if available (based on a patch from Alexander Hans). - The new function cOsd::SetOsdPosition() can be used to dynamically change the position and size of the OSD (based on a request from Christoph Haubrich). Plugins that implement skins should no longer use Setup.OSDWidth etc. directly, but should rather use cOsd::OsdWidth() etc. instead. Currently a change to the OSD position will only apply to newly opened OSDs.
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c74
1 files changed, 57 insertions, 17 deletions
diff --git a/tools.c b/tools.c
index a6af97a..dd2395a 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.123 2007/06/09 14:21:21 kls Exp $
+ * $Id: tools.c 1.129 2007/06/17 11:02:34 kls Exp $
*/
#include "tools.h"
@@ -649,6 +649,37 @@ int Utf8SymChars(const char *s, int Symbols)
return n;
}
+int Utf8StrLen(const char *s)
+{
+ if (cCharSetConv::SystemCharacterTable())
+ return strlen(s);
+ int n = 0;
+ while (*s) {
+ s += Utf8CharLen(s);
+ n++;
+ }
+ return n;
+}
+
+char *Utf8Strn0Cpy(char *Dest, const char *Src, int n)
+{
+ if (cCharSetConv::SystemCharacterTable())
+ return strn0cpy(Dest, Src, n);
+ char *d = Dest;
+ while (*Src) {
+ int sl = Utf8CharLen(Src);
+ n -= sl;
+ if (n > 0) {
+ while (sl--)
+ *d++ = *Src++;
+ }
+ else
+ break;
+ }
+ *d = 0;
+ return Dest;
+}
+
int Utf8ToArray(const char *s, uint *a, int Size)
{
int n = 0;
@@ -720,7 +751,7 @@ void cCharSetConv::SetSystemCharacterTable(const char *CharacterTable)
{
free(systemCharacterTable);
systemCharacterTable = NULL;
- if (!strcasestr(CharacterTable, "UTF")) {
+ if (!strcasestr(CharacterTable, "UTF-8")) {
// Set up a map for the character values 128...255:
char buf[129];
for (int i = 0; i < 128; i++)
@@ -741,7 +772,7 @@ void cCharSetConv::SetSystemCharacterTable(const char *CharacterTable)
const char *cCharSetConv::Convert(const char *From, char *To, size_t ToLength)
{
- if (cd != (iconv_t)-1) {
+ if (cd != (iconv_t)-1 && From && *From) {
char *FromPtr = (char *)From;
size_t FromLength = strlen(From);
char *ToPtr = To;
@@ -1105,21 +1136,39 @@ struct dirent *cReadDir::Next(void)
return directory && readdir_r(directory, &u.d, &result) == 0 ? result : NULL;
}
-// --- cFileNameList ---------------------------------------------------------
+// --- cStringList -----------------------------------------------------------
-cFileNameList::cFileNameList(const char *Directory)
+cStringList::~cStringList()
{
- Load(Directory);
+ Clear();
}
-cFileNameList::~cFileNameList()
+int cStringList::Find(const char *s) const
+{
+ for (int i = 0; i < Size(); i++) {
+ if (!strcmp(s, At(i)))
+ return i;
+ }
+ return -1;
+}
+
+void cStringList::Clear(void)
{
for (int i = 0; i < Size(); i++)
free(At(i));
}
+// --- cFileNameList ---------------------------------------------------------
+
+// TODO better GetFileNames(const char *Directory, cStringList *List)?
+cFileNameList::cFileNameList(const char *Directory)
+{
+ Load(Directory);
+}
+
bool cFileNameList::Load(const char *Directory)
{
+ Clear();
if (Directory) {
cReadDir d(Directory);
struct dirent *e;
@@ -1128,7 +1177,7 @@ bool cFileNameList::Load(const char *Directory)
if (strcmp(e->d_name, ".") && strcmp(e->d_name, ".."))
Append(strdup(e->d_name));
}
- Sort(CompareStrings);
+ Sort();
return true;
}
else
@@ -1137,15 +1186,6 @@ bool cFileNameList::Load(const char *Directory)
return false;
}
-int cFileNameList::Find(const char *FileName)
-{
- for (int i = 0; i < Size(); i++) {
- if (!strcmp(FileName, At(i)))
- return i;
- }
- return -1;
-}
-
// --- cFile -----------------------------------------------------------------
bool cFile::files[FD_SETSIZE] = { false };