title: How do I use ctypes to set a library's extern function pointer to a Python callback function?
body: <p>Some C libraries export function pointers such that the user of the library sets that function pointer to the address of their own function to implement a hook or callback.</p>
  
  <p>In this example library <code>liblibrary.so</code>, how do I set library_hook to a Python function using ctypes?</p>
  
  <p>library.h:</p>
  
  <pre><code>typedef int exported_function_t(char**, int);
  extern exported_function_t *library_hook;
  </code></pre>