strcpy (stpcpy (stpcpy (stpcpy (stpcpy (fullname, fname), "/"), locnames[cnt]), "/SYS_"),
t = stpcpy (stpcpy (fullname, fname), "/"); strcpy (stpcpy (stpcpy (t, locnames[cnt]), "/SYS_"),
add_locales_to_archive (nlist, list, replace)     size_t nlist;     char *list[];     bool replace;{  struct locarhandle ah;  int result = 0;  /* Open the archive.  This call never returns if we cannot     successfully open the archive.  */  open_archive (&ah);  while (nlist-- > 0)    {      const char *fname = *list++;      size_t fnamelen = strlen (fname);      struct stat64 st;      DIR *dirp;      struct dirent64 *d;      int seen;      locale_data_t data;      int cnt;      if (! be_quiet)	printf (_("Adding %s\n"), fname);      /* First see whether this really is a directory and whether it	 contains all the require locale category files.  */      if (stat64 (fname, &st) < 0)	{	  error (0, 0, _("stat of \"%s\" failed: %s: ignored"), fname,		 strerror (errno));	  continue;	}      if (!S_ISDIR (st.st_mode))	{	  error (0, 0, _("\"%s\" is no directory; ignored"), fname);	  continue;	}      dirp = opendir (fname);      if (dirp == NULL)	{	  error (0, 0, _("cannot open directory \"%s\": %s: ignored"),		 fname, strerror (errno));	  continue;	}      seen = 0;      while ((d = readdir64 (dirp)) != NULL)	{	  for (cnt = 0; cnt < __LC_LAST; ++cnt)	    if (cnt != LC_ALL)	      if (strcmp (d->d_name, locnames[cnt]) == 0)		{		  unsigned char d_type;		  /* We have an object of the required name.  If it's		     a directory we have to look at a file with the		     prefix "SYS_".  Otherwise we have found what we		     are looking for.  */#ifdef _DIRENT_HAVE_D_TYPE		  d_type = d->d_type;		  if (d_type != DT_REG)#endif		    {		      char fullname[fnamelen + 2 * strlen (d->d_name) + 7];#ifdef _DIRENT_HAVE_D_TYPE		      if (d_type == DT_UNKNOWN)#endif			{			  strcpy (stpcpy (stpcpy (fullname, fname), "/"),				  d->d_name);			  if (stat64 (fullname, &st) == -1)			    /* We cannot stat the file, ignore it.  */			    break;			  d_type = IFTODT (st.st_mode);			}		      if (d_type == DT_DIR)			{			  /* We have to do more tests.  The file is a			     directory and it therefore must contain a			     regular file with the same name except a			     "SYS_" prefix.  */			  strcpy (stpcpy (stpcpy (stpcpy (stpcpy (fullname,								  fname),							  "/"),						  d->d_name),					  "/SYS_"),				  d->d_name);			  if (stat64 (fullname, &st) == -1)			    /* There is no SYS_* file or we cannot			       access it.  */			    break;			  d_type = IFTODT (st.st_mode);			}		    }		  /* If we found a regular file (eventually after		     following a symlink) we are successful.  */		  if (d_type == DT_REG)		    ++seen;		  break;		}	}      closedir (dirp);      if (seen != __LC_LAST - 1)	{	  /* We don't have all locale category files.  Ignore the name.  */	  error (0, 0, _("incomplete set of locale files in \"%s\""),		 fname);	  continue;	}      /* Add the files to the archive.  To do this we first compute	 sizes and the MD5 sums of all the files.  */      for (cnt = 0; cnt < __LC_LAST; ++cnt)	if (cnt != LC_ALL)	  {	    char fullname[fnamelen + 2 * strlen (locnames[cnt]) + 7];	    int fd;	    strcpy (stpcpy (stpcpy (fullname, fname), "/"), locnames[cnt]);	    fd = open64 (fullname, O_RDONLY);	    if (fd == -1 || fstat64 (fd, &st) == -1)	      {		/* Cannot read the file.  */		if (fd != -1)		  close (fd);		break;	      }	    if (S_ISDIR (st.st_mode))	      {		close (fd);		strcpy (stpcpy (stpcpy (stpcpy (stpcpy (fullname, fname),						"/"),					locnames[cnt]),				"/SYS_"),			locnames[cnt]);		fd = open64 (fullname, O_RDONLY);		if (fd == -1 || fstat64 (fd, &st) == -1		    || !S_ISREG (st.st_mode))		  {		    if (fd != -1)		      close (fd);		    break;		  }	      }	    /* Map the file.  */	    data[cnt].addr = mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED,				     fd, 0);	    if (data[cnt].addr == MAP_FAILED)	      {		/* Cannot map it.  */		close (fd);		break;	      }	    data[cnt].size = st.st_size;	    __md5_buffer (data[cnt].addr, st.st_size, data[cnt].sum);	    /* We don't need the file descriptor anymore.  */	    close (fd);	  }      if (cnt != __LC_LAST)	{	  while (cnt-- > 0)	    if (cnt != LC_ALL)	      munmap (data[cnt].addr, data[cnt].size);	  error (0, 0, _("cannot read all files in \"%s\": ignored"), fname);	  continue;	}      result |= add_locale_to_archive (&ah, basename (fname), data, replace);      for (cnt = 0; cnt < __LC_LAST; ++cnt)	if (cnt != LC_ALL)	  munmap (data[cnt].addr, data[cnt].size);    }  /* We are done.  */  close_archive (&ah);  return result;}