Changeset 169 for trunk/src/sh_hash.c
- Timestamp:
- Apr 13, 2008, 9:59:55 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_hash.c
r167 r169 2497 2497 sl_strlcat(msg, tmp, SH_BUFSIZE); 2498 2498 2499 if (theFile->c_mode[0] == 'l' || theFile->link_path != NULL) 2499 if (theFile->c_mode[0] == 'l' || 2500 (theFile->link_path != NULL && theFile->link_path[0] != '-')) 2500 2501 { 2501 2502 tmp_lnk = sh_util_safe_name(theFile->link_path); … … 2663 2664 sl_strlcat(msg, tmp, SH_BUFSIZE); 2664 2665 2665 if (theFile->c_mode[0] == 'l' || theFile->link_path != NULL) 2666 if (theFile->c_mode[0] == 'l' || 2667 (theFile->link_path != NULL && theFile->link_path[0] != '-')) 2666 2668 { 2667 2669 tmp_lnk = sh_util_safe_name(theFile->link_path); … … 2739 2741 char timstr2m[32]; 2740 2742 char linkHash[KEY_LEN+1]; 2743 char * linkComp; 2741 2744 int maxcomp; 2742 2745 … … 2869 2872 if (p->theFile.c_mode[0] == 'l') 2870 2873 { 2871 if (sl_strlen(theFile->link_path) >= MAX_PATH_STORE) 2872 { 2873 sl_strlcpy(linkHash, 2874 sh_tiger_hash(theFile->link_path, 2875 TIGER_DATA, 2876 sl_strlen(theFile->link_path), 2877 hashbuf, sizeof(hashbuf)), 2878 MAX_PATH_STORE+1); 2879 maxcomp = MAX_PATH_STORE; 2880 } 2881 else 2882 { 2883 sl_strlcpy(linkHash, theFile->link_path, KEY_LEN + 1); 2884 maxcomp = KEY_LEN; 2885 } 2886 2887 2888 if ( sl_strncmp (linkHash, p->linkpath, maxcomp) != 0 && 2889 (theFile->check_mask & MODI_LNK) != 0) 2890 { 2874 if (!(theFile->link_path) && 2875 (theFile->check_mask & MODI_LNK) != 0) 2876 { 2877 linkComp = NULL; 2891 2878 modi_mask |= MODI_LNK; 2892 2879 change_code[1] = 'L'; 2893 2880 TPT ((0, FIL__, __LINE__, _("mod=<link>"))); 2894 } 2881 } 2882 else 2883 { 2884 if (sl_strlen(theFile->link_path) >= MAX_PATH_STORE) 2885 { 2886 sl_strlcpy(linkHash, 2887 sh_tiger_hash(theFile->link_path, 2888 TIGER_DATA, 2889 sl_strlen(theFile->link_path), 2890 hashbuf, sizeof(hashbuf)), 2891 MAX_PATH_STORE+1); 2892 linkComp = linkHash; 2893 maxcomp = KEY_LEN; 2894 } 2895 else 2896 { 2897 linkComp = theFile->link_path; 2898 maxcomp = MAX_PATH_STORE; 2899 } 2900 2901 if ( sl_strncmp (linkComp, p->linkpath, maxcomp) != 0 && 2902 (theFile->check_mask & MODI_LNK) != 0) 2903 { 2904 modi_mask |= MODI_LNK; 2905 change_code[1] = 'L'; 2906 TPT ((0, FIL__, __LINE__, _("mod=<link>"))); 2907 } 2908 } 2895 2909 } 2896 2910 … … 3349 3363 } 3350 3364 #endif 3351 } 3352 3353 3354 if ((modi_mask & MODI_LNK) != 0 && theFile->c_mode[0] == 'l') 3355 { 3356 tmp_lnk = sh_util_safe_name(theFile->link_path); 3357 tmp_lnk_old = sh_util_safe_name(p->linkpath); 3365 /* FIXME is this correct? */ 3366 if (theFile->c_mode[0] != 'l' && theFile->link_path && 3367 strlen(theFile->link_path) > 2) 3368 modi_mask |= MODI_LNK; 3369 } 3370 3371 3372 if ((modi_mask & MODI_LNK) != 0 /* && theFile->c_mode[0] == 'l' */) 3373 { 3374 if (theFile->link_path) 3375 tmp_lnk = sh_util_safe_name(theFile->link_path); 3376 else 3377 tmp_lnk = sh_util_strdup("-"); 3378 if (p->linkpath) 3379 tmp_lnk_old = sh_util_safe_name(p->linkpath); 3380 else 3381 tmp_lnk_old = sh_util_strdup("-"); 3358 3382 #ifdef SH_USE_XML 3359 3383 sl_snprintf(tmp, SH_BUFSIZE, _("link_old=\"%s\" link_new=\"%s\" "), … … 3599 3623 #endif 3600 3624 3601 static int ListFullDetail = S_FALSE;3625 static int ListFullDetail = S_FALSE; 3602 3626 static int ListWithDelimiter = S_FALSE; 3627 static char * ListFile = NULL; 3628 3629 int set_list_file (const char * c) 3630 { 3631 ListFile = sh_util_strdup(c); 3632 return 0; 3633 } 3603 3634 3604 3635 int set_full_detail (const char * c) … … 3858 3889 } 3859 3890 3891 #ifdef HAVE_LIBZ 3892 #include <zlib.h> 3893 #endif 3894 3895 int sh_hash_printcontent(char * linkpath) 3896 { 3897 #ifdef HAVE_LIBZ 3898 unsigned char * decoded; 3899 unsigned char * decompressed = NULL; 3900 size_t dlen; 3901 unsigned long clen; 3902 unsigned long clen_o; 3903 int res; 3904 3905 if (linkpath && *linkpath != '-') 3906 { 3907 dlen = sh_util_base64_dec_alloc (&decoded, 3908 (unsigned char *)linkpath, 3909 strlen(linkpath)); 3910 clen = dlen * 2 + 1; 3911 do { 3912 if (decompressed) 3913 SH_FREE(decompressed); 3914 clen += dlen; clen_o = clen; 3915 decompressed = SH_ALLOC(clen); 3916 res = uncompress(decompressed, &clen, decoded, dlen); 3917 if (res == Z_MEM_ERROR) 3918 { fprintf(stderr, _("Error: Not enough memory\n")); return -1; } 3919 if (res == Z_DATA_ERROR) 3920 { fprintf(stderr, _("Error: Data corrupt or incomplete\n")); return -1; } 3921 } while (res == Z_BUF_ERROR || clen == clen_o); 3922 decompressed[clen] = '\0'; 3923 fputs( (char*) decompressed, stdout); 3924 return 0; 3925 } 3926 #else 3927 (void) linkpath; 3928 #endif 3929 fprintf(stderr, _("Error: No data available\n")); 3930 return -1; 3931 } 3932 3860 3933 int sh_hash_list_db (const char * db_file) 3861 3934 { … … 3863 3936 SL_TICKET fd; 3864 3937 char * line; 3938 int flag = 0; 3865 3939 3866 3940 if (!db_file) … … 3900 3974 { 3901 3975 p = sh_hash_getdataent (fd, line, MAX_PATH_STORE); 3902 if ((p != NULL) && (p->fullpath[0] != 'K')) 3903 { 3904 if (ListFullDetail == S_FALSE) 3905 sh_hash_list_db_entry (p); 3976 if ((p != NULL) && (p->fullpath[0] == '/')) 3977 { 3978 if (!ListFile) 3979 { 3980 flag = 1; 3981 if (ListFullDetail == S_FALSE) 3982 sh_hash_list_db_entry (p); 3983 else 3984 sh_hash_list_db_entry_full_detail (p); 3985 } 3906 3986 else 3907 sh_hash_list_db_entry_full_detail (p); 3987 { 3988 if (0 != sl_strcmp(ListFile, p->fullpath)) 3989 { 3990 continue; 3991 } 3992 flag = 1; 3993 if ('l' != p->theFile.c_mode[0]) 3994 { 3995 if (sh_hash_printcontent(p->linkpath) < 0) 3996 { 3997 _exit(EXIT_FAILURE); 3998 return -1; 3999 } 4000 } 4001 else 4002 { 4003 fprintf(stderr, _("File is a link\n")); 4004 _exit(EXIT_FAILURE); 4005 return -1; 4006 } 4007 break; 4008 } 3908 4009 } 3909 4010 else if (p == NULL) … … 3919 4020 fflush(NULL); 3920 4021 4022 if (flag == 0) 4023 { 4024 fprintf(stderr, _("No file found\n")); 4025 _exit(EXIT_FAILURE); 4026 } 3921 4027 _exit(EXIT_SUCCESS); 3922 4028 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.