[Gambas-user] Calling library functions in Gambas2

easuter easuter at ...626...
Thu Aug 30 01:43:02 CEST 2007


Thanks Ron, but I'm not sure this is working out too well, lol 

What I need is to use parted to get the name (eg: xfs, reiserfs or ext3) of
the filesystem of a partition.
I've been battling to figure out which function in libparted exactly I need
and how to declare it (even after looking at the source code, which is
mostly lost on me since I haven no experience with C, just a few of the
basics).
I think that I need ped_filesystem_type_get
(http://www.gnu.org/software/parted/api/group__PedFileSystem.html#g7aedfb472456048086ebacb6c0f03836),
but have no idea how it should be declared in gambas to work properly.

Also, I'm not sure that this feature works 100%. 

For example, the simplest of all I tried just to test the EXTERN functions
in general it was:

PUBLIC EXTERN printf(stest AS String, itest AS Integer) AS String IN
"libc:6"

PUBLIC SUB main()
   PRINT printf("Testing string, now testing integer: %d", 5)
END

returns: Testing string, now testing integer: 5

That worked fine. However, calling the simplest function in libparted
(ped_get_version) did not return anything useful, but then again, I'm
probably doing something wrong.

PUBLIC EXTERN ped_get_version() AS String IN "libparted"

PUBLIC SUB main()
   PRINT ped_get_version()
END

returns an empty string.
If I make the extern declaration use an Integer as the return data-type for
ped_get_version, then a very useless number is returned (-1212003088).
Same happens when made to use Pointer and if I use
StrPtr(ped_get_version()), then the same empty string is returned as when I
use the String datatype.

I'd really appreciate any help in pointing out mistakes here, and if
possible some indicators as to what can be done about the
ped_filesystem_type_get function.

Cheers,

Eugéne
-- 
View this message in context: http://www.nabble.com/Calling-library-functions-in-Gambas2-tf4295859.html#a12398013
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list