forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

passing strings back from C/C++ to FTN95

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
KennyT



Joined: 02 Aug 2005
Posts: 317

PostPosted: Fri Mar 16, 2018 2:49 pm    Post subject: passing strings back from C/C++ to FTN95 Reply with quote

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
View user's profile Send private message Visit poster's website
KennyT



Joined: 02 Aug 2005
Posts: 317

PostPosted: Fri Mar 16, 2018 3:37 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1214
Location: Morrison, CO, USA

PostPosted: Fri Mar 16, 2018 5:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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