Add KRB5_CALLCONV decorator
authorKevin Wasserman <krwasserman@hotmail.com>
Thu, 15 Jan 2015 18:19:46 +0000 (13:19 -0500)
committerKevin Wasserman <krwasserman@hotmail.com>
Thu, 15 Jan 2015 18:19:46 +0000 (13:19 -0500)
Also improve type safety

json_gssapi/src/commands/GSSInitSecContext.cpp
json_gssapi/src/commands/GSSInitSecContext.h

index 0df10ed..6f8df60 100644 (file)
 
 #include "util_base64.h"
 
-typedef OM_uint32 (*init_sec_context)(
-    OM_uint32 *,        /* minor_status */
-    gss_cred_id_t,      /* claimant_cred_handle */
-    gss_ctx_id_t *,     /* context_handle */
-    gss_name_t,         /* target_name */
-    gss_OID,            /* mech_type (used to be const) */
-    OM_uint32,          /* req_flags */
-    OM_uint32,          /* time_req */
-    gss_channel_bindings_t,     /* input_chan_bindings */
-    gss_buffer_t,       /* input_token */
-    gss_OID *,          /* actual_mech_type */
-    gss_buffer_t,       /* output_token */
-    OM_uint32 *,        /* ret_flags */
-    OM_uint32 *         /* time_req */
-);
-
 void
 GSSInitSecContext::execute()
 {
   /* Variables */
-  init_sec_context fn = (init_sec_context)function;
   gss_OID actual_mech_type;
   
   /* Error checking */
@@ -76,7 +59,7 @@ GSSInitSecContext::execute()
 
   /* Main */
   // MRW -- fix so that this uses all of the vars from the object 
-  retVal = fn(
+  retVal = function(
     &minor_status,
     GSS_C_NO_CREDENTIAL,
     &context_handle,
@@ -308,14 +291,14 @@ JSONObject *GSSInitSecContext::toJSON()
 
 GSSInitSecContext::GSSInitSecContext(
   JSONObject *params, 
-  void *fn)
+  pfn_init_sec_context fn)
 {
   zeroOut(false);
   loadParameters(params);
   function = fn;
 }
 
-GSSInitSecContext::GSSInitSecContext(void *fn)
+GSSInitSecContext::GSSInitSecContext(pfn_init_sec_context fn)
 {
   zeroOut(false);
   function = fn;
index 71f9bf8..85c9766 100644 (file)
 #include <datamodel/GSSOID.h>
 #include <gssapi.h>
 
+typedef OM_uint32 (KRB5_CALLCONV *pfn_init_sec_context)(
+    OM_uint32 *,        /* minor_status */
+    gss_cred_id_t,      /* claimant_cred_handle */
+    gss_ctx_id_t *,     /* context_handle */
+    gss_name_t,         /* target_name */
+    gss_OID,            /* mech_type (used to be const) */
+    OM_uint32,          /* req_flags */
+    OM_uint32,          /* time_req */
+    gss_channel_bindings_t,     /* input_chan_bindings */
+    gss_buffer_t,       /* input_token */
+    gss_OID *,          /* actual_mech_type */
+    gss_buffer_t,       /* output_token */
+    OM_uint32 *,        /* ret_flags */
+    OM_uint32 *         /* time_req */
+);
+
 class GSSInitSecContext : public GSSCommand
 {
 public:
@@ -59,8 +75,8 @@ public:
   
     void execute();
     JSONObject *toJSON();
-    GSSInitSecContext(void *fn = (void *)&gss_init_sec_context);
-    GSSInitSecContext(JSONObject *params, void *fn = (void *)&gss_init_sec_context);
+    GSSInitSecContext(pfn_init_sec_context fn = &gss_init_sec_context);
+    GSSInitSecContext(JSONObject *params,  pfn_init_sec_context fn = &gss_init_sec_context);
     
     bool loadParameters(JSONObject *params);
     bool zeroOut(bool initialized = true);
@@ -78,7 +94,7 @@ public:
     const char * getTargetDisplayName();
     
 private:
-    void *function;
+    pfn_init_sec_context function;
     GSSContext context;
     GSSOID mechType;
     GSSOID actualMechType;