pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2016-03-18
2016-03-18 20:39:47 by Martin Nilsson <nilsson@fastmail.com>
c1dfb3bc2e5417c08008be6e350cd42b0273eaff (
17
lines) (+
17
/-
0
)
[
Show
|
Annotate
]
Branch:
8.1
Deduplication of push_random_string
2225:
} }
+
/**
+
* 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;