Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/etc/Divers/FileNb255.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <j2k/Fred/JFile.cpp>

Go to the source code of this file.

Defines

#define MAX   80
#define UCHAR   unsigned char
#define USHORT   unsigned short

Functions

void save ()
void load ()
void toDisk ()
void fromDisk ()
void test ()

Variables

short table [80]
char buffer [80 *2]
size_t length = 0


Define Documentation

#define MAX   80
 

Definition at line 48 of file FileNb255.cpp.

#define UCHAR   unsigned char
 

Definition at line 49 of file FileNb255.cpp.

#define USHORT   unsigned short
 

Definition at line 50 of file FileNb255.cpp.


Function Documentation

void fromDisk  
 

Definition at line 118 of file FileNb255.cpp.

Referenced by test().

00119 {
00120 JFile myFile( "number.txt", "rb" );
00121  myFile.putData( buffer, MAX*2 );
00122 }

void load  
 

Definition at line 81 of file FileNb255.cpp.

Referenced by test().

00082 {
00083   register unsigned short i = 0;
00084   register unsigned char  c = NULL;
00085   register unsigned short pos = 0;
00086   memset( buffer, 0, MAX );
00087   for( i = 0; i < MAX; i++ ) 
00088   {
00089     c = (UCHAR)buffer[ pos ];
00090     pos++;
00091     if ( c < 255 ) {
00092       table[ i ] = (USHORT)c;
00093     } else if ( c == 255 ) {
00094       c = (UCHAR)buffer[ pos ];
00095       pos++;
00096       table[ i ] = (USHORT)c;
00097     } else {
00098       printf( "Error: Number too big." );
00099     }
00100   } 
00101   length = pos;
00102 }

void save  
 

Definition at line 56 of file FileNb255.cpp.

Referenced by test().

00057 {
00058   register unsigned short i = 0;
00059   register unsigned char  c = NULL;
00060   register unsigned short pos = 0;
00061   memset( buffer, 0, MAX );
00062   for( i = 0; i < MAX; i++ ) 
00063   {
00064     if ( table[ i ] < 255 ) {
00065       c = (UCHAR)table[ i ];
00066       buffer[ pos ] = c;
00067       pos++;
00068     } else if ( table[ i ] < 510 ) {
00069       c = (UCHAR)(table[ i ] - 255);
00070       buffer[ pos ] = 255;
00071       pos++;
00072       buffer[ pos ] = c;
00073       pos++;
00074     } else {
00075       printf( "Error: Number too big." );
00076     }
00077   } 
00078   length = pos;
00079 }

void test  
 

Definition at line 124 of file FileNb255.cpp.

00125 {
00126   register unsigned short i = 0;
00127   for( i = 0; i < MAX; i++ ) {
00128     table[ i ] = (i+200) % 300;
00129   }
00130 
00131   save();
00132   toDisk();
00133  
00134   fromDisk();
00135   load();
00136 
00137   for( i = 0; i < MAX; i++ ) {
00138     printf( "[%d]\t", table[ i ] );
00139   }
00140 
00141 }

void toDisk  
 

Definition at line 112 of file FileNb255.cpp.

Referenced by test().

00113 {
00114 JFile myFile( "number.txt", "wb" );
00115  myFile.putData( buffer, length );
00116 }


Variable Documentation

char buffer[ 80 * 2 ]
 

Definition at line 53 of file FileNb255.cpp.

size_t length = 0
 

Definition at line 54 of file FileNb255.cpp.

short table[ 80 ]
 

Definition at line 52 of file FileNb255.cpp.


Generated on Sun Oct 14 18:47:30 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001