[fpc-pascal] Resending: Trying to convert some C code
Ole J. Røtne
ole.rotne at online.no
Tue Nov 7 11:52:28 CET 2006
Hello again
My 5 year old kid did send this before I got it ready,
So here goes again..
Would any FPC guru help me converting this C code?
(it's from bn.h/libeay32.dll)
typedef struct bignum_st BIGNUM;
struct bignum_st
{
BN_ULONG *d;
int top;
int dmax;
int neg;
int flags;
};
char *BN_bn2hex(const BIGNUM *a);
I guess my problem is understanding pointers, and how they work.
Tried something like this (did cut some checks & stuff to
make it short):
Unit bn;
{$MODE DELPHI}{$H+}
interface
uses
DynLibs;
type
bignum_st = record
d:pointer;
dmax:integer;
neg:integer;
flag:integer;
end;
BIGNUM = bignum_st;
BNPtr = ^BIGNUM;
var
BnLibHandle: TLibHandle = 0;
function InitLib: Boolean;
function BN_Bn2Hex(const a:BNPtr):PChar;
implementation
Type
TBN_bn2hex = function(a:BNPtr):PChar;
var
_BnBn2Hex: TBN_bn2hex = nil;
function BN_Bn2Hex(a:BNPtr):PChar;
begin
_BnBn2Hex(a);
end;
Function InitLib:boolean;
Begin
LibHandle := LoadLibrary('libeay32.dll');
_BnBn2Hex := GetProcAddress( BnLibHandle, 'BN_bn2hex');
result := true;
End;
End.
Left bits of the code out, and probably to much.
But I hope you get the idea..
(memo to self: never get coffe while kids are alone at comp)
Ole JR
More information about the fpc-pascal
mailing list