static void restore_envelope(ENVELOPE * e, const unsigned char *d, int *off, int convert) { int real_subj_off; restore_address(&e->return_path, d, off, convert); restore_address(&e->from, d, off, convert); restore_address(&e->to, d, off, convert); restore_address(&e->cc, d, off, convert); restore_address(&e->bcc, d, off, convert); restore_address(&e->sender, d, off, convert); restore_address(&e->reply_to, d, off, convert); restore_address(&e->mail_followup_to, d, off, convert); restore_char(&e->list_post, d, off, convert); restore_char(&e->subject, d, off, convert); restore_int((unsigned int *) (&real_subj_off), d, off); if (0 <= real_subj_off) e->real_subj = e->subject + real_subj_off; else e->real_subj = NULL; restore_char(&e->message_id, d, off, 0); restore_char(&e->supersedes, d, off, 0); restore_char(&e->date, d, off, 0); restore_char(&e->x_label, d, off, convert); restore_buffer(&e->spam, d, off, convert); restore_list(&e->references, d, off, 0); restore_list(&e->in_reply_to, d, off, 0); restore_list(&e->userhdrs, d, off, convert); }
/** * @brief select/deselect a nandflash target * @author Yang Yiming * @date 2012-12-25 * @param [in]nTarget target nandflash * @param [in]bSelect AK_TRUE to select, AK_FALSE to deselect * @return T_BOOL */ T_BOOL nfc_select(T_U8 nTarget, T_BOOL bSelect) { //only when additional #ce is needed, this block is essential if (s_nPhyPos[nTarget] < INVALID_GPIO) { gpio_set_pin_dir(s_nPhyPos[nTarget], GPIO_DIR_OUTPUT); gpio_set_pin_level(s_nPhyPos[nTarget], bSelect ? GPIO_LEVEL_LOW : GPIO_LEVEL_HIGH); } if (bSelect) { g_clk_map |= CLK_NFC_EN; store_int(INT_EN_L2); sys_module_enable(eVME_NANDFLASH_CLK, AK_TRUE); sys_share_pin_lock(ePIN_AS_NANDFLASH); s_nActChip = nTarget; } else { s_nActChip = 0xFF; sys_module_enable(eVME_NANDFLASH_CLK, AK_FALSE); sys_share_pin_unlock(ePIN_AS_NANDFLASH); restore_int(); g_clk_map &= ~CLK_NFC_EN; } return AK_TRUE; }
static void restore_buffer(BUFFER ** b, const unsigned char *d, int *off, int convert) { unsigned int used; unsigned int offset; restore_int(&used, d, off); if (!used) { return; } *b = safe_malloc(sizeof (BUFFER)); restore_char(&(*b)->data, d, off, convert); restore_int(&offset, d, off); (*b)->dptr = (*b)->data + offset; restore_int (&used, d, off); (*b)->dsize = used; restore_int (&used, d, off); (*b)->destroy = used; }
static int crc_matches(const char *d, unsigned int crc) { int off = sizeof (validate); unsigned int mycrc = 0; if (!d) return 0; restore_int(&mycrc, (unsigned char *) d, &off); return (crc == mycrc); }
static void restore_address(ADDRESS ** a, const unsigned char *d, int *off, int convert) { unsigned int counter; restore_int(&counter, d, off); while (counter) { *a = rfc822_new_address(); #ifdef EXACT_ADDRESS restore_char(&(*a)->val, d, off, convert); #endif restore_char(&(*a)->personal, d, off, convert); restore_char(&(*a)->mailbox, d, off, 0); restore_int((unsigned int *) &(*a)->group, d, off); a = &(*a)->next; counter--; } *a = NULL; }
static void restore_list(LIST ** l, const unsigned char *d, int *off, int convert) { unsigned int counter; restore_int(&counter, d, off); while (counter) { *l = safe_malloc(sizeof (LIST)); restore_char(&(*l)->data, d, off, convert); l = &(*l)->next; counter--; } *l = NULL; }
static void restore_parameter(PARAMETER ** p, const unsigned char *d, int *off, int convert) { unsigned int counter; restore_int(&counter, d, off); while (counter) { *p = safe_malloc(sizeof (PARAMETER)); restore_char(&(*p)->attribute, d, off, 0); restore_char(&(*p)->value, d, off, convert); p = &(*p)->next; counter--; } *p = NULL; }
static void restore_char(char **c, const unsigned char *d, int *off, int convert) { unsigned int size; restore_int(&size, d, off); if (size == 0) { *c = NULL; return; } *c = safe_malloc(size); memcpy(*c, d + *off, size); if (convert && !is_ascii (*c, size)) { char *tmp = safe_strdup (*c); if (mutt_convert_string (&tmp, "utf-8", Charset, 0) == 0) { mutt_str_replace (c, tmp); } else { FREE(&tmp); } } *off += size; }
/** * @brief Set the sd interface. * * Select the sd interface(INTERFACE_MMC1 or INTERFACE_SD2)and select the relevant registers,L2 ,pin. * @author Huang Xin * @date 2010-07-14 * @param cif[in] The selected interface,INTERFACE_MMC1 or INTERFACE_SD2. * @return T_VOID */ T_VOID set_interface(T_eCARD_INTERFACE cif, T_U8 bus_mode) { if(INTERFACE_NOT_SD != cif) { #if (DRV_SUPPORT_SPI_BOOT == 0) g_clk_map |= CLK_MCI_EN; #endif store_int(INT_EN_L2); //select pin share #if (CHIP_SEL_10C > 0) if(INTERFACE_SD2 == cif) { if(USE_ONE_BUS == bus_mode){ s_PinSelect = ePIN_AS_MCI2_1LINE; } else{ s_PinSelect = ePIN_AS_MCI2_4LINE; } } else { s_PinSelect = ePIN_AS_MCI1; } #else if(INTERFACE_SD2 == cif) { s_PinSelect = ePIN_AS_MCI2; } else { if (USE_EIGHT_BUS == bus_mode){ s_PinSelect = ePIN_AS_MCI1_8LINE; } else{ s_PinSelect = ePIN_AS_MCI1; } } #endif if(INTERFACE_SD2 == cif) { s_SdReg_Base = MCI2_MODULE_BASE_ADDR; s_L2Select = ADDR_MCI2; sys_module_enable(eVME_MCI2_CLK, AK_TRUE); } else { s_SdReg_Base = MCI1_MODULE_BASE_ADDR; s_L2Select = ADDR_MCI1; sys_module_enable(eVME_MCI1_CLK, AK_TRUE); } sys_share_pin_lock(s_PinSelect); } else { sys_module_enable(eVME_MCI1_CLK, AK_FALSE); sys_module_enable(eVME_MCI2_CLK, AK_FALSE); sys_share_pin_unlock(s_PinSelect); restore_int(); #if (DRV_SUPPORT_SPI_BOOT == 0) g_clk_map &= ~CLK_MCI_EN; #endif } }