Changeset 178 for trunk/src/common.c


Ignore:
Timestamp:
03/13/10 12:56:36 (14 years ago)
Author:
tim
Message:

reworked I/O to use callback functions

fixed a bug in mtime validation and consolidated time formatting code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/common.c

    r172 r178  
    3838
    3939
     40/* Windows is lame */
     41#ifdef O_BINARY
     42#define REGLOOKUP_OPEN_FLAGS O_RDONLY|O_BINARY
     43#else
     44#define REGLOOKUP_OPEN_FLAGS O_RDONLY
     45#endif
     46
     47
    4048void bailOut(int code, char* message)
    4149{
     
    337345  return ret_val;
    338346}
     347
     348
     349int openHive(const char* filename)
     350{
     351  int ret_val;
     352
     353  /* open an existing file */
     354  if ((ret_val = open(filename, REGLOOKUP_OPEN_FLAGS)) == -1)
     355  {
     356    fprintf(stderr, "ERROR: Failed to open hive.  Error returned: %s\n",
     357            strerror(errno));
     358    return -1;
     359  }
     360
     361  return ret_val;
     362}
     363
     364
     365void formatTime(const REGFI_NTTIME* nttime, char* output)
     366{
     367  time_t tmp_time[1];
     368  struct tm* tmp_time_s = NULL;
     369
     370  *tmp_time = regfi_nt2unix_time(nttime);
     371  tmp_time_s = gmtime(tmp_time);
     372  strftime(output,
     373           (4+1+2+1+2)+1+(2+1+2+1+2)+1,
     374              "%Y-%m-%d %H:%M:%S",
     375           tmp_time_s);
     376}
Note: See TracChangeset for help on using the changeset viewer.