title: ObjC blocks & openssl C callbacks
body: <p>Have a simple one-off tasks which needs a progress bar. OpenSSL has a useful
  callback which one can use for that:</p>
  
  <pre><code>rsa=RSA_generate_key(bits,RSA_F4,progressCallback,NULL);
  </code></pre>
  
  <p>with</p>
  
  <pre><code>static void callback(int p, int n, void *arg) {
      .. stuff
  </code></pre>
  
  <p>However I want to call this from ObjectiveC without too much ado:</p>
  
  <pre><code>    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
      hud.mode = MBProgressHUDModeAnnularDeterminate;
      hud.labelText = @"Generating CSR";
  
      [self genReq:^(int p,int n,void *arg) {
              hud.progress = --heuristic to guess where we are --
      } completionCallback:^{
              [MBProgressHUD hideHUDForView:self.view animated:YES];
      }];
  </code></pre>
  
  <p>With Genrec: as an objC method: </p>
  
  <pre><code>-(void)genReq:(void (^)(int,int,void *arg))progressCallback 
        completionCallback:(void (^)())completionCallback 
  {
      .....
      rsa=RSA_generate_key(bits,RSA_F4,progressCallback,NULL);
      assert(EVP_PKEY_assign_RSA(pkey,rsa));
      rsa=NULL;
      ....
  
     completionCallback();
  }
  </code></pre>
  
  <p>Now completionCallback(); works splendidly and as expected. But I get a compiler warning/error which I cannot quell for the progress callback:</p>
  
  <pre><code> Passing 'void (^__strong)(int, int, void *)' to parameter of incompatible type 'void (*)(int, int, void *)'
  </code></pre>
  
  <p>So am curious -- what is the appropriate way to do this ?</p>
  
  <p>Thanks,</p>
  
  <p>Dw.</p>