Solved

Delphi and Tuxedo

Posted on 2001-06-18
7
1,289 Views
Last Modified: 2008-03-03
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
Comment
Question by:Paul Sinnema
  • 3
  • 2
  • 2
7 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6203789
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
 
LVL 6

Expert Comment

by:zebada
ID: 6204126
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
 

Author Comment

by:Paul Sinnema
ID: 6208686
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6209089
Please send me the headers. I am a conversion specialist.
0
 

Author Comment

by:Paul Sinnema
ID: 6210402
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
 
LVL 6

Accepted Solution

by:
zebada earned 100 total points
ID: 6212859
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
 

Author Comment

by:Paul Sinnema
ID: 6223658
zebada,

Thanks for the effort.

Paul.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now