[svn-commits] jdixon: branch jdixon/chan_usbradio-1.4 r139865 - /team/jdixon/chan_usbradio-...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Aug 25 14:42:09 CDT 2008


Author: jdixon
Date: Mon Aug 25 14:42:08 2008
New Revision: 139865

URL: http://svn.digium.com/view/asterisk?view=rev&rev=139865
Log:
Cleaned up debug output (some) and fixed a/b loading problem

Modified:
    team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c

Modified: team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c
URL: http://svn.digium.com/view/asterisk/team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c?view=diff&rev=139865&r1=139864&r2=139865
==============================================================================
--- team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c (original)
+++ team/jdixon/chan_usbradio-1.4/dev-1.0/channels/chan_echolink.c Mon Aug 25 14:42:08 2008
@@ -31,7 +31,7 @@
 /*** MODULEINFO
  ***/
 
-/* Version 0.10, 08/25/2008
+/* Version 0.11, 08/25/2008
 Echolink channel driver for Asterisk/app_rpt.
 A lot more has to be added,
 Here is what comes to mind first:
@@ -1485,7 +1485,7 @@
 	sprintf(dbstr,"%c/call/%s",loading,call);
 	if (ast_db_get(EL_DB_ROOT,dbstr,str,sizeof(str) - 1)) return;
 	if (sscanf(str,"%s:%s",node,ipaddr) != 2) return;
-	ast_log(LOG_NOTICE,"Zapped %s\n",dbstr);
+	if (debug) ast_log(LOG_DEBUG,"Zapped %s\n",dbstr);
 	sprintf(dbstr,"%c/node/%s",loading,node);
 	ast_db_del(EL_DB_ROOT,dbstr);
 	sprintf(dbstr,"%c/ipaddr/%s",loading,ipaddr);
@@ -1519,9 +1519,9 @@
 	if ((r != Z_OK) && (r != Z_STREAM_END))
 	{
 		if (z->msg)
-			fprintf(stderr,"Unable to inflate (Zlib): %s\n",z->msg);
+			ast_log(LOG_ERROR,"Unable to inflate (Zlib): %s\n",z->msg);
 		else
-			fprintf(stderr,"Unable to inflate (Zlib)\n");
+			ast_log(LOG_ERROR,"Unable to inflate (Zlib)\n");
 		return -1;
 	}
 	return(buf1len - z->avail_out);
@@ -1567,9 +1567,7 @@
 
 	db_active = 'a';
 	db_loading = 'a';
-	dbstr[0] = db_active;
-	dbstr[1] = 0;
-	if (!ast_db_get(EL_DB_ROOT,dbstr,str,sizeof(str) - 1))
+	if (!ast_db_get(EL_DB_ROOT,"active",str,sizeof(str) - 1))
 	{
 		db_active = *str;
 		if (db_active == 'a') db_loading = 'b';
@@ -1581,15 +1579,15 @@
 	if (inflateInit(&z) != Z_OK)
 	{
 		if (z.msg)
-			fprintf(stderr,"Unable to init Zlib: %s\n",z.msg);
+			ast_log(LOG_ERROR,"Unable to init Zlib: %s\n",z.msg);
 		else
-			fprintf(stderr,"Unable to init Zlib\n");
+			ast_log(LOG_ERROR,"Unable to init Zlib\n");
 		return -1;
 	}
 	host = ast_gethostbyname(hostname,&ah);
 	if (!host)
 	{
-		ast_log(LOG_NOTICE,"Unable to resolve name for directory server %s\n",hostname);
+		ast_log(LOG_ERROR,"Unable to resolve name for directory server %s\n",hostname);
 		return -1;
 	}
 	memset(&dirserver, 0, sizeof(dirserver));       /* Clear struct */
