/** (c) Nullsoft, Inc. C O N F I D E N T I A L ** Filename: ** Project: ** Description: HTML generation from playlist ** Author: ** Created: **/ #include "main.h" #include #include "../nu/AutoChar.h" #include "resource.h" void doHtmlPlaylist(void) { FILE *fp = 0; wchar_t filename[MAX_PATH] = {0}, tp[MAX_PATH] = {0}; if (!GetTempPathW(MAX_PATH,tp)) StringCchCopyW(tp, MAX_PATH, L"."); if (GetTempFileNameW(tp, L"WHT", 0, filename)){ DeleteFileW(filename); StringCchCatW(filename, MAX_PATH, L".html"); } else StringCchCopyW(filename, MAX_PATH, L"wahtml_tmp.html"); fp = _wfopen(filename, L"wt"); if (!fp) { LPMessageBox(hPLWindow, IDS_HTML_ERROR_WRITE, IDS_ERROR, MB_OK | MB_ICONWARNING); return; } fprintf(fp, "\n" "\n" "\n" "\n" "\n" "Winamp Generated PlayList\n" "" "
" "

WINAMP

" "

playlist

" "
" "
\n" "", (char *)AutoChar(filename, CP_UTF8)); } else { fprintf(fp, "There are no tracks in the current playlist.
"); } fprintf(fp, "
\n"); int x, t = PlayList_getlength(), t_in_pl = 0, n_un = 0; for (x = 0; x < t; x ++) { int a = PlayList_getsonglength(x); if (a >= 0) t_in_pl += a; else n_un++; } if (t != n_un) { int old_t_in_pl=t_in_pl; t_in_pl += (n_un * t_in_pl) / (t - n_un); fprintf(fp, "%d track%s in playlist, ", t, t == 1 ? "" : "s"); fprintf(fp, "average track length: %d:%02d", old_t_in_pl / (t-n_un) / 60, (old_t_in_pl / (t - n_un)) % 60); fprintf(fp, "
%slaylist length: ", n_un ? "Estimated p" : "P"); if (t_in_pl / 3600) { fprintf(fp, "%d hour%s ", t_in_pl / 3600, t_in_pl / 3600 == 1 ? "" : "s"); t_in_pl %= 3600; } if (t_in_pl / 60) { fprintf(fp, "%d minute%s ", t_in_pl / 60, t_in_pl / 60 == 1 ? "" : "s"); t_in_pl %= 60; } fprintf(fp, "%d second%s %s", t_in_pl, t_in_pl == 1 ? "" : "s", n_un ? "
(" : ""); if (n_un) fprintf(fp, "%d track%s of unknown length)", n_un, n_un == 1 ? "" : "s"); fprintf(fp, "
Right-click here to save this HTML file." "
\n"); if (t > 0) { fprintf(fp, "
Playlist files:
    \n"); for (x = 0; x < t; x++) { wchar_t fn[FILENAME_SIZE] = {0}, ft[FILETITLE_SIZE] = {0}; int l; PlayList_getitem2W(x, fn, ft); AutoChar narrowFt(ft, CP_UTF8); char *p = narrowFt; l = PlayList_getsonglength(x); fprintf(fp, "
  1. "); while (p && *p) { if (*p == '&') fprintf(fp, "&"); else if (*p == '<') fprintf(fp, "<"); else if (*p == '>') fprintf(fp, ">"); else if (*p == '\'') fprintf(fp, "'"); else if (*p == '"') fprintf(fp, """); else fputc(*p, fp); p++; } if(l > 0) fprintf(fp, " (%d:%02d) \n", l / 60, l % 60); else fprintf(fp, " \n"); } fprintf(fp, "
\n"); } fprintf(fp, "

"); fclose(fp); myOpenURL(hPLWindow, filename); }