1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-05-18 00:58:26 -04:00

update from win32 build. Mostly cleanup work

svn path=/icecast/trunk/icecast/; revision=14867
This commit is contained in:
Karl Heyes 2008-05-12 01:21:06 +00:00
parent 90b705986c
commit 06510b997b
5 changed files with 211 additions and 181 deletions

View File

@ -33,18 +33,10 @@ typedef struct source_tag source_t;
#include "logging.h" #include "logging.h"
typedef struct _skeleton_codec_tag
{
} skeleton_codec_t;
static void skeleton_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec) static void skeleton_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
{ {
skeleton_codec_t *skeleton = codec->specific;
DEBUG0 ("freeing skeleton codec"); DEBUG0 ("freeing skeleton codec");
ogg_stream_clear (&codec->os); ogg_stream_clear (&codec->os);
free (skeleton);
free (codec); free (codec);
} }
@ -82,12 +74,9 @@ ogg_codec_t *initial_skeleton_page (format_plugin_t *plugin, ogg_page *page)
ogg_codec_t *codec = calloc (1, sizeof (ogg_codec_t)); ogg_codec_t *codec = calloc (1, sizeof (ogg_codec_t));
ogg_packet packet; ogg_packet packet;
skeleton_codec_t *skeleton_codec = calloc (1, sizeof (skeleton_codec_t));
ogg_stream_init (&codec->os, ogg_page_serialno (page)); ogg_stream_init (&codec->os, ogg_page_serialno (page));
ogg_stream_pagein (&codec->os, page); ogg_stream_pagein (&codec->os, page);
ogg_stream_packetout (&codec->os, &packet); ogg_stream_packetout (&codec->os, &packet);
DEBUG0("checking for skeleton codec"); DEBUG0("checking for skeleton codec");
@ -95,13 +84,11 @@ ogg_codec_t *initial_skeleton_page (format_plugin_t *plugin, ogg_page *page)
if ((packet.bytes<8) || memcmp(packet.packet, "fishead\0", 8)) if ((packet.bytes<8) || memcmp(packet.packet, "fishead\0", 8))
{ {
ogg_stream_clear (&codec->os); ogg_stream_clear (&codec->os);
free (skeleton_codec);
free (codec); free (codec);
return NULL; return NULL;
} }
INFO0 ("seen initial skeleton header"); INFO0 ("seen initial skeleton header");
codec->specific = skeleton_codec;
codec->process_page = process_skeleton_page; codec->process_page = process_skeleton_page;
codec->codec_free = skeleton_codec_free; codec->codec_free = skeleton_codec_free;
codec->headers = 1; codec->headers = 1;

View File

