pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:2218:    struct object *co = Pike_fp->current_object;    ref_push_function(co, f_RandomInterface_random_string_fun_num);    /* FIXME: precompiler doesn't generate usable fun_nums for variant    symbols. */    ref_push_function(co, find_shared_string_identifier(MK_STRING("random"),    co->prog));    apply_low(o, f, 2);    }   }    + /** +  * Generates a random string of length len, using the current +  * random_string() function, and pushes it on the stack. +  */ + PMOD_EXPORT void push_random_string(unsigned len) + { +  struct svalue *random = +  simple_mapping_string_lookup(get_builtin_constants(), "random_string"); +  if(!random || (TYPEOF(*random) != T_FUNCTION)) +  Pike_error("Unable to resolve random function.\n"); +  push_int(len); +  apply_svalue(random, 1); +  if(TYPEOF(Pike_sp[-1])!=T_STRING || Pike_sp[-1].u.string->len != len) +  Pike_error("Couldn't generate random string.\n"); + } +    #ifdef __NT__   #include <wincrypt.h>   static HCRYPTPROV crypto_handle;   PIKECLASS RandomSystem   {    INHERIT RandomInterface;       PIKEFUN string(8bit) random_string(int len)    {    if( len<1 )