System dependent routines for uupick.
Copyright (C) 1992 Ian Lance Taylor
This file is part of the Taylor UUCP package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
const char picksb_rcsid
[] = "$Id: picksb.c,v 1.1 1993/08/04 19:32:42 jtc Exp $";
#else /* ! HAVE_DIRENT_H */
#endif /* ! HAVE_DIRENT_H */
#endif /* HAVE_OPENDIR */
#if GETPWUID_DECLARATION_OK
extern struct passwd
*getpwuid ();
/* Directory of ~/receive/USER. */
/* Name of ~/receive/USER. */
/* Directory of ~/receive/USER/SYSTEM. */
/* Prepare to get a list of all the file to uupick for this user. */
fsysdep_uupick_init (zsystem
, zpubdir
)
zuser
= zsysdep_login_name ();
zStopdir
= (char *) xmalloc (strlen (zpubdir
)
sprintf (zStopdir
, "%s/receive/%s", zpubdir
, zuser
);
qStopdir
= opendir (zStopdir
);
if (qStopdir
== NULL
&& errno
!= ENOENT
)
ulog (LOG_ERROR
, "opendir (%s): %s", zStopdir
,
/* Return the next file from the uupick directories. */
zsysdep_uupick (zsysarg
, zpubdir
, pzfrom
, pzfull
)
qentry
= readdir (qStopdir
);
while (strcmp (qentry
->d_name
, ".") == 0
|| strcmp (qentry
->d_name
, "..") == 0);
zsystem
= qentry
->d_name
;
zdir
= zbufalc (strlen (zStopdir
) + strlen (zsystem
) + sizeof "/");
sprintf (zdir
, "%s/%s", zStopdir
, zsystem
);
qSsysdir
= opendir (zdir
);
if (errno
!= ENOENT
&& errno
!= ENOTDIR
)
ulog (LOG_ERROR
, "opendir (%s): %s", zdir
, strerror (errno
));
zSsysdir
= zbufcpy (zsystem
);
qentry
= readdir (qSsysdir
);
if (strcmp (qentry
->d_name
, ".") == 0
|| strcmp (qentry
->d_name
, "..") == 0)
*pzfrom
= zbufcpy (zSsysdir
);
*pzfull
= zsappend3 (zStopdir
, zSsysdir
, qentry
->d_name
);
return zbufcpy (qentry
->d_name
);
fsysdep_uupick_free (zsystem
, zpubdir
)
xfree ((pointer
) zStopdir
);
/* Expand a local file name for uupick. */
zsysdep_uupick_local_file (zfile
)
/* If this does not start with a simple ~, pass it to
zsysdep_local_file_cwd; as it happens, zsysdep_local_file_cwd
only uses the zpubdir argument if the file starts with a simple
~, so it doesn't really matter what we pass for zpubdir. */
|| (zfile
[1] != '/' && zfile
[1] != '\0'))
return zsysdep_local_file_cwd (zfile
, (const char *) NULL
);
q
= getpwuid (getuid ());
ulog (LOG_ERROR
, "Can't get home directory");
return zbufcpy (q
->pw_dir
);
return zsysdep_in_dir (q
->pw_dir
, zfile
+ 2);