@ -1100,7 +1100,7 @@ refbuf_t *stats_get_streams (void)
{ {
#define STREAMLIST_BLKSIZE 4096 #define STREAMLIST_BLKSIZE 4096
avl_node *node; avl_node *node;
int remaining = STREAMLIST_BLKSIZE; unsigned int remaining = STREAMLIST_BLKSIZE;
refbuf_t *start = refbuf_new (remaining), *cur = start; refbuf_t *start = refbuf_new (remaining), *cur = start;
char *buffer = cur->data; char *buffer = cur->data;

View File

@ -89,91 +89,47 @@ SOURCE=..\src\admin.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\admin.h
# End Source File
# Begin Source File
SOURCE=..\src\auth.c SOURCE=..\src\auth.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\auth.h
# End Source File
# Begin Source File
SOURCE=..\src\auth_htpasswd.c SOURCE=..\src\auth_htpasswd.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\auth_htpasswd.h
# End Source File
# Begin Source File
SOURCE=..\src\auth_url.c SOURCE=..\src\auth_url.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\auth_url.h
# End Source File
# Begin Source File
SOURCE=..\src\avl\avl.c SOURCE=..\src\avl\avl.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\avl\avl.h
# End Source File
# Begin Source File
SOURCE=..\src\cfgfile.c SOURCE=..\src\cfgfile.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\cfgfile.h
# End Source File
# Begin Source File
SOURCE=..\src\client.c SOURCE=..\src\client.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\client.h
# End Source File
# Begin Source File
SOURCE=..\src\compat.h
# End Source File
# Begin Source File
SOURCE=..\src\connection.c SOURCE=..\src\connection.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\connection.h
# End Source File
# Begin Source File
SOURCE=..\src\event.c SOURCE=..\src\event.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\event.h
# End Source File
# Begin Source File
SOURCE=..\src\format.c SOURCE=..\src\format.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format.h
# End Source File
# Begin Source File
SOURCE=..\src\format_flac.c SOURCE=..\src\format_flac.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format_flac.h SOURCE=..\src\format_kate.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -181,23 +137,15 @@ SOURCE=..\src\format_midi.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format_midi.h
# End Source File
# Begin Source File
SOURCE=..\src\format_mp3.c SOURCE=..\src\format_mp3.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format_mp3.h
# End Source File
# Begin Source File
SOURCE=..\src\format_ogg.c SOURCE=..\src\format_ogg.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format_ogg.h SOURCE=..\src\format_skeleton.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -205,74 +153,38 @@ SOURCE=..\src\format_speex.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format_speex.h
# End Source File
# Begin Source File
SOURCE=..\src\format_theora.c SOURCE=..\src\format_theora.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format_theora.h
# End Source File
# Begin Source File
SOURCE=..\src\format_vorbis.c SOURCE=..\src\format_vorbis.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\format_vorbis.h
# End Source File
# Begin Source File
SOURCE=..\src\fserve.c SOURCE=..\src\fserve.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\fserve.h
# End Source File
# Begin Source File
SOURCE=..\src\global.c SOURCE=..\src\global.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\global.h
# End Source File
# Begin Source File
SOURCE=..\src\httpp\httpp.c SOURCE=..\src\httpp\httpp.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\httpp\httpp.h
# End Source File
# Begin Source File
SOURCE=..\src\log\log.c SOURCE=..\src\log\log.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\log\log.h
# End Source File
# Begin Source File
SOURCE=..\src\logging.c SOURCE=..\src\logging.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\logging.h
# End Source File
# Begin Source File
SOURCE=..\src\md5.c SOURCE=..\src\md5.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\md5.h
# End Source File
# Begin Source File
SOURCE=..\src\os.h SOURCE=..\src\os.h
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -281,26 +193,14 @@ SOURCE=..\src\refbuf.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\refbuf.h
# End Source File
# Begin Source File
SOURCE=..\src\net\resolver.c SOURCE=..\src\net\resolver.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\net\resolver.h
# End Source File
# Begin Source File
SOURCE=..\src\sighandler.c SOURCE=..\src\sighandler.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\sighandler.h
# End Source File
# Begin Source File
SOURCE=..\src\slave.c SOURCE=..\src\slave.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -309,34 +209,18 @@ SOURCE=..\src\net\sock.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\net\sock.h
# End Source File
# Begin Source File
SOURCE=..\src\source.c SOURCE=..\src\source.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\source.h
# End Source File
# Begin Source File
SOURCE=..\src\stats.c SOURCE=..\src\stats.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\stats.h
# End Source File
# Begin Source File
SOURCE=..\src\thread\thread.c SOURCE=..\src\thread\thread.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\thread\thread.h
# End Source File
# Begin Source File
SOURCE=..\src\timing\timing.c SOURCE=..\src\timing\timing.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -345,32 +229,164 @@ SOURCE=..\src\util.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\util.h
# End Source File
# Begin Source File
SOURCE=..\src\xslt.c SOURCE=..\src\xslt.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\yp.c SOURCE=..\src\yp.c
# End Source File # End Source File
# Begin Source File
SOURCE=..\src\yp.h
# End Source File
# End Group # End Group
# Begin Group "Header Files" # Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl" # PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File # Begin Source File
SOURCE=..\src\admin.h
# End Source File
# Begin Source File
SOURCE=..\src\auth.h
# End Source File
# Begin Source File
SOURCE=..\src\auth_htpasswd.h
# End Source File
# Begin Source File
SOURCE=..\src\auth_url.h
# End Source File
# Begin Source File
SOURCE=..\src\avl\avl.h
# End Source File
# Begin Source File
SOURCE=..\src\cfgfile.h
# End Source File
# Begin Source File
SOURCE=..\src\client.h
# End Source File
# Begin Source File
SOURCE=..\src\compat.h
# End Source File
# Begin Source File
SOURCE=..\src\connection.h
# End Source File
# Begin Source File
SOURCE=..\src\event.h
# End Source File
# Begin Source File
SOURCE=..\src\format.h
# End Source File
# Begin Source File
SOURCE=..\src\format_flac.h
# End Source File
# Begin Source File
SOURCE=..\src\format_kate.h
# End Source File
# Begin Source File
SOURCE=..\src\format_midi.h
# End Source File
# Begin Source File
SOURCE=..\src\format_mp3.h
# End Source File
# Begin Source File
SOURCE=..\src\format_ogg.h
# End Source File
# Begin Source File
SOURCE=..\src\format_skeleton.h
# End Source File
# Begin Source File
SOURCE=..\src\format_speex.h
# End Source File
# Begin Source File
SOURCE=..\src\format_theora.h
# End Source File
# Begin Source File
SOURCE=..\src\format_vorbis.h
# End Source File
# Begin Source File
SOURCE=..\src\fserve.h
# End Source File
# Begin Source File
SOURCE=..\src\global.h
# End Source File
# Begin Source File
SOURCE=..\src\httpp\httpp.h
# End Source File
# Begin Source File
SOURCE=..\src\log\log.h
# End Source File
# Begin Source File
SOURCE=..\src\logging.h
# End Source File
# Begin Source File
SOURCE=..\src\md5.h
# End Source File
# Begin Source File
SOURCE=..\src\refbuf.h
# End Source File
# Begin Source File
SOURCE=..\src\net\resolver.h
# End Source File
# Begin Source File
SOURCE=..\src\sighandler.h
# End Source File
# Begin Source File
SOURCE=..\src\net\sock.h
# End Source File
# Begin Source File
SOURCE=..\src\source.h
# End Source File
# Begin Source File
SOURCE=..\src\stats.h
# End Source File
# Begin Source File
SOURCE=..\src\thread\thread.h
# End Source File
# Begin Source File
SOURCE=..\src\timing\timing.h SOURCE=..\src\timing\timing.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\src\util.h
# End Source File
# Begin Source File
SOURCE=..\src\xslt.h SOURCE=..\src\xslt.h
# End Source File # End Source File
# Begin Source File
SOURCE=..\src\yp.h
# End Source File
# End Group # End Group
# End Target # End Target
# End Project # End Project

View File

@ -1,6 +1,5 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h>
#include <direct.h> #include <direct.h>
extern "C" { extern "C" {
#include "thread/thread.h" #include "thread/thread.h"
@ -15,6 +14,10 @@ extern "C" {
#include "stats.h" #include "stats.h"
} }
// Issues to be wary of. Careful of the runtime you use, I've had printf and similar routines
// crash because of this on apparently valid strings. some weird thing related to checking for
// multiple byte characters. DeleteService only marks a service for deletion, and the docs
// are unclear on the cases that lead to purging however a reboot should do it.
SERVICE_STATUS ServiceStatus; SERVICE_STATUS ServiceStatus;
SERVICE_STATUS_HANDLE hStatus; SERVICE_STATUS_HANDLE hStatus;
@ -30,14 +33,16 @@ int InitService()
return(result); return(result);
} }
void installService(char *path) void installService (const char *path)
{ {
if (path) { if (path) {
char fullPath[8096*2] = ""; char fullPath[8096*2] = "\"";
int len = GetModuleFileName (NULL, fullPath+1, sizeof (fullPath)-1);
_snprintf(fullPath, sizeof (fullPath), "\"%s\\icecastService.exe\" \"%s\"", path, path); _snprintf(fullPath+len+1, sizeof (fullPath)-len, "\" \"%s\"", path);
SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (handle == NULL) SC_HANDLE manager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (manager == NULL)
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
FormatMessage( FormatMessage(
@ -58,9 +63,9 @@ void installService(char *path)
} }
SC_HANDLE service = CreateService( SC_HANDLE service = CreateService(
handle, manager,
"Icecast", PACKAGE_STRING,
"Icecast Media Server", PACKAGE_STRING " Streaming Media Server",
GENERIC_READ | GENERIC_EXECUTE, GENERIC_READ | GENERIC_EXECUTE,
SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START, SERVICE_AUTO_START,
@ -72,7 +77,7 @@ void installService(char *path)
NULL, NULL,
NULL NULL
); );
if (handle == NULL) if (service == NULL)
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
FormatMessage( FormatMessage(
@ -89,19 +94,19 @@ void installService(char *path)
printf ("CreateService: %s\n", (LPCTSTR)lpMsgBuf); printf ("CreateService: %s\n", (LPCTSTR)lpMsgBuf);
LocalFree( lpMsgBuf ); LocalFree( lpMsgBuf );
CloseServiceHandle (handle); CloseServiceHandle (manager);
return; return;
} }
printf("Service Installed\n"); printf("Service Installed\n");
CloseServiceHandle (service); CloseServiceHandle (service);
CloseServiceHandle (handle); CloseServiceHandle (manager);
} }
} }
void removeService() void removeService()
{ {
SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS ); SC_HANDLE manager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (handle == NULL) if (manager == NULL)
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
FormatMessage( FormatMessage(
@ -121,13 +126,15 @@ void removeService()
return; return;
} }
SC_HANDLE service = OpenService(handle, "Icecast", DELETE); SC_HANDLE service = OpenService (manager, PACKAGE_STRING, DELETE);
if (service) { if (service) {
DeleteService(service); DeleteService(service);
printf("Service Removed\n"); printf("Service Removed\n");
CloseServiceHandle (service);
} }
else else
printf("Service not found\n"); printf("Service not found\n");
CloseServiceHandle (manager);
} }
void ControlHandler(DWORD request) void ControlHandler(DWORD request)
{ {
@ -167,7 +174,7 @@ void ServiceMain(int argc, char** argv)
ServiceStatus.dwCheckPoint = 0; ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0; ServiceStatus.dwWaitHint = 0;
hStatus = RegisterServiceCtrlHandler("Icecast", (LPHANDLER_FUNCTION)ControlHandler); hStatus = RegisterServiceCtrlHandler(PACKAGE_STRING, (LPHANDLER_FUNCTION)ControlHandler);
if (hStatus == (SERVICE_STATUS_HANDLE)0) { if (hStatus == (SERVICE_STATUS_HANDLE)0) {
// Registering Control Handler failed // Registering Control Handler failed
return; return;
@ -188,11 +195,15 @@ void ServiceMain(int argc, char** argv)
/* Here we do the work */ /* Here we do the work */
int argc2 = 3; int argc2 = 3;
char* argv2[3]; char* argv2 [4];
argv2[0] = "icecastService.exe"; argv2 [0] = argv[0];
argv2[1] = "-c"; argv2 [1] = "-c";
argv2[2] = "icecast.xml"; if (argc < 2)
argv2 [2] = "icecast.xml";
else
argv2 [2] = argv[1];
argv2[3] = NULL;
int ret = mainService(argc2, (char **)argv2); int ret = mainService(argc2, (char **)argv2);
@ -203,33 +214,48 @@ void ServiceMain(int argc, char** argv)
} }
void main(int argc, char **argv) int main(int argc, char **argv)
{ {
if (argc < 2)
{
printf ("Usage:\n %s remove\n %s install path\n", argv[0], argv[0]);
return 0;
}
if (!strcmp(argv[1], "install"))
{
if (argc > 2)
{
printf ("Installing service from %s\n", argv[2]);
installService(argv[2]);
}
else
printf ("install requires a path arg as well\n");
Sleep (2000);
return 0;
}
if (!strcmp(argv[1], "remove") || !strcmp(argv[1], "uninstall"))
{
printf ("removing service\n");
removeService();
Sleep (2000);
return 0;
}
bool matched = false; if (_chdir(argv[1]) < 0)
if (argv[0]) { {
if (argv[1]) { printf ("unable to change to directory %s\n", argv[1]);
if (!strcmp(argv[1], "install")) { Sleep (2000);
installService(argv[2]); return 0;
matched = true; }
}
if (!strcmp(argv[1], "remove")) {
removeService();
matched = true;
}
}
}
if (matched) {
return;
}
_chdir(argv[1]);
SERVICE_TABLE_ENTRY ServiceTable[2]; SERVICE_TABLE_ENTRY ServiceTable[2];
ServiceTable[0].lpServiceName = "Icecast Server"; ServiceTable[0].lpServiceName = PACKAGE_STRING;
ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain; ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
ServiceTable[1].lpServiceName = NULL; ServiceTable[1].lpServiceName = NULL;
ServiceTable[1].lpServiceProc = NULL; ServiceTable[1].lpServiceProc = NULL;
// Start the control dispatcher thread for our service // Start the control dispatcher thread for our service
StartServiceCtrlDispatcher(ServiceTable); StartServiceCtrlDispatcher(ServiceTable);
return 0;
} }

View File

@ -42,7 +42,8 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /I "../../libxslt/include" /I "../../curl/include" /I "../../iconv/include" /I "../../libxml2/include" /I "..\src" /I "..\src/httpp" /I "..\src/thread" /I "..\src/log" /I "..\src/avl" /I "..\src/net" /I "..\src/timings" /I "../../pthreads" /I "../../oggvorbis-win32sdk-1.0.1/include" /I "../../theora/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32_SERVICE" /D "HAVE_CURL" /D "USE_YP" /D "HAVE_SYS_STAT_H" /D PACKAGE_VERSION=\"trunk\" /D "HAVE_THEORA" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "../" /I "../../libxslt/include" /I "../../curl/include" /I "../../iconv/include" /I "../../libxml2/include" /I "..\src" /I "..\src/httpp" /I "..\src/thread" /I "..\src/log" /I "..\src/avl" /I "..\src/net" /I "..\src/timings" /I "../../pthreads" /I "../../oggvorbis-win32sdk-1.0.1/include" /I "../../theora/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32_SERVICE" /D "HAVE_CURL" /D "USE_YP" /D "HAVE_SYS_STAT_H" /D PACKAGE_VERSION=\"trunk\" /D "HAVE_THEORA" /YX /FD /D PACKAGE_STRING=\"Icecast-trunk\" /c
# SUBTRACT CPP /X
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe