summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src/edit.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-05-15 22:46:24 +0000
committerpeter <peter@FreeBSD.org>1997-05-15 22:46:24 +0000
commit4f40fe8334ad5f056e1d9105f23fe7ac859c39ba (patch)
tree3b2f0092fa216d9f61059ba94b7f10b5bacf9496 /contrib/cvs/src/edit.c
parent8982e501c77217c860f79bba431f46a62b607a21 (diff)
downloadFreeBSD-src-4f40fe8334ad5f056e1d9105f23fe7ac859c39ba.zip
FreeBSD-src-4f40fe8334ad5f056e1d9105f23fe7ac859c39ba.tar.gz
Import of cvs-1.9.9-970515 onto vendor branch.
Obtained from: cyclic.com
Diffstat (limited to 'contrib/cvs/src/edit.c')
-rw-r--r--contrib/cvs/src/edit.c141
1 files changed, 73 insertions, 68 deletions
diff --git a/contrib/cvs/src/edit.c b/contrib/cvs/src/edit.c
index 0473a03..8d3bbb1 100644
--- a/contrib/cvs/src/edit.c
+++ b/contrib/cvs/src/edit.c
@@ -8,11 +8,7 @@
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. */
+ GNU General Public License for more details. */
#include "cvs.h"
#include "getline.h"
@@ -29,23 +25,26 @@ static int setting_tedit;
static int setting_tunedit;
static int setting_tcommit;
-static int onoff_fileproc PROTO ((struct file_info *finfo));
+static int onoff_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-onoff_fileproc (finfo)
+onoff_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
fileattr_set (finfo->file, "_watched", turning_on ? "" : NULL);
return 0;
}
-static int onoff_filesdoneproc PROTO ((int, char *, char *));
+static int onoff_filesdoneproc PROTO ((void *, int, char *, char *, List *));
static int
-onoff_filesdoneproc (err, repository, update_dir)
+onoff_filesdoneproc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
int err;
char *repository;
char *update_dir;
+ List *entries;
{
if (setting_default)
fileattr_set (NULL, "_watched", turning_on ? "" : NULL);
@@ -62,13 +61,16 @@ watch_onoff (argc, argv)
int err;
optind = 1;
- while ((c = getopt (argc, argv, "l")) != -1)
+ while ((c = getopt (argc, argv, "+lR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case '?':
default:
usage (watch_usage);
@@ -88,10 +90,7 @@ watch_onoff (argc, argv)
if (local)
send_arg ("-l");
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server (turning_on ? "watch-on\012" : "watch-off\012", 0);
return get_responses_and_close ();
}
@@ -102,11 +101,11 @@ watch_onoff (argc, argv)
lock_tree_for_write (argc, argv, local, 0);
err = start_recursion (onoff_fileproc, onoff_filesdoneproc,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
- lock_tree_cleanup ();
+ Lock_Cleanup ();
return err;
}
@@ -128,10 +127,11 @@ watch_off (argc, argv)
return watch_onoff (argc, argv);
}
-static int dummy_fileproc PROTO ((struct file_info *finfo));
+static int dummy_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-dummy_fileproc (finfo)
+dummy_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
/* This is a pretty hideous hack, but the gist of it is that recurse.c
@@ -140,7 +140,7 @@ dummy_fileproc (finfo)
return 0;
}
-static int ncheck_fileproc PROTO ((struct file_info *finfo));
+static int ncheck_fileproc PROTO ((void *callerdat, struct file_info *finfo));
/* Check for and process notifications. Local only. I think that doing
this as a fileproc is the only way to catch all the
@@ -149,7 +149,8 @@ static int ncheck_fileproc PROTO ((struct file_info *finfo));
processed the directory. */
static int
-ncheck_fileproc (finfo)
+ncheck_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
int notif_type;
@@ -165,7 +166,7 @@ ncheck_fileproc (finfo)
/* We send notifications even if noexec. I'm not sure which behavior
is most sensible. */
- fp = fopen (CVSADM_NOTIFY, "r");
+ fp = CVS_FOPEN (CVSADM_NOTIFY, "r");
if (fp == NULL)
{
if (!existence_error (errno))
@@ -212,7 +213,7 @@ ncheck_fileproc (finfo)
if (fclose (fp) < 0)
error (0, errno, "cannot close %s", CVSADM_NOTIFY);
- if (unlink (CVSADM_NOTIFY) < 0)
+ if ( CVS_UNLINK (CVSADM_NOTIFY) < 0)
error (0, errno, "cannot remove %s", CVSADM_NOTIFY);
return 0;
@@ -243,9 +244,9 @@ send_notifications (argc, argv, local)
}
err += start_recursion (dummy_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
send_to_server ("noop\012", 0);
if (strcmp (command_name, "release") == 0)
@@ -260,18 +261,19 @@ send_notifications (argc, argv, local)
lock_tree_for_write (argc, argv, local, 0);
err += start_recursion (ncheck_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
- lock_tree_cleanup ();
+ 0);
+ Lock_Cleanup ();
}
return err;
}
-static int edit_fileproc PROTO ((struct file_info *finfo));
+static int edit_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-edit_fileproc (finfo)
+edit_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
FILE *fp;
@@ -313,19 +315,10 @@ edit_fileproc (finfo)
copy so that if the user removes the working file, then restores it
with "cvs update" (which clears _editors but does not update
CVSADM_BASE), then a future "cvs edit" can still win. */
- /* Could save a system call by only calling mkdir if trying to create
- the output file fails. But copy_file isn't set up to facilitate
- that. */
- if (CVS_MKDIR (CVSADM_BASE, 0777) < 0)
- {
- if (errno != EEXIST
-#ifdef EACCESS
- /* OS/2; see longer comment in client.c. */
- && errno != EACCESS
-#endif
- )
- error (1, errno, "cannot mkdir %s", CVSADM_BASE);
- }
+ /* Could save a system call by only calling mkdir_if_needed if
+ trying to create the output file fails. But copy_file isn't
+ set up to facilitate that. */
+ mkdir_if_needed (CVSADM_BASE);
basefilename = xmalloc (10 + sizeof CVSADM_BASE + strlen (finfo->file));
strcpy (basefilename, CVSADM_BASE);
strcat (basefilename, "/");
@@ -338,10 +331,11 @@ edit_fileproc (finfo)
static const char *const edit_usage[] =
{
- "Usage: %s %s [-l] [files...]\n",
+ "Usage: %s %s [-lR] [files...]\n",
"-l: Local directory only, not recursive\n",
+ "-R: Process directories recursively\n",
"-a: Specify what actions for temporary watch, one of\n",
- " edit,unedit,commit.all,none\n",
+ " edit,unedit,commit,all,none\n",
NULL
};
@@ -363,13 +357,16 @@ edit (argc, argv)
setting_tunedit = 0;
setting_tcommit = 0;
optind = 1;
- while ((c = getopt (argc, argv, "la:")) != -1)
+ while ((c = getopt (argc, argv, "+lRa:")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case 'a':
a_omitted = 0;
if (strcmp (optarg, "edit") == 0)
@@ -412,19 +409,20 @@ edit (argc, argv)
/* No need to readlock since we aren't doing anything to the
repository. */
err = start_recursion (edit_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
err += send_notifications (argc, argv, local);
return err;
}
-static int unedit_fileproc PROTO ((struct file_info *finfo));
+static int unedit_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-unedit_fileproc (finfo)
+unedit_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
FILE *fp;
@@ -494,13 +492,16 @@ unedit (argc, argv)
usage (edit_usage);
optind = 1;
- while ((c = getopt (argc, argv, "l")) != -1)
+ while ((c = getopt (argc, argv, "+lR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case '?':
default:
usage (edit_usage);
@@ -513,9 +514,9 @@ unedit (argc, argv)
/* No need to readlock since we aren't doing anything to the
repository. */
err = start_recursion (unedit_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
err += send_notifications (argc, argv, local);
@@ -768,16 +769,16 @@ notify_do (type, filename, who, val, watches, repository)
size_t line_len = 0;
args.notifyee = NULL;
- usersname = xmalloc (strlen (CVSroot)
+ usersname = xmalloc (strlen (CVSroot_directory)
+ sizeof CVSROOTADM
+ sizeof CVSROOTADM_USERS
+ 20);
- strcpy (usersname, CVSroot);
+ strcpy (usersname, CVSroot_directory);
strcat (usersname, "/");
strcat (usersname, CVSROOTADM);
strcat (usersname, "/");
strcat (usersname, CVSROOTADM_USERS);
- fp = fopen (usersname, "r");
+ fp = CVS_FOPEN (usersname, "r");
if (fp == NULL && !existence_error (errno))
error (0, errno, "cannot read %s", usersname);
if (fp != NULL)
@@ -871,7 +872,7 @@ notify_check (repository, update_dir)
/* We send notifications even if noexec. I'm not sure which behavior
is most sensible. */
- fp = fopen (CVSADM_NOTIFY, "r");
+ fp = CVS_FOPEN (CVSADM_NOTIFY, "r");
if (fp == NULL)
{
if (!existence_error (errno))
@@ -897,7 +898,8 @@ notify_check (repository, update_dir)
client_notify (repository, update_dir, filename, notif_type, val);
}
-
+ if (line)
+ free (line);
if (ferror (fp))
error (0, errno, "cannot read %s", CVSADM_NOTIFY);
if (fclose (fp) < 0)
@@ -911,14 +913,17 @@ notify_check (repository, update_dir)
static const char *const editors_usage[] =
{
- "Usage: %s %s [files...]\n",
+ "Usage: %s %s [-lR] [files...]\n",
+ "\t-l\tProcess this directory only (not recursive).\n",
+ "\t-R\tProcess directories recursively.\n",
NULL
};
-static int editors_fileproc PROTO ((struct file_info *finfo));
+static int editors_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-editors_fileproc (finfo)
+editors_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
char *them;
@@ -979,13 +984,16 @@ editors (argc, argv)
usage (editors_usage);
optind = 1;
- while ((c = getopt (argc, argv, "l")) != -1)
+ while ((c = getopt (argc, argv, "+lR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case '?':
default:
usage (editors_usage);
@@ -1004,17 +1012,14 @@ editors (argc, argv)
if (local)
send_arg ("-l");
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server ("editors\012", 0);
return get_responses_and_close ();
}
#endif /* CLIENT_SUPPORT */
return start_recursion (editors_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 1, (char *)NULL,
- 0, 0);
+ 0);
}
OpenPOWER on IntegriCloud