- Timestamp:
- 12/15/09 22:18:05 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r165 r166 1271 1271 1272 1272 1273 /******************************************************************* 1274 * Open the registry file and then read in the REGF block to get the 1275 * first hbin offset. 1276 *******************************************************************/ 1273 /****************************************************************************** 1274 ******************************************************************************/ 1277 1275 REGFI_FILE* regfi_open(const char* filename) 1276 { 1277 REGFI_FILE* ret_val; 1278 int fd; 1279 1280 /* open an existing file */ 1281 if ((fd = open(filename, REGFI_OPEN_FLAGS)) == -1) 1282 { 1283 /* fprintf(stderr, "regfi_open: failure to open %s (%s)\n", filename, strerror(errno));*/ 1284 return NULL; 1285 } 1286 1287 ret_val = regfi_alloc(fd); 1288 1289 if(ret_val == NULL) 1290 close(fd); 1291 1292 return ret_val; 1293 } 1294 1295 1296 /****************************************************************************** 1297 ******************************************************************************/ 1298 REGFI_FILE* regfi_alloc(int fd) 1278 1299 { 1279 1300 struct stat sbuf; … … 1281 1302 REGFI_HBIN* hbin = NULL; 1282 1303 uint32 hbin_off, file_length, cache_secret; 1283 int fd;1284 1304 bool rla; 1285 1305 1286 /* open an existing file */1287 if ((fd = open(filename, REGFI_OPEN_FLAGS)) == -1)1288 {1289 /* fprintf(stderr, "regfi_open: failure to open %s (%s)\n", filename, strerror(errno));*/1290 return NULL;1291 }1292 1293 1306 /* Determine file length. Must be at least big enough 1294 1307 * for the header and one hbin. … … 1300 1313 return NULL; 1301 1314 1302 /* read in an existing file*/1315 /* Read file header */ 1303 1316 if ((rb = regfi_parse_regf(fd, true)) == NULL) 1304 1317 { 1305 /* fprintf(stderr, "regfi_open: Failed to read initial REGF block\n"); */ 1306 close(fd); 1318 /* fprintf(stderr, "regfi_alloc: Failed to read initial REGF block\n"); */ 1307 1319 return NULL; 1308 1320 } … … 1312 1324 if(rb->hbins == NULL) 1313 1325 { 1314 /* fprintf(stderr, "regfi_open: Failed to create HBIN list.\n"); */ 1315 close(fd); 1326 /* fprintf(stderr, "regfi_alloc: Failed to create HBIN list.\n"); */ 1316 1327 talloc_free(rb); 1317 1328 return NULL; … … 1350 1361 /****************************************************************************** 1351 1362 ******************************************************************************/ 1352 int regfi_close(REGFI_FILE *file)1363 int regfi_close(REGFI_FILE* file) 1353 1364 { 1354 1365 int fd; … … 1361 1372 file->fd = -1; 1362 1373 1363 range_list_free(file->hbins); 1364 1365 if(file->sk_cache != NULL) 1366 lru_cache_destroy(file->sk_cache); 1374 regfi_free(file); 1375 1376 return close(fd); 1377 } 1378 1379 1380 /****************************************************************************** 1381 ******************************************************************************/ 1382 void regfi_free(REGFI_FILE *file) 1383 { 1384 if(file->last_message != NULL) 1385 free(last_message); 1367 1386 1368 1387 talloc_free(file); 1369 return close(fd);1370 1388 } 1371 1389 … … 2077 2095 2078 2096 2079 /******************************************************************* 2097 /****************************************************************************** 2080 2098 * Convert from UTF-16LE to specified character set. 2081 2099 * On error, returns a negative errno code. 2082 ******************************************************************* /2100 *****************************************************************************/ 2083 2101 int32 regfi_conv_charset(const char* input_charset, const char* output_charset, 2084 2102 uint8* input, char* output, … … 2901 2919 uint16 num_chunks, bool strict) 2902 2920 { 2903 uint32 cell_length, chunk_offset , data_left;2921 uint32 cell_length, chunk_offset; 2904 2922 range_list* ret_val; 2905 2923 uint16 i; … … 2911 2929 goto fail; 2912 2930 2913 for(i=0; (i<num_chunks) && (data_left>0); i++)2931 for(i=0; i<num_chunks; i++) 2914 2932 { 2915 2933 chunk_offset = offsets[i]+REGFI_REGF_SIZE;
Note: See TracChangeset
for help on using the changeset viewer.