@@ -1600,27 +1598,27 @@
 	sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
 	if (sock < 0)
 	{
-		ast_log(LOG_NOTICE,"Unable to obtain a socket for directory server %s\n",hostname);
+		ast_log(LOG_ERROR,"Unable to obtain a socket for directory server %s\n",hostname);
 		return -1;
 	}
         /* Establish connection */
 	if (connect(sock,(struct sockaddr *) &dirserver,
 		sizeof(dirserver)) < 0)
 	{
-		ast_log(LOG_NOTICE,"Unable to connect to directory server %s\n",hostname);
+		ast_log(LOG_ERROR,"Unable to connect to directory server %s\n",hostname);
 		return -1;
 	}
 	sprintf(str,"F%s\r",snapshot_id);
 	if (send(sock,str,strlen(str),0) < 0)
 	{
-		ast_log(LOG_NOTICE,"Unable to send to directory server %s\n",hostname);
+		ast_log(LOG_ERROR,"Unable to send to directory server %s\n",hostname);
 		return -1;
 	}
 	str[strlen(str) - 1] = 0;
-printf("Sending: %s to %s\n",str,hostname);
+	if (debug) printf("Sending: %s to %s\n",str,hostname);
 	if (recv(sock,str,4,0) != 4)
 	{
-		ast_log(LOG_NOTICE,"Error in directory download (header) on %s\n",hostname);
+		ast_log(LOG_ERROR,"Error in directory download (header) on %s\n",hostname);
 		return -1;
 	} 
 	dir_compressed = 1;
@@ -1639,10 +1637,9 @@
 	{
 		if (el_net_get_line(sock,str,sizeof(str) - 1,dir_compressed,&z) < 1)
 		{
-			ast_log(LOG_NOTICE,"Error in directory download (header) on %s\n",hostname);
+			ast_log(LOG_ERROR,"Error in directory download (header) on %s\n",hostname);
 			return -1;
 		}
-printf("Line is: %s len %d\n",str,strlen(str));
 		if (!strncmp(str,"@@@",3))
 		{
 			dir_partial = 0;
@@ -1653,20 +1650,20 @@
 		}
 		else
 		{
-			ast_log(LOG_NOTICE,"Error in header on %s\n",hostname);
+			ast_log(LOG_ERROR,"Error in header on %s\n",hostname);
 			return -1;
 		}
 	}
 	if (el_net_get_line(sock,str,sizeof(str) - 1,dir_compressed,&z) < 1)
 	{
-		ast_log(LOG_NOTICE,"Error in directory download (header) on %s\n",hostname);
+		ast_log(LOG_ERROR,"Error in directory download (header) on %s\n",hostname);
 		return -1;
 	}
 	if (dir_compressed)
 	{
 		if(sscanf(str,"%d:%s",&rep_lines,snapshot_id) < 2)
 		{
-			ast_log(LOG_NOTICE,"Error in parsing header on %s\n",hostname);
+			ast_log(LOG_ERROR,"Error in parsing header on %s\n",hostname);
 			return -1;
 		}	
 	}
@@ -1674,7 +1671,7 @@
 	{
 		if(sscanf(str,"%d",&rep_lines) < 1)
 		{
-			ast_log(LOG_NOTICE,"Error in parsing header on %s\n",hostname);
+			ast_log(LOG_ERROR,"Error in parsing header on %s\n",hostname);
 			return -1;
 		}	
 	}
@@ -1703,13 +1700,13 @@
 		}
 		if (el_net_get_line(sock,str,sizeof(str) - 1,dir_compressed,&z) < 1)
 		{
-			ast_log(LOG_NOTICE,"Error in directory download on %s\n",hostname);
+			ast_log(LOG_ERROR,"Error in directory download on %s\n",hostname);
 			el_zapem(db_loading);
 			return -1;
 		}
 		if (el_net_get_line(sock,str,sizeof(str) - 1,dir_compressed,&z) < 1)
 		{
-			ast_log(LOG_NOTICE,"Error in directory download on %s\n",hostname);
+			ast_log(LOG_ERROR,"Error in directory download on %s\n",hostname);
 			el_zapem(db_loading);
 			return -1;
 		}
@@ -1718,7 +1715,7 @@
 		strncpy(nodenum,str,sizeof(nodenum) - 1);
 		if (el_net_get_line(sock,str,sizeof(str) - 1,dir_compressed,&z) < 1)
 		{
-			ast_log(LOG_NOTICE,"Error in directory download on %s\n",hostname);
+			ast_log(LOG_ERROR,"Error in directory download on %s\n",hostname);
 			el_zapem(db_loading);
 			return -1;
 		}
