Changeset 227 for trunk/src/sh_hash.c
- Timestamp:
- Apr 20, 2009, 5:59:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_hash.c
r212 r227 1338 1338 --sig_raised; --sig_urgent; 1339 1339 retval = 1; exitval = EXIT_SUCCESS; 1340 SH_FREE(line); 1341 line = NULL; 1340 1342 goto unlock_and_return; 1341 1343 } … … 2173 2175 unsigned char * str, int size) 2174 2176 { 2175 file_type tmpFile;2176 2177 int i = 0; 2177 2178 char * p; 2178 2179 char i2h[2]; 2179 2180 tmpFile.attr_string = NULL; 2181 tmpFile.link_path = NULL; 2182 2183 sl_strlcpy(tmpFile.fullpath, key, PATH_MAX); 2184 tmpFile.size = val1; 2185 tmpFile.mtime = val2; 2186 tmpFile.ctime = val3; 2187 2188 tmpFile.atime = 0; 2189 tmpFile.mode = 0; 2190 tmpFile.owner = 0; 2191 tmpFile.group = 0; 2192 sl_strlcpy(tmpFile.c_owner, _("root"), 5); 2193 sl_strlcpy(tmpFile.c_group, _("root"), 5); 2180 file_type * tmpFile = SH_ALLOC(sizeof(file_type)); 2181 2182 tmpFile->attr_string = NULL; 2183 tmpFile->link_path = NULL; 2184 2185 sl_strlcpy(tmpFile->fullpath, key, PATH_MAX); 2186 tmpFile->size = val1; 2187 tmpFile->mtime = val2; 2188 tmpFile->ctime = val3; 2189 2190 tmpFile->atime = 0; 2191 tmpFile->mode = 0; 2192 tmpFile->owner = 0; 2193 tmpFile->group = 0; 2194 sl_strlcpy(tmpFile->c_owner, _("root"), 5); 2195 sl_strlcpy(tmpFile->c_group, _("root"), 5); 2194 2196 2195 2197 if ((str != NULL) && (size < (PATH_MAX/2)-1)) 2196 2198 { 2197 tmpFile .c_mode[0] = 'l';2198 tmpFile .c_mode[1] = 'r'; tmpFile.c_mode[2] = 'w';2199 tmpFile .c_mode[3] = 'x'; tmpFile.c_mode[4] = 'r';2200 tmpFile .c_mode[5] = 'w'; tmpFile.c_mode[6] = 'x';2201 tmpFile .c_mode[7] = 'r'; tmpFile.c_mode[8] = 'w';2202 tmpFile .c_mode[9] = 'x'; tmpFile.c_mode[10] = '\0';2203 tmpFile .link_path = SH_ALLOC((size * 2) + 2);2199 tmpFile->c_mode[0] = 'l'; 2200 tmpFile->c_mode[1] = 'r'; tmpFile->c_mode[2] = 'w'; 2201 tmpFile->c_mode[3] = 'x'; tmpFile->c_mode[4] = 'r'; 2202 tmpFile->c_mode[5] = 'w'; tmpFile->c_mode[6] = 'x'; 2203 tmpFile->c_mode[7] = 'r'; tmpFile->c_mode[8] = 'w'; 2204 tmpFile->c_mode[9] = 'x'; tmpFile->c_mode[10] = '\0'; 2205 tmpFile->link_path = SH_ALLOC((size * 2) + 2); 2204 2206 for (i = 0; i < size; ++i) 2205 2207 { 2206 2208 p = sh_util_charhex (str[i],i2h); 2207 tmpFile .link_path[2*i] = p[0];2208 tmpFile .link_path[2*i+1] = p[1];2209 tmpFile .link_path[2*i+2] = '\0';2209 tmpFile->link_path[2*i] = p[0]; 2210 tmpFile->link_path[2*i+1] = p[1]; 2211 tmpFile->link_path[2*i+2] = '\0'; 2210 2212 } 2211 2213 } … … 2213 2215 { 2214 2216 for (i = 0; i < 10; ++i) 2215 tmpFile .c_mode[i] = '-';2216 tmpFile .c_mode[10] = '\0';2217 tmpFile .link_path = sh_util_strdup("-");2217 tmpFile->c_mode[i] = '-'; 2218 tmpFile->c_mode[10] = '\0'; 2219 tmpFile->link_path = sh_util_strdup("-"); 2218 2220 } 2219 2221 2220 2222 if (sh.flag.checkSum == SH_CHECK_CHECK && 2221 2223 sh.flag.update == S_TRUE) 2222 sh_hash_pushdata_memory (&tmpFile, SH_KEY_NULL); 2223 else 2224 sh_hash_pushdata (&tmpFile, SH_KEY_NULL); 2225 2226 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 2224 sh_hash_pushdata_memory (tmpFile, SH_KEY_NULL); 2225 else 2226 sh_hash_pushdata (tmpFile, SH_KEY_NULL); 2227 2228 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 2229 SH_FREE(tmpFile); 2227 2230 return; 2228 2231 } … … 2234 2237 int * size) 2235 2238 { 2236 file_type tmpFile;2237 2239 size_t len; 2238 2240 char * p; 2239 2241 int i; 2240 2242 char * retval = NULL; 2243 file_type * tmpFile = SH_ALLOC(sizeof(file_type)); 2241 2244 2242 2245 *size = 0; 2243 2246 2244 if (0 == sh_hash_get_it (key, &tmpFile))2245 { 2246 *val1 = tmpFile .size;2247 *val2 = tmpFile .mtime;2248 *val3 = tmpFile .ctime;2249 2250 if (tmpFile .link_path && tmpFile.link_path[0] != '-')2251 { 2252 len = strlen(tmpFile .link_path);2247 if (0 == sh_hash_get_it (key, tmpFile)) 2248 { 2249 *val1 = tmpFile->size; 2250 *val2 = tmpFile->mtime; 2251 *val3 = tmpFile->ctime; 2252 2253 if (tmpFile->link_path && tmpFile->link_path[0] != '-') 2254 { 2255 len = strlen(tmpFile->link_path); 2253 2256 2254 2257 p = SH_ALLOC((len/2)+1); 2255 i = sh_util_hextobinary (p, tmpFile .link_path, len);2258 i = sh_util_hextobinary (p, tmpFile->link_path, len); 2256 2259 2257 2260 if (i == 0) … … 2279 2282 *val3 = 0; 2280 2283 } 2281 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 2284 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 2285 SH_FREE(tmpFile); 2282 2286 return retval; 2283 2287 } … … 3990 3994 decompressed[clen] = '\0'; 3991 3995 fputs( (char*) decompressed, stdout); 3996 SH_FREE(decompressed); 3992 3997 return 0; 3993 3998 }
Note:
See TracChangeset
for help on using the changeset viewer.