1TYPEMAP
2
3GSSAPI::Status					T_OBJ_NU
4
5GSSAPI::Name					PTROBJ_
6GSSAPI::OID					PTROBJ_
7GSSAPI::OID::Set				PTROBJ_
8GSSAPI::Cred					PTROBJ_
9GSSAPI::Context					PTROBJ_
10GSSAPI::Binding					PTROBJ_
11
12GSSAPI::OID_const				PTROBJ_CONST
13GSSAPI::OID::Set_const				PTROBJ_CONST
14
15GSSAPI::Name_out				PTROBJ_OUT
16GSSAPI::Cred_out				PTROBJ_OUT
17GSSAPI::OID_out					PTROBJ_OUT
18GSSAPI::OID::Set_out				PTROBJ_OUT
19GSSAPI::Context_out				PTROBJ_OUT
20GSSAPI::Binding_out				PTROBJ_OUT
21I32_out						T_IV_OUT
22int_out						T_IV_OUT
23gss_cred_usage_t_out				T_IV_OUT
24U32_out						T_U_LONG_OUT
25OM_uint32_out					T_IV_OUT
26
27GSSAPI::Name_optout				PTROBJ_OPTOUT
28GSSAPI::Cred_optout				PTROBJ_OPTOUT
29GSSAPI::OID_optout				PTROBJ_OPTOUT
30GSSAPI::OID::Set_optout				PTROBJ_OPTOUT
31I32_optout					T_IV_OPTOUT
32int_optout					T_IV_OPTOUT
33gss_cred_usage_t_optout				T_IV_OPTOUT
34U32_optout					T_U_LONG_OPTOUT
35OM_uint32_optout				T_IV_OPTOUT
36
37GSSAPI::Name_opt				PTROBJ_OPT
38GSSAPI::OID_opt					PTROBJ_OPT
39GSSAPI::OID::Set_opt				PTROBJ_OPT
40GSSAPI::Cred_opt				PTROBJ_OPT
41GSSAPI::Context_opt				PTROBJ_OPT
42GSSAPI::Binding_opt				PTROBJ_OPT
43
44gss_buffer_desc					T_BUFFER_DESC
45gss_buffer_desc_out				T_BUFFER_DESC_OUT
46gss_buffer_desc_copy				T_BUFFER_DESC_COPY
47gss_buffer_str					T_BUFFER_STR
48gss_buffer_str_out				T_BUFFER_STR_OUT
49gss_oidstr_out                  T_BUFFER_OIDSTR_OUT
50gss_cred_usage_t				T_IV
51gss_qop_t					T_UV
52OM_uint32					T_U_LONG
53
54GSSAPI_obj					PTROBJ_OPT
55
56#
57#	Okay, what at T_OBJ_NU, PTROBJ and PTROBJ_OPT?
58#
59#	T_OBJ_NU is a small object which can be freely copied: it must
60#	not contain pointers and is effectively passwd by value-return
61#
62
63INPUT
64
65T_OBJ_NU
66	if (!SvOK($arg)) {
67	    Zero(&$var, 1, ${type});
68	}
69	else if (sv_derived_from($arg, \"${ntype}\")) {
70	    SV *	tmp = SvRV($arg);
71	    STRLEN	len;
72	    char *	tmpc = SvPV(tmp, len);
73	    if (len != sizeof($var)) {
74		croak(\"$var is not of type ${ntype} (wrong size)\");
75	    }
76	    Copy(tmpc, &$var, 1, ${type});
77	}
78	else {
79	    croak(\"$var is not of type ${ntype}\");
80	}
81
82PTROBJ_
83	if (sv_derived_from($arg, \"${ntype}\")) {
84	    SV *tmp = SvRV($arg);
85	    $var = (${type}) SvIV(tmp);
86	    if ($var == NULL) {
87		croak(\"$var has no value\");
88	    }
89	}
90	else {
91	    croak(\"$var is not of type ${ntype}\");
92	}
93
94PTROBJ_CONST
95	"This should not happen"
96
97PTROBJ_OPT
98	if (!SvOK($arg)) {
99	    $var = NULL;
100	}
101	else if (sv_derived_from($arg, \"${ \substr($ntype, 0, -4) }\")) {
102	    SV *tmp = SvRV($arg);
103	    $var = (${type}) SvIV(tmp);
104	}
105	else {
106	    croak(\"$var is not of type ${ \substr($ntype, 0, -4) }\");
107	}
108
109PTROBJ_OUT
110	if (SvREADONLY($arg)) {
111	    croak(\"Modification of a read-only value attempted, $var\");
112	}
113	$var = NULL;
114
115PTROBJ_OPTOUT
116	if (SvREADONLY($arg)) {
117	    $var = NULL;
118	}
119	else {
120	    $var = &${var}_real;
121	    ${var}_real = NULL;
122	}
123
124T_IV_OUT
125	if (SvREADONLY($arg)) {
126	    croak(\"Modification of a read-only value attempted, $var\");
127	}
128	$var = 0;
129
130T_U_LONG_OUT
131	if (SvREADONLY($arg)) {
132	    croak(\"Modification of a read-only value attempted, $var\");
133	}
134	$var = 0;
135
136T_IV_OPTOUT
137	if (SvREADONLY($arg)) {
138	    $var = NULL;
139	} else {
140	    $var = &${var}_real;
141	    ${var}_real = 0;
142	}
143
144T_U_LONG_OPTOUT
145	if (SvREADONLY($arg)) {
146	    $var = NULL;
147	} else {
148	    $var = &${var}_real;
149	    ${var}_real = 0;
150	}
151
152T_BUFFER_DESC
153	$var.value = SvPV($arg, $var.length);
154
155T_BUFFER_DESC_OUT
156	$var.length = 0;
157	$var.value = NULL;
158
159T_BUFFER_DESC_COPY
160	if (!SvOK($arg)) {
161	    $var.length = 0;
162	    $var.value = NULL;
163	} else {
164	    void *p = SvPV($arg, $var.length);
165	    New(0, $var.value, $var.length, char);
166	    Copy(p, $var.value, $var.length, char);
167	}
168
169T_BUFFER_STR
170	$var.value = SvPV($arg, $var.length);
171	if ($var.length) {
172	    if (((char*)$var.value)[$var.length-2] != '\\0' &&
173		((char*)$var.value)[$var.length-1]   == '\\0')
174		$var.length++;
175	} else if (((char*)$var.value)[0] == '\\0') {
176	    $var.length++;
177	}
178
179T_BUFFER_STR_OUT
180	$var.length = 0;
181	$var.value = NULL;
182
183T_BUFFER_OIDSTR_OUT
184    $var.length = 0;
185    $var.value = NULL;
186
187
188
189OUTPUT
190
191T_OBJ_NU
192	sv_setref_pvn($arg, \"${ntype}\", (void*)&$var, sizeof($var));
193
194PTROBJ_
195	{
196	    SV *tmp = SvRV($arg);
197	    if ((IV)(void*)$var != SvIV(tmp)) {
198		sv_setref_iv($arg, \"${ntype}\", (IV)(void*)$var);
199	    }
200	}
201
202PTROBJ_CONST
203	SvREADONLY_on(sv_setref_iv($arg, \"${ \substr($ntype, 0, -6) }\",
204				   (IV)(void*)$var));
205
206PTROBJ_OPT
207	if (!SvOK($arg)) {
208	    sv_setref_iv($arg, \"${ \substr($ntype, 0, -4) }\",
209					(IV)(void*)$var);
210	}
211	else {
212	    SV *tmp = SvRV($arg);
213	    if ((IV)(void*)$var != SvIV(tmp)) {
214		sv_setref_iv($arg, \"${ \substr($ntype, 0, -4) }\",
215					    (IV)(void*)$var);
216	    }
217	}
218
219PTROBJ_OUT
220	sv_setref_iv($arg, \"${ \substr($ntype, 0, -4) }\", (IV)(void*)$var);
221
222PTROBJ_OPTOUT
223	if ($var != NULL) {
224	    sv_setref_iv($arg, \"${ \substr($ntype, 0, -7) }\",
225					(IV)(void*)${var}_real);
226	}
227
228T_IV_OUT
229	sv_setiv_mg($arg, $var);
230
231T_U_LONG_OUT
232	sv_setuv_mg($arg, (UV)$var);
233
234T_IV_OPTOUT
235	if ($var != NULL) {
236	    sv_setiv_mg($arg, ${var}_real);
237	}
238
239T_U_LONG_OPTOUT
240	if ($var != NULL) {
241	    sv_setuv_mg($arg, (UV)${var}_real);
242	}
243
244T_BUFFER_DESC
245	if (SvREADONLY($arg)) {
246	} else if ($var.value != NULL) {
247	    sv_setpvn_mg($arg, $var.value, $var.length);
248	} else {
249	    sv_setsv_mg($arg, &PL_sv_undef);
250	}
251	{
252	    OM_uint32 minor;
253	    gss_release_buffer(&minor, &$var);
254	}
255
256T_BUFFER_DESC_OUT
257	if (SvREADONLY($arg)) {
258	} else if ($var.value != NULL) {
259	    sv_setpvn_mg($arg, $var.value, $var.length);
260	} else {
261	    sv_setsv_mg($arg, &PL_sv_undef);
262	}
263	{
264	    OM_uint32 minor;
265	    gss_release_buffer(&minor, &$var);
266	}
267
268T_BUFFER_DESC_COPY
269	if (SvREADONLY($arg)) {
270	} else if ($var.value != NULL) {
271	    sv_setpvn_mg($arg, $var.value, $var.length);
272	} else {
273	    sv_setsv_mg($arg, &PL_sv_undef);
274	}
275
276T_BUFFER_STR
277	if ($var.value != NULL) {
278	    sv_setpv($arg, $var.value);
279	    SvSETMAGIC($arg);
280	} else {
281	    sv_setsv_mg($arg, &PL_sv_undef);
282	}
283	{
284	    OM_uint32 minor;
285	    gss_release_buffer(&minor, &$var);
286	}
287
288
289T_BUFFER_STR_OUT
290	if ($var.value != NULL) {
291            sv_setpvn($arg, $var.value, $var.length);
292	    SvSETMAGIC($arg);
293	} else {
294	    sv_setsv_mg($arg, &PL_sv_undef);
295	}
296	{
297	    OM_uint32 minor;
298	    gss_release_buffer(&minor, &$var);
299	}
300
301T_BUFFER_OIDSTR_OUT
302    if ($var.value != NULL) {
303            sv_setpv($arg, $var.value );
304        SvSETMAGIC($arg);
305    } else {
306        sv_setsv_mg($arg, &PL_sv_undef);
307    }
308    {
309        OM_uint32 minor;
310        gss_release_buffer(&minor, &$var);
311    }
312
313#
314#	Okay, what do all these different typemaps do?  Anything that
315#	starts with "PTROBJ" deals with references to objects.  The
316#	different versions just allow for different calling conventions.
317#	For example, while the basic PTROBJ typemap requires that a
318#	non-undef value be passed in, the PTROBJ_OPT typemap will
319#	map an undef to the C NULL value (these are all only used with C
320#	pointer types).  The PTROBJ type is similar to the standard
321#	typemap T_PTROBJ, the difference being that on output,
322#	T_PTROBJ will turn the C NULL pointer into a reference to
323#	undef while PTROBJ_OPT will still return a blessed value.
324#
325#
326#			uses	 may	 may	 may	 may	 outputs
327#	name		input	input	input	input	output	  const
328#			value	undef	 NULL	const	 NULL
329#	------------------------------------------------------------------
330#	PTROBJ		  Y	  N	  N	  Y	  Y	    N
331#	PTROBJ_OPT	  Y	  Y	  Y	  Y	  Y	    N
332#	PTROBJ_OUT	  N	  -	  -	  N	  Y	    N
333#	PTROBJ_OPTOUT	  N	  -	  -	  Y	  Y	    N
334#	PTROBJ_CONST	 	 		   	  Y	    Y
335#
336#
337#	PTROBJ is for input parameters that must not turn out to be
338#	NULL pointers once mapped.
339#
340#	PTROBJ_OPT is for input parameters that may turn out to be
341#	NULL pointers once mapped.
342#
343#	PTROBJ_OUT is for required output parameters.  A variable must be
344#	given, but its value is ignored.
345#
346#	PTROBJ_OPTOUT is for optional output parameters.  If a variable
347#	is given, its value is ignored.  See below for more.
348#
349#	PTROBJ_CONST is for output parameters that are actual constants
350#
351#	PTROBJ_OPTOUT deserves special explanation.  It is intended
352#	for optional output paramaters where the actual function
353#	is expecting either the NULL value or a pointer to the
354#	target variable.  A value is thus returned iff NULL was not
355#	passed to the function.  The perl usage is to pass undef
356#	if you don't want the value, and the input routine will map
357#	that to a NULL pointer.  When used, you have to supply a
358#	'real' variable via a PREINIT: block which can be pointed
359#	to by the variable represented by the function parameter.
360#	This 'real' variable is named by appending "_real" to the
361#	name of the parameter and stripping the "_optout" from the
362#	typename.  Of course, since this is in a PREINIT: block and
363#	not a INPUT: block, you have to do the mapping of object
364#	type to real type, ala "GSSAPI::Context" -> "GSSAPI__Context".
365#	So, a usage will run something like:
366#
367#	foo(param)
368#	    PREINIT:
369#		GSSAPI__OID		param_real
370#	    INPUT:
371#		GSSAPI::OID_optout	param
372#	    CODE:
373#		...
374#
375#	Yeah, it's ugly, but it makes the rest of the code look good.
376#
377#
378