text
stringlengths
0
357
free(json);
return addr_out;
}
char* dc_get_oauth2_addr(dc_context_t* context, const char* addr,
const char* code)
{
char* access_token = NULL;
char* addr_out = NULL;
oauth2_t* oauth2 = NULL;
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC
|| (oauth2=get_info(addr))==NULL || oauth2->get_userinfo==NULL) {
goto cleanup;
}
access_token = dc_get_oauth2_access_token(context, addr, code, 0);
addr_out = get_oauth2_addr(context, oauth2, access_token);
if (addr_out==NULL) {
free(access_token);
access_token = dc_get_oauth2_access_token(context, addr, code, DC_REGENERATE);
addr_out = get_oauth2_addr(context, oauth2, access_token);
}
cleanup:
free(access_token);
free(oauth2);
return addr_out;
}
```
Filename: dc_openssl.c
```c
#include <openssl/ssl.h>
#include <openssl/rand.h>
#include <openssl/rsa.h>
#include <openssl/evp.h>
#include "dc_context.h"
static pthread_mutex_t s_init_lock = PTHREAD_MUTEX_INITIALIZER;
static int s_init_not_required = 0;
static int s_init_counter = 0;
static pthread_mutex_t* s_mutex_buf = NULL;
/**
* Skip OpenSSL initialisation.
* By default, the OpenSSL library is initialized thread-safe when calling
* dc_context_new() the first time. When the last context-object is deleted
* using dc_context_unref(), the OpenSSL library will be released as well.
*
* If your app needs OpenSSL on its own _outside_ these calls, you have to initialize the
* OpenSSL-library yourself and skip the initialisation in deltachat-core by calling
* dc_openssl_init_not_required() _before_ calling dc_context_new() the first time.
*
* Multiple calls to dc_openssl_init_not_required() are not needed, however,
* they do not harm.
*
* @memberof dc_context_t
* @return None.
*/
void dc_openssl_init_not_required(void)
{
pthread_mutex_lock(&s_init_lock);
s_init_not_required = 1;
pthread_mutex_unlock(&s_init_lock);
}
static unsigned long id_function(void)
{
return ((unsigned long)pthread_self());
}
static void locking_function(int mode, int n, const char* file, int line)
{
if (mode & CRYPTO_LOCK) {
pthread_mutex_lock(&s_mutex_buf[n]);
}
else {
pthread_mutex_unlock(&s_mutex_buf[n]);
}
}
struct CRYPTO_dynlock_value
{
pthread_mutex_t mutex;
};
static struct CRYPTO_dynlock_value* dyn_create_function(const char* file, int line)
{