Solved

Delphi and Tuxedo

Posted on 2001-06-18
7
1,332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month4 days, 4 hours left to enroll

630 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