Commit 9e168dc8 authored by Michael Smith's avatar Michael Smith

Lots of fixes for screwy code formatting, plus:

make streams public by default, send ice-private: 1 to make them private.
However, default config file has yp servers commented out.

A little fix for compilation on some solaris systems

Redo some config file stuff: now all the passwords are inside an element
<authentication>, (though for now they're also accepted in the old location),
and added admin username and password. Move some of the admin activities over
to using the admin passwords (admin action that affect a mountpoint use the
source password)

Fill in some (but not yet all, maybe i'll do that later) of the infrastructure
for per-mountpoint passwords.

Fix lots of headers/code so that it works properly/portably  on non-win32
systems.

svn path=/trunk/icecast/; revision=4325
parent ffb1f3bc
...@@ -8,6 +8,8 @@ BUGS ...@@ -8,6 +8,8 @@ BUGS
- make install - doesn't install configs? - make install - doesn't install configs?
- pthread/bsd: -pthread instead of -lpthread (autoconf)
FEATURES FEATURES
-------- --------
...@@ -30,4 +32,24 @@ FEATURES ...@@ -30,4 +32,24 @@ FEATURES
- stats to list currently connected clients: ip and hostname - stats to list currently connected clients: ip and hostname
- stream switching (drop clients to another stream on disconnect of source)
- a) fallbacks from named location to new mountpoint
- OR b) fallbacks for connected clients to new mountpoint (so newly-connecting
clients just get a 404 on the old path)
- OR c) combination - first one, plus generic alias ability?
- /admin/* for all admin functionality
- configuring fallbacks
- mp3 metadata injection
- remote shutdown?
- general registerable url-handlers in connection.c rather than hard-coded list
(already getting unmaintainable)
- httpp - split out query string for further processing
- finish mp3 metadata: http://server:ip/admin.cgi?pass=%s&mode=updinfo&mount=%s&song=%s
...@@ -11,12 +11,23 @@ ...@@ -11,12 +11,23 @@
<source-timeout>10</source-timeout> <source-timeout>10</source-timeout>
</limits> </limits>
<source-password>hackme</source-password> <authentication>
<relay-password>hackme</relay-password> <!-- Sources log in with username 'source' -->
<source-password>hackme</source-password>
<directory> <!-- Relays log in username 'relay' -->
<yp-url>http://www.oddsock.org/cgi-bin/yp-cgi</yp-url> <relay-password>hackme</relay-password>
</directory>
<!-- Admin logs in with the username given below -->
<admin-user>admin</admin-user>
<admin-password>hackme</admin-password>
</authentication>
<!-- Uncomment this if you want directory listings -->
<!--
<directory>
<yp-url>http://www.oddsock.org/cgi-bin/yp-cgi</yp-url>
</directory>
-->
<hostname>localhost</hostname> <hostname>localhost</hostname>
<port>8000</port> <port>8000</port>
...@@ -30,15 +41,15 @@ ...@@ -30,15 +41,15 @@
<fileserve>1</fileserve> <fileserve>1</fileserve>
<paths> <paths>
<basedir>/usr/local/icecast2</basedir> <basedir>/usr/local/icecast</basedir>
<logdir>/usr/local/icecast2/logs</logdir> <logdir>/usr/local/icecast/logs</logdir>
<webroot>/usr/local/icecast2/web</webroot> <webroot>/usr/local/icecast/web</webroot>
</paths> </paths>
<logging> <logging>
<accesslog>access.log</accesslog> <accesslog>access.log</accesslog>
<errorlog>error.log</errorlog> <errorlog>error.log</errorlog>
<loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error --> <loglevel>4</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
</logging> </logging>
<security> <security>
......
...@@ -54,6 +54,7 @@ static void _parse_directory(xmlDocPtr doc, xmlNodePtr node); ...@@ -54,6 +54,7 @@ static void _parse_directory(xmlDocPtr doc, xmlNodePtr node);
static void _parse_paths(xmlDocPtr doc, xmlNodePtr node); static void _parse_paths(xmlDocPtr doc, xmlNodePtr node);
static void _parse_logging(xmlDocPtr doc, xmlNodePtr node); static void _parse_logging(xmlDocPtr doc, xmlNodePtr node);
static void _parse_security(xmlDocPtr doc, xmlNodePtr node); static void _parse_security(xmlDocPtr doc, xmlNodePtr node);
static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node);
static void _add_server(xmlDocPtr doc, xmlNodePtr node); static void _add_server(xmlDocPtr doc, xmlNodePtr node);
void config_initialize(void) void config_initialize(void)
...@@ -171,7 +172,7 @@ static void _set_defaults(void) ...@@ -171,7 +172,7 @@ static void _set_defaults(void)
_configuration.relay_password = CONFIG_DEFAULT_RELAY_PASSWORD; _configuration.relay_password = CONFIG_DEFAULT_RELAY_PASSWORD;
_configuration.ice_login = CONFIG_DEFAULT_ICE_LOGIN; _configuration.ice_login = CONFIG_DEFAULT_ICE_LOGIN;
_configuration.fileserve = CONFIG_DEFAULT_FILESERVE; _configuration.fileserve = CONFIG_DEFAULT_FILESERVE;
_configuration.touch_freq = CONFIG_DEFAULT_TOUCH_FREQ; _configuration.touch_interval = CONFIG_DEFAULT_TOUCH_FREQ;
_configuration.dir_list = NULL; _configuration.dir_list = NULL;
_configuration.hostname = CONFIG_DEFAULT_HOSTNAME; _configuration.hostname = CONFIG_DEFAULT_HOSTNAME;
_configuration.port = CONFIG_DEFAULT_PORT; _configuration.port = CONFIG_DEFAULT_PORT;
...@@ -207,7 +208,10 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node) ...@@ -207,7 +208,10 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node)
} else if (strcmp(node->name, "admin") == 0) { } else if (strcmp(node->name, "admin") == 0) {
if (_configuration.admin && _configuration.admin != CONFIG_DEFAULT_ADMIN) xmlFree(_configuration.admin); if (_configuration.admin && _configuration.admin != CONFIG_DEFAULT_ADMIN) xmlFree(_configuration.admin);
_configuration.admin = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); _configuration.admin = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (strcmp(node->name, "source-password") == 0) { } else if(strcmp(node->name, "authentication") == 0) {
_parse_authentication(doc, node->xmlChildrenNode);
} else if (strcmp(node->name, "source-password") == 0) {
/* TODO: This is the backwards-compatibility location */
char *mount, *pass; char *mount, *pass;
if ((mount = (char *)xmlGetProp(node, "mount")) != NULL) { if ((mount = (char *)xmlGetProp(node, "mount")) != NULL) {
pass = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); pass = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
...@@ -218,8 +222,9 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node) ...@@ -218,8 +222,9 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node)
_configuration.source_password = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); _configuration.source_password = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} }
} else if (strcmp(node->name, "relay-password") == 0) { } else if (strcmp(node->name, "relay-password") == 0) {
if (_configuration.relay_password && _configuration.relay_password != CONFIG_DEFAULT_RELAY_PASSWORD) xmlFree(_configuration.relay_password); /* TODO: This is the backwards-compatibility location */
_configuration.relay_password = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); if (_configuration.relay_password && _configuration.relay_password != CONFIG_DEFAULT_RELAY_PASSWORD) xmlFree(_configuration.relay_password);
_configuration.relay_password = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (strcmp(node->name, "icelogin") == 0) { } else if (strcmp(node->name, "icelogin") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
_configuration.ice_login = atoi(tmp); _configuration.ice_login = atoi(tmp);
...@@ -300,6 +305,47 @@ static void _parse_limits(xmlDocPtr doc, xmlNodePtr node) ...@@ -300,6 +305,47 @@ static void _parse_limits(xmlDocPtr doc, xmlNodePtr node)
} while ((node = node->next)); } while ((node = node->next));
} }
static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node)
{
do {
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "source-password") == 0) {
char *mount, *pass;
if ((mount = (char *)xmlGetProp(node, "mount")) != NULL) {
pass = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
/* FIXME: This is a placeholder for per-mount passwords */
}
else {
if (_configuration.source_password &&
_configuration.source_password !=
CONFIG_DEFAULT_SOURCE_PASSWORD)
xmlFree(_configuration.source_password);
_configuration.source_password =
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
}
} else if (strcmp(node->name, "relay-password") == 0) {
if (_configuration.relay_password &&
_configuration.relay_password !=
CONFIG_DEFAULT_RELAY_PASSWORD)
xmlFree(_configuration.relay_password);
_configuration.relay_password =
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (strcmp(node->name, "admin-password") == 0) {
if(_configuration.admin_password)
xmlFree(_configuration.admin_password);
_configuration.admin_password =
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (strcmp(node->name, "admin-user") == 0) {
if(_configuration.admin_username)
xmlFree(_configuration.admin_username);
_configuration.admin_username =
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
}
} while ((node = node->next));
}
static void _parse_directory(xmlDocPtr doc, xmlNodePtr node) static void _parse_directory(xmlDocPtr doc, xmlNodePtr node)
{ {
char *tmp; char *tmp;
...@@ -313,16 +359,19 @@ static void _parse_directory(xmlDocPtr doc, xmlNodePtr node) ...@@ -313,16 +359,19 @@ static void _parse_directory(xmlDocPtr doc, xmlNodePtr node)
if (xmlIsBlankNode(node)) continue; if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "yp-url") == 0) { if (strcmp(node->name, "yp-url") == 0) {
if (_configuration.yp_url[_configuration.num_yp_directories]) xmlFree(_configuration.yp_url[_configuration.num_yp_directories]); if (_configuration.yp_url[_configuration.num_yp_directories])
_configuration.yp_url[_configuration.num_yp_directories] = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); xmlFree(_configuration.yp_url[_configuration.num_yp_directories]);
_configuration.yp_url[_configuration.num_yp_directories] =
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (strcmp(node->name, "yp-url-timeout") == 0) { } else if (strcmp(node->name, "yp-url-timeout") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
_configuration.yp_url_timeout[_configuration.num_yp_directories] = atoi(tmp); _configuration.yp_url_timeout[_configuration.num_yp_directories] =
atoi(tmp);
} else if (strcmp(node->name, "server") == 0) { } else if (strcmp(node->name, "server") == 0) {
_add_server(doc, node->xmlChildrenNode); _add_server(doc, node->xmlChildrenNode);
} else if (strcmp(node->name, "touch-freq") == 0) { } else if (strcmp(node->name, "touch-interval") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
_configuration.touch_freq = atoi(tmp); _configuration.touch_interval = atoi(tmp);
if (tmp) xmlFree(tmp); if (tmp) xmlFree(tmp);
} }
} while ((node = node->next)); } while ((node = node->next));
...@@ -411,7 +460,7 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node) ...@@ -411,7 +460,7 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node)
char *tmp; char *tmp;
server = (ice_config_dir_t *)malloc(sizeof(ice_config_dir_t)); server = (ice_config_dir_t *)malloc(sizeof(ice_config_dir_t));
server->touch_freq = _configuration.touch_freq; server->touch_interval = _configuration.touch_interval;
server->host = NULL; server->host = NULL;
addnode = 0; addnode = 0;
...@@ -420,11 +469,12 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node) ...@@ -420,11 +469,12 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node)
if (xmlIsBlankNode(node)) continue; if (xmlIsBlankNode(node)) continue;
if (strcmp(node->name, "host") == 0) { if (strcmp(node->name, "host") == 0) {
server->host = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); server->host = (char *)xmlNodeListGetString(doc,
node->xmlChildrenNode, 1);
addnode = 1; addnode = 1;
} else if (strcmp(node->name, "touch-freq") == 0) { } else if (strcmp(node->name, "touch-interval") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
server->touch_freq = atoi(tmp); server->touch_interval = atoi(tmp);
if (tmp) xmlFree(tmp); if (tmp) xmlFree(tmp);
} }
server->next = NULL; server->next = NULL;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
typedef struct ice_config_dir_tag typedef struct ice_config_dir_tag
{ {
char *host; char *host;
int touch_freq; int touch_interval;
struct ice_config_dir_tag *next; struct ice_config_dir_tag *next;
} ice_config_dir_t; } ice_config_dir_t;
...@@ -31,8 +31,10 @@ typedef struct ice_config_tag ...@@ -31,8 +31,10 @@ typedef struct ice_config_tag
char *source_password; char *source_password;
char *relay_password; char *relay_password;
char *admin_username;
char *admin_password;
int touch_freq; int touch_interval;
ice_config_dir_t *dir_list; ice_config_dir_t *dir_list;
char *hostname; char *hostname;
......
...@@ -32,11 +32,11 @@ void _dump_config(ice_config_t *config) ...@@ -32,11 +32,11 @@ void _dump_config(ice_config_t *config)
printf("threadpool_size = %d\n", config->threadpool_size); printf("threadpool_size = %d\n", config->threadpool_size);
printf("client_timeout = %d\n", config->client_timeout); printf("client_timeout = %d\n", config->client_timeout);
printf("source_password = %s\n", config->source_password); printf("source_password = %s\n", config->source_password);
printf("touch_freq = %d\n", config->touch_freq); printf("touch_interval = %d\n", config->touch_interval);
node = config->dir_list; node = config->dir_list;
while (node) { while (node) {
printf("directory.touch_freq = %d\n", node->touch_freq); printf("directory.touch_interval = %d\n", node->touch_interval);
printf("directory.host = %s\n", node->host); printf("directory.host = %s\n", node->host);
node = node->next; node = node->next;
......
...@@ -404,7 +404,17 @@ static int _check_relay_pass(http_parser_t *parser) ...@@ -404,7 +404,17 @@ static int _check_relay_pass(http_parser_t *parser)
return _check_pass_http(parser, "relay", pass); return _check_pass_http(parser, "relay", pass);
} }
static int _check_source_pass(http_parser_t *parser) static int _check_admin_pass(http_parser_t *parser)
{
char *pass = config_get_config()->admin_password;
char *user = config_get_config()->admin_username;
if(!pass || !user)
return 0;
return _check_pass_http(parser, "admin", pass);
}
static int _check_source_pass(http_parser_t *parser, char *mount)
{ {
char *pass = config_get_config()->source_password; char *pass = config_get_config()->source_password;
int ret; int ret;
...@@ -428,15 +438,15 @@ static void handle_fallback_request(client_t *client) ...@@ -428,15 +438,15 @@ static void handle_fallback_request(client_t *client)
char *mount, *value, *old; char *mount, *value, *old;
int bytes; int bytes;
if(!_check_source_pass(client->parser)) { mount = httpp_get_query_param(client->parser, "mount");
value = httpp_get_query_param(client->parser, "fallback");
if(!_check_source_pass(client->parser, mount)) {
INFO0("Bad or missing password on fallback configuration request"); INFO0("Bad or missing password on fallback configuration request");
client_send_401(client); client_send_401(client);
return; return;
} }
mount = httpp_get_query_param(client->parser, "mount");
value = httpp_get_query_param(client->parser, "fallback");
if(value == NULL || mount == NULL) { if(value == NULL || mount == NULL) {
client_send_400(client, "Missing parameter"); client_send_400(client, "Missing parameter");
return; return;
...@@ -472,16 +482,16 @@ static void handle_metadata_request(client_t *client) ...@@ -472,16 +482,16 @@ static void handle_metadata_request(client_t *client)
mp3_state *state; mp3_state *state;
int bytes; int bytes;
if(!_check_source_pass(client->parser)) { action = httpp_get_query_param(client->parser, "mode");
mount = httpp_get_query_param(client->parser, "mount");
value = httpp_get_query_param(client->parser, "song");
if(!_check_source_pass(client->parser, mount)) {
INFO0("Metadata request with wrong or missing password"); INFO0("Metadata request with wrong or missing password");
client_send_401(client); client_send_401(client);
return; return;
} }
action = httpp_get_query_param(client->parser, "mode");
mount = httpp_get_query_param(client->parser, "mount");
value = httpp_get_query_param(client->parser, "song");
if(value == NULL || action == NULL || mount == NULL) { if(value == NULL || action == NULL || mount == NULL) {
client_send_400(client, "Missing parameter"); client_send_400(client, "Missing parameter");
return; return;
...@@ -533,7 +543,7 @@ static void _handle_source_request(connection_t *con, ...@@ -533,7 +543,7 @@ static void _handle_source_request(connection_t *con,
INFO1("Source logging in at mountpoint \"%s\"", uri); INFO1("Source logging in at mountpoint \"%s\"", uri);
stats_event_inc(NULL, "source_connections"); stats_event_inc(NULL, "source_connections");
if (!_check_source_pass(parser)) { if (!_check_source_pass(parser, uri)) {
INFO1("Source (%s) attempted to login with invalid or missing password", uri); INFO1("Source (%s) attempted to login with invalid or missing password", uri);
client_send_401(client); client_send_401(client);
return; return;
...@@ -564,7 +574,7 @@ static void _handle_stats_request(connection_t *con, ...@@ -564,7 +574,7 @@ static void _handle_stats_request(connection_t *con,
stats_event_inc(NULL, "stats_connections"); stats_event_inc(NULL, "stats_connections");
if (!_check_source_pass(parser)) { if (!_check_admin_pass(parser)) {
ERROR0("Bad password for stats connection"); ERROR0("Bad password for stats connection");
connection_close(con); connection_close(con);
httpp_destroy(parser); httpp_destroy(parser);
...@@ -606,7 +616,7 @@ static void _handle_get_request(connection_t *con, ...@@ -606,7 +616,7 @@ static void _handle_get_request(connection_t *con,
*/ */
/* TODO: add GUID-xxxxxx */ /* TODO: add GUID-xxxxxx */
if (strcmp(uri, "/admin/stats.xml") == 0) { if (strcmp(uri, "/admin/stats.xml") == 0) {
if (!_check_source_pass(parser)) { if (!_check_admin_pass(parser)) {
INFO0("Request for /admin/stats.xml with incorrect or no password"); INFO0("Request for /admin/stats.xml with incorrect or no password");
client_send_401(client); client_send_401(client);
return; return;
......
...@@ -226,7 +226,7 @@ static void *fserv_thread_function(void *arg) ...@@ -226,7 +226,7 @@ static void *fserv_thread_function(void *arg)
&client->buf[client->offset], &client->buf[client->offset],
client->datasize - client->offset); client->datasize - client->offset);
// TODO: remove clients if they take too long. /* TODO: remove clients if they take too long. */
if(sbytes >= 0) { if(sbytes >= 0) {
client->offset += sbytes; client->offset += sbytes;
client->client->con->sent_bytes += sbytes; client->client->con->sent_bytes += sbytes;
......
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <thread/thread.h> #include <thread/thread.h>
...@@ -20,10 +21,10 @@ ...@@ -20,10 +21,10 @@
#define CATMODULE "geturl" #define CATMODULE "geturl"
static curl_connection curl_connections[NUM_CONNECTIONS]; static curl_connection curl_connections[NUM_CONNECTIONS];
mutex_t _curl_mutex; static mutex_t _curl_mutex;
size_t size_t curl_write_memory_callback(void *ptr, size_t size,
curl_write_memory_callback(void *ptr, size_t size, size_t nmemb, void *data) size_t nmemb, void *data)
{ {
register int realsize = size * nmemb; register int realsize = size * nmemb;
...@@ -35,8 +36,9 @@ curl_write_memory_callback(void *ptr, size_t size, size_t nmemb, void *data) ...@@ -35,8 +36,9 @@ curl_write_memory_callback(void *ptr, size_t size, size_t nmemb, void *data)
return realsize; return realsize;
} }
size_t
curl_header_memory_callback(void *ptr, size_t size, size_t nmemb, void *data) size_t curl_header_memory_callback(void *ptr, size_t size,
size_t nmemb, void *data)
{ {
char *p1 = 0; char *p1 = 0;
char *p2 = 0; char *p2 = 0;
...@@ -48,19 +50,18 @@ curl_header_memory_callback(void *ptr, size_t size, size_t nmemb, void *data) ...@@ -48,19 +50,18 @@ curl_header_memory_callback(void *ptr, size_t size, size_t nmemb, void *data)
p1 = (char *)ptr + strlen("SID: "); p1 = (char *)ptr + strlen("SID: ");
p2 = strchr((const char *)p1, '\r'); p2 = strchr((const char *)p1, '\r');
memset(mem->sid, '\000', sizeof(mem->sid)); memset(mem->sid, '\000', sizeof(mem->sid));
if (p2) { if (p2) {
if (p2-p1 > sizeof(mem->sid)-1) { if (p2-p1 > sizeof(mem->sid)-1) {
copylen = sizeof(mem->sid)-1; copylen = sizeof(mem->sid)-1;
}
else {
copylen = p2-p1;
}
strncpy(mem->sid, p1, copylen);
} }
else { else {
strncpy(mem->sid, p1, sizeof(mem->sid)-1); copylen = p2-p1;
strcpy(mem->sid, p1);
} }
strncpy(mem->sid, p1, copylen);
}
else {
strncpy(mem->sid, p1, sizeof(mem->sid)-1);
}
} }
if (!strncmp(ptr, "YPMessage: ", strlen("YPMessage: "))) { if (!strncmp(ptr, "YPMessage: ", strlen("YPMessage: "))) {
p1 = (char *)ptr + strlen("YPMessage: "); p1 = (char *)ptr + strlen("YPMessage: ");
...@@ -77,12 +78,11 @@ curl_header_memory_callback(void *ptr, size_t size, size_t nmemb, void *data) ...@@ -77,12 +78,11 @@ curl_header_memory_callback(void *ptr, size_t size, size_t nmemb, void *data)
} }
else { else {
strncpy(mem->message, p1, sizeof(mem->message)-1); strncpy(mem->message, p1, sizeof(mem->message)-1);
strcpy(mem->message, p1);
} }
} }
if (!strncmp(ptr, "TouchFreq: ", strlen("TouchFreq: "))) { if (!strncmp(ptr, "TouchFreq: ", strlen("TouchFreq: "))) {
p1 = (char *)ptr + strlen("TouchFreq: "); p1 = (char *)ptr + strlen("TouchFreq: ");
mem->touch_freq = atoi(p1); mem->touch_interval = atoi(p1);
} }
if (!strncmp(ptr, "YPResponse: ", strlen("YPResponse: "))) { if (!strncmp(ptr, "YPResponse: ", strlen("YPResponse: "))) {
p1 = (char *)ptr + strlen("YPResponse: "); p1 = (char *)ptr + strlen("YPResponse: ");
...@@ -95,13 +95,14 @@ int curl_initialize() ...@@ -95,13 +95,14 @@ int curl_initialize()
int i = 0; int i = 0;
thread_mutex_create(&_curl_mutex); thread_mutex_create(&_curl_mutex);
memset(&curl_connections, '\000', sizeof(curl_connections)); memset(&curl_connections, 0, sizeof(curl_connections));
for (i=0; i<NUM_CONNECTIONS; i++) { for (i=0; i<NUM_CONNECTIONS; i++) {
curl_connections[i].curl_handle = curl_easy_init(); curl_connections[i].curl_handle = curl_easy_init();
curl_easy_setopt(curl_connections[i].curl_handle, curl_easy_setopt(curl_connections[i].curl_handle,
CURLOPT_WRITEFUNCTION, curl_write_memory_callback); CURLOPT_WRITEFUNCTION, curl_write_memory_callback);
curl_easy_setopt(curl_connections[i].curl_handle, curl_easy_setopt(curl_connections[i].curl_handle,
CURLOPT_WRITEHEADER, (void *)&(curl_connections[i].header_result)); CURLOPT_WRITEHEADER,
(void *)&(curl_connections[i].header_result));
curl_easy_setopt(curl_connections[i].curl_handle, curl_easy_setopt(curl_connections[i].curl_handle,
CURLOPT_HEADERFUNCTION, curl_header_memory_callback); CURLOPT_HEADERFUNCTION, curl_header_memory_callback);
curl_easy_setopt(curl_connections[i].curl_handle, curl_easy_setopt(curl_connections[i].curl_handle,
...@@ -114,7 +115,7 @@ void curl_shutdown() ...@@ -114,7 +115,7 @@ void curl_shutdown()
int i = 0; int i = 0;
for (i=0; i<NUM_CONNECTIONS; i++) { for (i=0; i<NUM_CONNECTIONS; i++) {
curl_easy_cleanup(curl_connections[i].curl_handle); curl_easy_cleanup(curl_connections[i].curl_handle);
memset(&(curl_connections[i]), '\000', sizeof(curl_connections[i])); memset(&(curl_connections[i]), 0, sizeof(curl_connections[i]));
} }
} }
int curl_get_connection() int curl_get_connection()
...@@ -145,9 +146,9 @@ int curl_release_connection(int which) ...@@ -145,9 +146,9 @@ int curl_release_connection(int which)
{ {
thread_mutex_lock(&_curl_mutex); thread_mutex_lock(&_curl_mutex);
curl_connections[which].in_use = 0; curl_connections[which].in_use = 0;
memset(&(curl_connections[which].result), '\000', memset(&(curl_connections[which].result), 0,
sizeof(curl_connections[which].result)); sizeof(curl_connections[which].result));
memset(&(curl_connections[which].header_result), '\000', memset(&(curl_connections[which].header_result), 0,
sizeof(curl_connections[which].header_result)); sizeof(curl_connections[which].header_result));
thread_mutex_unlock(&_curl_mutex); thread_mutex_unlock(&_curl_mutex);
return 1; return 1;
...@@ -155,7 +156,7 @@ int curl_release_connection(int which) ...@@ -155,7 +156,7 @@ int curl_release_connection(int which)
void curl_print_header_result(struct curl_memory_struct2 *mem) { void curl_print_header_result(struct curl_memory_struct2 *mem) {
DEBUG1("SID -> (%s)", mem->sid); DEBUG1("SID -> (%s)", mem->sid);
DEBUG1("Message -> (%s)", mem->message); DEBUG1("Message -> (%s)", mem->message);
DEBUG1("Touch Freq -> (%d)", mem->touch_freq);