src/commands/simple/tar.c File Reference

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
#include <tar.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <utime.h>
#include <sys/wait.h>
#include <stdio.h>
#include <errno.h>
#include <dirent.h>

Go to the source code of this file.

Classes

struct  link

Defines

#define POSIX_COMP
#define DIRECT_3
#define direct   dirent
#define TRUE   1
#define FALSE   0
#define STRING_SIZE   256
#define HEADER_SIZE   TBLOCK
#define NAME_SIZE   NAMSIZ
#define m_name   name
#define m_mode   mode
#define m_uid   uid
#define m_gid   gid
#define m_size   size
#define m_time   mtime
#define m_checksum   chksum
#define m_linked   typeflag
#define m_link   linkname
#define hdr_block   dummy
#define m   header
#define member   dbuf
#define INT_TYPE   (sizeof(header.member.m_uid))
#define LONG_TYPE   (sizeof(header.member.m_size))
#define NIL_HEADER   ((HEADER *) 0)
#define NIL_PTR   ((char *) 0)
#define TBLOCK_SIZE   TBLOCK
#define flush()   print(NIL_PTR)
#define block_size()

Typedefs

typedef char BOOL
typedef union hblock HEADER

Functions

 _PROTOTYPE (int main,(int argc, char **argv))
 _PROTOTYPE (void error,(char *s1, char *s2))
 _PROTOTYPE (BOOL get_header,(void))
 _PROTOTYPE (void tarfile,(void))
 _PROTOTYPE (void extract,(char *file))
 _PROTOTYPE (void copy,(char *file, int from, int to, long bytes))
 _PROTOTYPE (long convert,(char str[], int type))
 _PROTOTYPE (int checksum,(void))
 _PROTOTYPE (int is_dir,(char *file))
 _PROTOTYPE (char *path_name,(char *file))
 _PROTOTYPE (void add_path,(char *name))
 _PROTOTYPE (void add_close,(int fd))
 _PROTOTYPE (int add_open,(char *file, struct stat *st))
 _PROTOTYPE (void make_header,(char *file, struct stat *st))
 _PROTOTYPE (void is_added,(struct stat *st, char *file))
 _PROTOTYPE (void is_deleted,(struct stat *st))
 _PROTOTYPE (char *is_linked,(struct stat *st))
 _PROTOTYPE (void mread,(int fd, char *address, int bytes))
 _PROTOTYPE (int bread,(int fd, char *address, int bytes))
 _PROTOTYPE (void print,(char *str))
 _PROTOTYPE (char *num_out,(long number))
 _PROTOTYPE (void string_print,(char *buffer, char *fmt,...))
void error (char *s1, char *s2)
int main (int argc, argv)
BOOL get_header ()
void tarfile ()
void skip_entry ()
void extract (char *file)
void delete (char *file)
void do_chown (char *file)
void timestamp (char *file)
void copy (char *file, int from, int to, long bytes)
long convert (str, int type)
int checksum ()
int is_dir (char *file)
char * path_name (char *file)
void add_path (char *name)
void add_file (char *file)
void verb_print (char *s1, char *s2)
void add_close (int fd)
int add_open (char *file, struct stat *st)
void make_header (char *file, struct stat *st)
void is_added (struct stat *st, char *file)
void is_deleted (struct stat *st)
char * is_linked (struct stat *st)
void clear_header ()
void adjust_boundary ()
void mread (int fd, char *address, int bytes)
void mwrite (int fd, char *address, int bytes)
int bread (int fd, char *address, int bytes)
int bwrite (int fd, char *address, int bytes)
void print (char *str)
char * num_out (long number)
void string_print (char *buffer, char *fmt)

Variables

struct linklink_top
HEADER header
BOOL show_fl
BOOL creat_fl
BOOL ext_fl
int tar_fd
char usage [] = "Usage: tar [cxt][vo][F][f] tarfile [files]."
char io_buffer [TBLOCK_SIZE]
char path [NAME_SIZE]
char pathname [NAME_SIZE]
int force_flag = 0
int chown_flag = 0
int verbose_flag = 0
int norec_flag = 0
ino_t ar_inode
dev_t ar_dev
int total_blocks
int u_mask
char output [TBLOCK_SIZE]


