- Timestamp:
- Oct 30, 2011, 8:54:38 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_files.c
r363 r365 283 283 static int sh_files_pushdir (int class, const char * str_s); 284 284 static int sh_files_pushfile (int class, const char * str_s); 285 static int sh_files_checkdir (int class, int rdepth, char * dirName, 285 static int sh_files_checkdir (int class, unsigned long check_mask, 286 int rdepth, char * dirName, 286 287 char * relativeName); 287 static ShFileType sh_files_filecheck (int class, char * dirName,288 char * fileName, int * reported,289 int rsrcflag);290 288 291 289 static long MaxRecursionLevel = 0; … … 356 354 #endif 357 355 sl_strlcpy(pstr, sh_hash_getpolicy(ptr->class), sizeof(pstr)); 358 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_CHK, pstr, tmp); 356 sh_error_handle ((-1), FIL__, __LINE__, 0, 357 MSG_FI_CHK, pstr, tmp); 359 358 } 360 359 361 360 BREAKEXIT(sh_files_filecheck); 362 361 tmp_reported = ptr->is_reported; /* fix aliasing warning */ 363 status = sh_files_filecheck (ptr->class, dir, file,362 status = sh_files_filecheck (ptr->class, ptr->check_mask, dir, file, 364 363 &tmp_reported, 0); 365 364 ptr->is_reported = tmp_reported; … … 937 936 char * name; 938 937 int class; 938 unsigned long check_mask; 939 939 int rdepth; 940 940 short type; … … 944 944 static zAVLTree * zglobList = NULL; 945 945 946 static void sh_files_pushglob (int class, int type, const char * p, int rdepth) 946 static void sh_files_pushglob (int class, int type, const char * p, int rdepth, 947 unsigned long check_mask, int flag) 947 948 { 948 949 int globstatus = -1; … … 970 971 new_item_ptr->name = fileName; 971 972 new_item_ptr->class = class; 973 new_item_ptr->check_mask = (flag == 0) ? sh_files_maskof(class) : check_mask; 972 974 new_item_ptr->rdepth = rdepth; 973 975 new_item_ptr->type = type; … … 1058 1060 { 1059 1061 sh_files_pushglob(testPattern->class, testPattern->type, 1060 testPattern->name, testPattern->rdepth); 1062 testPattern->name, testPattern->rdepth, 1063 testPattern->check_mask, 1); 1061 1064 } 1062 1065 SL_RET0(_("sh_files_check_globPatterns")); … … 1083 1086 int sh_files_delglobstack () 1084 1087 { 1085 SL_ENTER(_("sh_files_del filestack"));1088 SL_ENTER(_("sh_files_delglobstack")); 1086 1089 1087 1090 zAVLFreeTree (zglobList, free_globstack); 1088 1091 zglobList = NULL; 1089 1092 1090 SL_RETURN(0, _("sh_files_del filestack"));1093 SL_RETURN(0, _("sh_files_delglobstack")); 1091 1094 } 1092 1095 … … 1190 1193 else 1191 1194 { 1192 sh_files_pushglob (class, SH_LIST_FILE, p, 0 );1195 sh_files_pushglob (class, SH_LIST_FILE, p, 0, 0, 0); 1193 1196 } 1194 1197 … … 1268 1271 { 1269 1272 BREAKEXIT(sh_files_filecheck); 1270 sh_files_filecheck (dst_ptr->class, ptr->name,1273 sh_files_filecheck (dst_ptr->class, dst_ptr->check_mask, ptr->name, 1271 1274 NULL, &status, 0); 1272 1275 dst_ptr->checked = S_TRUE; … … 1280 1283 1281 1284 if (status == S_FALSE) 1282 sh_files_filecheck (ptr->class, ptr-> name, NULL, &status, 0);1285 sh_files_filecheck (ptr->class, ptr->check_mask, ptr->name, NULL, &status, 0); 1283 1286 1284 1287 BREAKEXIT(sh_files_checkdir); 1285 status = sh_files_checkdir (ptr->class, ptr-> rdepth, ptr->name,1288 status = sh_files_checkdir (ptr->class, ptr->check_mask, ptr->rdepth, ptr->name, 1286 1289 ptr->name); 1287 1290 … … 1601 1604 else 1602 1605 { 1603 sh_files_pushglob (class, which_dirList, tail, rdepth );1606 sh_files_pushglob (class, which_dirList, tail, rdepth, 0, 0); 1604 1607 } 1605 1608 #else … … 1745 1748 /* -- check a single directory and its content 1746 1749 */ 1747 static int sh_files_checkdir (int iclass, int idepth, char * iname, 1750 static int sh_files_checkdir (int iclass, unsigned long check_mask, 1751 int idepth, char * iname, 1748 1752 char * relativeName) 1749 1753 { … … 1769 1773 int class_next; 1770 1774 int file_class_next; 1775 unsigned long check_mask_next; 1776 unsigned long file_check_mask_next; 1771 1777 1772 1778 int checked_flag = S_FALSE; … … 1836 1842 SL_RETURN((-1), _("sh_files_checkdir")); 1837 1843 } 1838 1839 1844 1840 1845 /* ---- stat the directory ---- 1841 1846 */ … … 1844 1849 theFile->attr_string = NULL; 1845 1850 theFile->link_path = NULL; 1851 theFile->check_mask = check_mask; 1846 1852 1847 1853 (void) relativeName; … … 1983 1989 rdepth_next = rdepth - 1; 1984 1990 class_next = class; 1991 check_mask_next = check_mask; 1985 1992 file_class_next = class; 1993 file_check_mask_next = check_mask; 1986 1994 checked_flag = -1; 1987 1995 cchecked_flag = -1; … … 2000 2008 */ 2001 2009 file_class_next = dst_ptr->class; 2010 file_check_mask_next = dst_ptr->check_mask; 2002 2011 checked_flag = dst_ptr->checked; 2003 2012 cchecked_flag = dst_ptr->childs_checked; … … 2015 2024 */ 2016 2025 file_class_next = dst_ptr->class; 2026 file_check_mask_next = dst_ptr->check_mask; 2017 2027 checked_flag = dst_ptr->checked; 2018 2028 cchecked_flag = dst_ptr->childs_checked; … … 2029 2039 */ 2030 2040 file_class_next = dst_ptr->class; 2041 file_check_mask_next = dst_ptr->check_mask; 2031 2042 checked_flag = dst_ptr->checked; 2032 2043 /* not set, hence always FALSE */ … … 2065 2076 dummy = dst_ptr->is_reported; 2066 2077 2067 checkit = sh_files_filecheck (file_class_next, 2078 checkit = sh_files_filecheck (file_class_next, file_check_mask_next, 2068 2079 iname, 2069 2080 dirlist->sh_d_name, … … 2084 2095 { 2085 2096 ++theDir->NumDirs; 2097 2086 2098 if (rdepth_next >= 0 && cchecked_flag != S_TRUE) 2087 2099 { … … 2103 2115 rdepth_next = tmp_ptr->rdepth; 2104 2116 class_next = tmp_ptr->class; 2117 check_mask_next = tmp_ptr->check_mask; 2105 2118 /* 28. Aug 2001 reversed 2106 2119 */ … … 2120 2133 rdepth_next = tmp_ptr->rdepth; 2121 2134 class_next = tmp_ptr->class; 2135 check_mask_next = tmp_ptr->check_mask; 2122 2136 /* 28. Aug 2001 reversed 2123 2137 */ … … 2127 2141 } 2128 2142 2129 2143 if (cchecked_flag == S_FALSE) 2130 2144 { 2131 sh_files_checkdir (class_next, rdepth_next, tmpcat,2145 sh_files_checkdir (class_next, check_mask_next, rdepth_next, tmpcat, 2132 2146 dirlist->sh_d_name); 2133 2147 tmp_ptr->childs_checked = S_TRUE; … … 2138 2152 } 2139 2153 else if (checked_flag == -1) 2140 sh_files_checkdir (class_next, rdepth_next, tmpcat,2154 sh_files_checkdir (class_next, check_mask_next, rdepth_next, tmpcat, 2141 2155 dirlist->sh_d_name); 2142 2156 … … 2218 2232 } 2219 2233 2220 static ShFileType sh_files_filecheck (int class, char * dirName, 2221 char * infileName, 2222 int * reported, 2223 int rsrcflag) 2234 static void * sh_dummy_fileName; 2235 static void * sh_dummy_tmpname; 2236 static void * sh_dummy_tmpdir; 2237 2238 ShFileType sh_files_filecheck (int class, unsigned long check_mask, 2239 char * dirName, 2240 char * infileName, 2241 int * reported, 2242 int rsrcflag) 2224 2243 { 2225 2244 /* 28 Aug 2001 allow NULL fileName … … 2241 2260 theFile = SH_ALLOC(sizeof(file_type)); 2242 2261 2262 /* Take the address to keep gcc from putting it into a register. 2263 * Avoids the 'clobbered by longjmp' warning. 2264 */ 2265 sh_dummy_fileName = (void *) &fileName; 2266 sh_dummy_tmpname = (void *) &tmpname; 2267 sh_dummy_tmpdir = (void *) &tmpdir; 2268 2243 2269 BREAKEXIT(sh_derr); 2244 2270 … … 2263 2289 if (dirName == NULL /* || fileName == NULL */) 2264 2290 { 2291 SH_MUTEX_LOCK(mutex_thread_nolog); 2265 2292 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_NULL); 2293 SH_MUTEX_UNLOCK(mutex_thread_nolog); 2266 2294 SH_FREE(fullpath); 2267 2295 SH_FREE(theFile); … … 2276 2304 { 2277 2305 tmpname = sh_util_safe_name (fileName); 2306 SH_MUTEX_LOCK(mutex_thread_nolog); 2278 2307 sh_error_handle (ShDFLevel[SH_ERR_T_NAME], FIL__, __LINE__, 0, 2279 2308 MSG_FI_OBSC2, 2280 2309 "", tmpname); 2310 SH_MUTEX_UNLOCK(mutex_thread_nolog); 2281 2311 SH_FREE(tmpname); 2282 2312 } … … 2285 2315 tmpdir = sh_util_safe_name (dirName); 2286 2316 tmpname = sh_util_safe_name (fileName); 2317 SH_MUTEX_LOCK(mutex_thread_nolog); 2287 2318 sh_error_handle (ShDFLevel[SH_ERR_T_NAME], FIL__, __LINE__, 0, 2288 2319 MSG_FI_OBSC2, 2289 2320 tmpdir, tmpname); 2321 SH_MUTEX_UNLOCK(mutex_thread_nolog); 2290 2322 SH_FREE(tmpname); 2291 2323 SH_FREE(tmpdir); … … 2299 2331 tmpdir = sh_util_safe_name (dirName); 2300 2332 tmpname = sh_util_safe_name (fileName); 2333 SH_MUTEX_LOCK(mutex_thread_nolog); 2301 2334 sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__, 0, 2302 2335 MSG_FI_2LONG2, 2303 2336 tmpdir, tmpname); 2337 SH_MUTEX_UNLOCK(mutex_thread_nolog); 2304 2338 SH_FREE(tmpname); 2305 2339 SH_FREE(tmpdir); … … 2313 2347 */ 2314 2348 sl_strlcpy (theFile->fullpath, fullpath, PATH_MAX); 2315 theFile->check_mask = sh_files_maskof(class);2349 theFile->check_mask = check_mask /* sh_files_maskof(class) */; 2316 2350 theFile->file_reported = (*reported); 2317 2351 theFile->attr_string = NULL; … … 2347 2381 { 2348 2382 tmpname = sh_util_safe_name (fullpath); /* fixed in 1.5.4 */ 2383 SH_MUTEX_LOCK(mutex_thread_nolog); 2349 2384 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_CSUM, 2350 2385 fileHash, tmpname); 2386 SH_MUTEX_UNLOCK(mutex_thread_nolog); 2351 2387 SH_FREE(tmpname); 2352 2388 } … … 2462 2498 SL_RETURN((0),_("sh_files_fullpath")); 2463 2499 } 2464 2465 2500 2466 2501 /* -----------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.