Get files stored in the public directory by uucp -t.
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 uupick_rcsid
[] = "$Id: uupick.c,v 1.1 1993/08/04 19:36:56 jtc Exp $";
static void upmovedir
P((const char *zfull
, const char *zrelative
,
static void upmove
P((const char *zfrom
, const char *zto
));
char abProgram
[] = "uupick";
/* Long getopt options. */
static const struct option asPlongopts
[] = { { NULL
, 0, NULL
, 0 } };
static void upusage
P((void));
const char *zsystem
= NULL
;
/* -I: configuration file name. */
const char *zconfig
= NULL
;
struct uuconf_system ssys
;
char *zfile
, *zfrom
, *zfull
;
while ((iopt
= getopt_long (argc
, argv
, "I:s:x:", asPlongopts
,
/* System name to get files from. */
/* Name configuration file. */
if (fsysdep_other_config (optarg
))
/* Set debugging level. */
iDebug
|= idebug_parse (optarg
);
/* Long option found and flag set. */
iuuconf
= uuconf_init (&puuconf
, (const char *) NULL
, zconfig
);
if (iuuconf
!= UUCONF_SUCCESS
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
usysdep_initialize (puuconf
, INIT_GETCWD
| INIT_NOCHDIR
);
iuuconf
= uuconf_system_info (puuconf
, zsystem
, &ssys
);
if (iuuconf
== UUCONF_SUCCESS
)
zpubdir
= zbufcpy (ssys
.uuconf_zpubdir
);
(void) uuconf_system_free (puuconf
, &ssys
);
else if (iuuconf
!= UUCONF_NOT_FOUND
)
(void) ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
iuuconf
= uuconf_pubdir (puuconf
, &zpubdir
);
if (iuuconf
!= UUCONF_SUCCESS
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
if (! fsysdep_uupick_init (zsystem
, zpubdir
))
&& ((zfile
= zsysdep_uupick (zsystem
, zpubdir
, &zfrom
, &zfull
))
fdir
= fsysdep_directory (zfull
);
|| strcmp (zallsys
, zfrom
) != 0)
printf ("from %s: %s %s ?\n", zfrom
, fdir
? "dir" : "file",
if (fgets (ab
, sizeof ab
, stdin
) == NULL
)
(void) fsysdep_rmdir (zfull
);
ulog (LOG_ERROR
, "remove (%s): %s", zfull
,
zto
= ab
+ 1 + strspn (ab
+ 1, " \t");
zto
[strcspn (zto
, " \t\n")] = '\0';
zlocal
= zsysdep_uupick_local_file (zto
);
zto
= zsysdep_in_dir (zlocal
, zfile
);
usysdep_walk_tree (zfull
, upmovedir
, (pointer
) zto
);
(void) fsysdep_rmdir (zfull
);
zallsys
= zbufcpy (zfrom
);
ulog (LOG_ERROR
, "Can't print directory");
ulog (LOG_ERROR
, "fopen (%s): %s", zfull
,
while (fgets (ab
, sizeof ab
, e
) != NULL
)
(void) fputs (ab
, stdout
);
printf ("uupick commands:\n");
printf ("<return>: skip file\n");
printf ("m [dir]: move file to directory\n");
printf ("a [dir]: move all files from this system to directory\n");
printf ("p: list file to stdout\n");
printf ("! command: shell escape\n");
(void) fsysdep_uupick_free (zsystem
, zpubdir
);
/* Avoid error about not returning. */
/* Print usage message. */
"Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n",
"Usage: uupick [-s system] [-I config] [-x debug]\n");
" -s system: Only consider files from named system\n");
" -x debug: Set debugging level\n");
" -I file: Set configuration file to use\n");
#endif /* HAVE_TAYLOR_CONFIG */
/* This routine is called by usysdep_walk_tree when moving the
contents of an entire directory. */
upmovedir (zfull
, zrelative
, pinfo
)
const char *ztodir
= (const char *) pinfo
;
zto
= zsysdep_in_dir (ztodir
, zrelative
);
(void) fsysdep_move_file (zfrom
, zto
, TRUE
, TRUE
, FALSE
,