<s>
GTK-server	B-Language
is	O
an	O
open-source	B-Application
project	O
released	O
under	O
the	O
GNU	B-License
General	I-License
Public	I-License
License	I-License
.	O
</s>
<s>
The	O
GTK-server	B-Language
project	O
aims	O
to	O
bring	O
Graphical	B-Application
User	I-Application
Interface	I-Application
programming	O
to	O
any	O
interpreted	B-Application
language	I-Application
using	O
the	O
GIMP	B-Application
Tool	I-Application
Kit	I-Application
(	O
GTK	B-Application
)	O
or	O
XForms	B-Application
.	O
</s>
<s>
The	O
GTK-server	B-Language
provides	O
a	O
stream-oriented	O
interface	O
to	O
GTK	B-Application
.	O
</s>
<s>
If	O
the	O
GTK-server	B-Language
is	O
compiled	O
as	O
a	O
standalone	O
binary	O
,	O
it	O
allows	O
five	O
different	O
interfaces	O
:	O
stdin	O
,	O
fifo	O
(	O
named	B-Operating_System
pipe	I-Operating_System
)	O
,	O
ipc	O
(	O
message	B-Operating_System
queue	I-Operating_System
)	O
,	O
tcp	O
or	O
udp	O
.	O
</s>
<s>
Any	O
interpreted	B-Application
language	I-Application
or	O
shellscript	O
with	O
I/O	O
capabilities	O
can	O
start	O
the	O
GTK-server	B-Language
with	O
an	O
argument	O
specifying	O
the	O
type	O
of	O
interface	O
,	O
and	O
can	O
start	O
sending	O
GTK	B-Application
function	O
calls	O
in	O
S-Expression	B-Protocol
format	O
.	O
</s>
<s>
After	O
each	O
request	O
,	O
the	O
GTK-server	B-Language
returns	O
a	O
result	O
,	O
depending	O
on	O
the	O
type	O
of	O
GTK	B-Application
function	O
invoked	O
.	O
</s>
<s>
If	O
the	O
GTK-server	B-Language
is	O
compiled	O
as	O
a	O
shared	O
object	O
,	O
it	O
exports	O
the	O
function	O
'	O
gtk	B-Application
 '	O
,	O
which	O
must	O
be	O
imported	O
in	O
the	O
client	O
program	O
first	O
.	O
</s>
<s>
After	O
that	O
,	O
the	O
client	O
program	O
can	O
start	O
sending	O
GTK	B-Application
function	O
calls	O
in	O
S-Expression	B-Protocol
format	O
as	O
argument	O
to	O
the	O
imported	O
'	O
gtk	B-Application
 '	O
