forked from jonsafari/mocp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor librcc use so that initialisation and cleanup occur only once.
git-svn-id: svn://svn.daper.net/moc/trunk@2430 910807d9-36e0-0310-a014-e9ea483e2ba4
- Loading branch information
jcf
committed
Jul 8, 2012
1 parent
e89da1c
commit 0905063
Showing
11 changed files
with
122 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* MOC - music on console | ||
* Copyright (C) 2005,2011 Damian Pietras <[email protected]> | ||
* | ||
* 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 of the License, or | ||
* (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
# include "config.h" | ||
#endif | ||
|
||
#include <stdlib.h> | ||
|
||
#ifdef HAVE_RCC | ||
# include <librcc.h> | ||
#endif | ||
|
||
#include <assert.h> | ||
|
||
#include "rcc.h" | ||
|
||
char *rcc_reencode (char *str) | ||
{ | ||
char *result = str; | ||
|
||
assert (str != NULL); | ||
|
||
#ifdef HAVE_RCC | ||
rcc_string rccstring; | ||
|
||
rccstring = rccFrom (NULL, 0, str); | ||
if (rccstring) { | ||
if (*rccstring) { | ||
char *reencoded; | ||
|
||
reencoded = rccToCharset (NULL, "UTF-8", rccstring); | ||
if (reencoded) { | ||
free (result); | ||
result = reencoded; | ||
} | ||
} | ||
|
||
free (rccstring); | ||
} | ||
#endif /* HAVE_RCC */ | ||
|
||
return result; | ||
} | ||
|
||
void rcc_init () | ||
{ | ||
#ifdef HAVE_RCC | ||
rcc_class classes[] = { | ||
{"input", RCC_CLASS_STANDARD, NULL, NULL, "Input Encoding", 0}, | ||
{"output", RCC_CLASS_KNOWN, NULL, NULL, "Output Encoding", 0}, | ||
{NULL, 0, NULL, NULL, NULL, 0} | ||
}; | ||
|
||
rccInit (); | ||
rccInitDefaultContext (NULL, 0, 0, classes, 0); | ||
rccLoad (NULL, "moc"); | ||
rccSetOption (NULL, RCC_OPTION_TRANSLATE, | ||
RCC_OPTION_TRANSLATE_SKIP_PARRENT); | ||
rccSetOption (NULL, RCC_OPTION_AUTODETECT_LANGUAGE, 1); | ||
#endif /* HAVE_RCC */ | ||
} | ||
|
||
void rcc_cleanup () | ||
{ | ||
#ifdef HAVE_RCC | ||
rccFree (); | ||
#endif /* HAVE_RCC */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef RCC_H | ||
#define RCC_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
char *rcc_reencode (char *); | ||
void rcc_init (); | ||
void rcc_cleanup (); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.