1/* addbas.c
2   If we have a directory, add in a base name.  */
3
4#include "uucp.h"
5
6#include "uudefs.h"
7#include "sysdep.h"
8#include "system.h"
9
10/* If we have a directory, add a base name.  */
11
12char *
13zsysdep_add_base (zfile, zname)
14     const char *zfile;
15     const char *zname;
16{
17  size_t clen;
18  const char *zlook;
19  char *zfree;
20  char *zret;
21
22#if DEBUG > 0
23  if (*zfile != '/')
24    ulog (LOG_FATAL, "zsysdep_add_base: %s: Can't happen", zfile);
25#endif
26
27  clen = strlen (zfile);
28
29  if (zfile[clen - 1] != '/')
30    {
31      if (! fsysdep_directory (zfile))
32	return zbufcpy (zfile);
33      zfree = NULL;
34    }
35  else
36    {
37      /* Trim out the trailing '/'.  */
38      zfree = zbufcpy (zfile);
39      zfree[clen - 1] = '\0';
40      zfile = zfree;
41    }
42
43  zlook = strrchr (zname, '/');
44  if (zlook != NULL)
45    zname = zlook + 1;
46
47  zret = zsysdep_in_dir (zfile, zname);
48  ubuffree (zfree);
49  return zret;
50}
51