New Era : Embedding C problem
Posted in 1998
This is a multi-part message in MIME format. ------=_NextPart_000_0005_01BDDB19.E6B8AD90 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I have a dll written in New Era2.12 with embedded C in it (VC1.51). I am trying to convert this to New Era 3.10 with embedded VC5.0. I have changed obsolete keywords FAR, PASCAL etc in VC151 to current = syntax. However, I still cannot compile. Has anyone any experience of this problem? Are there any tricks to = embedding C in ne3.10 (I have tried putting the -nosql in the New Era = options from library template, still no joy). I have included both versions of code on the off chance that someone is = very, very bored: Here we go, current version (non compiling) first *************************************************************************= ***** begin_c BOOL __declspec( dllexport ) WINAPI encrypt(char *buffer,char *key,char = *text){ int key_len, p, c_char, key_pos, text_len; key_len=3Dstrlen(key); text_len=3Dstrlen(text); for(p=3D0,key_pos=3D0;p<text_len;++p,++key_pos){ if(key_pos=3D=3Dkey_len) key_pos=3D0; c_char=3Dtext[p] ^ key[key_pos]; buffer[(p*2)]=3D'A'+(c_char/26); buffer[(p*2)+1]=3D'A'+(c_char%26); } buffer[text_len*2]=3D0; return TRUE; } BOOL __declspec( dllexport ) WINAPI decrypt(char *buffer,char *key,char = *text){ int key_len, p, c_char, key_pos, text_len; =20 key_len=3Dstrlen(key); text_len=3Dstrlen(text); if(strstr(text,".DBF")=3D=3DNULL) { =20 for(p=3D0,key_pos=3D0;(p*2)<text_len;++p,++key_pos){ if(key_pos=3D=3Dkey_len) key_pos=3D0; c_char=3D((text[(p*2)]-'A')*26)+(text[(p*2+1)]-'A'); buffer[p]=3Dc_char^ key[key_pos]; } buffer[p]=3D0; } else { strcpy(buffer,text); } return TRUE; } end_c #########################################################################= ############ function n_decrypt(l_key,f_path) variable f_path char(*) variable l_key char(*) variable buffer char(*) variable i integer let buffer=3D" " for i=3D1 to (length(f_path)) let buffer=3Dbuffer||" " end for begin_c decrypt(buffer,l_key,f_path); end_c DISPLAY buffer return buffer=20 end function #########################################################################= ############ function n_encrypt(l_key,f_path) variable f_path char(*) variable l_key char(*) variable buffer char(*) variable i integer let buffer=3D" " for i=3D1 to (length(f_path)*2)-1 let buffer=3Dbuffer||" " end for begin_c encrypt(buffer,l_key,f_path); end_c return buffer end function *********** and now the old, but working version = ************************************* begin_c void FAR PASCAL _export encrypt(char *buffer,char *key,char *text){ int key_len; int p; int c_char; int key_pos; int text_len; key_len=3Dstrlen(key); text_len=3Dstrlen(text); for(p=3D0,key_pos=3D0;p<text_len;++p,++key_pos){ if(key_pos=3D=3Dkey_len) key_pos=3D0; c_char=3Dtext[p] ^ key[key_pos]; buffer[(p*2)]=3D'A'+(c_char/26); buffer[(p*2)+1]=3D'A'+(c_char%26); } buffer[text_len*2]=3D0; } void FAR PASCAL _export decrypt(char *buffer,char *key,char *text){ int key_len; int p; int c_char; int key_pos; int text_len; =20 key_len=3Dstrlen(key); text_len=3Dstrlen(text); if(strstr(text,".DBF")=3D=3DNULL) { =20 for(p=3D0,key_pos=3D0;(p*2)<text_len;++p,++key_pos){ if(key_pos=3D=3Dkey_len) key_pos=3D0; c_char=3D((text[(p*2)]-'A')*26)+(text[(p*2+1)]-'A'); buffer[p]=3Dc_char^ key[key_pos]; } buffer[p]=3D0; } else { strcpy(buffer,text); } } end_c #########################################################################= ############ function n_decrypt(l_key,f_path) variable f_path char(*) variable l_key char(*) variable buffer char(*) variable i integer let buffer=3D" " for i=3D1 to (length(f_path)) let buffer=3Dbuffer||" " end for begin_c decrypt(buffer,l_key,f_path); end_c return buffer=20 end function #########################################################################= ############ function n_encrypt(l_key,f_path) variable f_path char(*) variable l_key char(*) variable buffer char(*) variable i integer let buffer=3D" " for i=3D1 to (length(f_path)*2)-1 let buffer=3Dbuffer||" " end for begin_c encrypt(buffer,l_key,f_path); end_c return buffer end function ------=_NextPart_000_0005_01BDDB19.E6B8AD90 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.72.2106.6"' name=3DGENERATOR> </HEAD> <BODY> <DIV>Hi all,</DIV> <DIV>I have a dll written in New Era2.12 with embedded C in it = (VC1.51).</DIV> <DIV>I am trying to convert this to New Era 3.10 with embedded = VC5.0.</DIV> <DIV> </DIV> <DIV>I have changed obsolete keywords FAR, PASCAL etc in VC151 to = current=20 syntax. However, I still cannot compile.</DIV> <DIV> </DIV> <DIV>Has anyone any experience of this problem? Are there any tricks to=20 embedding C in ne3.10 (I have tried putting the=20 <STRONG>-</STRONG><STRONG>nosql</STRONG> in the New Era options from = library=20 template, still no joy).</DIV> <DIV> </DIV> <DIV>I have included both versions of code on the off chance that = someone is=20 very, very bored:</DIV> <DIV> </DIV> <DIV>Here we go, current version (non compiling) first</DIV> <DIV>********************************************************************= **********</DIV> <DIV><BR><FONT size=3D2>begin_c</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>BOOL __declspec( dllexport ) WINAPI encrypt(char = *buffer,char=20 *key,char *text){<BR> int key_len, p, c_char, key_pos, = text_len;<BR></FONT></DIV> <DIV><FONT size=3D2> = key_len=3Dstrlen(key);<BR> =20 text_len=3Dstrlen(text);</FONT></DIV> <DIV><FONT size=3D2> =20 for(p=3D0,key_pos=3D0;p<text_len;++p,++key_pos){<BR> = =20 if(key_pos=3D=3Dkey_len)=20 key_pos=3D0;<BR> &nb= sp; =20 c_char=3Dtext[p] ^=20 key[key_pos];<BR> &nb