
libbadpenguin 0.3.3
===================

libbadpenguin is a small static library used in many utilities that are 
part of the Antonio Gallo's (AGX) GNU/Linux distribution "Bad Penguin". 
It provides functions to manage the filesystem, double linked lists
(chains), terminal (cursor and color) and to handle TAR archives.

libbadpenguin goal is to speed-up the development of console tools
and scripts without requireing memory-expensive library such as
'ncurses' or 'GNU glib'. libbadpenguin is indeed to be small as 
possibile in order to be linked statically to avoid dependencie
problem between different distributions.



badpenguin-ansi.h
-----------------
Include macros and constant to be used on console terminals
to handle colors. You can use the FG_* and BG_* constants into
a printf statement to change the foreground and background color
of your terminal or one of the other defined macros to manage
the colour terminal. Please see this file to a detailed description
of each feature.



badpenguin-chain.h
------------------
I decided to develop this functions because the GNU glib is 
to big to link statically (1999 by Antonio Gallo)

This header provide you the ability to manage double-linked
lists (chain). First allocate a root node for the chain useing:
    TChain *mychain = NULL;
    mychain = chain_create();

then you can add new items at the end of the chain:
    TChainItem *myitem = NULL;
    myitem = chain_append(mychain);

you can also insert a new items in ascending order using the 'name'
properties of the TChainItem structure:
    TChainItem *myitem = NULL;
    myitem = chain_insert(mychain, "green", 0);
the thirth parameter is the order (0=ascending; 1=descending).

You can delete the whole chain with:
    chain_cleanall(mychain);
and if you want also to dispose the main pointer use:
    chain_delete(mychain);
    
The main chain have a member 'count' with the number of items
currently into the chain.

Each chain's item have a member to hold a name (char*) and
the item's data, this member called 'data' is of type (void*)
so require a type castingt to be used.

- int chain_remove(TChainItem *item);
  can be used to remove and Item from the chain, note that any
  allocated space into the data members is not freed
  this is because you need this data later and simply copied
  the pointer not the whole data structure :-)



badpenguin-errors.h
-------------------
It is a simple list of common errors used into badpenguin tools.
If you think to contribure and we should use standard error code
please have a discussion with 'AGX'



badpenguin-fs.h
-------------------
It is a list of function to access the filesystem:

- int deltree(char *s);
  recursively delete the specified directory, I/O errors are signaled
  as warnings and are non blocking;

- char *dirbase(char *s1) {
  allocate space for a new string containing the basename of *s1
  
- char *dirpath(char *s1);
  allocate space for a new string containing the dirname of *s1

- long diskfree(char *s);
  return the number of bytes available under a specified directory of
  a give mounted filestytems. Return -1 in case of errors.
  
- int file_exists( char* s );
  return 0 if the file, dir or link exists otherwise it's an I/O error;
  
- int file_time( char *filename, time_t newtime, time_t nowtime );
  set the new access and modification datatime upon a file;

- int is_directory( char *p, char *d );
  check if a file specified as path (p) + basename (d) is a directory
  or not
  
- int is_regularfile( char *p, char *d );
  check if a file specified as path (p) + basename (d) is a regular
  file or not
  
- int makedir( char* s, mode_t m );
  create a directory, if the father directory also does not exists
  try to create it;

- int move_dir( char* source, char* target);
  move a full directory tree
  
- int move_file( char* source, char* target);
  move a file on the same filesystem, if the files are on two different
  filesystems then it try to copy it first and then to unlink the old one;
  
- int read_line( FILE* fd, char* buffer );
  read a line from a text file ignoring '\r' and returning when '\n'
  or the EOF is encountered;

- int runshell (char *command);
  execute the specified command using the shell 'sh'
  
- int runcommand (char *options[], int fdin, int fdout, int fderr );
  run the command directly without the shell but you have to give an
  array of program options where options[0] is the binary file to run
  and also you can redirect the input, output or error from/to a 
  different file

- char *strtoken( char **s, char *d);
  instead of strtok this return NULL when 2 delimiters are not
  separated by any chars like in /etc/group for example
 
 
  
badpenguin-untar.h
------------------
This provide the untar() function that is used to exctract a .tar.gz or
just a .tar file into a temporary directory and according to determinet
options.

This contains also libbadpenguin_version() that can be used to print
the version of the library builded into the program and the version
of the Z lib used.

