Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/archival/gzip.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 267  struct globals { Line 267  struct globals {
267  #define DECLARE(type, array, size) \  #define DECLARE(type, array, size) \
268   type * array   type * array
269  #define ALLOC(type, array, size) \  #define ALLOC(type, array, size) \
270   array = xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type));   array = xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type))
271  #define FREE(array) \  #define FREE(array) \
272   do { free(array); array = NULL; } while (0)   do { free(array); array = NULL; } while (0)
273    
# Line 389  static void put_32bit(ulg n) Line 389  static void put_32bit(ulg n)
389  }  }
390    
391  /* ===========================================================================  /* ===========================================================================
  * Clear input and output buffers  
  */  
 static void clear_bufs(void)  
 {  
  G1.outcnt = 0;  
 #ifdef DEBUG  
  G1.insize = 0;  
 #endif  
  G1.isize = 0;  
 }  
   
   
 /* ===========================================================================  
392   * Run a set of bytes through the crc shift register.  If s is a NULL   * Run a set of bytes through the crc shift register.  If s is a NULL
393   * pointer, then initialize the crc shift register contents instead.   * pointer, then initialize the crc shift register contents instead.
394   * Return the current crc in either case.   * Return the current crc in either case.
# Line 1186  static void gen_codes(ct_data * tree, in Line 1173  static void gen_codes(ct_data * tree, in
1173    
1174   Tracec(tree != G2.static_ltree,   Tracec(tree != G2.static_ltree,
1175     (stderr, "\nn %3d %c l %2d c %4x (%x) ", n,     (stderr, "\nn %3d %c l %2d c %4x (%x) ", n,
1176   (isgraph(n) ? n : ' '), len, tree[n].Code,   (n > ' ' ? n : ' '), len, tree[n].Code,
1177   next_code[len] - 1));   next_code[len] - 1));
1178   }   }
1179  }  }
# Line 1554  static void compress_block(ct_data * ltr Line 1541  static void compress_block(ct_data * ltr
1541   lc = G1.l_buf[lx++];   lc = G1.l_buf[lx++];
1542   if ((flag & 1) == 0) {   if ((flag & 1) == 0) {
1543   SEND_CODE(lc, ltree); /* send a literal byte */   SEND_CODE(lc, ltree); /* send a literal byte */
1544   Tracecv(isgraph(lc), (stderr, " '%c' ", lc));   Tracecv(lc > ' ', (stderr, " '%c' ", lc));
1545   } else {   } else {
1546   /* Here, lc is the match length - MIN_MATCH */   /* Here, lc is the match length - MIN_MATCH */
1547   code = G2.length_code[lc];   code = G2.length_code[lc];
# Line 2015  char* make_new_name_gzip(char *filename) Line 2002  char* make_new_name_gzip(char *filename)
2002  }  }
2003    
2004  static  static
2005  USE_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)  IF_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)
2006  {  {
2007   struct stat s;   struct stat s;
2008    
2009   clear_bufs();   /* Clear input and output buffers */
2010     G1.outcnt = 0;
2011    #ifdef DEBUG
2012     G1.insize = 0;
2013    #endif
2014     G1.isize = 0;
2015    
2016     /* Reinit G2.xxx */
2017     memset(&G2, 0, sizeof(G2));
2018     G2.l_desc.dyn_tree     = G2.dyn_ltree;
2019     G2.l_desc.static_tree  = G2.static_ltree;
2020     G2.l_desc.extra_bits   = extra_lbits;
2021     G2.l_desc.extra_base   = LITERALS + 1;
2022     G2.l_desc.elems        = L_CODES;
2023     G2.l_desc.max_length   = MAX_BITS;
2024     //G2.l_desc.max_code     = 0;
2025     G2.d_desc.dyn_tree     = G2.dyn_dtree;
2026     G2.d_desc.static_tree  = G2.static_dtree;
2027     G2.d_desc.extra_bits   = extra_dbits;
2028     //G2.d_desc.extra_base   = 0;
2029     G2.d_desc.elems        = D_CODES;
2030     G2.d_desc.max_length   = MAX_BITS;
2031     //G2.d_desc.max_code     = 0;
2032     G2.bl_desc.dyn_tree    = G2.bl_tree;
2033     //G2.bl_desc.static_tree = NULL;
2034     G2.bl_desc.extra_bits  = extra_blbits,
2035     //G2.bl_desc.extra_base  = 0;
2036     G2.bl_desc.elems       = BL_CODES;
2037     G2.bl_desc.max_length  = MAX_BL_BITS;
2038     //G2.bl_desc.max_code    = 0;
2039    
2040   s.st_ctime = 0;   s.st_ctime = 0;
2041   fstat(STDIN_FILENO, &s);   fstat(STDIN_FILENO, &s);
2042   zip(s.st_ctime);   zip(s.st_ctime);
2043   return 0;   return 0;
2044  }  }
2045    
2046    #if ENABLE_FEATURE_GZIP_LONG_OPTIONS
2047    static const char gzip_longopts[] ALIGN1 =
2048     "stdout\0"              No_argument       "c"
2049     "to-stdout\0"           No_argument       "c"
2050     "force\0"               No_argument       "f"
2051     "verbose\0"             No_argument       "v"
2052    #if ENABLE_GUNZIP
2053     "decompress\0"          No_argument       "d"
2054     "uncompress\0"          No_argument       "d"
2055     "test\0"                No_argument       "t"
2056    #endif
2057     "quiet\0"               No_argument       "q"
2058     "fast\0"                No_argument       "1"
2059     "best\0"                No_argument       "9"
2060     ;
2061    #endif
2062    
2063  /*  /*
2064   * Linux kernel build uses gzip -d -n. We accept and ignore it.   * Linux kernel build uses gzip -d -n. We accept and ignore it.
2065   * Man page says:   * Man page says:
# Line 2049  int gzip_main(int argc UNUSED_PARAM, cha Line 2083  int gzip_main(int argc UNUSED_PARAM, cha
2083  {  {
2084   unsigned opt;   unsigned opt;
2085    
2086    #if ENABLE_FEATURE_GZIP_LONG_OPTIONS
2087     applet_long_options = gzip_longopts;
2088    #endif
2089   /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */   /* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
2090   opt = getopt32(argv, "cfv" USE_GUNZIP("dt") "q123456789n");   opt = getopt32(argv, "cfv" IF_GUNZIP("dt") "q123456789n");
2091  #if ENABLE_GUNZIP /* gunzip_main may not be visible... */  #if ENABLE_GUNZIP /* gunzip_main may not be visible... */
2092   if (opt & 0x18) // -d and/or -t   if (opt & 0x18) // -d and/or -t
2093   return gunzip_main(argc, argv);   return gunzip_main(argc, argv);
# Line 2061  int gzip_main(int argc UNUSED_PARAM, cha Line 2098  int gzip_main(int argc UNUSED_PARAM, cha
2098   //if (opt & 0x4) // -v   //if (opt & 0x4) // -v
2099   argv += optind;   argv += optind;
2100    
2101   SET_PTR_TO_GLOBALS(xzalloc(sizeof(struct globals) + sizeof(struct globals2))   SET_PTR_TO_GLOBALS((char *)xzalloc(sizeof(struct globals)+sizeof(struct globals2))
2102   + sizeof(struct globals));   + sizeof(struct globals));
  barrier();  
  G2.l_desc.dyn_tree    = G2.dyn_ltree;  
  G2.l_desc.static_tree = G2.static_ltree;  
  G2.l_desc.extra_bits  = extra_lbits;  
  G2.l_desc.extra_base  = LITERALS + 1;  
  G2.l_desc.elems       = L_CODES;  
  G2.l_desc.max_length  = MAX_BITS;  
  //G2.l_desc.max_code    = 0;  
   
  G2.d_desc.dyn_tree    = G2.dyn_dtree;  
  G2.d_desc.static_tree = G2.static_dtree;  
  G2.d_desc.extra_bits  = extra_dbits;  
  //G2.d_desc.extra_base  = 0;  
  G2.d_desc.elems       = D_CODES;  
  G2.d_desc.max_length  = MAX_BITS;  
  //G2.d_desc.max_code    = 0;  
   
  G2.bl_desc.dyn_tree    = G2.bl_tree;  
  //G2.bl_desc.static_tree = NULL;  
  G2.bl_desc.extra_bits  = extra_blbits,  
  //G2.bl_desc.extra_base  = 0;  
  G2.bl_desc.elems       = BL_CODES;  
  G2.bl_desc.max_length  = MAX_BL_BITS;  
  //G2.bl_desc.max_code    = 0;  
2103    
2104   /* Allocate all global buffers (for DYN_ALLOC option) */   /* Allocate all global buffers (for DYN_ALLOC option) */
2105   ALLOC(uch, G1.l_buf, INBUFSIZ);   ALLOC(uch, G1.l_buf, INBUFSIZ);

Legend:
Removed from v.983  
changed lines
  Added in v.984