readMetaRoot.c File Reference

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

Go to the source code of this file.

Functions

unsigned int CountFreeBits (const int byte)
unsigned int CountnFree (char m_BitMap)
int main (int argc, char *argv[])

Function Documentation

unsigned int CountFreeBits ( const int  byte  ) 

Definition at line 24 of file readMetaRoot.c.

00025 {
00026     unsigned int count = 0;
00027     int i, mask = 0x80;
00028     for( i = 0; i < 8; i++ )
00029     {
00030         if( ( mask & byte ) == mask )
00031             count++;
00032         mask = mask >> 1;
00033     }
00034     return count;
00035 }

unsigned int CountnFree ( char  m_BitMap  ) 

Definition at line 37 of file readMetaRoot.c.

00038 {
00039     // Count number of free bits in bitmap
00040     unsigned int count;
00041 
00042     count = CountFreeBits( m_BitMap );
00043     return count;
00044 }

int main ( int  argc,
char *  argv[] 
)

Definition at line 46 of file readMetaRoot.c.

00047 {
00048     int   file, i;
00049     char  c;
00050     unsigned int sum;
00051 
00052     for( i = 1; i < argc; i++ )
00053     {
00054         file = open( argv[ i ], O_RDONLY );
00055         if( file > 0 )
00056         {
00057             sum  = 0;
00058             while( read( file, (char *)&c, 1 ) == 1 )
00059             {
00060                 sum += CountnFree( c );
00061             }
00062             close( file );
00063             fprintf( stderr, "sum = %u\n", sum );
00064         }
00065         else
00066             fprintf( stderr, "Nao consegui abrir o arquivo\n" );
00067     }
00068 
00069     return( 0 );
00070 }

Generated on Wed Jul 4 16:03:30 2012 for RIO by  doxygen 1.6.3