[gimp] Added a getenv procedure to the ftx extension of Script-Fu.
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Added a getenv procedure to the ftx extension of Script-Fu.
- Date: Thu, 17 Mar 2011 21:48:32 +0000 (UTC)
commit 5c07d3b52da954503f5ecf4786ef8f1ca9c29e33
Author: Kevin Cozens <kcozens cvs gnome org>
Date: Sun Mar 6 17:33:32 2011 -0500
Added a getenv procedure to the ftx extension of Script-Fu.
plug-ins/script-fu/ftx/ftx.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/script-fu/ftx/ftx.c b/plug-ins/script-fu/ftx/ftx.c
index 0f67815..81386d8 100644
--- a/plug-ins/script-fu/ftx/ftx.c
+++ b/plug-ins/script-fu/ftx/ftx.c
@@ -48,6 +48,8 @@ pointer foreign_diropenstream(scheme *sc, pointer args);
pointer foreign_dirreadentry(scheme *sc, pointer args);
pointer foreign_dirrewind(scheme *sc, pointer args);
pointer foreign_dirclosestream(scheme *sc, pointer args);
+
+pointer foreign_getenv(scheme *sc, pointer args);
pointer foreign_time(scheme *sc, pointer args);
pointer foreign_gettimeofday(scheme *sc, pointer args);
pointer foreign_usleep(scheme *sc, pointer args);
@@ -242,6 +244,31 @@ pointer foreign_dirclosestream(scheme *sc, pointer args)
}
+pointer foreign_getenv(scheme *sc, pointer args)
+{
+ pointer first_arg;
+ pointer ret;
+ char *varname;
+ const char *value;
+
+ if (args == sc->NIL)
+ return sc->F;
+
+ first_arg = sc->vptr->pair_car(args);
+
+ if (!sc->vptr->is_string(first_arg))
+ return sc->F;
+
+ varname = sc->vptr->string_value(first_arg);
+ value = g_getenv(varname);
+ if (value == NULL)
+ ret = sc->F;
+ else
+ ret = sc->vptr->mk_string(sc,value);
+
+ return ret;
+}
+
pointer foreign_time(scheme *sc, pointer args)
{
time_t now;
@@ -301,6 +328,9 @@ void init_ftx (scheme *sc)
{
int i;
+ sc->vptr->scheme_define(sc,sc->global_env,
+ sc->vptr->mk_symbol(sc,"getenv"),
+ sc->vptr->mk_foreign_func(sc, foreign_getenv));
sc->vptr->scheme_define(sc, sc->global_env,
sc->vptr->mk_symbol(sc,"time"),
sc->vptr->mk_foreign_func(sc, foreign_time));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]