Define Documentation

 
static int block_size (  ) 

Value:

(int) ((convert(header.member.m_size, LONG_TYPE) \
  + (long) TBLOCK_SIZE - 1) / (long) TBLOCK_SIZE)

Definition at line 188 of file tar.c.

#define direct   dirent

Definition at line 85 of file tar.c.

#define DIRECT_3

Definition at line 78 of file tar.c.

#define FALSE   0

Definition at line 101 of file tar.c.

#define flush ( void   )     print(NIL_PTR)

Definition at line 161 of file tar.c.

#define hdr_block   dummy

Definition at line 120 of file tar.c.

#define HEADER_SIZE   TBLOCK

Definition at line 104 of file tar.c.

#define INT_TYPE   (sizeof(header.member.m_uid))

Definition at line 154 of file tar.c.

#define LONG_TYPE   (sizeof(header.member.m_size))

Definition at line 155 of file tar.c.

#define m   header

Definition at line 121 of file tar.c.

#define m_checksum   chksum

Definition at line 117 of file tar.c.

#define m_gid   gid

Definition at line 114 of file tar.c.

#define m_link   linkname

Definition at line 119 of file tar.c.

#define m_linked   typeflag

Definition at line 118 of file tar.c.

#define m_mode   mode

Definition at line 112 of file tar.c.

#define m_name   name

Definition at line 111 of file tar.c.

#define m_size   size

Definition at line 115 of file tar.c.

#define m_time   mtime

Definition at line 116 of file tar.c.

#define m_uid   uid

Definition at line 113 of file tar.c.

#define member   dbuf

Definition at line 122 of file tar.c.

#define NAME_SIZE   NAMSIZ

Definition at line 105 of file tar.c.

#define NIL_HEADER   ((HEADER *) 0)

Definition at line 157 of file tar.c.

#define NIL_PTR   ((char *) 0)

Definition at line 158 of file tar.c.

#define POSIX_COMP

Definition at line 77 of file tar.c.

#define STRING_SIZE   256

Definition at line 103 of file tar.c.

#define TBLOCK_SIZE   TBLOCK

Definition at line 159 of file tar.c.

#define TRUE   1

Definition at line 100 of file tar.c.


Typedef Documentation

typedef char BOOL

Definition at line 99 of file tar.c.

typedef union hblock HEADER

Definition at line 108 of file tar.c.


Function Documentation

_PROTOTYPE ( void  string_print,
(char *buffer, char *fmt,...)   
)

_PROTOTYPE ( char *  num_out,
(long number)   
)

