Commit 06510b99 authored by Karl Heyes's avatar Karl Heyes

update from win32 build. Mostly cleanup work

svn path=/icecast/trunk/icecast/; revision=14867
parent 90b70598
......@@ -33,18 +33,10 @@ typedef struct source_tag source_t;
#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)
{
skeleton_codec_t *skeleton = codec->specific;
DEBUG0 ("freeing skeleton codec");
ogg_stream_clear (&codec->os);
free (skeleton);
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_packet packet;
skeleton_codec_t *skeleton_codec = calloc (1, sizeof (skeleton_codec_t));
ogg_stream_init (&codec->os, ogg_page_serialno (page));
ogg_stream_pagein (&codec->os, page);
ogg_stream_packetout (&codec->os, &packet);
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))
{
ogg_stream_clear (&codec->os);
free (skeleton_codec);
free (codec);
return NULL;
}
INFO0 ("seen initial skeleton header");
codec->specific = skeleton_codec;
codec->process_page = process_skeleton_page;
codec->codec_free = skeleton_codec_free;
codec->headers = 1;
......
......@@ -1100,7 +1100,7 @@ refbuf_t *stats_get_streams (void)
{
#define STREAMLIST_BLKSIZE 4096
avl_node *node;
int remaining = STREAMLIST_BLKSIZE;
unsigned int remaining = STREAMLIST_BLKSIZE;
refbuf_t *start = refbuf_new (remaining), *cur = start;
char *buffer = cur->data;
......
......@@ -89,288 +89,304 @@ SOURCE=..\src\admin.c
# End Source File
# Begin Source File
SOURCE=..\src\admin.h
SOURCE=..\src\auth.c
# End Source File
# Begin Source File
SOURCE=..\src\auth.c
SOURCE=..\src\auth_htpasswd.c
# End Source File
# Begin Source File
SOURCE=..\src\auth.h
SOURCE=..\src\auth_url.c
# End Source File
# Begin Source File
SOURCE=..\src\auth_htpasswd.c
SOURCE=..\src\avl\avl.c
# End Source File
# Begin Source File
SOURCE=..\src\auth_htpasswd.h
SOURCE=..\src\cfgfile.c
# End Source File
# Begin Source File
SOURCE=..\src\auth_url.c
SOURCE=..\src\client.c
# End Source File
# Begin Source File
SOURCE=..\src\auth_url.h
SOURCE=..\src\connection.c
# End Source File
# Begin Source File
SOURCE=..\src\avl\avl.c
SOURCE=..\src\event.c
# End Source File
# Begin Source File
SOURCE=..\src\avl\avl.h
SOURCE=..\src\format.c
# End Source File
# Begin Source File
SOURCE=..\src\cfgfile.c
SOURCE=..\src\format_flac.c
# End Source File
# Begin Source File
SOURCE=..\src\cfgfile.h
SOURCE=..\src\format_kate.c
# End Source File
# Begin Source File
SOURCE=..\src\client.c
SOURCE=..\src\format_midi.c
# End Source File
# Begin Source File
SOURCE=..\src\client.h
SOURCE=..\src\format_mp3.c
# End Source File
# Begin Source File
SOURCE=..\src\compat.h
SOURCE=..\src\format_ogg.c
# End Source File
# Begin Source File
SOURCE=..\src\connection.c
SOURCE=..\src\format_skeleton.c
# End Source File
# Begin Source File
SOURCE=..\src\connection.h
SOURCE=..\src\format_speex.c
# End Source File
# Begin Source File
SOURCE=..\src\event.c
SOURCE=..\src\format_theora.c
# End Source File
# Begin Source File
SOURCE=..\src\event.h
SOURCE=..\src\format_vorbis.c
# End Source File
# Begin Source File
SOURCE=..\src\format.c
SOURCE=..\src\fserve.c
# End Source File
# Begin Source File
SOURCE=..\src\format.h
SOURCE=..\src\global.c
# End Source File
# Begin Source File
SOURCE=..\src\format_flac.c
SOURCE=..\src\httpp\httpp.c
# End Source File
# Begin Source File
SOURCE=..\src\format_flac.h
SOURCE=..\src\log\log.c
# End Source File
# Begin Source File
SOURCE=..\src\format_midi.c
SOURCE=..\src\logging.c
# End Source File
# Begin Source File
SOURCE=..\src\format_midi.h
SOURCE=..\src\md5.c
# End Source File
# Begin Source File
SOURCE=..\src\format_mp3.c
SOURCE=..\src\os.h
# End Source File
# Begin Source File
SOURCE=..\src\format_mp3.h
SOURCE=..\src\refbuf.c
# End Source File
# Begin Source File
SOURCE=..\src\format_ogg.c
SOURCE=..\src\net\resolver.c
# End Source File
# Begin Source File
SOURCE=..\src\format_ogg.h
SOURCE=..\src\sighandler.c
# End Source File
# Begin Source File
SOURCE=..\src\format_speex.c
SOURCE=..\src\slave.c
# End Source File
# Begin Source File
SOURCE=..\src\format_speex.h
SOURCE=..\src\net\sock.c
# End Source File
# Begin Source File
SOURCE=..\src\format_theora.c
SOURCE=..\src\source.c
# End Source File
# Begin Source File
SOURCE=..\src\format_theora.h
SOURCE=..\src\stats.c
# End Source File
# Begin Source File
SOURCE=..\src\format_vorbis.c
SOURCE=..\src\thread\thread.c
# End Source File
# Begin Source File
SOURCE=..\src\format_vorbis.h
SOURCE=..\src\timing\timing.c
# End Source File
# Begin Source File
SOURCE=..\src\fserve.c
SOURCE=..\src\util.c
# End Source File
# Begin Source File
SOURCE=..\src\fserve.h
SOURCE=..\src\xslt.c
# End Source File
# Begin Source File
SOURCE=..\src\global.c
SOURCE=..\src\yp.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\src\global.h
SOURCE=..\src\admin.h
# End Source File
# Begin Source File
SOURCE=..\src\httpp\httpp.c
SOURCE=..\src\auth.h
# End Source File
# Begin Source File
SOURCE=..\src\httpp\httpp.h
SOURCE=..\src\auth_htpasswd.h
# End Source File
# Begin Source File
SOURCE=..\src\log\log.c
SOURCE=..\src\auth_url.h
# End Source File
# Begin Source File
SOURCE=..\src\log\log.h
SOURCE=..\src\avl\avl.h
# End Source File
# Begin Source File
SOURCE=..\src\logging.c
SOURCE=..\src\cfgfile.h
# End Source File
# Begin Source File
SOURCE=..\src\logging.h
SOURCE=..\src\client.h
# End Source File
# Begin Source File
SOURCE=..\src\md5.c
SOURCE=..\src\compat.h
# End Source File
# Begin Source File
SOURCE=..\src\md5.h
SOURCE=..\src\connection.h
# End Source File
# Begin Source File
SOURCE=..\src\os.h
SOURCE=..\src\event.h
# End Source File
# Begin Source File
SOURCE=..\src\refbuf.c
SOURCE=..\src\format.h
# End Source File
# Begin Source File
SOURCE=..\src\refbuf.h
SOURCE=..\src\format_flac.h
# End Source File
# Begin Source File
SOURCE=..\src\net\resolver.c
SOURCE=..\src\format_kate.h
# End Source File
# Begin Source File
SOURCE=..\src\net\resolver.h
SOURCE=..\src\format_midi.h
# End Source File
# Begin Source File
SOURCE=..\src\sighandler.c
SOURCE=..\src\format_mp3.h
# End Source File
# Begin Source File
SOURCE=..\src\sighandler.h
SOURCE=..\src\format_ogg.h
# End Source File
# Begin Source File
SOURCE=..\src\slave.c
SOURCE=..\src\format_skeleton.h
# End Source File
# Begin Source File
SOURCE=..\src\net\sock.c
SOURCE=..\src\format_speex.h
# End Source File
# Begin Source File
SOURCE=..\src\net\sock.h
SOURCE=..\src\format_theora.h
# End Source File
# Begin Source File
SOURCE=..\src\source.c
SOURCE=..\src\format_vorbis.h
# End Source File
# Begin Source File
SOURCE=..\src\source.h
SOURCE=..\src\fserve.h
# End Source File
# Begin Source File
SOURCE=..\src\stats.c
SOURCE=..\src\global.h
# End Source File
# Begin Source File
SOURCE=..\src\stats.h
SOURCE=..\src\httpp\httpp.h
# End Source File
# Begin Source File
SOURCE=..\src\thread\thread.c
SOURCE=..\src\log\log.h
# End Source File
# Begin Source File
SOURCE=..\src\thread\thread.h
SOURCE=..\src\logging.h
# End Source File
# Begin Source File
SOURCE=..\src\timing\timing.c
SOURCE=..\src\md5.h
# End Source File
# Begin Source File
SOURCE=..\src\util.c
SOURCE=..\src\refbuf.h
# End Source File
# Begin Source File
SOURCE=..\src\util.h
SOURCE=..\src\net\resolver.h
# End Source File
# Begin Source File
SOURCE=..\src\xslt.c
SOURCE=..\src\sighandler.h
# End Source File
# Begin Source File
SOURCE=..\src\yp.c
SOURCE=..\src\net\sock.h
# End Source File
# Begin Source File
SOURCE=..\src\yp.h
SOURCE=..\src\source.h
# End Source File
# End Group
# Begin Group "Header Files"
# Begin Source File
# PROP Default_Filter "h;hpp;hxx;hm;inl"
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
# End Source File
# Begin Source File
SOURCE=..\src\util.h
# End Source File
# Begin Source File
SOURCE=..\src\xslt.h
# End Source File
# Begin Source File
SOURCE=..\src\yp.h
# End Source File
# End Group
# End Target
# End Project
#include <windows.h>
#include <stdio.h>
#include <errno.h>
#include <direct.h>
extern "C" {
#include "thread/thread.h"
......@@ -15,6 +14,10 @@ extern "C" {
#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_HANDLE hStatus;
......@@ -30,14 +33,16 @@ int InitService()
return(result);
}
void installService(char *path)
void installService (const char *path)
{
if (path) {
char fullPath[8096*2] = "";
if (path) {
char fullPath[8096*2] = "\"";
int len = GetModuleFileName (NULL, fullPath+1, sizeof (fullPath)-1);
_snprintf(fullPath, sizeof (fullPath), "\"%s\\icecastService.exe\" \"%s\"", path, path);
SC_HANDLE handle = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (handle == NULL)
_snprintf(fullPath+len+1, sizeof (fullPath)-len, "\" \"%s\"", path);
SC_HANDLE manager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (manager == NULL)
{
LPVOID lpMsgBuf;
FormatMessage(
......@@ -58,9 +63,9 @@ void installService(char *path)
}
SC_HANDLE service = CreateService(
handle,
"Icecast",
"Icecast Media Server",
manager,
PACKAGE_STRING,
PACKAGE_STRING " Streaming Media Server",
GENERIC_READ | GENERIC_EXECUTE,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
......@@ -72,7 +77,7 @@ void installService(char *path)
NULL,
NULL
);
if (handle == NULL)
if (service == NULL)
{
LPVOID lpMsgBuf;
FormatMessage(
......@@ -89,19 +94,19 @@ void installService(char *path)
printf ("CreateService: %s\n", (LPCTSTR)lpMsgBuf);
LocalFree( lpMsgBuf );
CloseServiceHandle (handle);
CloseServiceHandle (manager);
return;
}
printf("Service Installed\n");
CloseServiceHandle (service);
CloseServiceHandle (handle);
CloseServiceHandle (manager);
}
}
void removeService()
{
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;
FormatMessage(
......@@ -121,13 +126,15 @@ void removeService()
return;
}
SC_HANDLE service = OpenService(handle, "Icecast", DELETE);
SC_HANDLE service = OpenService (manager, PACKAGE_STRING, DELETE);
if (service) {
DeleteService(service);
printf("Service Removed\n");
CloseServiceHandle (service);
}
else
printf("Service not found\n");
CloseServiceHandle (manager);
}
void ControlHandler(DWORD request)
{
......@@ -167,7 +174,7 @@ void ServiceMain(int argc, char** argv)
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;
hStatus = RegisterServiceCtrlHandler("Icecast", (LPHANDLER_FUNCTION)ControlHandler);
hStatus = RegisterServiceCtrlHandler(PACKAGE_STRING, (LPHANDLER_FUNCTION)ControlHandler);
if (hStatus == (SERVICE_STATUS_HANDLE)0) {
// Registering Control Handler failed
return;
......@@ -188,11 +195,15 @@ void ServiceMain(int argc, char** argv)
/* Here we do the work */
int argc2 = 3;
char* argv2[3];
char* argv2 [4];
argv2[0] = "icecastService.exe";
argv2[1] = "-c";
argv2[2] = "icecast.xml";
argv2 [0] = argv[0];
argv2 [1] = "-c";
if (argc < 2)
argv2 [2] = "icecast.xml";
else
argv2 [2] = argv[1];
argv2[3] = NULL;
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 (argv[0]) {
if (argv[1]) {
if (!strcmp(argv[1], "install")) {
installService(argv[2]);
matched = true;
}
if (!strcmp(argv[1], "remove")) {
removeService();
matched = true;
}
}
}
if (matched) {
return;
}
_chdir(argv[1]);
if (_chdir(argv[1]) < 0)
{
printf ("unable to change to directory %s\n", argv[1]);
Sleep (2000);
return 0;
}
SERVICE_TABLE_ENTRY ServiceTable[2];
ServiceTable[0].lpServiceName = "Icecast Server";
ServiceTable[0].lpServiceName = PACKAGE_STRING;
ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
ServiceTable[1].lpServiceName = NULL;
ServiceTable[1].lpServiceProc = NULL;
// Start the control dispatcher thread for our service
StartServiceCtrlDispatcher(ServiceTable);
return 0;
}
......@@ -42,7 +42,8 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# 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 RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment