Forum: Ruby Ruby / DL problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E4b00857b845342264923e3e6c504c14?d=identicon&s=25 Bama Test (Guest)
on 2006-05-24 18:37
(Received via mailing list)
I've got a DLL that I'm working on interfacing to  - i've got everything
working except for this one function.

int CreateDataFile ( const char* csUserID,
                                 const char* chOptionalTemplateFilePath,
                                 const char* csPrefix,
                                 const char* csSuffix,
                                 char*& newFileID);

the problem is with the newFileID parameter - it's defined as "points
to the buffer that receives the string of the File ID created. Maximum
length of this buffer is 20 bytes."

I've tried defining the call as both
@createfile = msg["CreateDataFile", "ISSSSP"]
and
@createfile = msg["CreateDataFile", "ISSSSS"]

and then passing in the values like this
x = ""
ptr = DL.malloc(20)
a = @createfile.call('eldon',x,x,x,ptr)

the function runs successfully but I can't ever retrieve the value of
the FileID created from ptr and from what I can tell It still looks
empty. So I figure I must either be defining it incorrectly or passing
it in the call wrong. From my memory of C the & is actually a pointer
to a memory location, but there seems something in my memory that it
might mean something different when referenced like this (it's been
like 10 years since i did anything in C) and I've done a ton of google
searches already.

Any guesses as to what i might be doing wrong?

Thanks

Eldon

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
E51d56251ec4affafe85ee9367228965?d=identicon&s=25 Park Heesob (Guest)
on 2006-05-25 05:03
(Received via mailing list)
Hi,

>                                  const char* chOptionalTemplateFilePath,
>and
>it in the call wrong. From my memory of C the & is actually a pointer
>to a memory location, but there seems something in my memory that it
>might mean something different when referenced like this (it's been
>like 10 years since i did anything in C) and I've done a ton of google
>searches already.
>
>Any guesses as to what i might be doing wrong?
>
define like this
@createfile = msg["CreateDataFile", "ISSSSP"]

and call like this

ptr = "\0" * 20
a = @createfile.call('eldon',x,x,x,[ptr].pack("P"))
puts ptr


Regards,

Park Heesob
This topic is locked and can not be replied to.