Index: /vtcross/trunk/src/shell/cr_shell.cpp
===================================================================
--- /vtcross/trunk/src/shell/cr_shell.cpp	(revision 169)
+++ /vtcross/trunk/src/shell/cr_shell.cpp	(revision 175)
@@ -43,27 +43,28 @@
 {
 	for(size_t i = 0; i < ce_info->numUtilities ; i++) {
-        LOG("Shell:: Utility: %s\n\tUnits: %s\n\tGoal: %s\n\tTarget: %s\n", \
-                uList[i]->name, uList[i]->units, uList[i]->goal, \
-                uList[i]->target);
+        LOG("Shell:: Utility: %s\n\tUnits: %s\n\tGoal: %s\n\tTarget: %f\n", \
+                uList[i]->name.c_str(), uList[i]->units.c_str(), \
+                uList[i]->goal.c_str(), uList[i]->target);
 	}
 
 	for(size_t i = 0; i < ce_info->numParameters; i++) {
 	    LOG("Shell:: Radio Operation Profile has been sucessfully sent.\n");
-        LOG("Shell:: Parameter: %s\n\tUnits: %s\n\tMin: %s\n\t", \
-                pList[i]->name, pList[i]->units, pList[i]->min);
-        LOG("\tMax: %s\n\tStep: %s\n", pList[i]->max, pList[i]->step);
+        LOG("Shell:: Parameter: %s\n\tUnits: %s\n\tMin: %f\n\t", \
+                pList[i]->name.c_str(), pList[i]->units.c_str(), \
+                pList[i]->min);
+        LOG("\tMax: %f\n\tStep: %f\n", pList[i]->max, pList[i]->step);
 
 		for(size_t j = 0; j < pList[i]->numAffects; j++) {
-			LOG("\t\tAffect %s -> %s\n", pList[i]->affection_list[j].u->name, \
-                    pList[i]->affection_list[j].relation);
+			LOG("\t\tAffect %s -> %s\n", pList[i]->affection_list[j].u->name.c_str(), \
+                    pList[i]->affection_list[j].relation.c_str());
 		}
 	}
 	
     for(size_t i = 0; i < ce_info->numObservables; i++) {
-		LOG("Observable: %s\n", oList[i]->name);
+		LOG("Observable: %s\n", oList[i]->name.c_str());
 
 		for(size_t j = 0; j < oList[i]->numAffects; j++) {
-			LOG("\t\tAffect %s -> %s ", oList[i]->affection_list[j].u->name, \
-                    oList[i]->affection_list[j].relation);
+			LOG("\t\tAffect %s -> %s ", oList[i]->affection_list[j].u->name.c_str(), \
+                    oList[i]->affection_list[j].relation.c_str());
 		}
 	}
@@ -71,4 +72,9 @@
 
 
+// TODO should this function really be called parse 'ce' config?  Seems like it
+// affects the entire radio?
+// TODO Why are we always returning 1? Is this just a success variable? It's not
+// even being used when we call it...
+// TODO this function needs some serious comments
 int32_t
 parse_ce_config(TiXmlDocument* doc, Utility* u[], Parameter* p[], \
@@ -116,6 +122,6 @@
             u[item_count]->goal = uGoal;
 
-   		if(pChild->QueryFloatAttribute("target", &u[i]->target) != TIXML_SUCCESS) 
-            u[i]->target = -1;
+   		if(pChild->QueryFloatAttribute("target", &u[item_count]->target) != TIXML_SUCCESS) 
+            u[item_count]->target = -1;
 
 		item_count++;
@@ -143,7 +149,7 @@
    			const char *oUtilName = pSecondChild->Attribute("utility");
 			if(oUtilName) {
-				for(attribute_count = 0; u[attribute_count]! = NULL; attribute_count++ ) {
+				for(attribute_count = 0; u[attribute_count] != NULL; attribute_count++ ) {
 					if(u[attribute_count]->name == oUtilName) {
-						o[i]->affection_list[affect_count].u = u[attribute_count];
+						o[item_count]->affection_list[affect_count].u = u[attribute_count];
 
 						const char *oRelate = pSecondChild->Attribute("relationship");
@@ -158,7 +164,8 @@
 			}
 
-			if(!match_found) 
+			if(!match_found) { 
                 ERROR(1, "Error: %s: %s is not a valid utility.\n", \
-                        o[i]->name, oUtilName);
+                        o[item_count]->name.c_str(), oUtilName);
+            }
             else
                 match_found = false;	
@@ -189,11 +196,11 @@
             p[item_count]->units = pUnits;
 
-   		if(pChild->QueryFloatAttribute("min", &p[i]->min) != TIXML_SUCCESS) 
+   		if(pChild->QueryFloatAttribute("min", &p[item_count]->min) != TIXML_SUCCESS) 
             p[item_count]->min = -1;
 
-   		if(pChild->QueryFloatAttribute("max", &p[i]->max) != TIXML_SUCCESS) 
+   		if(pChild->QueryFloatAttribute("max", &p[item_count]->max) != TIXML_SUCCESS) 
             p[item_count]->max = -1;
 
-   		if(pChild->QueryFloatAttribute("step", &p[i]->step) != TIXML_SUCCESS) 
+   		if(pChild->QueryFloatAttribute("step", &p[item_count]->step) != TIXML_SUCCESS) 
             p[item_count]->step = -1;
 		
@@ -223,5 +230,5 @@
 			if(!match_found) {
                 ERROR(1, "Error: %s: %s is not a valid utility.\n", \
-                        p[item_count]->name, pUtilName);
+                        p[item_count]->name.c_str(), pUtilName);
             }
 
@@ -237,41 +244,4 @@
 
 	return 1;
-}
-
-
-int32_t 
-ReceiveMessage(int32_t socket, char* buffer) 
-{
-    int32_t i,n;
-   
-    n = recv(socket,buffer,256,MSG_PEEK);
-    
-    for(i=0;i<256;i++){
-        if(strcmp(&buffer[i],"\0") == 0) break;
-    }
-    n = recv(socket,buffer,i+1,0);
-    if (n < 0)
-        ERROR(1, "Error reading from socket!\n");
-    //    printf("ReadMessage:%s %d\n",buffer,n);
-
-    return n;
-}
-
-
-int32_t
-SendMessage(int32_t socketfd, string message) 
-{
-	int32_t n;
-
-	message.append("\0");	
-	// Write message back to client
-    n = send(socketfd,message.c_str(),(message.size()+1),0);
-    if (n<0)
-        ERROR(1, "Error sending to client\n");
-    if(n == 0)
-        printf("Client closed the socket.\n");
-
-	//printf("SendMessage:%s %d\n",message.c_str(),n);	
-    return n;
 }
 
@@ -292,8 +262,8 @@
 	// send utility	
     for(i = 0; i < ce_info->numUtilities; i++) {
-		SendMessage(socketfd,uList[i]->name);
-		SendMessage(socketfd,uList[i]->units);
-		SendMessage(socketfd,uList[i]->goal);
-		sprintf(var,"%f",uList[i]->target);
+		SendMessage(socketfd, uList[i]->name.c_str());
+		SendMessage(socketfd, uList[i]->units.c_str());
+		SendMessage(socketfd, uList[i]->goal.c_str());
+		sprintf(var,"%f", uList[i]->target);
 		SendMessage(socketfd,var);
 	}
@@ -303,6 +273,6 @@
 	SendMessage(socketfd,counter);
 	for(i = 0; i < ce_info->numParameters; i++) {
-		SendMessage(socketfd,pList[i]->name);
-		SendMessage(socketfd,pList[i]->units);
+		SendMessage(socketfd,pList[i]->name.c_str());
+		SendMessage(socketfd,pList[i]->units.c_str());
 		sprintf(var,"%f",pList[i]->min);
 		SendMessage(socketfd,var);
@@ -315,6 +285,6 @@
 		SendMessage(socketfd,counter);
 		for(j = 0; j < pList[i]->numAffects; j++) {
-			SendMessage(socketfd,pList[i]->affection_list[j].u->name);
-			SendMessage(socketfd,pList[i]->affection_list[j].relation);
+			SendMessage(socketfd,pList[i]->affection_list[j].u->name.c_str());
+			SendMessage(socketfd,pList[i]->affection_list[j].relation.c_str());
 		}
 	}
@@ -324,11 +294,11 @@
 	SendMessage(socketfd,counter);
 	for(i = 0; i < ce_info->numObservables; i++) {
-		SendMessage(socketfd,oList[i]->name);
+		SendMessage(socketfd,oList[i]->name.c_str());
 		
 		sprintf(counter,"%i",oList[i]->numAffects); 
 		SendMessage(socketfd,counter);
 		for(j = 0; j < oList[i]->numAffects; j++) {
-			SendMessage(socketfd,oList[i]->affection_list[j].u->name);
-			SendMessage(socketfd,oList[i]->affection_list[j].relation);
+			SendMessage(socketfd,oList[i]->affection_list[j].u->name.c_str());
+			SendMessage(socketfd,oList[i]->affection_list[j].relation.c_str());
 		}
 	}
@@ -337,5 +307,5 @@
     char buffer[256];
         string message;
-	n = ReceiveMessage(socketfd, buffer);
+	ReadMessage(socketfd, buffer);
     //printf("%s\n", buffer);
         //cout << message << endl;
@@ -399,10 +369,9 @@
 	char var[50];
     int32_t i;
-    string control_msg;
+    char* control_msg = "val";
     
     int32_t socketfd = ce_info->policy_socket;
 
     // Control message that validation request is coming
-    control_msg = "val";
 	SendMessage(socketfd,control_msg);
 
@@ -413,6 +382,6 @@
 	SendMessage(socketfd,counter);
 	for(i = 0; i < ce_info->numParameters; i++) {
-		SendMessage(socketfd,pList[i]->name);
-		SendMessage(socketfd,pList[i]->units);
+		SendMessage(socketfd,pList[i]->name.c_str());
+		SendMessage(socketfd,pList[i]->units.c_str());
 		sprintf(var,"%f",pList[i]->min);
 		SendMessage(socketfd,var);
@@ -449,5 +418,5 @@
     for (i = 0; i < ce_info->numParameters; i++){
         bzero(buffer,256);
-        ReceiveMessage(sockfd,buffer);
+        ReadMessage(sockfd,buffer);
         var = atof(buffer);
         pList[i]->value = var;
@@ -594,5 +563,5 @@
     /* Receive message from client */
     bzero(buffer,256);
-    ReceiveMessage(socketfd,buffer);
+    ReadMessage(socketfd,buffer);
 
     printf("Cognitive Radio:: Message Received - %s.\n\n", buffer);
