FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

winamp: More code cleanup · netdebug/hexchat@174db0e · GitHub

forked from hexchat/hexchat

Commit 174db0e

Browse files
committed
winamp: More code cleanup
1 parent f64b61a commit 174db0e

1 file changed

Lines changed: 16 additions & 47 deletions

File tree

‎plugins/winamp/winamp.c‎

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,9 @@
2222

2323
static hexchat_plugin *ph; /* plugin handle */
2424

25-
BOOL winamp_found = FALSE;
26-
27-
int status = 0;
28-
29-
/* Slightly modified from X-Chat's log_escape_strcpy */
30-
static char *
31-
song_strcpy (char *dest, char *src)
32-
{
33-
while (*src)
34-
{
35-
*dest = *src;
36-
dest++;
37-
src++;
38-
39-
if (*src == '%')
40-
{
41-
dest[0] = '%';
42-
dest++;
43-
}
44-
}
45-
46-
dest[0] = 0;
47-
return dest - 1;
48-
}
49-
5025
static int
5126
winamp(char *word[], char *word_eol[], void *userdata)
5227
{
53-
wchar_t wcurrent_play[2048];
54-
char *current_play, *p;
55-
char p_esc[2048];
56-
char cur_esc[2048];
57-
char truc[2048];
5828
HWND hwndWinamp = FindWindowW(L"Winamp v1.x",NULL);
5929

6030
if (hwndWinamp)
@@ -98,7 +68,9 @@ winamp(char *word[], char *word_eol[], void *userdata)
9868
}
9969
else if (!word_eol[2][0])
10070
{
101-
int len = GetWindowTextW(hwndWinamp, wcurrent_play, sizeof(wcurrent_play));
71+
wchar_t wcurrent_play[2048];
72+
char *current_play, *p;
73+
int len = GetWindowTextW(hwndWinamp, wcurrent_play, G_N_ELEMENTS(wcurrent_play));
10274

10375
current_play = g_utf16_to_utf8 (wcurrent_play, len, NULL, NULL, NULL);
10476
if (!current_play)
@@ -109,36 +81,33 @@ winamp(char *word[], char *word_eol[], void *userdata)
10981

11082
if (strchr(current_play, '-'))
11183
{
112-
84+
/* Remove any trailing text and whitespace */
11385
p = current_play + strlen(current_play) - 8;
11486
while (p >= current_play)
11587
{
116-
if (!strnicmp(p, "- Winamp", 8)) break;
117-
p--;
88+
if (!strnicmp(p, "- Winamp", 8))
89+
break;
90+
p--;
11891
}
11992

12093
if (p >= current_play)
12194
p--;
12295

12396
while (p >= current_play && *p == ' ')
12497
p--;
125-
*++p=0;
126-
127-
p = strchr(current_play, '.') + 1;
128-
129-
song_strcpy(p_esc, p);
130-
song_strcpy(cur_esc, current_play);
98+
*++p = '\0';
13199

100+
/* Ignore any leading track number */
101+
p = strstr (current_play, ". ");
132102
if (p)
133-
{
134-
sprintf(truc, "me is now playing:%s", p_esc);
135-
}
103+
p += 2;
136104
else
137-
{
138-
sprintf(truc, "me is now playing:%s", cur_esc);
139-
}
105+
p = current_play;
140106

141-
hexchat_commandf(ph, truc);
107+
if (*p != '\0')
108+
hexchat_commandf (ph, "me is now playing: %s", p);
109+
else
110+
hexchat_print (ph, "Winamp: No song information found.");
142111
g_free (current_play);
143112
}
144113
else

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL