MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » March 2008

AW: GLib library for iSeries



fixed

I made an email request for the ported c source code to the address on the ibm page. If i get the c code, i could create the prototypes. I found an old glib version and the docs on the net (not so easy because of the aged version). What would really benefit the rpg community would be the data types/data containers of glib so you don't have to roll your own (too late for me cause i allready written my own linked list impl downloadable on my homepage). I got a simple program working with the glist data type.

I took a look at the current version of the g_list functions for the prototypes (and hoped that they hadn't changed =)

*---------------------------------------------------------------
* Prototypen
*---------------------------------------------------------------
D g_list_append PR * extproc('g_list_append')
D list * value
D dataPtr * value
*
D g_list_prepend PR * extproc('g_list_prepend')
D list * value
D dataPtr * value
*
D g_list_length PR 10U 0 extproc('g_list_length')
D list * value
*
D g_list_free PR extproc('g_list_free')
D list * value
*
D g_list_first PR * extproc('g_list_first')
D list * value

*---------------------------------------------------------------
* Datenstrukturen
*---------------------------------------------------------------
D glist DS qualified based(tmpl_ptr)
D data *
D next *
D prev *


*---------------------------------------------------------------
* Variablen
*---------------------------------------------------------------
D listPtr S * inz(*null)
D list DS likeds(glist) based(listPtr)
D ptr S *
D var S 40A based(ptr)
D tmpPtr S *
D tmpDS DS based(tmpPtr) likeds(glist)
D tmp S 50A


/free
dsply %trimr('List length: ' + %char(g_list_length(listPtr)));

ptr = %alloc(100);
var = 'Mihael Schmidt 1';
listPtr = g_list_append(listPtr : ptr);
ptr = %alloc(100);
var = 'Mihael Schmidt 2';
listPtr = g_list_append(listPtr : ptr);
ptr = %alloc(100);
var = 'Mihael Schmidt 3';
listPtr = g_list_append(listPtr : ptr);

dsply %trimr('List length: ' + %char(g_list_length(listPtr)));

tmpPtr = g_list_first(listPtr);
tmp = %str(tmpDS.data);
dsply tmp;

g_list_free(listPtr);

*inlr = *on;
return;
/end-free

As your c skill is probably miles over mine, does the prototypes make sense? And do you know if the g_list_free function also deallocates the memory so that i don't have to call dealloc for it?

And i still don't understand when i have to use the *CWIDEN keyword with the EXTPROC keyword.

Thanx in advance.

Mihael Schmidt

-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Scott Klement
Gesendet: Donnerstag, 27. März 2008 23:51
An: Midrange Systems Technical Discussion
Betreff: Re: GLib library for iSeries

Hi Mihael,

I thought the same thing... but I never found an include file (a copy
book for C programmers) with the prototypes, etc, for the GLIB service
program, so I never sat down and tried to use it from RPG.

I suppose I could go find the original glib.h on the web somewhere and
assume that IBM didn't change the prototypes... but I never really got
around to looking further...



Schmidt, Mihael wrote:
Hello,

i just noticed that there is a port of the glib c-library to the
iSeries. Does anybody has any experience (good or bad) with the
library on the iSeries (and perhaps with its usage in RPG).

The library can be downloaded here:
http://www-03.ibm.com/servers/enable/site/porting/iseries/overview/gnu_utilities.html


One thing that leaves me uncertain is the version of the library ,
1.2.2. That is a bit outdated. The current version is 2.16.1 afaik.






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact