in reply to A problem converting C code to XS

I would suggest using perl's ability to return multiple values. Your wrapper for getting the theme name could return both the error code and a regular perl string that way.

Update: Here is an example using Inline::C. You can examine the XS code it generates (a bit of ugly stuff, but it works).

use strict; use Inline (C => Config => CLEAN_AFTER_BUILD => 0); use Inline C => <<'END_OF_C_CODE'; void twoout() { int first = 42; char *second = "abc"; Inline_Stack_Vars; Inline_Stack_Reset; Inline_Stack_Push(sv_2mortal(newSViv(first))); Inline_Stack_Push(sv_2mortal(newSVpvn(second,3))); Inline_Stack_Done; } END_OF_C_CODE my ($num, $str) = twoout(); print "num = $num, str = $str\n";