@@ -1728,20 +1725,20 @@
 		sprintf(dbstr,"%c/ipaddr/%s",db_loading,ipaddr);
 		if (ast_db_put(EL_DB_ROOT,dbstr,nodenum) != 0)
 		{
-			ast_log(LOG_NOTICE,"Error in putting ipaddr record %s (nodenum %s)",ipaddr,nodenum);
+			ast_log(LOG_ERROR,"Error in putting ipaddr record %s (nodenum %s)",ipaddr,nodenum);
 			return -1;
 		}
 		sprintf(dbstr,"%c/nodenum/%s",db_loading,nodenum);
 		if (ast_db_put(EL_DB_ROOT,dbstr,ipaddr))
 		{
- 			ast_log(LOG_NOTICE,"Error in putting nodenum record %s (ipaddr %s)",nodenum,ipaddr);
+ 			ast_log(LOG_ERROR,"Error in putting nodenum record %s (ipaddr %s)",nodenum,ipaddr);
 			return -1;
 		}
 		sprintf(dbstr,"%c/call/%s",db_loading,call);
 		sprintf(dbstr1,"%s:%s",nodenum,ipaddr);
 		if (ast_db_put(EL_DB_ROOT,dbstr,dbstr1))
 		{
- 			ast_log(LOG_NOTICE,"Error in putting call record %s (ipaddr %s)",nodenum,ipaddr);
+ 			ast_log(LOG_ERROR,"Error in putting call record %s (ipaddr %s)",nodenum,ipaddr);
 			return -1;
 		}
 		n++;
@@ -1752,13 +1749,16 @@
 	dbstr[1] = 0;
 	if (ast_db_put(EL_DB_ROOT,"active",dbstr) != 0)
 	{
-		ast_log(LOG_NOTICE,"Error in finalizing DB process on %s\n",hostname);
+		ast_log(LOG_ERROR,"Error in finalizing DB process on %s\n",hostname);
 		return -1;
 	}
 	close(sock);
-	ast_log(LOG_NOTICE,"Diretory pgm done downloading, %d records\n",n);
-	printf("Compressed: %d, Partial: %d\n",dir_compressed,dir_partial);
-	if (dir_compressed) printf("Got snapshot_id: %s\n",snapshot_id);
+	if (debug)
+	{
+		ast_log(LOG_DEBUG,"Diretory pgm done downloading, %d records\n",n);
+		ast_log(LOG_DEBUG,"Compressed: %d, Partial: %d\n",dir_compressed,dir_partial);
+		if (dir_compressed) ast_log(LOG_DEBUG,"Got snapshot_id: %s\n",snapshot_id);
+	}
 	return(dir_compressed);
 }
 
@@ -1774,7 +1774,7 @@
 			if (++curdir >= EL_MAX_SERVERS) curdir = 0;
 			continue;
 		}
-		ast_log(LOG_NOTICE, "Trying to do directory downloa Echolink server %s\n", instances[0]->elservers[curdir]);
+		if (debug) ast_log(LOG_DEBUG, "Trying to do directory downloa Echolink server %s\n", instances[0]->elservers[curdir]);
 		rc = do_el_directory(instances[0]->elservers[curdir]);
 		if (rc < 0)
 		{
@@ -1795,7 +1795,7 @@
    int rc = 0;
    struct el_instance *instp = (struct el_instance *)data;
 
-   ast_log(LOG_NOTICE, "Echolink registration thread started on %s.\n",instp->name);
+   if (debug) ast_log(LOG_DEBUG, "Echolink registration thread started on %s.\n",instp->name);
    while (run_forever)
    {
       if (i >= EL_MAX_SERVERS)
@@ -1808,7 +1808,7 @@
       } while (i < EL_MAX_SERVERS);
 
       if (i < EL_MAX_SERVERS) {
-         ast_log(LOG_NOTICE, "Trying to register with Echolink server %s\n", instp->elservers[i]);
+         if (debug) ast_log(LOG_DEBUG, "Trying to register with Echolink server %s\n", instp->elservers[i]);
          rc = sendcmd(instp->elservers[i++],instp); 
       }
       if (rc == 0)




More information about the svn-commits mailing list