Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1358
  • Last Modified:

Delphi and Tuxedo

I have a C++ headerfile containing the C prototypes for calling functions in a DLL (fml32.dll of Tuxedo). How do I convert these to be used with Delphi?
0
Paul Sinnema
Asked:
Paul Sinnema
  • 3
  • 2
  • 2
1 Solution
 
robert_marquardtCommented:
Send the headers to me (robert_marquardt@gmx.de).
I will give it a try. If the DLL is not too big then add it also.
I am member of Project JEDI (http://delphi-jedi.org). Director to be precise :-)
Please consider donating the conversion.
0
 
zebadaCommented:
This might help you get started... you get the idea - it's fairly easy to add more FML32 functions.

The following is extracted from my FML32/ATMI wrapper objects that I have developed for Delphi. Let me know if you need anymore info/examples.

const
  LIBFML32_DLL = 'libfml32.dll';
  LIBWSC_DLL = 'wtuxws32.dll';

  BADFLDID = 0;
  FIRSTFLDID = 0;

  FMINVAL = 0;                        // bottom of error message codes
  FALIGNERR = 1;                      // fielded buffer not aligned
  FNOTFLD = 2;                        // buffer not fielded
  FNOSPACE = 3;                       // no space in fielded buffer
  FNOTPRES = 4;                       // field not present
  FBADFLD = 5;                        // unknown field number or type
  FTYPERR = 6;                        // illegal field type
  FEUNIX = 7;                         // unix system call error
  FBADNAME = 8;                       // unknown field name
  FMALLOC = 9;                        // malloc failed
  FSYNTAX = 10;                       // bad syntax in boolean expression
  FFTOPEN = 11;                       // cannot find or open field table
  FFTSYNTAX = 12;                     // syntax error in field table
  FEINVAL = 13;                       // invalid argument to function
  FBADTBL = 14;                       // destructive concurrent access to field table
  FBADVIEW = 15;                      // cannot find or get view
  FVFSYNTAX = 16;                     // bad viewfile
  FVFOPEN = 17;                       // cannot find or open viewfile
  FBADACM = 18;                       // ACM contains negative value
  FNOCNAME = 19;                      // cname not found
  FEBADOP = 20;                       // operation invalid for field type
  FMAXVAL = 21;                       // top of error message codes

  FLD_SHORT = 0;                      // Short integer
  FLD_LONG = 1;                       // Long integer
  FLD_CHAR = 2;                       // Character
  FLD_FLOAT = 3;                      // single-precision
  FLD_DOUBLE = 4;                     // double precision
  FLD_STRING = 5;                     // null terminated string
  FLD_CARRAY = 6;                     // Binary
                                      // 7 reserved for FLD_INT
                                      // 8 reserved for FLD_DECIMAL
  FLD_PTR = 9;                        // Pointer
  FLD_FML32 = 10;                     // Embedded FML32
  FLD_VIEW32 = 11;                    // Embedded VIEW32

type
// -------------------------------------------------------------------------
  FLDID = longword;
  PFLDID = ^longword;
  FLDLEN = longword;
  PFLDLEN = ^longword;
  FLDOCC = longint;
  PFLDOCC = ^longint;


function fml_getFerror: integer; stdcall; external LIBFML32_DLL name 'getFerror32';
function fml_Fstrerror(err: integer): Pointer; stdcall; external LIBFML32_DLL name 'Fstrerror32';

function fml_Flen(fbfr: Pointer; fieldid: FLDID; occ: FLDOCC): FLDLEN; stdcall; external LIBFML32_DLL name 'Flen32';
function fml_Ftypcvt(tolen: PFLDLEN; totype: integer; fromval: Pointer; fromtype: integer; fromlen: FLDLEN): Pointer; stdcall; external LIBFML32_DLL name 'Ftypcvt32';
function fml_Fadd(fbfr: Pointer; fieldid: FLDID; value: Pointer; len: FLDLEN): integer; stdcall; external LIBFML32_DLL name 'Fadd32';
function fml_Fget(fbfr: Pointer; fieldid: FLDID; occ: FLDOCC; value: Pointer; len: PFLDLEN): integer; stdcall; external LIBFML32_DLL name 'Fget32';
function fml_Fchg(fbfr: Pointer; fieldid: FLDID; occ: FLDOCC; value: Pointer; len: FLDLEN): integer; stdcall; external LIBFML32_DLL name 'Fchg32';

function fml_Finit(fbfr: Pointer; len: FLDLEN): integer; stdcall; external LIBFML32_DLL name 'Finit32';
function fml_Fsizeof(fbfr: Pointer): integer; stdcall; external LIBFML32_DLL name 'Fsizeof32';
function fml_Fused(fbfr: Pointer): integer; stdcall; external LIBFML32_DLL name 'Fused32';
function fml_Funused(fbfr: Pointer): integer; stdcall; external LIBFML32_DLL name 'Funused32';
function fml_Fnum(fbfr: Pointer): integer; stdcall; external LIBFML32_DLL name 'Fnum32';
function fml_Fidxused(fbfr: Pointer): integer; stdcall; external LIBFML32_DLL name 'Fidxused32';

function fml_Foccur(fbfr: Pointer; fieldid: FLDID): integer; stdcall; external LIBFML32_DLL name 'Foccur32';
function fml_FNext(fbfr: Pointer; fieldid: PFLDID; occ: PFLDOCC; value: Pointer; len: PFLDLEN): integer; stdcall; external LIBFML32_DLL name 'Fnext32';

function fml_Fname(fieldid: FLDID): PChar; stdcall; external LIBFML32_DLL name 'Fname32';
function fml_Ftype(fieldid: FLDID): PChar; stdcall; external LIBFML32_DLL name 'Ftype32';
function fml_Fldtype(fieldid: FLDID): integer; stdcall; external LIBFML32_DLL name 'Fldtype32';
function fml_Fldid(fieldname: PChar): integer; stdcall; external LIBFML32_DLL name 'Fldid32';
0
 
Paul SinnemaAuthor Commented:
How do I implement your code. I've tried to create a Unit with it, but the functions are not know outside the unit. Do I need to import them or something?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
robert_marquardtCommented:
Please send me the headers. I am a conversion specialist.
0
 
Paul SinnemaAuthor Commented:
I believe the problem is bit bigger then I expected. I now know how to implement the code above, but I'm not able to connect to Tuxedo. I think this is because I'm unable to us the 'buildclient' process of Tuxedo. How did you implement the connection?
0
 
zebadaCommented:
You don't need to connect to TUXEDO to use the fml32 dll functions.

If, however, you want to invoke services then that obviously requires a connection to TUXEDO.

Here's some relevant bits of code.
Let me know if you need more info.

const
  LIBWSC_DLL = 'wtuxws32.dll';
  MAXTIDENT = 30;
  MAXUSERDATA = 32;

type
  PPointer = ^Pointer;

  TTpinit = record
    Usrname: array[0..MAXTIDENT-1+2] of char;
    Cltname: array[0..MAXTIDENT-1+2] of char;
    Passwd: array[0..MAXTIDENT-1+2] of char;
    Grpname: array[0..MAXTIDENT-1+2] of char;
    Flags: integer;
    DataLen: integer;
    Data: array[0..MAXUSERDATA-1] of char;
  end;

var
  tpinfo: ^TTpinit;

function atmi_gettpurcode: longint; stdcall; external LIBWSC_DLL name 'gettpurcode';
function atmi_gettperrno: longint; stdcall; external LIBWSC_DLL name 'gettperrno';
function atmi_tpstrerror(err: integer): Pointer; stdcall; external LIBWSC_DLL name 'tpstrerror';

function atmi_tuxputenv(ptr: Pointer): longint stdcall; external LIBWSC_DLL name 'tuxputenv';

function atmi_tpalloc(type_: Pointer; subtype: Pointer; size: longint): Pointer; stdcall; external LIBWSC_DLL name 'tpalloc';
procedure atmi_tpfree(ptr: Pointer); stdcall; external LIBWSC_DLL name 'tpfree';

function atmi_tpinit(tpinfo: Pointer): integer; stdcall; external LIBWSC_DLL name 'tpinit';
function atmi_tpterm: longint; stdcall; external LIBWSC_DLL name 'tpterm';

function atmi_tpcall(svc: PChar; idata: Pointer; ilen: longint; odata: PPointer; olen: Pointer; flags: longint): integer; stdcall; external LIBWSC_DLL name 'tpcall';

// Sample code - in real life you would pass in all the
// relevant parameters.
procedure TAtmi.Connect(wsnaddr: string);
var
  data: string;
  u,c,ap,g,up: string
begin
  u := 'JamesBond';
  c := 'MyProgramName';
  ap := 'ApplicationPassword'; // Specified when tmloadcf is executed.
  g := '';  // Leave groupname blank if not using XA
  up := 'UserPassword';

  if ( atmi_tuxputenv(PChar(wsnaddr))<0 ) then
    raise EAtmi.Create;

  StrCopy(tpinfo.Usrname,PChar(Copy(UsrName,1,MAXTIDENT)));
  StrCopy(tpinfo.Cltname,PChar(Copy(c,1,MAXTIDENT)));
  StrCopy(tpinfo.Passwd,PChar(Copy(ap,1,MAXTIDENT)));
  tpinfo.Flags := 0;
  StrCopy(tpinfo.Grpname,PChar(Copy(g,1,MAXTIDENT)));
  data := Copy(up,1,MAXUSERDATA);
  StrCopy(tpinfo.Data,PChar(data));
  tpinfo.Data[Length(data)] := Chr(0);
  tpinfo.DataLen := Length(data)+1;

  if ( atmi_tpinit(tpinfo)<0 ) then
    // Can't connect
  else
    // Connection OK
end;


0
 
Paul SinnemaAuthor Commented:
zebada,

Thanks for the effort.

Paul.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now