예제 #1
0
void
sim_xml_config_set_config_server (SimXmlConfig  *xmlconfig,
				  SimConfig     *config,
				  xmlNodePtr     node)
{
  gchar  *value;

  g_return_if_fail (SIM_IS_XML_CONFIG (xmlconfig));
  g_return_if_fail (SIM_IS_CONFIG (config));
  g_return_if_fail (node);

  if (strcmp ((gchar *) node->name, OBJECT_SERVER))
    {
      g_message ("Invalid config server node %s", node->name);
      return;
    }

  if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_PORT)))
    {
      config->server.port = strtol (value, (char **) NULL, 10);
      xmlFree(value);
    }

  if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_NAME)))
    {
      config->server.name = g_strdup (value);
      xmlFree(value);
    }

  if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_IP)))
    {
      config->server.ip = g_strdup (value);
      xmlFree(value);
    }

	if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_HA_IP)))
    {
      config->server.HA_ip = g_strdup (value);
      xmlFree(value);
    }

	if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_HA_PORT)))
    {
	    if (sim_string_is_number (value, 0))
  	  {
   			config->server.HA_port = atoi (value);
      	xmlFree(value);
		  }
	    else
  	  {
    	  g_message ("Error: May be that you introduced a bad remote HA port in the server's config.xml?");
      	xmlFree(value);
	      return;
  	  }
    }



/*  if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_INTERFACE)))
    {
      config->server.interface = g_strdup (value);
      xmlFree(value);
    }
	*/
}
예제 #2
0
/*
 *	Load the server's placed "UP" in the architecture, the master/s server/s
 *
 */
void
sim_xml_config_set_config_rserver (SimXmlConfig  *xmlconfig,
																  SimConfig     *config,
																  xmlNodePtr     node)
{
  SimConfigRServer  *rserver;
  gchar             *value;

  g_return_if_fail (xmlconfig);
  g_return_if_fail (SIM_IS_XML_CONFIG (xmlconfig));
  g_return_if_fail (config);
  g_return_if_fail (SIM_IS_CONFIG (config));
  g_return_if_fail (node);

  if (strcmp ((gchar *) node->name, OBJECT_RSERVER))
  {
    g_message ("Invalid config rserver node %s", node->name);
    return;
  }

  rserver = sim_config_rserver_new ();

  if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_NAME)))
  {
    rserver->name = g_strdup (value);
    xmlFree(value);
  }
  if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_IP)))
  {
    if (value)
		{	
			rserver->ia = gnet_inetaddr_new_nonblock (value, 0);
			if (rserver->ia)
			{
				rserver->ip = g_strdup (value);
				xmlFree(value);			
			}
			else
			{
				g_message ("Error: May be that you introduced a bad remote server IP in the server's config.xml?");
				sim_config_rserver_free(rserver);
				xmlFree(value);			
				return;
			}
		}
		else
		{
			g_message ("Error: May be that you didn't introduced a remote server IP in the server's config.xml?");
      sim_config_rserver_free(rserver);
      return;								
		}
  }
	
  if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_PORT)))
  {
		if (sim_string_is_number (value, 0))
		{
	    rserver->port = strtol (value, (char **) NULL, 10);
		  xmlFree(value);
		}
		else
		{
			g_message ("Error: May be that you introduced a bad remote IP port in the server's config.xml?");
			sim_config_rserver_free(rserver);
		  xmlFree(value);
			return;											 
		}
  }

	if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_HA_ROLE)))
  {
    if (!g_ascii_strcasecmp (value, "active"))
		{
			rserver->is_HA_server = TRUE;
			rserver->HA_role = HA_ROLE_ACTIVE;
		}
		else				
		if (!g_ascii_strcasecmp (value, "passive"))
		{
			rserver->is_HA_server = TRUE;
			rserver->HA_role = HA_ROLE_PASSIVE;
		}
    else	
		{
			rserver->is_HA_server = FALSE;
			rserver->HA_role = HA_ROLE_NONE;
		}
    xmlFree(value);
  }

	if ((value = (gchar *) xmlGetProp (node, (xmlChar *) PROPERTY_PRIMARY)))
  {
    if (!g_ascii_strcasecmp (value, "true"))
		{
			rserver->primary = TRUE;
		}
		else				
		if (!g_ascii_strcasecmp (value, "false"))
		{
			rserver->primary = FALSE;
		}
		else
		{
      g_message ("Error: May be that you introduced a bad primary in the server's config.xml?: please write TRUE or FALSE");
    	xmlFree(value);
      sim_config_rserver_free(rserver);
			return;
		}
    xmlFree(value);
  }


  if (!rserver->port)
	{
		rserver->port = 40001;
	}

	gnet_inetaddr_set_port (rserver->ia, rserver->port);	
	
  config->rservers = g_list_append (config->rservers, rserver);
}