cvsuser     04/07/21 06:24:20

  Modified:    classes  env.pmc
  Log:
  Add get/set pmc to env
  
  Revision  Changes    Path
  1.15      +62 -1     parrot/classes/env.pmc
  
  Index: env.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/env.pmc,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -w -r1.14 -r1.15
  --- env.pmc   10 Jul 2004 15:30:37 -0000      1.14
  +++ env.pmc   21 Jul 2004 13:24:20 -0000      1.15
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: env.pmc,v 1.14 2004/07/10 15:30:37 leo Exp $
  +$Id: env.pmc,v 1.15 2004/07/21 13:24:20 dan Exp $
   
   =head1 NAME
   
  @@ -78,6 +78,41 @@
   
   /*
   
  +=item C<STRING *get_pmc_keyed(PMC *key)>
  +
  +Returns a String PMC for the environment variable C<*key>.
  +
  +=cut
  +
  +*/
  +
  +    PMC* get_pmc_keyed(PMC* key) {
  +        char *keyname = string_to_cstring(interpreter,
  +            VTABLE_get_string(interpreter, key));
  +        int free_it = 0;
  +        STRING *retval;
  +        PMC *return_pmc;
  +        char *val = NULL;
  +
  +        if (keyname) {
  +            val = Parrot_getenv(keyname, &free_it);
  +            string_cstring_free(keyname);
  +            if (val) {
  +                retval = string_from_cstring(interpreter, val, 0);
  +            } else {
  +                retval = string_from_cstring(interpreter, "", 0);
  +            }
  +        } else {
  +            retval = string_from_cstring(interpreter, "", 0);
  +        }
  +        if (free_it && val) mem_sys_free(val);
  +        return_pmc = pmc_new(INTERP, enum_class_String);
  +        VTABLE_set_string_native(INTERP, return_pmc, retval);
  +        return return_pmc;
  +    }
  +
  +/*
  +
   =item C<void set_string_keyed(PMC *key, STRING *value)>
   
   Sets the environment variable C<*key> to C<*value>.
  @@ -103,6 +138,32 @@
   
   /*
   
  +=item C<void set_pmc_keyed(PMC *key, PMC *value)>
  +
  +Sets the environment variable C<*key> to C<*value>.
  +
  +=cut
  +
  +*/
  +
  +    void set_pmc_keyed(PMC* key, PMC* value) {
  +        char *keyname = string_to_cstring(interpreter,
  +            VTABLE_get_string(interpreter, key));
  +        STRING *str_value = VTABLE_get_string(INTERP, value);
  +        char *env_val = string_to_cstring(interpreter, str_value);
  +        if (keyname && env_val) {
  +            Parrot_setenv(keyname, env_val);
  +        }
  +        if (keyname) {
  +            string_cstring_free(keyname);
  +        }
  +        if (env_val) {
  +            string_cstring_free(env_val);
  +        }
  +    }
  +
  +/*
  +
   =item C<INTVAL exists_keyed(PMC *key)>
   
   Returns whether the environment variable for C<*key> exists.
  
  
  

Reply via email to