Update of /cvsroot/blob/blob/src/lib
In directory usw-pr-cvs1:/tmp/cvs-serv8879
Modified Files:
tar.c
Log Message:
- use TAR_BLOCKSIZE instead of magic numbers
- made non-exported functions static
- don't export tar_io_conf, it's wrapped by io_configure()
Index: tar.c
===================================================================
RCS file: /cvsroot/blob/blob/src/lib/tar.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tar.c 2 May 2002 15:28:54 -0000 1.3
+++ tar.c 3 May 2002 09:59:16 -0000 1.4
@@ -59,7 +59,6 @@
static char module_version[] = "$Id$";
-
/**********************************************************************
* static functions
*/
@@ -73,9 +72,9 @@
static int tar_from_oct( unsigned char *start, size_t digits, unsigned long *value );
/* io driver stuff */
-int tar_io_conf( io_driver_t * io, void *conf );
-int tar_io_read( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io );
-int tar_io_write( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io );
+static int tar_io_conf( io_driver_t * io, void *conf );
+static int tar_io_read( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io );
+static int tar_io_write( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io );
/**********************************************************************/
/**********************************************************************/
@@ -90,7 +89,7 @@
/**********************************************************************
* io driver for tar archives
*/
-void init_tar_default_io( void )
+static void init_tar_default_io( void )
{
int ret;
static io_driver_t def_tar_io_driver;
@@ -112,8 +111,8 @@
if ( !io || !arch )
return -EINVAL;
- DBG( 5, "%s: driver=%p, arch=%p\n", __FUNCTION__,
- driver, arch );
+ DBG( 5, "%s: io=%p, arch=%p\n", __FUNCTION__,
+ io, arch );
io->conf = tar_io_conf;
io->read = tar_io_read;
@@ -130,7 +129,7 @@
}
/* the user gives us a filename in conf */
-int tar_io_conf( io_driver_t * io, void *conf )
+static int tar_io_conf( io_driver_t * io, void *conf )
{
int ret;
char *name;
@@ -169,7 +168,7 @@
return 0;
}
-int tar_io_read( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io )
+static int tar_io_read( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io )
{
io_driver_t *child;
tar_arch_t *arch;
@@ -183,7 +182,7 @@
if ( !child )
return -EINVAL;
- offset = arch->f_start_block*512;
+ offset = arch->f_start_block*TAR_BLOCKSIZE;
DBG( 3, "%s: dest=%p, src=%p(=%p), amount=%d, child=%p\n", __FUNCTION__,
dest, src, (char *)((u32)src + offset), amount, child );
@@ -191,7 +190,7 @@
return io_read(dest, (unsigned char *)(offset + (u32)src), amount, child );
}
-int tar_io_write( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io )
+static int tar_io_write( unsigned char *dest, unsigned char *src, size_t amount, io_driver_t *io )
{
return -EINVAL;
}
@@ -366,7 +365,7 @@
if ( !size )
return -EINVAL;
- ret = io_read( dest, (unsigned char*)(arch->f_start_block*512), arch->f_size, arch->io_driver );
+ ret = io_read( dest, (unsigned char*)(arch->f_start_block*TAR_BLOCKSIZE), arch->f_size, arch->io_driver );
if ( ret )
return ret;
@@ -383,7 +382,7 @@
return -EINVAL;
/* get header */
- ret = io_read( arch->buffer, (unsigned char *)(arch->block*512), 512, arch->io_driver );
+ ret = io_read( arch->buffer, (unsigned char *)(arch->block*TAR_BLOCKSIZE), TAR_BLOCKSIZE, arch->io_driver );
if ( ret ) {
printf( "tar: cant get block: %d\n", ret );
goto DONE;
@@ -407,7 +406,7 @@
}
arch->f_start_block = arch->block;
- arch->f_blocks = (arch->f_size/512) + (arch->f_size%512?1:0);
+ arch->f_blocks = (arch->f_size/TAR_BLOCKSIZE) + (arch->f_size%TAR_BLOCKSIZE?1:0);
printf( "tar: %s %ld bytes, %d blocks\n", phdr->name,
arch->f_size, arch->f_blocks );
|