struct binding *binding; char *result;   if (domainname == NULL || domainname[0] == '\0') return NULL;  __libc_rwlock_wrlock (_nl_state_lock);  for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) { int compare = strcmp (domainname, binding->domainname); if (compare == 0)  break; if (compare < 0) {  binding = NULL; break; } }  if (dirname == NULL)  result = binding == NULL ? (char *) _nl_default_dirname : binding->dirname; else if (binding != NULL) {  result = binding->dirname; if (strcmp (dirname, result) != 0) { if (strcmp (dirname, _nl_default_dirname) == 0) result = (char *) _nl_default_dirname; else { #if defined _LIBC || defined HAVE_STRDUP result = strdup (dirname); #else size_t len = strlen (dirname) + 1; result = (char *) malloc (len); if (result != NULL) memcpy (result, dirname, len); #endif }  if (result != NULL) { if (binding->dirname != _nl_default_dirname) free (binding->dirname);  binding->dirname = result; } } } else {  size_t len = strlen (domainname) + 1; struct binding *new_binding = (struct binding *) malloc (sizeof (*new_binding) + len);  if (new_binding == NULL) result = NULL; else { memcpy (new_binding->domainname, domainname, len);  if (strcmp (dirname, _nl_default_dirname) == 0) result = new_binding->dirname = (char *) _nl_default_dirname; else { #if defined _LIBC || defined HAVE_STRDUP result = new_binding->dirname = strdup (dirname); #else len = strlen (dirname) + 1; result = new_binding->dirname = (char *) malloc (len); if (result != NULL) memcpy (new_binding->dirname, dirname, len); #endif } }  if (result != NULL) {  if (_nl_domain_bindings == NULL || strcmp (domainname, _nl_domain_bindings->domainname) < 0) { new_binding->next = _nl_domain_bindings; _nl_domain_bindings = new_binding; } else { binding = _nl_domain_bindings; while (binding->next != NULL && strcmp (domainname, binding->next->domainname) > 0) binding = binding->next;  new_binding->next = binding->next; binding->next = new_binding; } } else if (new_binding != NULL) free (new_binding); }   if (result != NULL) ++_nl_msg_cat_cntr;  __libc_rwlock_unlock (_nl_state_lock);  return result;
set_binding_values (domainname, &dirname, NULL); return (char *) dirname;
BINDTEXTDOMAIN (domainname, dirname)     const char *domainname;     const char *dirname;{  struct binding *binding;  char *result;  /* Some sanity checks.  */  if (domainname == NULL || domainname[0] == '\0')    return NULL;  __libc_rwlock_wrlock (_nl_state_lock);  for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)    {      int compare = strcmp (domainname, binding->domainname);      if (compare == 0)	/* We found it!  */	break;      if (compare < 0)	{	  /* It is not in the list.  */	  binding = NULL;	  break;	}    }  if (dirname == NULL)    /* The current binding has be to returned.  */    result = binding == NULL ? (char *) _nl_default_dirname : binding->dirname;  else if (binding != NULL)    {      /* The domain is already bound.  If the new value and the old	 one are equal we simply do nothing.  Otherwise replace the	 old binding.  */      result = binding->dirname;      if (strcmp (dirname, result) != 0)	{	  if (strcmp (dirname, _nl_default_dirname) == 0)	    result = (char *) _nl_default_dirname;	  else	    {#if defined _LIBC || defined HAVE_STRDUP	      result = strdup (dirname);#else	      size_t len = strlen (dirname) + 1;	      result = (char *) malloc (len);	      if (result != NULL)		memcpy (result, dirname, len);#endif	    }	  if (result != NULL)	    {	      if (binding->dirname != _nl_default_dirname)		free (binding->dirname);	      binding->dirname = result;	    }	}    }  else    {      /* We have to create a new binding.  */      size_t len = strlen (domainname) + 1;      struct binding *new_binding =	(struct binding *) malloc (sizeof (*new_binding) + len);      if (new_binding == NULL)	result = NULL;      else	{	  memcpy (new_binding->domainname, domainname, len);	  if (strcmp (dirname, _nl_default_dirname) == 0)	    result = new_binding->dirname = (char *) _nl_default_dirname;	  else	    {#if defined _LIBC || defined HAVE_STRDUP	      result = new_binding->dirname = strdup (dirname);#else	      len = strlen (dirname) + 1;	      result = new_binding->dirname = (char *) malloc (len);	      if (result != NULL)		memcpy (new_binding->dirname, dirname, len);#endif	    }	}      if (result != NULL)	{	  /* Now enqueue it.  */	  if (_nl_domain_bindings == NULL	      || strcmp (domainname, _nl_domain_bindings->domainname) < 0)	    {	      new_binding->next = _nl_domain_bindings;	      _nl_domain_bindings = new_binding;	    }	  else	    {	      binding = _nl_domain_bindings;	      while (binding->next != NULL		     && strcmp (domainname, binding->next->domainname) > 0)		binding = binding->next;	      new_binding->next = binding->next;	      binding->next = new_binding;	    }	}      else if (new_binding != NULL)	free (new_binding);    }  /* For a succesful call we flush the caches.  */  if (result != NULL)    ++_nl_msg_cat_cntr;  __libc_rwlock_unlock (_nl_state_lock);  return result;}