? enh-reservations.diff
? src/edit.c-0
? vms/Makefile
Index: src/ChangeLog
===================================================================
RCS file: /home/nyap/.cvsroot/cvs/src/ChangeLog,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -r1.1.1.1 -r1.1.1.1.2.1
1c1,12
< 2000-09-19  Larry Jones  <larry.jones@sdrc.com> 
---
> 2001-03-07  Noel Yap <yap_noel@yahoo.com>
> 
> 	* client.c (to_server_buffer_flush, from_server_buffer_read): created
> 	functions.
> 
> 	* commit.c (commit, check_fileproc): "-c" option added to check for valid
> 	edit.
> 
> 	* edit.c (editors_output, check_fileproc, check_edits, edit): "-c" option
> 	added to check for existing editors.  "-f" option added to force edit.
> 
> 2000-09-19  Larry Jones  <larry.jones@sdrc.com>
Index: src/client.c
===================================================================
RCS file: /home/nyap/.cvsroot/cvs/src/client.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -r1.1.1.1 -r1.1.1.1.2.1
242c242
< 	    
---
> 
275c275
<     
---
> 
627c627
<    
---
> 
874c874
<     
---
> 
1126c1126
< 	    
---
> 
1129c1129
< 	    
---
> 
1150c1150
< 	       
---
> 
1642c1642
<     
---
> 
1652c1652
<     
---
> 
1677c1677
< 	
---
> 
1850c1850
< 		    if (gunzip_and_write (fd, short_pathname, 
---
> 		    if (gunzip_and_write (fd, short_pathname,
1890c1890
< 	       or not based on whether the server supports "Rcs-diff".  
---
> 	       or not based on whether the server supports "Rcs-diff".
2051c2051
<    
---
> 
2507c2507
<     
---
> 
2658c2658
<      * 
---
>      *
3360c3360
< /* 
---
> /*
3377c3377
<       
---
> 
3449c3449
< 	
---
> 
3577c3577
<           
---
> 
3621c3621
< 	
---
> 
3751c3751
<     
---
> 
3829c3829
<         
---
> 
3832c3832
<         if (password == NULL) 
---
>         if (password == NULL)
3911c3911
< 			   "unrecognized auth response from %s: %s", 
---
> 			   "unrecognized auth response from %s: %s",
3918,3919c3918,3919
< 		error (1, 0, 
< 		       "unrecognized auth response from %s: %s", 
---
> 		error (1, 0,
> 		       "unrecognized auth response from %s: %s",
4032c4032
<   
---
> 
5373,5374c5373,5374
<     
<     /* The fact that we do this here as well as start_recursion is a bit 
---
> 
>     /* The fact that we do this here as well as start_recursion is a bit
5836a5837,5850
> }
> 
> void
> to_server_buffer_flush (void)
> {
>     buf_flush (to_server, 1);
> }
> 
> void
> from_server_buffer_read (line, lenp)
>     char **line;
>     int *lenp;
> {
>     buf_read_line (from_server, line, lenp);
Index: src/client.h
===================================================================
RCS file: /home/nyap/.cvsroot/cvs/src/client.h,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -r1.1.1.1 -r1.1.1.1.2.1
200a201,203
> 
> extern void from_server_buffer_read PROTO((char **, int *));
> extern void to_server_buffer_flush PROTO((void));
Index: src/commit.c
===================================================================
RCS file: /home/nyap/.cvsroot/cvs/src/commit.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -r1.1.1.1 -r1.1.1.1.2.1
71a72
> static int check_valid_edit = 0;
87c88,89
<     "Usage: %s %s [-nRlf] [-m msg | -F logfile] [-r rev] files...\n",
---
>     "Usage: %s %s [-cnRlf] [-m msg | -F logfile] [-r rev] files...\n",
>     "\t-c\tCheck for valid edits before committing.\n",
361c363
<     while ((c = getopt (argc, argv, "+nlRm:fF:r:")) != -1)
---
>     while ((c = getopt (argc, argv, "+cnlRm:fF:r:")) != -1)
364a367,369
>             case 'c':
>                 check_valid_edit = 1;
>                 break;
394a400
>                 check_valid_edit = 0;
550a557,558
>         if (check_valid_edit)
>             send_arg("-c");
824a833,835
>         {
>             char *editor = NULL;
> 
997a1009,1058
> 
>             {
>                 char *editors = NULL;
> 
>                 editors = fileattr_get0 (finfo->file, "_editors");
>                 if (editors != NULL)
>                 {
>                     char *caller = getcaller ();
>                     char *p = NULL;
>                     char *p0 = NULL;
> 
>                     p = editors;
>                     p0 = p;
>                     while (*p != '\0')
>                     {
>                         p = strchr (p, '>');
>                         if (p == NULL)
>                         {
>                             break;
>                         }
>                         *p = '\0';
>                         if (strcmp (caller, p0) == 0)
>                         {
>                             break;
>                         }
>                         p = strchr (p + 1, ',');
>                         if (p == NULL)
>                         {
>                             break;
>                         }
>                         ++p;
>                         p0 = p;
>                     }
> 
>                     if (strcmp (caller, p0) == 0)
>                     {
>                         editor = caller;
>                     }
> 
>                     free (editors);
>                 }
>             }
> 
>             if (check_valid_edit && editor == NULL)
>             {
>                 error (0, 0, "Valid edit does not exist for %s", finfo->fullname);
>                 freevers_ts (&vers);
>                 return 1;
>             }
> 
1057a1119,1120
>         }
> 
Index: src/edit.c
===================================================================
RCS file: /home/nyap/.cvsroot/cvs/src/edit.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -r1.1.1.1 -r1.1.1.1.2.1
20a21
> static int check_edited = 0;
271a273,513
> 
> static int editors_output PROTO ((struct file_info *finfo));
> 
> static int
>     editors_output (finfo)
>     struct file_info *finfo;
> {
>     char *them;
>     char *p;
> 
>     them = fileattr_get0 (finfo->file, "_editors");
>     if (them == NULL)
>         return 0;
> 
>     cvs_output (finfo->fullname, 0);
> 
>     p = them;
>     while (1)
>     {
>         cvs_output ("\t", 1);
>         while (*p != '>' && *p != '\0')
>             cvs_output (p++, 1);
>         if (*p == '\0')
>         {
>             /* Only happens if attribute is misformed.  */
>             cvs_output ("\n", 1);
>             break;
>         }
>         ++p;
>         cvs_output ("\t", 1);
>         while (1)
>         {
>             while (*p != '+' && *p != ',' && *p != '\0')
>                 cvs_output (p++, 1);
>             if (*p == '\0')
>             {
>                 cvs_output ("\n", 1);
>                 goto out;
>             }
>             if (*p == ',')
>             {
>                 ++p;
>                 break;
>             }
>             ++p;
>             cvs_output ("\t", 1);
>         }
>         cvs_output ("\n", 1);
>     }
> 
> out:
>     free (them);
> 
>     return 0;
> }
> 
> 
> static int check_fileproc PROTO ((void *callerdat, struct file_info *finfo));
> 
> /* check file that is to be edited if it's already being edited */
> 
> static int
> check_fileproc (callerdat, finfo)
>     void *callerdat;
>     struct file_info *finfo;
> {
>     char *editors = NULL;
>     int editors_found = 0;
>     FILE *fp;
>     time_t now;
>     int status;
>     char *ascnow;
>     char *basefilename;
> 
> #ifdef CLIENT_SUPPORT
>     if (client_active)
>     {
>         int len = 0;
>         int possibly_more_editors = 0;
> 
>         send_file_names (1, &finfo->fullname, SEND_EXPAND_WILD);
>         send_to_server ("editors\012", 0);
> 
>         do
>         {
>             possibly_more_editors = 0;
> 
>             to_server_buffer_flush ();
>             from_server_buffer_read (&editors, &len);
> 
>             if (editors != NULL)
>             {
>                 if (strcmp (editors, "ok") != 0)
>                 {
>                     possibly_more_editors = 1;
> 
>                     if (editors[0] == 'M')
>                     {
>                         editors_found = 1;
> 
>                         if(!really_quiet)
>                         {
>                             cvs_output (editors + 2, 0);
>                             cvs_output ("\n", 0);
>                         }
>                     }
>                     else
>                     {
>                         struct response *rs = NULL;
>                         char *cmd = NULL;
> 
>                         cmd = editors;
> 
>                         for (rs = responses; rs->name != NULL; ++rs)
>                         {
>                             if (strncmp (cmd, rs->name, strlen (rs->name)) == 0)
>                             {
>                                 int cmdlen = strlen (rs->name);
>                                 if (cmd[cmdlen] == ' ')
>                                     ++cmdlen;
>                                 else if (cmd[cmdlen] != '\0')
>                                     /*
>                                      * The first len characters match, but it's a different
>                                      * response.  e.g. the response is "oklahoma" but we
>                                      * matched "ok".
>                                      */
>                                     continue;
>                                 (*rs->func) (cmd + cmdlen, len - cmdlen);
>                                 break;
>                             }
>                         }
> 
>                         if (rs->name == NULL)
>                         {
>                             /* It's OK to print just to the first '\0'.  */
>                             /* We might want to handle control characters and the like
>                                in some other way other than just sending them to stdout.
>                                One common reason for this error is if people use :ext:
>                                with a version of rsh which is doing CRLF translation or
>                                something, and so the client gets "ok^M" instead of "ok".
>                                Right now that will tend to print part of this error
>                                message over the other part of it.  It seems like we could
>                                do better (either in general, by quoting or omitting all
>                                control characters, and/or specifically, by detecting the CRLF
>                                case and printing a specific error message).  */
>                             error (0, 0,
>                                    "warning: unrecognized response `%s' from cvs server",
>                                    cmd);
>                         }
>                     }
>                 }
> 
>                 free(editors);
>             }
>         } while (possibly_more_editors);
>     }
>     else
> #endif /* CLIENT_SUPPORT */
>     {
>         /* This is a somewhat screwy way to check for this, because it
>            doesn't help errors other than the nonexistence of the file
>            (e.g. permissions problems).  It might be better to rearrange
>            the code so that CVSADM_NOTIFY gets written only after the
>            various actions succeed (but what if only some of them
>            succeed).  */
>         if (!isfile (finfo->file))
>         {
>             error (0, 0, "no such file %s; ignored", finfo->fullname);
>             return 0;
>         }
> 
>         editors = fileattr_get0 (finfo->file, "_editors");
>         if(!really_quiet && editors != NULL)
>         {
>             editors_output (finfo);
>         }
> 
>         if(editors != NULL)
>         {
>             editors_found = 1;
> 
>             free (editors);
>         }
>     }
> 
>     if(check_edited && editors_found)
>     {
>         status = 1;
>     }
>     else
>     {
>         status = 0;
>     }
> 
>     return status;
> }
> 
> static int check_edits PROTO ((int, char **, int));
> 
> /* Look through the CVS/fileattr file and check for editors */
> static int
> check_edits (argc, argv, local)
>     int argc;
>     char **argv;
>     int local;
> {
>     int err = 0;
> 
> #ifdef CLIENT_SUPPORT
>     if (client_active)
>     {
>         if (strcmp (command_name, "release") != 0)
>         {
>             start_server ();
>             ign_setup ();
>         }
> 
>         if (local)
>             send_arg ("-l");
>         send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
>     }
> #endif
> 
> 	err += start_recursion (check_fileproc, (FILESDONEPROC) NULL,
>                             (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
>                             argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
>                             0);
> 
> #ifdef CLIENT_SUPPORT
>     if (client_active)
>     {
>         send_to_server ("noop\012", 0);
>         if (strcmp (command_name, "release") == 0)
>             err += get_server_responses ();
>         else
>             err += get_responses_and_close ();
>     }
> #endif
>     return err;
> }
> 
354c596,598
<     "Usage: %s %s [-lR] [files...]\n",
---
>     "Usage: %s %s [-cflR] [files...]\n",
>     "-c: Check that working files are unedited\n",
>     "-f: Force edit if working files are edited (default)\n",
370c614
<     int err;
---
>     int err = 0;
381c625
<     while ((c = getopt (argc, argv, "+lRa:")) != -1)
---
>     while ((c = getopt (argc, argv, "+cflRa:")) != -1)
384a629,634
>             case 'c':
>                 check_edited = 1;
>                 break;
>             case 'f':
>                 check_edited = 0;
>                 break;
440a691,697
>     err = check_edits (argc, argv, local);
>     if(err)
>     {
>         error (1, 0, "files being edited!");
>     }
>     else
>     {
446a704
>     }
1038,1082c1296
<     char *them;
<     char *p;
< 
<     them = fileattr_get0 (finfo->file, "_editors");
<     if (them == NULL)
< 	return 0;
< 
<     cvs_output (finfo->fullname, 0);
< 
<     p = them;
<     while (1)
<     {
< 	cvs_output ("\t", 1);
< 	while (*p != '>' && *p != '\0')
< 	    cvs_output (p++, 1);
< 	if (*p == '\0')
< 	{
< 	    /* Only happens if attribute is misformed.  */
< 	    cvs_output ("\n", 1);
< 	    break;
< 	}
< 	++p;
< 	cvs_output ("\t", 1);
< 	while (1)
< 	{
< 	    while (*p != '+' && *p != ',' && *p != '\0')
< 		cvs_output (p++, 1);
< 	    if (*p == '\0')
< 	    {
< 		cvs_output ("\n", 1);
< 		goto out;
< 	    }
< 	    if (*p == ',')
< 	    {
< 		++p;
< 		break;
< 	    }
< 	    ++p;
< 	    cvs_output ("\t", 1);
< 	}
< 	cvs_output ("\n", 1);
<     }
<   out:;
<     free (them);
<     return 0;
---
>     return editors_output (finfo);
Index: src/version.c
===================================================================
RCS file: /home/nyap/.cvsroot/cvs/src/version.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -r1.1.1.1 -r1.1.1.1.2.1
6c6
<  * 
---
>  *
9c9
<  * 
---
>  *
15c15
< char *version_string = "Concurrent Versions System (CVS) 1.11";
---
> char *version_string = "Concurrent Versions System (CVS) 1.11 (reservations)";
75d74
< 	
