|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
KennyT
Joined: 02 Aug 2005 Posts: 317
|
Posted: Fri Mar 16, 2018 2:49 pm Post subject: passing strings back from C/C++ to FTN95 |
|
|
an old chestnut but i'm driving myself round in circles trying to make this work!
i have a routine written in C under VS2017:
int checkout_(char *feature, char *version, char* option, char *mess)
And i want to set the "mess" string back in FTN.
under VS, i can see that:
+ mess 0x32a20ed0 "Licensed number of users already reached.\nFeature: REP5\nLicense path: @localhost Licensing error:-4,132" char *
what do i have to set in my interface routine in FTN do get this back?
i've tried:
c_external checkout 'checkout_' (string, string, string, outstring) : integer*4
c_external checkout 'checkout_' (string, string, string, string) : integer*4
c_external checkout 'checkout_' (string, string, string, ref) : integer*4
with:
ierr = checkout(feature_t, ver_t, opt_t, mess)
what's thee correct way to do it, pretty please!
K |
|
Back to top |
|
|
KennyT
Joined: 02 Aug 2005 Posts: 317
|
Posted: Fri Mar 16, 2018 3:37 pm Post subject: |
|
|
ok, i've worked out a way to do it:
in C:
int checkout_(char *feature, char *version, char* option, char **mess)
in FTN:
stdcall checkout 'checkout_' (string, string, string, ref) : integer*4
iadd = loc(mess)
ierr = checkout(feature_t, ver_t, opt_t, iadd)
then the address IADD points to the string and can be copied byte-by-byte to a character variable, testing for CR or LF along the way.
not very elegant, but it seems to work.
K |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Mar 16, 2018 5:04 pm Post subject: |
|
|
If you look at the Windows API calls, many contain a length parameter to define how long the result can be so as not to over-run buffers.
That is what I use when coding "C" routines that need to return character values to FTN95. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|