src/client_list.c
int deleteFromList(char* service_name)
{
 	reg_list_item_t *prev_node = NULL, *curr_node = NULL;

	if( NULL == service_name ) 
	{
		ParodusError("Invalid value for service\n");
		return -1;
	}
	ParodusInfo("service to be deleted: %s\n", service_name);

	prev_node = NULL;
	curr_node = g_head ;	

	// Traverse to get the link to be deleted
	while( NULL != curr_node )
	{
		if(strcmp(curr_node->service_name, service_name) == 0)
		{
			ParodusPrint("Found the node to delete\n");
			if( NULL == prev_node )
			{
				ParodusPrint("need to delete first client\n");
			 	g_head = curr_node->next;
			}
			else
			{
				ParodusPrint("Traversing to find node\n");
			 	prev_node->next = curr_node->next;
			}
			
			ParodusPrint("Deleting the node\n");
                        if(nn_shutdown(curr_node->sock, curr_node->endpoint) < 0)
                        {
                           ParodusError ("nn_shutdown socket=%d endpt=%d, err=%d\n", 
				curr_node->sock, curr_node->endpoint, errno);
                        }
			if (nn_close (curr_node->sock) < 0)
                        {
                           ParodusError ("nn_close socket=%d err=%d\n", 
				curr_node->sock, errno);
                        }
			free( curr_node );
			curr_node = NULL;
			ParodusInfo("Deleted successfully and returning..\n");
			numOfClients =numOfClients - 1;
			ParodusPrint("numOfClients after delete is %d\n", numOfClients);
			return 0;
		}
		
		prev_node = curr_node;
		curr_node = curr_node->next;
	}
	ParodusError("Could not find the entry to delete from list\n");
	return -1;
}
/** To delete clients from registered list ***/
To delete clients from registered list
To delete clients from registered list
int deleteFromList(char* service_name)
{
 	reg_list_item_t *prev_node = NULL, *curr_node = NULL;
	if( NULL == service_name ) 
	{
		ParodusError("Invalid value for service\n");
		return -1;
	}
	ParodusInfo("service to be deleted: %s\n", service_name);
	prev_node = NULL;
	curr_node = g_head ;	
	while( NULL != curr_node )
	{
		if(strcmp(curr_node->service_name, service_name) == 0)
		{
			ParodusPrint("Found the node to delete\n");
			if( NULL == prev_node )
			{
				ParodusPrint("need to delete first client\n");
			 	g_head = curr_node->next;
			}
			else
			{
				ParodusPrint("Traversing to find node\n");
			 	prev_node->next = curr_node->next;
			}
			ParodusPrint("Deleting the node\n");
                        if(nn_shutdown(curr_node->sock, curr_node->endpoint) < 0)
                        {
                           ParodusError ("nn_shutdown socket=%d endpt=%d, err=%d\n", 
				curr_node->sock, curr_node->endpoint, errno);
                        }
			if (nn_close (curr_node->sock) < 0)
                        {
                           ParodusError ("nn_close socket=%d err=%d\n", 
				curr_node->sock, errno);
                        }
			free( curr_node );
			curr_node = NULL;
			ParodusInfo("Deleted successfully and returning..\n");
			numOfClients =numOfClients - 1;
			ParodusPrint("numOfClients after delete is %d\n", numOfClients);
			return 0;
		}
		prev_node = curr_node;
		curr_node = curr_node->next;
	}
	ParodusError("Could not find the entry to delete from list\n");
	return -1;
}
int deleteFromList ( char * service_name ) { reg_list_item_t * prev_node = NULL , * curr_node = NULL ; if ( NULL == service_name ) { ParodusError ( " \n " ) ; return -1 ; } ParodusInfo ( " \n " , service_name ) ; prev_node = NULL ; curr_node = g_head ; while ( NULL != curr_node ) { if ( strcmp ( curr_node -> service_name , service_name ) == 0 ) { ParodusPrint ( " \n " ) ; if ( NULL == prev_node ) { ParodusPrint ( " \n " ) ; g_head = curr_node -> next ; } else { ParodusPrint ( " \n " ) ; prev_node -> next = curr_node -> next ; } ParodusPrint ( " \n " ) ; if ( nn_shutdown ( curr_node -> sock , curr_node -> endpoint ) < 0 ) { ParodusError ( " \n " , curr_node -> sock , curr_node -> endpoint , errno ) ; } if ( nn_close ( curr_node -> sock ) < 0 ) { ParodusError ( " \n " , curr_node -> sock , errno ) ; } free ( curr_node ) ; curr_node = NULL ; ParodusInfo ( " \n " ) ; numOfClients = numOfClients - 1 ; ParodusPrint ( " \n " , numOfClients ) ; return 0 ; } prev_node = curr_node ; curr_node = curr_node -> next ; } ParodusError ( " \n " ) ; return -1 ; }
To delete clients from registered list
To delete clients from registered list
// Traverse to get the link to be deleted