Diff for /libaitsync/src/dir.c between versions 1.3.2.2 and 1.3.2.4

version 1.3.2.2, 2012/11/13 13:38:14 version 1.3.2.4, 2012/11/13 13:58:39
Line 65  find_tag(int const * __restrict tags, struct tagDirNam Line 65  find_tag(int const * __restrict tags, struct tagDirNam
                         if (l[tags[t] + i].hash == hash) {                          if (l[tags[t] + i].hash == hash) {
                                 /* finded & marked for delete! */                                  /* finded & marked for delete! */
                                 find = (struct tagDirName*) &l[tags[t] + i];                                  find = (struct tagDirName*) &l[tags[t] + i];
                                find->ch = '*';                                find->ch = DIFF_D0;
                                 break;                                  break;
                         }                          }
         }          }
Line 141  create_diridx(const char *csDir, int lm, int *tags, st Line 141  create_diridx(const char *csDir, int lm, int *tags, st
                 } else                  } else
                         memset(&l[n + 1], 0, sizeof(struct tagDirName));                          memset(&l[n + 1], 0, sizeof(struct tagDirName));
   
                l[n].ch = '<';                l[n].ch = DIFF_D1;
                 l[n].tag = crcFletcher16((u_short*) d.d_name,                   l[n].tag = crcFletcher16((u_short*) d.d_name, 
                                 d.d_namlen / 2 + d.d_namlen % 2);                                  d.d_namlen / 2 + d.d_namlen % 2);
                 l[n].hash = crcAdler((u_char*) d.d_name, d.d_namlen);                  l[n].hash = crcAdler((u_char*) d.d_name, d.d_namlen);
                strlcpy(l[n].name, d.d_name, MAXPATHLEN);                strlcpy(l[n].name, d.d_name, sizeof l[n].name);
                 if (lm & 1) {                  if (lm & 1) {
                         if (lstat(d.d_name, &sb) != -1) {                          if (lstat(d.d_name, &sb) != -1) {
                                memset(szStr, 0, STRSIZ);                                memset(szStr, 0, sizeof szStr);
 #if defined(__OpenBSD__)  #if defined(__OpenBSD__)
                                strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S",                                 strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", 
                                                 localtime((time_t*) &sb.st_mtim));                                                  localtime((time_t*) &sb.st_mtim));
 #else  #else
                                strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S",                                 strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", 
                                                 localtime((time_t*) &sb.st_mtime));                                                  localtime((time_t*) &sb.st_mtime));
 #endif  #endif
                                 switch (d.d_type) {                                  switch (d.d_type) {
                                         case DT_FIFO:                                          case DT_FIFO:
                                                strlcpy(szType, "fifo", STRSIZ);                                                strlcpy(szType, "fifo", sizeof szType);
                                                 break;                                                  break;
                                         case DT_CHR:                                          case DT_CHR:
                                                strlcpy(szType, "char", STRSIZ);                                                strlcpy(szType, "char", sizeof szType);
                                                 break;                                                  break;
                                         case DT_DIR:                                          case DT_DIR:
                                                strlcpy(szType, "dir", STRSIZ);                                                strlcpy(szType, "dir", sizeof szType);
                                                 break;                                                  break;
                                         case DT_BLK:                                          case DT_BLK:
                                                strlcpy(szType, "block", STRSIZ);                                                strlcpy(szType, "block", sizeof szType);
                                                 break;                                                  break;
                                         case DT_REG:                                          case DT_REG:
                                                strlcpy(szType, "file", STRSIZ);                                                strlcpy(szType, "file", sizeof szType);
                                                 break;                                                  break;
                                         case DT_LNK:                                          case DT_LNK:
                                                strlcpy(szType, "link", STRSIZ);                                                strlcpy(szType, "link", sizeof szType);
                                                 break;                                                  break;
                                         case DT_SOCK:                                          case DT_SOCK:
                                                strlcpy(szType, "socket", STRSIZ);                                                strlcpy(szType, "socket", sizeof szType);
                                                 break;                                                  break;
 /* OpenBSD does not have this type */  /* OpenBSD does not have this type */
 #ifdef DT_WHT  #ifdef DT_WHT
                                         case DT_WHT:                                          case DT_WHT:
                                                strlcpy(szType, "wht", STRSIZ);                                                strlcpy(szType, "wht", sizeof szType);
                                                 break;                                                  break;
 #endif  #endif
                                         case DT_UNKNOWN:                                          case DT_UNKNOWN:
                                         default:                                          default:
                                                strlcpy(szType, "unknown", STRSIZ);                                                strlcpy(szType, "unknown", sizeof szType);
                                                 break;                                                  break;
                                 }                                  }
                                snprintf(l[n].extra, STRSIZ,                                 snprintf(l[n].extra, sizeof l[n].extra, 
                                                 "%s links=%d inode=%ld %d:%d perm=0%o size=%ld %s",                                                   "%s links=%d inode=%ld %d:%d perm=0%o size=%ld %s", 
                                                 szType, sb.st_nlink, (long) sb.st_ino,                                                   szType, sb.st_nlink, (long) sb.st_ino, 
                                                 sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff,                                                   sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff, 
Line 365  sync_dircmpList(const char *csDir1, const char *csDir2 Line 365  sync_dircmpList(const char *csDir1, const char *csDir2
                                 } else                                  } else
                                         memset(&l[n + 1], 0, sizeof(struct tagDirName));                                          memset(&l[n + 1], 0, sizeof(struct tagDirName));
   
                                l[n].ch = '>';                                l[n].ch = DIFF_D2;
                                 l[n].tag = t;                                  l[n].tag = t;
                                 l[n].hash = hash;                                  l[n].hash = hash;
                                strlcpy(l[n].name, d.d_name, MAXPATHLEN);                                strlcpy(l[n].name, d.d_name, sizeof l[n].name);
                                 if (lm & 1) {                                  if (lm & 1) {
                                         if (lstat(d.d_name, &sb) != -1) {                                          if (lstat(d.d_name, &sb) != -1) {
                                                memset(szStr, 0, STRSIZ);                                                memset(szStr, 0, sizeof szStr);
 #if defined(__OpenBSD__)  #if defined(__OpenBSD__)
                                                strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S",                                                 strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", 
                                                                 localtime((time_t*) &sb.st_mtim));                                                                  localtime((time_t*) &sb.st_mtim));
 #else  #else
                                                strftime(szStr, STRSIZ, "%Y-%m-%d %H:%M:%S",                                                 strftime(szStr, sizeof szStr, "%Y-%m-%d %H:%M:%S", 
                                                                 localtime((time_t*) &sb.st_mtime));                                                                  localtime((time_t*) &sb.st_mtime));
 #endif  #endif
                                                 switch (d.d_type) {                                                  switch (d.d_type) {
                                                         case DT_FIFO:                                                          case DT_FIFO:
                                                                strlcpy(szType, "fifo", STRSIZ);                                                                strlcpy(szType, "fifo", sizeof szType);
                                                                 break;                                                                  break;
                                                         case DT_CHR:                                                          case DT_CHR:
                                                                strlcpy(szType, "char", STRSIZ);                                                                strlcpy(szType, "char", sizeof szType);
                                                                 break;                                                                  break;
                                                         case DT_DIR:                                                          case DT_DIR:
                                                                strlcpy(szType, "dir", STRSIZ);                                                                strlcpy(szType, "dir", sizeof szType);
                                                                 break;                                                                  break;
                                                         case DT_BLK:                                                          case DT_BLK:
                                                                strlcpy(szType, "block", STRSIZ);                                                                strlcpy(szType, "block", sizeof szType);
                                                                 break;                                                                  break;
                                                         case DT_REG:                                                          case DT_REG:
                                                                strlcpy(szType, "file", STRSIZ);                                                                strlcpy(szType, "file", sizeof szType);
                                                                 break;                                                                  break;
                                                         case DT_LNK:                                                          case DT_LNK:
                                                                strlcpy(szType, "link", STRSIZ);                                                                strlcpy(szType, "link", sizeof szType);
                                                                 break;                                                                  break;
                                                         case DT_SOCK:                                                          case DT_SOCK:
                                                                strlcpy(szType, "socket", STRSIZ);                                                                strlcpy(szType, "socket", sizeof szType);
                                                                 break;                                                                  break;
 /* OpenBSD does not have this type */  /* OpenBSD does not have this type */
 #ifdef DT_WHT  #ifdef DT_WHT
                                                         case DT_WHT:                                                          case DT_WHT:
                                                                strlcpy(szType, "wht", STRSIZ);                                                                strlcpy(szType, "wht", sizeof szType);
                                                                 break;                                                                  break;
 #endif  #endif
                                                         case DT_UNKNOWN:                                                          case DT_UNKNOWN:
                                                         default:                                                          default:
                                                                strlcpy(szType, "unknown", STRSIZ);                                                                strlcpy(szType, "unknown", sizeof szType);
                                                                 break;                                                                  break;
                                                 }                                                  }
                                                snprintf(l[n].extra, STRSIZ,                                                 snprintf(l[n].extra, sizeof l[n].extra, 
                                                                 "%s links=%d inode=%ld %d:%d perm=0%o "                                                                  "%s links=%d inode=%ld %d:%d perm=0%o "
                                                                 "size=%ld %s", szType, sb.st_nlink,                                                                   "size=%ld %s", szType, sb.st_nlink, 
                                                                 (long) sb.st_ino, sb.st_uid, sb.st_gid,                                                                   (long) sb.st_ino, sb.st_uid, sb.st_gid, 
Line 436  sync_dircmpList(const char *csDir1, const char *csDir2 Line 436  sync_dircmpList(const char *csDir1, const char *csDir2
                                 return -1;                                  return -1;
                         }                          }
                 }                  }
                while (fgets(szLine, STRSIZ, f)) {                while (fgets(szLine, sizeof szLine, f)) {
                         if (!*szLine || *szLine == '#')                          if (!*szLine || *szLine == '#')
                                 continue;                                  continue;
   
Line 464  sync_dircmpList(const char *csDir1, const char *csDir2 Line 464  sync_dircmpList(const char *csDir1, const char *csDir2
                                 } else                                  } else
                                         memset(&l[n + 1], 0, sizeof(struct tagDirName));                                          memset(&l[n + 1], 0, sizeof(struct tagDirName));
   
                                l[n].ch = '>';                                l[n].ch = DIFF_D2;
                                 l[n].tag = t;                                  l[n].tag = t;
                                 l[n].hash = hash;                                  l[n].hash = hash;
                                strlcpy(l[n].name, str, MAXPATHLEN);                                strlcpy(l[n].name, str, sizeof l[n].name);
                                 if (lm & 1 && (str = strtok_r(NULL, "\r\n", &pbrk)))                                  if (lm & 1 && (str = strtok_r(NULL, "\r\n", &pbrk)))
                                        strlcpy(l[n].extra, str, STRSIZ);                                        strlcpy(l[n].extra, str, sizeof l[n].extra);
   
                                 n++;                                  n++;
                         }                          }
Line 480  sync_dircmpList(const char *csDir1, const char *csDir2 Line 480  sync_dircmpList(const char *csDir1, const char *csDir2
   
         /* delete equal elemets !!! */          /* delete equal elemets !!! */
         for (i = cx = 0; i < n; i++)          for (i = cx = 0; i < n; i++)
                if (l[i].ch == '*') {                if (l[i].ch == DIFF_D0) {
                         memmove(&l[i], &l[i + 1], (n - i + 1) * sizeof(struct tagDirName));                          memmove(&l[i], &l[i + 1], (n - i + 1) * sizeof(struct tagDirName));
                         cx++;                          cx++;
                         i--;                          i--;

Removed from v.1.3.2.2  
changed lines
  Added in v.1.3.2.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>