diff options
Diffstat (limited to 'plugins/Variables/src/parse_external.cpp')
-rw-r--r-- | plugins/Variables/src/parse_external.cpp | 73 |
1 files changed, 26 insertions, 47 deletions
diff --git a/plugins/Variables/src/parse_external.cpp b/plugins/Variables/src/parse_external.cpp index 418eb0f3a9..b8b0b5f942 100644 --- a/plugins/Variables/src/parse_external.cpp +++ b/plugins/Variables/src/parse_external.cpp @@ -28,18 +28,14 @@ static void (WINAPI *acUninit)() = NULL; static unsigned int lastAMIPFailure = -1;
static TCHAR *getFullWinampTitleText() {
-
- TCHAR *szTitle, *szWinText;
- HWND hwndWinamp;
-
- hwndWinamp = FindWindow(_T("STUDIO"), NULL);
+ HWND hwndWinamp = FindWindow(_T("STUDIO"), NULL);
if (hwndWinamp == NULL)
hwndWinamp = FindWindow(_T("Winamp v1.x"),NULL);
if (hwndWinamp == NULL)
return NULL;
- szWinText = (TCHAR*)mir_alloc((GetWindowTextLength(hwndWinamp) + 1)*sizeof(TCHAR));
+ TCHAR *szWinText = (TCHAR*)mir_alloc((GetWindowTextLength(hwndWinamp) + 1)*sizeof(TCHAR));
if (szWinText == NULL)
return NULL;
@@ -47,7 +43,7 @@ static TCHAR *getFullWinampTitleText() { mir_free(szWinText);
return NULL;
}
- szTitle = (TCHAR*)mir_alloc((2*_tcslen(szWinText)+1)*sizeof(TCHAR));
+ TCHAR *szTitle = (TCHAR*)mir_alloc((2*_tcslen(szWinText)+1)*sizeof(TCHAR));
if (szTitle == NULL) {
mir_free(szWinText);
return NULL;
@@ -60,19 +56,16 @@ static TCHAR *getFullWinampTitleText() { }
static TCHAR *parseWinampSong(ARGUMENTSINFO *ai) {
-
- TCHAR *szTitle, *scur, *cur, *res;
-
if (ai->argc != 1) {
return NULL;
}
- res = NULL;
- szTitle = getFullWinampTitleText();
+ TCHAR *res = NULL;
+ TCHAR *szTitle = getFullWinampTitleText();
if (szTitle == NULL) {
return NULL;
}
- scur = _tcschr(szTitle, _T('.'));
- cur = _tcsstr(scur, _T(" - Winamp"));
+ TCHAR *scur = _tcschr(szTitle, _T('.'));
+ TCHAR *cur = _tcsstr(scur, _T(" - Winamp"));
if ((scur == NULL) || (cur == NULL) || (scur >= cur) || (scur > (szTitle + _tcslen(szTitle) - 2)) || (cur > (szTitle + _tcslen(szTitle)))) {
mir_free(szTitle);
return NULL;
@@ -88,19 +81,16 @@ static TCHAR *parseWinampSong(ARGUMENTSINFO *ai) { }
static TCHAR *parseWinampState(ARGUMENTSINFO *ai) {
-
- TCHAR *szTitle, *scur, *cur, *res;
-
if (ai->argc != 1) {
return NULL;
}
- res = NULL;
- szTitle = getFullWinampTitleText();
+ TCHAR *res = NULL;
+ TCHAR *szTitle = getFullWinampTitleText();
if (szTitle == NULL) {
return NULL;
}
- scur = _tcschr(szTitle, _T('.'));
- cur = _tcsstr(scur, _T(" - Winamp"));
+ TCHAR *scur = _tcschr(szTitle, _T('.'));
+ TCHAR *cur = _tcsstr(scur, _T(" - Winamp"));
if ((scur == NULL) || (cur == NULL)) {
mir_free(szTitle);
return mir_tstrdup(TranslateT("Stopped"));
@@ -144,17 +134,14 @@ static unsigned int checkAMIP() { }
static TCHAR *parseAMIPEval(ARGUMENTSINFO *ai) {
-
- TCHAR *tszRes;
- char *cmd;
char szRes[AC_BUFFER_SIZE];
- tszRes = NULL;
+ TCHAR *tszRes = NULL;
if (ai->argc != 2) {
return NULL;
}
- cmd = mir_t2a(ai->targv[1]);
+ char *cmd = mir_t2a(ai->targv[1]);
if (checkAMIP() != 0) {
log_debugA("checkAMIP failed");
@@ -176,17 +163,14 @@ static TCHAR *parseAMIPEval(ARGUMENTSINFO *ai) { }
static TCHAR *parseAMIPFormat(ARGUMENTSINFO *ai) {
-
- TCHAR *tszRes;
- char *cmd;
char szRes[AC_BUFFER_SIZE];
- tszRes = NULL;
+ TCHAR *tszRes = NULL;
if (ai->argc != 2) {
return NULL;
}
- cmd = mir_t2a(ai->targv[1]);
+ char *cmd = mir_t2a(ai->targv[1]);
if (checkAMIP() != 0) {
@@ -206,21 +190,16 @@ static TCHAR *parseAMIPFormat(ARGUMENTSINFO *ai) { }
static int initAMIP() {
-
- HMODULE hModule;
-
- hModule = LoadLibraryA("ac.dll");
+ HMODULE hModule = LoadLibrary(_T("ac.dll"));
if (hModule == NULL) {
- char path[MAX_PATH];
- char *cur;
-
- GetModuleFileNameA(NULL, path, sizeof(path));
- cur = strrchr(path, '\\');
+ TCHAR path[MAX_PATH];
+ GetModuleFileName(NULL, path, MAX_PATH);
+ TCHAR *cur = _tcsrchr(path, '\\');
if (cur != NULL)
- strcpy(cur+1, "ac.dll");
+ _tcscpy(cur+1, _T("ac.dll"));
else
- strcpy(cur, "ac.dll");
- hModule = LoadLibraryA(path);
+ _tcscpy(cur, _T("ac.dll"));
+ hModule = LoadLibrary(path);
}
if (hModule == NULL) {
return -1;
@@ -235,11 +214,11 @@ static int initAMIP() { int registerExternalTokens() {
- registerIntToken(_T(WINAMPSONG), parseWinampSong, TRF_FIELD, Translate("External Applications\tretrieves song name of the song currently playing in Winamp"));
- registerIntToken(_T(WINAMPSTATE), parseWinampState, TRF_FIELD, Translate("External Applications\tretrieves current Winamp state (Playing/Paused/Stopped)"));
+ registerIntToken(_T(WINAMPSONG), parseWinampSong, TRF_FIELD, LPGEN("External Applications")"\t"LPGEN("retrieves song name of the song currently playing in Winamp"));
+ registerIntToken(_T(WINAMPSTATE), parseWinampState, TRF_FIELD, LPGEN("External Applications")"\t"LPGEN("retrieves current Winamp state (Playing/Paused/Stopped)"));
if (!initAMIP()) {
- registerIntToken(_T(AMIPEVAL), parseAMIPEval, TRF_FUNCTION, Translate("External Applications\t(x)\tretrieves info from AMIP (x is var_<variable> with any AMIP variable)"));
- registerIntToken(_T(AMIPFORMAT), parseAMIPFormat, TRF_FUNCTION|TRF_UNPARSEDARGS, Translate("External Applications\t(x)\tretrieves info from AMIP (x is AMIP format string)"));
+ registerIntToken(_T(AMIPEVAL), parseAMIPEval, TRF_FUNCTION, LPGEN("External Applications")"\t(x)\t"LPGEN("retrieves info from AMIP (x is var_<variable> with any AMIP variable)"));
+ registerIntToken(_T(AMIPFORMAT), parseAMIPFormat, TRF_FUNCTION|TRF_UNPARSEDARGS, LPGEN("External Applications")"\t(x)\t"LPGEN("retrieves info from AMIP (x is AMIP format string)"));
}
else {
log_infoA("Variables: ac.dll for AMIP not found");
|