--- libaitsync/src/dir.c 2014/02/04 16:58:17 1.5 +++ libaitsync/src/dir.c 2016/08/18 09:53:02 1.5.4.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: dir.c,v 1.5 2014/02/04 16:58:17 misho Exp $ +* $Id: dir.c,v 1.5.4.1 2016/08/18 09:53:02 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2014 +Copyright 2004 - 2016 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -142,9 +142,15 @@ create_diridx(const char *csDir, int lm, int *tags, st memset(&l[n + 1], 0, sizeof(struct tagDirName)); l[n].ch = DIFF_D1; +#ifndef __linux__ l[n].tag = crcFletcher16((u_short*) d.d_name, d.d_namlen / 2 + d.d_namlen % 2); l[n].hash = crcAdler((u_char*) d.d_name, d.d_namlen); +#else + l[n].tag = crcFletcher16((u_short*) d.d_name, + strlen(d.d_name) / 2 + strlen(d.d_name) % 2); + l[n].hash = crcAdler((u_char*) d.d_name, strlen(d.d_name)); +#endif strlcpy(l[n].name, d.d_name, sizeof l[n].name); if (lm & 1) { if (lstat(d.d_name, &sb) != -1) { @@ -190,8 +196,8 @@ create_diridx(const char *csDir, int lm, int *tags, st break; } snprintf(l[n].extra, sizeof l[n].extra, - "%s links=%d inode=%ld %d:%d perm=0%o size=%ld %s", - szType, sb.st_nlink, (long) sb.st_ino, + "%s links=%ld inode=%ld %d:%d perm=0%o size=%ld %s", + szType, (long) sb.st_nlink, (long) sb.st_ino, sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff, (long) sb.st_size, szStr); } @@ -247,7 +253,11 @@ sync_dirChkSum(const char *csDir, u_char **md) while (!readdir_r(dir, &d, &pd) && pd) { if (d.d_type == DT_DIR && (!strcmp(d.d_name, ".") || !strcmp(d.d_name, ".."))) continue; +#ifndef __linux__ MD5_Update(&ctx, d.d_name, d.d_namlen); +#else + MD5_Update(&ctx, d.d_name, strlen(d.d_name)); +#endif ret++; } MD5_Final(*md, &ctx); @@ -351,8 +361,13 @@ sync_dircmpList(const char *csDir1, const char *csDir2 if (d.d_type == DT_DIR && (!strcmp(d.d_name, ".") || !strcmp(d.d_name, ".."))) continue; else { +#ifndef __linux__ t = crcFletcher16((u_short*) d.d_name, d.d_namlen / 2 + d.d_namlen % 2); hash = crcAdler((u_char*) d.d_name, d.d_namlen); +#else + t = crcFletcher16((u_short*) d.d_name, strlen(d.d_name) / 2 + strlen(d.d_name) % 2); + hash = crcAdler((u_char*) d.d_name, strlen(d.d_name)); +#endif } find = find_tag(tags, l, t, hash); @@ -417,8 +432,8 @@ sync_dircmpList(const char *csDir1, const char *csDir2 break; } snprintf(l[n].extra, sizeof l[n].extra, - "%s links=%d inode=%ld %d:%d perm=0%o " - "size=%ld %s", szType, sb.st_nlink, + "%s links=%ld inode=%ld %d:%d perm=0%o " + "size=%ld %s", szType, (long) sb.st_nlink, (long) sb.st_ino, sb.st_uid, sb.st_gid, sb.st_mode & 0x1fff, (long) sb.st_size, szStr);