Just for the record (for other newbies as I am), it turns out that the best 
approach is to actually check in the C source code what is the actual size for 
each field. So in the original source code I added lines like this:
    
    
    printf("\nversion: %d   version_needed: %d    flag: %d\n", 
sizeof(file_info.version), sizeof(file_info.version_needed), 
sizeof(file_info.flag));
    printf("compression_method: %d   dosDate: %d    crc: %d\n", 
sizeof(file_info.compression_method), sizeof(file_info.dosDate), 
sizeof(file_info.crc));
    printf("compressed_size: %d   uncompressed_size: %d    size_filename: 
%d\n", sizeof(file_info.compressed_size), sizeof(file_info.uncompressed_size), 
sizeof(file_info.size_filename));
    printf("size_file_extra: %d\n", sizeof(file_info.size_file_extra));
    printf("size_file_comment: %d\n", sizeof(file_info.size_file_comment));
    printf("size_file_comment: %d\n", sizeof(file_info.size_file_comment));
    
    Run

As consequence, I realized that the appropriate sizes were:
    
    
    tm_unz* = object
      tm_sec:uint32   #;            /* seconds after the minute - [0,59] */
      tm_min:uint32   # ;            /* minutes after the hour - [0,59] */
      tm_hour:uint32  #;           /* hours since midnight - [0,23] */
      tm_mday:uint32  #;           /* day of the month - [1,31] */
      tm_mon:uint32  #;            /* months since January - [0,11] */
      tm_year:uint32  #;           /* years - [1980..2044] */
    
    # uLong (4 bytes): uint32
    unz_file_info64* = ref object  #{.packed.}
          version:uint64              # version made by                2 bytes  
 // uLong
          version_needed:uint64       # version needed to extract      2 bytes  
 // uLong
          flag:uint64                  # general purpose bit flag        2 
bytes   // uLong
          compression_method:uint64   # compression method             2 bytes  
 // uLong
          dosDate:uint64              # last mod file date in Dos fmt   4 bytes 
  // uLong
          crc:uint64                  # crc-32                         4 bytes  
 // uLong
          compressed_size:uint64      # compressed size                8 bytes  
 // ZPOS64_T
          uncompressed_size:uint64    # uncompressed size              8 bytes  
 // ZPOS64_T   329385
          size_filename:uint64         # filename length                 2 
bytes   // uLong
          size_file_extra:uint64       # extra field length              2 
bytes   // uLOng
          size_file_comment:uint64     # file comment length             2 
bytes   // uLong
          disk_num_start:uint64       # disk number start              2 bytes  
 // uLong
          internal_fa:uint64          # internal file attributes        2 bytes 
  // uLong
          external_fa:uint64          # external file attributes        4 bytes 
  // uLong
          tmu_date:tm_unz             # tm_unz
    
    Run

Reply via email to