Hi,
for PuREST JSON on Windows, I need a way to verify SSL signatures, because currently this is not working. One way to accomplish that, is setting the path to the certificate file. As I want to package the file with the zip, I would like to store it in the same directory as the dll for the externals.
I have two externals [rest] and [oauth] that share all the code for libcurl, threading etc. (via a struct), so in the function where I need to set the path to the certificate file, I need to get the path of the dll to set the certificate store correctly.
Both classes are created by functions like:
rest_class = class_new(gensym("rest"), (t_newmethod)rest_new, (t_method)rest_free, sizeof(t_rest), 0, A_GIMME, 0);
and
t_rest *x = (t_rest *)pd_new(rest_class);
Now, I need a way to get the value "rest" from this *x, for this:
static void *ctw_exec_req(void *thread_args) { struct _ctw *common = thread_args;
/* more declarations */
#ifdef _WIN32 /* Workaround for loading certificates on Windows */ char path[2048]; /* This will output the path to pd.exe */ GetModuleFileName(NULL, path, 2048); post("dll path: %s", path); /* This will output the path to rest.dll, how do I get "rest" from *thread_args */ GetModuleFileName(GetModuleHandle("rest"), path, 2048); post("dll path: %s", path); #endif
/* all the rest to execute request via curl */ }
Thanks in advance, Thomas
I think you want c_externdir, i.e.
rest_class->c_externdir->s_name,
That's the directory that the external was loaded from. You'll need to #include "m_imp.h". See externals/hcs/cursor.c for an example.
.hc
On 04/17/2013 03:58 PM, Thomas Mayer wrote:
Hi,
for PuREST JSON on Windows, I need a way to verify SSL signatures, because currently this is not working. One way to accomplish that, is setting the path to the certificate file. As I want to package the file with the zip, I would like to store it in the same directory as the dll for the externals.
I have two externals [rest] and [oauth] that share all the code for libcurl, threading etc. (via a struct), so in the function where I need to set the path to the certificate file, I need to get the path of the dll to set the certificate store correctly.
Both classes are created by functions like:
rest_class = class_new(gensym("rest"), (t_newmethod)rest_new, (t_method)rest_free, sizeof(t_rest), 0, A_GIMME, 0);
and
t_rest *x = (t_rest *)pd_new(rest_class);
Now, I need a way to get the value "rest" from this *x, for this:
static void *ctw_exec_req(void *thread_args) { struct _ctw *common = thread_args;
/* more declarations */
#ifdef _WIN32 /* Workaround for loading certificates on Windows */ char path[2048]; /* This will output the path to pd.exe */ GetModuleFileName(NULL, path, 2048); post("dll path: %s", path); /* This will output the path to rest.dll, how do I get "rest" from *thread_args */ GetModuleFileName(GetModuleHandle("rest"), path, 2048); post("dll path: %s", path); #endif
/* all the rest to execute request via curl */ }
Thanks in advance, Thomas