text stringlengths 0 357 |
|---|
sjhashFree(new_elem); |
return data; |
} |
} |
if (pH->count > pH->htsize) |
{ |
rehash(pH,pH->htsize*2); |
} |
assert( pH->htsize>0); |
assert( (pH->htsize & (pH->htsize-1))==0); |
h = hraw & (pH->htsize-1); |
insertElement(pH, &pH->ht[h], new_elem); |
new_elem->data = data; |
return 0; |
} |
``` |
Filename: dc_imap.c |
```c |
#include <stdlib.h> |
#include <libetpan/libetpan.h> |
#include <sys/stat.h> |
#include <string.h> |
#include <unistd.h> |
#include "dc_context.h" |
#include "dc_imap.h" |
#include "dc_job.h" |
#include "dc_loginparam.h" |
#include "dc_oauth2.h" |
static int setup_handle_if_needed (dc_imap_t*); |
static void unsetup_handle (dc_imap_t*); |
#define FREE_SET(a) if((a)) { mailimap_set_free((a)); (a)=NULL; } |
#define FREE_FETCH_LIST(a) if((a)) { mailimap_fetch_list_free((a)); (a)=NULL; } |
/******************************************************************************* |
* Tools |
******************************************************************************/ |
int dc_imap_is_error(dc_imap_t* imap, int code) |
{ |
if (code==MAILIMAP_NO_ERROR /*0*/ |
|| code==MAILIMAP_NO_ERROR_AUTHENTICATED /*1*/ |
|| code==MAILIMAP_NO_ERROR_NON_AUTHENTICATED /*2*/) |
{ |
return 0; |
} |
if (code==MAILIMAP_ERROR_STREAM /*4*/ |
|| code==MAILIMAP_ERROR_PARSE /*5*/) |
{ |
dc_log_info(imap->context, 0, "IMAP stream lost; we'll reconnect soon."); |
imap->should_reconnect = 1; |
} |
return 1; |
} |
static char* get_error_msg(dc_imap_t* imap, const char* what_failed, int code) |
{ |
char* stock = NULL; |
dc_strbuilder_t msg; |
dc_strbuilder_init(&msg, 1000); |
switch (code) { |
case MAILIMAP_ERROR_LOGIN: |
stock = dc_stock_str_repl_string(imap->context, DC_STR_CANNOT_LOGIN, imap->imap_user); |
dc_strbuilder_cat(&msg, stock); |
break; |
default: |
dc_strbuilder_catf(&msg, "%s, IMAP-error #%i", what_failed, code); |
break; |
} |
free(stock); |
stock = NULL; |
if (imap->etpan->imap_response) { |
dc_strbuilder_cat(&msg, "\n\n"); |
stock = dc_stock_str_repl_string2(imap->context, DC_STR_SERVER_RESPONSE, imap->imap_server, imap->etpan->imap_response); |
dc_strbuilder_cat(&msg, stock); |
} |
free(stock); |
stock = NULL; |
return msg.buf; |
} |
static void get_config_lastseenuid(dc_imap_t* imap, const char* folder, uint32_t* uidvalidity, uint32_t* lastseenuid) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.