www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/09/10:31:03

From: "Pieter van Ginkel" <pginkel AT westbrabant DOT net>
To: <djgpp AT delorie DOT com>
Subject: SIGABRT code ???
Date: Mon, 9 Feb 1998 16:31:51 +0100
Message-ID: <01bd356f$d8209d60$5d2f86c2@pieter>
MIME-Version: 1.0

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<len; i++ )
  {
    read( file, chars, 2 );
    line[i] =3D decryptchar( chars );
    if( line[i]=3D=3Dendchar )
    {
      line[i+1]=3D0;
      break;
    }
  }
  line[len]=3D0;
}
void ifcrypt::readlen( char * line, int len )
{
  char chars[2];
  char returned;
  int i;
  for( i=3D0; i<len; i++ )
  {
    read( file, chars, 2 );
    line[i] =3D decryptchar( chars );
  }
}


Thanks,

Pieter van Ginkel,

the Netherlands.

pginkel AT westbrabant DOT net

http://home.westbrabant.net/~pginkel  (ie40 or higher only!!!)

------=_NextPart_000_0004_01BD3578.39E50560
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>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...</FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>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.</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>The library in =
wich the class=20
is made is this (partially!!!)</FONT></FONT><FONT =
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3></FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>struct=20
ifcrypt<BR>{<BR>public:<BR>&nbsp; ifcrypt( char * filename, const char * =

_pasword );<BR>&nbsp; ifcrypt( void );<BR>&nbsp; ~ifcrypt( void =
);<BR>&nbsp;=20
void open( char * filename, const char * _pasword );<BR>&nbsp; void =
readline(=20
char * line, int len, char endchar=3D'\n' );<BR>&nbsp; void readlen( =
char * line,=20
int len );<BR>&nbsp; void close( void );</FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; bool =
correct( void=20
)<BR>&nbsp;&nbsp;&nbsp; { return !file&lt;0; };</FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3>private:<BR>&nbsp; char=20
decryptchar( char * chars );</FONT></FONT><FONT =
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; char *=20
pasword;<BR>&nbsp; bool fileopen;<BR>&nbsp; int =
file;<BR>};</FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3>ifcrypt::~ifcrypt( void=20
)<BR>{<BR>&nbsp; // This one is emty. Forfuture changes, it is defined=20
anyway.<BR>}</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>char =
ifcrypt::decryptchar( char=20
* chars )<BR>{<BR></FONT></FONT><FONT size=3D3><FONT color=3D#000000=20
face=3DArial></FONT>// Sorry, couldn't give this. =
CLASSIFIED</FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3>}</FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>ifcrypt::ifcrypt( =
void=20
)<BR>{<BR>&nbsp; fileopen=3Dfalse;<BR>}</FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>ifcrypt::ifcrypt( =
char *=20
filename, const char * _pasword )<BR>{<BR>&nbsp; open( filename, =
_pasword=20
);<BR>}</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>void =
ifcrypt::open( char *=20
filename, const char * _pasword )<BR>{<BR>&nbsp; char * dummy =3D (char =
*)malloc(=20
strlen( CRYPT_STRING )+1 ); // Crypt_string is a identifier string with=20
#define.</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; file =3D =
::open( filename,=20
O_BINARY ); // open is included from the library</FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; pasword =
=3D (char=20
*)malloc( strlen( _pasword )+1 );<BR>&nbsp; strcpy( pasword, _pasword=20
);</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; readline( =
dummy, strlen(=20
CRYPT_STRING ));</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; if( =
strcmp( dummy,=20
CRYPT_STRING )=3D=3D0 )<BR>&nbsp;&nbsp;&nbsp; fileopen=3Dtrue;<BR>&nbsp; =

else<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; =
fileopen=3Dfalse;<BR>&nbsp;&nbsp;&nbsp;=20
::close( file );<BR>&nbsp; }</FONT></FONT><FONT =
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; free( =
dummy=20
);</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp;=20
return;<BR>}</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>void =
ifcrypt::close( void=20
)<BR>{<BR>&nbsp; ::close( file );<BR>&nbsp; free( pasword=20
);<BR>}</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>void =
ifcrypt::readline( char *=20
line, int len, char endchar )<BR>{<BR>&nbsp; char chars[2];<BR>&nbsp; =
char=20
returned;</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; int=20
i;</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; for( =
i=3D0; i&lt;len; i++=20
)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; read( file, chars, 2=20
);<BR>&nbsp;&nbsp;&nbsp; line[i] =3D decryptchar( chars =
);</FONT></FONT><FONT=20
size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3>&nbsp;&nbsp;&nbsp; if(=20
line[i]=3D=3Dendchar )<BR>&nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
line[i+1]=3D0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
break;<BR>&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp; }</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp;=20
line[len]=3D0;<BR>}</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>void =
ifcrypt::readlen( char *=20
line, int len )<BR>{<BR>&nbsp; char chars[2];<BR>&nbsp; char=20
returned;</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; int=20
i;</FONT></FONT><FONT size=3D3></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT size=3D3>&nbsp; for( =
i=3D0; i&lt;len; i++=20
)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp; read( file, chars, 2=20
);<BR>&nbsp;&nbsp;&nbsp; line[i] =3D decryptchar( chars );<BR>&nbsp;=20
}<BR>}</FONT></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3></FONT></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3></FONT></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3>Thanks,</FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial><FONT =
size=3D3></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>Pieter van Ginkel,</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>the Netherlands.</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><A=20
href=3D"mailto:pginkel AT westbrabant DOT net">pginkel AT westbrabant DOT net</A></FONT=
></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><A=20
href=3D"http://home.westbrabant.net/~pginkel">http://home.westbrabant.net=
/~pginkel</A>&nbsp;=20
(ie40 or higher only!!!)</FONT></DIV></BODY></HTML>

------=_NextPart_000_0004_01BD3578.39E50560--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019