From: "Pieter van Ginkel" To: Subject: SIGABRT code ??? Date: Mon, 9 Feb 1998 16:31:51 +0100 Message-ID: <01bd356f$d8209d60$5d2f86c2@pieter> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0004_01BD3578.39E50560" Precedence: bulk Dit is een meerdelig bericht in MIME-indeling. ------=_NextPart_000_0004_01BD3578.39E50560 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I've made a class to work with files. I first made it with fstream, but = i got a problem with binary opening of the files. Now, i've don it with = simple open and close... Whats the problem is that everything is working normally, but when I = call file.close(); (a instance of ifctypt), the program calls SIGABRT = and aborts. It doesn't really goes to the routines, but then it calls = the routine, it goes to the last line in the library of the project and = quits (with a sigabrt). I'm getting really sick of this so please help = me. The library in wich the class is made is this (partially!!!) struct ifcrypt { public: ifcrypt( char * filename, const char * _pasword ); ifcrypt( void ); ~ifcrypt( void ); void open( char * filename, const char * _pasword ); void readline( char * line, int len, char endchar=3D'\n' ); void readlen( char * line, int len ); void close( void ); bool correct( void ) { return !file<0; }; private: char decryptchar( char * chars ); char * pasword; bool fileopen; int file; }; ifcrypt::~ifcrypt( void ) { // This one is emty. Forfuture changes, it is defined anyway. } char ifcrypt::decryptchar( char * chars ) { // Sorry, couldn't give this. CLASSIFIED } ifcrypt::ifcrypt( void ) { fileopen=3Dfalse; } ifcrypt::ifcrypt( char * filename, const char * _pasword ) { open( filename, _pasword ); } void ifcrypt::open( char * filename, const char * _pasword ) { char * dummy =3D (char *)malloc( strlen( CRYPT_STRING )+1 ); // = Crypt_string is a identifier string with #define. file =3D ::open( filename, O_BINARY ); // open is included from the = library pasword =3D (char *)malloc( strlen( _pasword )+1 ); strcpy( pasword, _pasword ); readline( dummy, strlen( CRYPT_STRING )); if( strcmp( dummy, CRYPT_STRING )=3D=3D0 ) fileopen=3Dtrue; else { fileopen=3Dfalse; ::close( file ); } free( dummy ); return; } void ifcrypt::close( void ) { ::close( file ); free( pasword ); } void ifcrypt::readline( char * line, int len, char endchar ) { char chars[2]; char returned; int i; for( i=3D0; i
I've made a class = to work with=20 files. I first made it with fstream, but i got a problem with binary = opening of=20 the files. Now, i've don it with simple open and = close... 
Whats the problem = is that=20 everything is working normally, but when I call file.close(); (a = instance of=20 ifctypt), the program calls SIGABRT and aborts. It doesn't really goes = to the=20 routines, but then it calls the routine, it goes to the last line in the = library=20 of the project and quits (with a sigabrt). I'm getting really sick of = this so=20 please help me. 
The library in = wich the class=20 is made is this (partially!!!) 
 
struct=20 ifcrypt
{
public:
  ifcrypt( char * filename, const char * = _pasword );
  ifcrypt( void );
  ~ifcrypt( void = );
 =20 void open( char * filename, const char * _pasword );
  void = readline(=20 char * line, int len, char endchar=3D'\n' );
  void readlen( = char * line,=20 int len );
  void close( void );
 
  bool = correct( void=20 )
    { return !file<0; };
 
private:
  char=20 decryptchar( char * chars );
 
  char *=20 pasword;
  bool fileopen;
  int = file;
};
 
ifcrypt::~ifcrypt( void=20 )
{
  // This one is emty. Forfuture changes, it is defined=20 anyway.
}
 
char = ifcrypt::decryptchar( char=20 * chars )
{
// Sorry, couldn't give this. = CLASSIFIED 
} 
ifcrypt::ifcrypt( = void=20 )
{
  fileopen=3Dfalse;
}
 
ifcrypt::ifcrypt( = char *=20 filename, const char * _pasword )
{
  open( filename, = _pasword=20 );
}
 
void = ifcrypt::open( char *=20 filename, const char * _pasword )
{
  char * dummy =3D (char = *)malloc(=20 strlen( CRYPT_STRING )+1 ); // Crypt_string is a identifier string with=20 #define.
 
  file =3D = ::open( filename,=20 O_BINARY ); // open is included from the library
  pasword = =3D (char=20 *)malloc( strlen( _pasword )+1 );
  strcpy( pasword, _pasword=20 );
 
  readline( = dummy, strlen(=20 CRYPT_STRING )); 
  if( = strcmp( dummy,=20 CRYPT_STRING )=3D=3D0 )
    fileopen=3Dtrue;
  = else
  {
    = fileopen=3Dfalse;
   =20 ::close( file );
  }
 
  free( = dummy=20 ); 
 =20 return;
}
 
void = ifcrypt::close( void=20 )
{
  ::close( file );
  free( pasword=20 );
}
 
void = ifcrypt::readline( char *=20 line, int len, char endchar )
{
  char chars[2];
  = char=20 returned;
 
  int=20 i; 
  for( = i=3D0; i<len; i++=20 )
  {
    read( file, chars, 2=20 );
    line[i] =3D decryptchar( chars = );
 
    if(=20 line[i]=3D=3Dendchar )
    = {
     =20 line[i+1]=3D0;
      = break;
   =20 }
  }
 
 =20 line[len]=3D0;
}
 
void = ifcrypt::readlen( char *=20 line, int len )
{
  char chars[2];
  char=20 returned;
 
  int=20 i; 
  for( = i=3D0; i<len; i++=20 )
  {
    read( file, chars, 2=20 );
    line[i] =3D decryptchar( chars );
 =20 }
}
 
 
 
Thanks,
 
Pieter van Ginkel,
 
the Netherlands.
 
pginkel AT westbrabant DOT net
 
http://home.westbrabant.net= /~pginkel =20 (ie40 or higher only!!!)
------=_NextPart_000_0004_01BD3578.39E50560--