[xiph-cvs] cvs commit: icecast/src main.c source.c
Ed
oddsock at xiph.org
Wed Apr 16 20:23:19 PDT 2003
oddsock 03/04/16 23:23:19
Modified: src main.c source.c
Log:
printf to stdout not valid with our win32 binary, so lets now use something that will work on win32. note that these should only be used up to the point at which logging is started, then everything should go there.
also added a new stat to represent what is currently being sent to the yp server as "what's playing"
Revision Changes Path
1.26 +37 -15 icecast/src/main.c
Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/main.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- main.c 27 Mar 2003 17:09:57 -0000 1.25
+++ main.c 17 Apr 2003 03:23:18 -0000 1.26
@@ -42,6 +42,15 @@
#undef CATMODULE
#define CATMODULE "main"
+static void _fatal_error(char *perr)
+{
+#ifdef WIN32
+ MessageBox(NULL, perr, "Error", MB_OK);
+#else
+ fprintf(stdout, "%s\n", perr);
+#endif
+}
+
static void _print_usage()
{
printf("Usage:\n");
@@ -132,6 +141,8 @@
{
char fn_error[FILENAME_MAX];
char fn_access[FILENAME_MAX];
+ char pbuf[1024];
+
ice_config_t *config = config_get_config_unlocked();
if(strcmp(config->error_log, "-")) {
@@ -150,11 +161,14 @@
log_set_level(errorlog, config->loglevel);
log_set_level(accesslog, 4);
- if (errorlog < 0)
- fprintf(stderr, "FATAL: could not open %s for error logging\n", fn_error);
- if (accesslog < 0)
- fprintf(stderr, "FATAL: could not open %s for access logging\n", fn_access);
-
+ if (errorlog < 0) {
+ _fatal_error("FATAL: could not open error logging");
+ }
+ if (accesslog < 0) {
+ memset(pbuf, '\000', sizeof(pbuf));
+ snprintf(pbuf, sizeof(pbuf)-1, "FATAL: could not open access logging");
+ _fatal_error(pbuf);
+ }
if (errorlog >= 0 && accesslog >= 0) return 1;
return 0;
@@ -166,6 +180,7 @@
int i = 0;
int ret = 0;
int successful = 0;
+ char pbuf[1024];
config = config_get_config_unlocked();
@@ -177,8 +192,11 @@
config->listeners[i].port, config->listeners[i].bind_address);
if (global.serversock[i] == SOCK_ERROR) {
- fprintf(stderr, "Could not create listener socket on port %d\n",
- config->listeners[i].port);
+ memset(pbuf, '\000', sizeof(pbuf));
+ snprintf(pbuf, sizeof(pbuf)-1,
+ "Could not create listener socket on port %d",
+ config->listeners[i].port);
+ _fatal_error(pbuf);
return 0;
}
else {
@@ -212,7 +230,7 @@
return 0;
if (!_start_listening()) {
- fprintf(stderr, "Failed trying to listen on server socket\n");
+ _fatal_error("Failed trying to listen on server socket");
return 0;
}
@@ -311,6 +329,7 @@
{
int res, ret;
char filename[512];
+ char pbuf[1024];
/* parse the '-c icecast.xml' option
** only, so that we can read a configfile
@@ -325,19 +344,22 @@
ret = config_initial_parse_file(filename);
config_release_config();
if (ret < 0) {
- fprintf(stderr, "FATAL: error parsing config file:");
+ memset(pbuf, '\000', sizeof(pbuf));
+ snprintf(pbuf, sizeof(pbuf)-1,
+ "FATAL: error parsing config file (%s)", filename);
+ _fatal_error(pbuf);
switch (ret) {
case CONFIG_EINSANE:
- fprintf(stderr, "filename was null or blank\n");
+ _fatal_error("filename was null of blank");
break;
case CONFIG_ENOROOT:
- fprintf(stderr, "no root element found\n");
+ _fatal_error("no root element found");
break;
case CONFIG_EBADROOT:
- fprintf(stderr, "root element is not <icecast>\n");
+ _fatal_error("root element is not <icecast>");
break;
default:
- fprintf(stderr, "parse error\n");
+ _fatal_error("XML config parsing error");
break;
}
_shutdown_subsystems();
@@ -353,7 +375,7 @@
/* Bind socket, before we change userid */
if(!_server_proc_init()) {
- fprintf(stderr, "Server startup failed. Exiting.\n");
+ _fatal_error("Server startup failed. Exiting");
_shutdown_subsystems();
return 1;
}
@@ -379,7 +401,7 @@
sighandler_initialize();
if (!_start_logging()) {
- fprintf(stderr, "FATAL: Could not start logging\n");
+ _fatal_error("FATAL: Could not start logging");
_shutdown_subsystems();
return 1;
}
<p><p>1.51 +1 -1 icecast/src/source.c
Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- source.c 11 Apr 2003 03:00:24 -0000 1.50
+++ source.c 17 Apr 2003 03:23:18 -0000 1.51
@@ -831,7 +831,7 @@
source->ypdata[i]->current_song =
malloc(strlen((char *)escaped) +1);
strcpy(source->ypdata[i]->current_song, (char *)escaped);
- stats_event(source->mount, stat_name, (char *)info);
+ stats_event(source->mount, "yp_currently_playing", (char *)info);
free(escaped);
}
break;
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list