function	O
.	O
</s>
<s>
Before	O
the	O
GTK-server	B-Language
actually	O
can	O
execute	O
GTK	B-Application
functions	O
,	O
it	O
has	O
to	O
read	O
a	O
configuration	O
file	O
in	O
which	O
the	O
prototypes	O
of	O
the	O
GTK	B-Application
functions	O
are	O
described	O
.	O
</s>
<s>
Since	O
version	O
2.2.3	O
this	O
also	O
can	O
be	O
done	O
on-the-fly	O
,	O
allowing	O
the	O
GTK-server	B-Language
to	O
run	O
without	O
configuration	O
file	O
.	O
</s>
<s>
Implementing	O
the	O
GTK-server	B-Language
leads	O
to	O
the	O
following	O
considerations	O
.	O
</s>
<s>
Accessing	O
foreign	O
functions	O
is	O
only	O
possible	O
when	O
the	O
accessed	O
libraries	O
are	O
created	O
with	O
a	O
non	O
object	B-Language
oriented	I-Language
programming	I-Language
language	I-Language
like	O
C	B-Language
or	O
Pascal	O
.	O
</s>
<s>
Libraries	O
created	O
with	O
C++	B-Language
for	O
example	O
,	O
use	O
name	B-Language
mangling	I-Language
in	O
order	O
to	O
unify	O
overloaded	B-Language
functions	I-Language
.	O
</s>
<s>
This	O
means	O
that	O
the	O
actual	O
functionname	O
in	O
a	O
C++	B-Language
library	O
cannot	O
be	O
known	O
once	O
the	O
shared	O
library	O
has	O
been	O
compiled	O
.	O
</s>
<s>
Therefore	O
,	O
libraries	O
like	O
wxWidgets	B-Language
,	O
the	O
Qt	B-Language
toolkit	I-Language
,	O
FLTK	B-Language
which	O
are	O
programmed	O
in	O
C++	B-Language
,	O
cannot	O
be	O
accessed	O
with	O
the	O
GTK-server	B-Language
concept	O
.	O
</s>
<s>
The	O
GTK	B-Application
library	O
was	O
implemented	O
in	O
the	O
C	B-Language
programming	I-Language
language	I-Language
.	O
</s>
<s>
Since	O
C	B-Language
is	O
a	O
strongly	O
typed	O
programming	O
language	O
,	O
the	O
interpreted	O
program	O
needs	O
to	O
know	O
the	O
type	O
of	O
arguments	O
and	O
the	O
type	O
of	O
the	O
return	O
value	O
for	O
each	O
GTK	B-Application
function	O
during	O
runtime	O
.	O
</s>
<s>
These	O
can	O
be	O
defined	O
on-the-fly	O
or	O
in	O
a	O
configuration	O
file	O
,	O
which	O
is	O
parsed	O
by	O
the	O
GTK-server	B-Language
during	O
startup	O
.	O
</s>
<s>
However	O
,	O
the	O
GTK-server	B-Language
does	O
not	O
know	O
the	O
actual	O
functions	O
which	O
are	O
going	O
to	O
be	O
used	O
by	O
the	O
interpreted	O
client	O
program	O
,	O
so	O
for	O
GTK-server	B-Language
all	O
arguments	O
and	O
return	O
values	O
for	O
each	O
GTK	B-Application
function	O
are	O
variable	O
types	O
.	O
</s>
<s>
This	O
leads	O
to	O
a	O
problem	O
for	O
the	O
implementation	O
,	O
because	O
the	O
GTK	B-Application
functions	O
and	O
the	O
corresponding	O
arguments	O
and	O
return	O
values	O
cannot	O
be	O
hardcoded	O
into	O
the	O
GTK-server	B-Language
binary	O
.	O
</s>
<s>
The	O
way	O
to	O
resolve	O
this	O
is	O
by	O
using	O
a	O
foreign	B-Application
function	I-Application
interface	I-Application
.	O
</s>
<s>
Currently	O
,	O
four	O
external	O
foreign	B-Application
function	I-Application
interfaces	I-Application
are	O
supported	O
by	O
GTK-server	B-Language
:	O
libffi	B-Language
,	O
FFCALL	O
,	O
C/Invoke	O
and	O
dyncall	O
.	O
</s>
<s>
One	O
of	O
these	O
libraries	O
should	O
be	O
available	O
on	O
the	O
target	O
system	O
,	O
in	O
order	O
to	O
compile	O
the	O
GTK-server	B-Language
successfully	O
.	O
</s>
<s>
The	O
following	O
KornShell	B-Language
script	O
starts	O
the	O
GTK-server	B-Language
in	O
stdin	O
mode	O
,	O
and	O
creates	O
a	O
simple	O
window	O
with	O
an	O
exit	O
button	O
:	O
</s>
<s>
Although	O
GTK	B-Application
was	O
meant	O
to	O
be	O
used	O
with	O
the	O
C	B-Language
programming	I-Language
language	I-Language
,	O
it	O
is	O
now	O
possible	O
to	O
use	O
GTK	B-Application
from	O
any	O
interpreted	B-Application
language	I-Application
without	O
changing	O
the	O
actual	O
implementation	O
of	O
the	O
interpreter	B-Application
.	O
</s>
<s>
Also	O
,	O
GTK	B-Application
1.x	O
,	O
GTK2.x	O
and	O
GTK	B-Application
3.x	O
can	O
be	O
reached	O
.	O
</s>
<s>
Optionally	O
,	O
any	O
other	O
shared	O
library	O
can	O
be	O
used	O
,	O
like	O
OpenGL	B-Application
related	O
libraries	O
,	O
Poppler	B-Language
,	O
Mozilla	B-Operating_System
,	O
but	O
also	O
libc	B-Language
,	O
sqlite	B-Language
and	O
a	O
music	O
library	O
like	O
MikMod	O
.	O
</s>
<s>
When	O
using	O
the	O
GTK-server	B-Language
as	O
a	O
standalone	O
binary	O
,	O
it	O
inevitably	O
creates	O
an	O
additional	O
process	O
in	O
the	O
processlist	O
.	O
</s>
<s>
Also	O
,	O
GTK	B-Application
functions	O
defined	O
as	O
a	O
macro	O
cannot	O
be	O
reached	O
by	O
a	O
client	O
program	O
.	O
</s>
