[asterisk-commits] mmichelson: branch group/asterisk-cpp r168410 - /team/group/asterisk-cpp/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 10 19:32:35 CST 2009


Author: mmichelson
Date: Sat Jan 10 19:32:34 2009
New Revision: 168410

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168410
Log:
devicestate.c compiles


Modified:
    team/group/asterisk-cpp/main/devicestate.c

Modified: team/group/asterisk-cpp/main/devicestate.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/devicestate.c?view=diff&rev=168410&r1=168409&r2=168410
==============================================================================
--- team/group/asterisk-cpp/main/devicestate.c (original)
+++ team/group/asterisk-cpp/main/devicestate.c Sat Jan 10 19:32:34 2009
@@ -155,7 +155,7 @@
 	{ AST_STATE_BUSY,            AST_DEVICE_BUSY },
 	{ AST_STATE_DIALING_OFFHOOK, AST_DEVICE_INUSE },
 	{ AST_STATE_PRERING,         AST_DEVICE_RINGING },
-	{ -100,                      -100 },
+	{ (enum ast_channel_state) -100, (enum ast_device_state) -100 },
 };
 
 /*! \brief  A device state provider (not a channel) */
@@ -190,15 +190,14 @@
 	char device[1];
 };
 
-struct {
+struct devstate_collector_struct_name {
+	devstate_collector_struct_name() {thread = AST_PTHREADT_NULL;}
 	pthread_t thread;
 	struct ast_event_sub *event_sub;
 	ast_cond_t cond;
 	ast_mutex_t lock;
 	AST_LIST_HEAD_NOLOCK(, devstate_change) devstate_change_q;
-} devstate_collector = {
-	.thread = AST_PTHREADT_NULL,
-};
+} devstate_collector;
 
 /* Forward declarations */
 static int getproviderstate(const char *provider, const char *address);
@@ -218,7 +217,7 @@
 enum ast_device_state ast_state_chan2dev(enum ast_channel_state chanstate)
 {
 	int i;
-	chanstate &= 0xFFFF;
+	chanstate = (enum ast_channel_state) (chanstate & 0xFFFF);
 	for (i = 0; chan2dev[i].chan != -100; i++) {
 		if (chan2dev[i].chan == chanstate) {
 			return chan2dev[i].dev;
@@ -295,7 +294,7 @@
 	if (!event)
 		return res;
 
-	res = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
+	res = (enum ast_device_state) ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
 
 	ast_event_destroy(event);
 
@@ -334,7 +333,7 @@
 
 	if (provider)  {
 		ast_debug(3, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
-		return getproviderstate(provider, number);
+		return (enum ast_device_state) getproviderstate(provider, number);
 	}
 
 	ast_debug(4, "No provider found, checking channel drivers for %s - %s\n", tech, number);
@@ -345,7 +344,7 @@
 	if (!(chan_tech->devicestate)) /* Does the channel driver support device state notification? */
 		return ast_parse_device_state(device); /* No, try the generic function */
 
-	res = chan_tech->devicestate(number);
+	res = (enum ast_device_state) chan_tech->devicestate(number);
 
 	if (res != AST_DEVICE_UNKNOWN)
 		return res;
@@ -371,7 +370,7 @@
 {
 	struct devstate_prov *devprov;
 
-	if (!callback || !(devprov = ast_calloc(1, sizeof(*devprov))))
+	if (!callback || !(devprov = (struct devstate_prov *) ast_calloc(1, sizeof(*devprov))))
 		return -1;
 
 	devprov->callback = callback;
@@ -481,7 +480,7 @@
 
 	if (state != AST_DEVICE_UNKNOWN) {
 		devstate_event(device, state);
-	} else if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
+	} else if (change_thread == AST_PTHREADT_NULL || !(change = (struct state_change *) ast_calloc(1, sizeof(*change) + strlen(device)))) {
 		/* we could not allocate a change struct, or */
 		/* there is no background thread, so process the change now */
 		do_state_change(device);
@@ -565,7 +564,7 @@
 
 static void devstate_cache_cb(const struct ast_event *event, void *data)
 {
-	struct change_collection *collection = data;
+	struct change_collection *collection = (struct change_collection *) data;
 	int i;
 	const struct ast_eid *eid;
 
@@ -575,7 +574,7 @@
 		return;
 	}
 
-	if (!(eid = ast_event_get_ie_raw(event, AST_EVENT_IE_EID))) {
+	if (!(eid = (struct ast_eid *) ast_event_get_ie_raw(event, AST_EVENT_IE_EID))) {
 		ast_log(LOG_ERROR, "Device state change event with no EID\n");
 		return;
 	}
@@ -590,7 +589,7 @@
 
 static void process_collection(const char *device, struct change_collection *collection)
 {
-	int i;
+	unsigned int i;
 	struct ast_devstate_aggregate agg;
 	enum ast_device_state state;
 	struct ast_event *event;
@@ -599,8 +598,8 @@
 
 	for (i = 0; i < collection->num_states; i++) {
 		ast_debug(1, "Adding per-server state of '%s' for '%s'\n", 
-			ast_devstate2str(collection->states[i].state), device);
-		ast_devstate_aggregate_add(&agg, collection->states[i].state);
+			ast_devstate2str((enum ast_device_state) collection->states[i].state), device);
+		ast_devstate_aggregate_add(&agg, (enum ast_device_state) collection->states[i].state);
 	}
 
 	state = ast_devstate_aggregate_result(&agg);
@@ -614,7 +613,7 @@
 	if (event) {
 		enum ast_device_state old_state;
 
-		old_state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
+		old_state = (enum ast_device_state) ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
 		
 		ast_event_destroy(event);
 
@@ -645,9 +644,9 @@
 static void handle_devstate_change(struct devstate_change *sc)
 {
 	struct ast_event_sub *tmp_sub;
-	struct change_collection collection = {
-		.num_states = 0,
-	};
+	struct change_collection collection;
+
+	memset(&collection, 0, sizeof(collection));
 
 	ast_debug(1, "Processing device state change for '%s'\n", sc->device);
 
@@ -696,7 +695,7 @@
 	uint32_t state;
 
 	device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
-	eid = ast_event_get_ie_raw(event, AST_EVENT_IE_EID);
+	eid = (struct ast_eid *) ast_event_get_ie_raw(event, AST_EVENT_IE_EID);
 	state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
 
 	if (ast_strlen_zero(device) || !eid) {
@@ -704,7 +703,7 @@
 		return;
 	}
 
-	if (!(sc = ast_calloc(1, sizeof(*sc) + strlen(device))))
+	if (!(sc = (struct devstate_change *) ast_calloc(1, sizeof(*sc) + strlen(device))))
 		return;
 
 	strcpy(sc->device, device);




More information about the asterisk-commits mailing list