struct generic_string *s; switch( Pike_sp[-1].type ) { case PIKE_T_OBJECT: if( FIRST_INHERIT( Pike_sp[-1].u.object ) == string_program ) s = (struct generic_string*)Pike_sp[-1].u.object->storage; break; case PIKE_T_STRING: s = (struct generic_string *)Pike_sp[-1].u.string; }
/ Per Hedbor ()
Previous text:
2003-01-30 15:45: Subject: Re: OpenSSL wrapper vs Pike's SSL (Was: Bz2)
For the general case, the C code would have to allocate a new char (or wchar_t, or whatever) array, probably on the stack, and then copy the contents of the general string object character by character using the `[] operator. You can't do it the easy way by casting the object to a normal pike string, as that defeats the entire purpose of SecretString.
Not at all nessesary if the SecretString inherits from, say, String, which in turn is implemented in C, with a storage identical to a struct pike_string, only not shared.
/ Per Hedbor ()