_PROTOTYPE ( void  print,
(char *str  
)

_PROTOTYPE ( int  bread,
(int fd, char *address, int bytes)   
)

_PROTOTYPE ( void  mread,
(int fd, char *address, int bytes)   
)

_PROTOTYPE ( char *  is_linked,
(struct stat *st  
)

_PROTOTYPE ( void  is_deleted,
(struct stat *st  
)

_PROTOTYPE ( void  is_added,
(struct stat *st, char *file  
)

_PROTOTYPE ( void  make_header,
(char *file, struct stat *st  
)

_PROTOTYPE ( int  add_open,
(char *file, struct stat *st  
)

_PROTOTYPE ( void  add_close,
(int fd  
)

_PROTOTYPE ( void  add_path,
(char *name  
)

_PROTOTYPE ( char *  path_name,
(char *file  
)

_PROTOTYPE ( int  is_dir,
(char *file  
)

_PROTOTYPE ( int  checksum,
(void)   
)

_PROTOTYPE ( long  convert,
(char str[], int type  
)

_PROTOTYPE ( void  copy,
(char *file, int from, int to, long bytes)   
)

_PROTOTYPE ( void  extract,
(char *file  
)

_PROTOTYPE ( void  tarfile,
(void)   
)

_PROTOTYPE ( BOOL  get_header,
(void)   
)

_PROTOTYPE ( void  error,
(char *s1, char *s2)   
)

_PROTOTYPE ( int  main,
(int argc, char **argv)   
)

void add_close ( int  fd  ) 

Definition at line 840 of file tar.c.

void add_file ( char *  file  ) 

Definition at line 665 of file tar.c.

int add_open ( char *  file,
struct stat st 
)

Definition at line 849 of file tar.c.

void add_path ( char *  name  ) 

Definition at line 639 of file tar.c.

void adjust_boundary (  ) 

Definition at line 964 of file tar.c.

int bread ( int  fd,
char *  address,
int  bytes 
)

Definition at line 993 of file tar.c.

int bwrite ( int  fd,
char *  address,
int  bytes 
)

Definition at line 1009 of file tar.c.

int checksum (  ) 

Definition at line 609 of file tar.c.

void clear_header (  ) 

Definition at line 957 of file tar.c.

long convert ( str  ,
int  type 
)

Definition at line 592 of file tar.c.

void copy ( char *  file,
int  from,
int  to,
long  bytes 
)

Definition at line 573 of file tar.c.

void delete ( char *  file  ) 

Definition at line 522 of file tar.c.

void do_chown ( char *  file  ) 

Definition at line 534 of file tar.c.

void error ( char *  s1,
char *  s2 
)

Definition at line 224 of file tar.c.

void extract ( char *  file  ) 

Definition at line 412 of file tar.c.

BOOL get_header (  ) 

Definition at line 332 of file tar.c.

void is_added ( struct stat st,
char *  file 
)

Definition at line 902 of file tar.c.

void is_deleted ( struct stat st  ) 

Definition at line 924 of file tar.c.

int is_dir ( char *  file  ) 

Definition at line 622 of file tar.c.

char* is_linked ( struct stat st  ) 

Definition at line 935 of file tar.c.

int main ( int argc  ,
argv   
)

Definition at line 232 of file tar.c.

void make_header ( char *  file,
struct stat st 
)

Definition at line 863 of file tar.c.

void mread ( int  fd,
char *  address,
int  bytes 
)

Definition at line 977 of file tar.c.

void mwrite ( int  fd,
char *  address,
int  bytes 
)

Definition at line 984 of file tar.c.

char* num_out ( long  number  ) 

Definition at line 1046 of file tar.c.

char* path_name ( char *  file  ) 

Definition at line 631 of file tar.c.

void print ( char *  str  ) 

Definition at line 1026 of file tar.c.

void skip_entry (  ) 

Definition at line 405 of file tar.c.

void string_print ( char *  buffer,
char *  fmt 
)

Definition at line 1064 of file tar.c.

void tarfile (  ) 

Definition at line 352 of file tar.c.

void timestamp ( char *  file  ) 

Definition at line 564 of file tar.c.

void verb_print ( char *  s1,
char *  s2 
)

Definition at line 834 of file tar.c.


Variable Documentation

dev_t ar_dev

Definition at line 183 of file tar.c.

ino_t ar_inode

Definition at line 182 of file tar.c.

int chown_flag = 0

Definition at line 176 of file tar.c.

Definition at line 163 of file tar.c.

Definition at line 163 of file tar.c.

int force_flag = 0

Definition at line 171 of file tar.c.

Definition at line 152 of file tar.c.

char io_buffer[TBLOCK_SIZE]

Definition at line 168 of file tar.c.

struct link * link_top

int norec_flag = 0

Definition at line 179 of file tar.c.

char output[TBLOCK_SIZE]

Definition at line 1025 of file tar.c.

char path[NAME_SIZE]

Definition at line 169 of file tar.c.

char pathname[NAME_SIZE]

Definition at line 170 of file tar.c.

Definition at line 163 of file tar.c.

int tar_fd

Definition at line 165 of file tar.c.

Definition at line 185 of file tar.c.

int u_mask

Definition at line 186 of file tar.c.

void usage = "Usage: tar [cxt][vo][F][f] tarfile [files]."

Definition at line 167 of file tar.c.

int verbose_flag = 0

Definition at line 177 of file tar.c.


Generated on Tue Mar 9 04:36:36 2010 for Minix by  doxygen 1.5.8