[BACK]Return to resp.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Diff for /src/usr.bin/cvs/Attic/resp.c between version 1.46 and 1.47

version 1.46, 2005/07/22 16:27:29 version 1.47, 2005/07/23 11:19:46
Line 72 
Line 72 
 static int  cvs_resp_rcsdiff   (struct cvsroot *, int, char *);  static int  cvs_resp_rcsdiff   (struct cvsroot *, int, char *);
 static int  cvs_resp_template  (struct cvsroot *, int, char *);  static int  cvs_resp_template  (struct cvsroot *, int, char *);
 static int  cvs_resp_copyfile  (struct cvsroot *, int, char *);  static int  cvs_resp_copyfile  (struct cvsroot *, int, char *);
   static int  cvs_resp_createdir (char *);
   
   
 struct cvs_resphdlr {  struct cvs_resphdlr {
         int (*hdlr)(struct cvsroot *, int, char *);          int (*hdlr)(struct cvsroot *, int, char *);
 } cvs_resp_swtab[CVS_RESP_MAX + 1] = {  } cvs_resp_swtab[CVS_RESP_MAX + 1] = {
Line 345 
Line 345 
 {  {
         int fd, len;          int fd, len;
         char rpath[MAXPATHLEN], statpath[MAXPATHLEN];          char rpath[MAXPATHLEN], statpath[MAXPATHLEN];
         struct stat dst;  
   
         /* remote directory line */          /* remote directory line */
         if (cvs_getln(root, rpath, sizeof(rpath)) < 0)          if (cvs_getln(root, rpath, sizeof(rpath)) < 0)
Line 353 
Line 352 
   
         STRIP_SLASH(line);          STRIP_SLASH(line);
   
         /* if the directory doesn't exist, first create it */          /*
         if ((stat(line, &dst) == -1) && (errno == ENOENT)) {           * Create the directory if it does not exist.
                 if ((mkdir(line, 0755) == -1) && (errno != ENOENT)) {           */
                         cvs_log(LP_ERRNO, "failed to create %s", line);          if (cvs_resp_createdir(line) < 0)
                         return (-1);                  return (-1);
                 }  
         }  
   
         len = snprintf(statpath, sizeof(statpath), "%s/%s", line,          len = snprintf(statpath, sizeof(statpath), "%s/%s", line,
             CVS_PATH_STATICENTRIES);              CVS_PATH_STATICENTRIES);
Line 395 
Line 392 
  * cvs_resp_sticky()   * cvs_resp_sticky()
  *   *
  * Handler for the `Clear-sticky' and `Set-sticky' responses.  If the   * Handler for the `Clear-sticky' and `Set-sticky' responses.  If the
  * specified directory doesn't exist, we create it and attach it to the   * specified directory doesn't exist, we create it.
  * global file structure.  
  */   */
 static int  static int
 cvs_resp_sticky(struct cvsroot *root, int type, char *line)  cvs_resp_sticky(struct cvsroot *root, int type, char *line)
 {  {
         char buf[MAXPATHLEN], subdir[MAXPATHLEN], *file;          char buf[MAXPATHLEN];
         struct cvs_ent *ent;  
         CVSFILE *cf, *sdir;  
         CVSENTRIES *entf;  
   
         /* get the remote path */          /* get the remote path */
         if (cvs_getln(root, buf, sizeof(buf)) < 0)          if (cvs_getln(root, buf, sizeof(buf)) < 0)
Line 412 
Line 405 
   
         STRIP_SLASH(line);          STRIP_SLASH(line);
   
           if (cvs_resp_createdir(line) < 0)
                   return (-1);
   
           return (0);
   }
   
   /*
    * Shared code for cvs_resp[static, sticky]
    *
    * Looks if the directory requested exists, if it doesn't it will
    * create it plus all administrative files as well.
    */
   static int
   cvs_resp_createdir(char *line)
   {
           CVSFILE *base, *cf;
           CVSENTRIES *entf;
           struct stat st;
           struct cvs_ent *ent;
           char *file, subdir[MAXPATHLEN], buf[MAXPATHLEN];
   
         cvs_splitpath(line, subdir, sizeof(subdir), &file);          cvs_splitpath(line, subdir, sizeof(subdir), &file);
         sdir = cvs_file_find(cvs_files, subdir);          base = cvs_file_loadinfo(subdir, CF_NOFILES, NULL, NULL, 1);
         if (sdir == NULL) {          if (base == NULL)
                 cvs_log(LP_ERR, "failed to find %s", subdir);  
                 return (-1);                  return (-1);
         }  
   
         cf = cvs_file_find(sdir, file);          /*
         if (cf == NULL) {           * If <line> doesn't exist, we create it.
                 /* attempt to create it */           */
                 cf = cvs_file_create(sdir, line, DT_DIR, 0755);          if (stat(line, &st) == -1) {
                 if (cf == NULL) {                  if (errno != ENOENT) {
                           cvs_log(LP_ERRNO, "failed to stat '%s'", line);
                         return (-1);                          return (-1);
                 }                  }
                 cf->cf_repo = strdup(line);  
                 if (cf->cf_repo == NULL) {  
                         cvs_log(LP_ERRNO, "failed to duplicate `%s'", line);  
                         cvs_file_free(cf);  
                         return (-1);  
                 }  
                 cf->cf_root = root;  
                 root->cr_ref++;  
   
                 if (cvs_file_attach(sdir, cf) < 0) {                  cf = cvs_file_create(base, line, DT_DIR, 0755);
                         cvs_file_free(cf);                  if (cf == NULL) {
                           cvs_file_free(base);
                         return (-1);                          return (-1);
                 }                  }
   
Line 466 
Line 472 
                         if (strcmp(subdir, cvs_resp_lastdir))                          if (strcmp(subdir, cvs_resp_lastdir))
                                 cvs_ent_close(entf);                                  cvs_ent_close(entf);
                 }                  }
   
                   cvs_file_free(cf);
         }          }
   
         if (type == CVS_RESP_CLRSTICKY)          cvs_file_free(base);
                 cf->cf_flags &= ~CVS_DIRF_STICKY;  
         else if (type == CVS_RESP_SETSTICKY)  
                 cf->cf_flags |= CVS_DIRF_STICKY;  
   
         return (0);          return (0);
 }  }
   

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47