static INT32 find_feed_node(struct MULTIFEED_INFO *info, struct FEED_INFO *feed_node ) { INT32 ret = -1; UINT8 i = 0; struct FEED_INFO * feed; if( feed_node == NULL ) return ret; for( i=0; i<info->num; i++ ) { feed = get_feed_node( info, i ); if( feed == NULL ) return ret; if( feed_node->transport_stream_id == feed->transport_stream_id && feed_node->original_network_id == feed->original_network_id && feed_node->service_id == feed->service_id && feed_node->is_known == feed->is_known && MEMCMP( feed_node->name, feed->name, sizeof(feed->name) )==0 && MEMCMP( &feed_node->p_node, &feed->p_node, sizeof(feed->p_node) )==0 ) { ret = i; break; } } return ret; }
/* * write the data and check if the data written to the proper position * return 0 if position as expected, otherwise -1 */ static int put_and_test(const char *alias, const char *buf, int size) { int code; char test_buf[BIG_ENOUGH]; /* check arguments for sanity */ if(size < 0 || buf == NULL || alias == NULL) return -1; /* put the data and update the channel size */ code = WRITE(alias, buf, size); if(code != size) return code; eofpos += code; /* read from the start channel position (0) */ code = PREAD(alias, test_buf, size, 0); ZTEST(code == size); ZTEST(MEMCMP(buf, test_buf, size) != 0); /* read from the current channel position (eofpos) */ code = PREAD(alias, test_buf, size, eofpos); ZTEST(code == 0); /* read from the proper alias position (eofpos - size) */ code = PREAD(alias, test_buf, size, eofpos - size); ZTEST(code == size); ZTEST(MEMCMP(buf, test_buf, size) == 0); return 0; }
void process_fddi(register u_char *u, register const struct pcap_pkthdr *h, register const u_char *p) { register struct fddi_header *fh; register struct ether_arp *ea; register u_char *sea, *sha; register time_t t; u_int32_t sia; fh = (struct fddi_header *)p; ea = (struct ether_arp *)(fh + 1); if (!swapped) { bit_reverse(fh->src, 6); bit_reverse(fh->dst, 6); } if (!sanity_fddi(fh, ea, h->caplen)) return; /* Source MAC hardware ethernet address */ sea = (u_char *)fh->src; /* Source ARP ethernet address */ sha = (u_char *)SHA(ea); /* Source ARP ip address */ BCOPY(SPA(ea), &sia, 4); /* Watch for bogons */ if (isbogon(sia)) { dosyslog(LOG_INFO, "bogon", sia, sea, sha); return; } /* Watch for ethernet broadcast */ if (MEMCMP(sea, zero, 6) == 0 || MEMCMP(sea, allones, 6) == 0 || MEMCMP(sha, zero, 6) == 0 || MEMCMP(sha, allones, 6) == 0) { dosyslog(LOG_INFO, "ethernet broadcast", sia, sea, sha); return; } /* Double check ethernet addresses */ if (MEMCMP(sea, sha, 6) != 0) { dosyslog(LOG_INFO, "ethernet mismatch", sia, sea, sha); return; } /* Got a live one */ t = h->ts.tv_sec; can_checkpoint = 0; if (!ent_add(sia, sea, t, NULL)) syslog(LOG_ERR, "ent_add(%s, %s, %ld) failed", intoa(sia), e2str(sea), t); can_checkpoint = 1; }
static void LoadHeader(LoadState* S) { lu_byte h[LUAC_HEADERSIZE]; lu_byte s[LUAC_HEADERSIZE]; luaU_header(h); MEMCPY(s,h,sizeof(char)); /* first char already read */ LoadBlock(S,s+sizeof(char),LUAC_HEADERSIZE-sizeof(char)); if (MEMCMP(h,s,N0)==0) return; if (MEMCMP(h,s,N1)!=0) error(S,"not a"); if (MEMCMP(h,s,N2)!=0) error(S,"version mismatch in"); if (MEMCMP(h,s,N3)!=0) error(S,"incompatible"); else error(S,"corrupted"); }
INT32 DB_get_node_by_id_from_table(DB_TABLE *table, UINT32 node_id,UINT32 *node_addr) { //UINT32 node_addr = 0; UINT16 i; *node_addr = 0; for(i = 0; i < table->node_num; i++) { if(0 == MEMCMP((UINT8 *)&node_id, table->table_buf[i].node_id, NODE_ID_SIZE)) { MEMCPY((UINT8 *)node_addr, table->table_buf[i].node_addr,NODE_ADDR_SIZE); break; } } if(i == table->node_num) { NODE_API_PRINTF("DB_get_node_by_id_from_table(): node id %d not find!\n",node_id); return DBERR_API_NOFOUND; } /* if(SUCCESS != DO_read_node(node_id, node_addr,node_len, node)) { NODE_API_PRINTF("DB_get_node_by_id_from_table():read node failed!\n"); return DBERR_PACK; } */ return DB_SUCCES; }
/* Select NIM Device from Device List */ struct nim_device* dev_select_nim(UINT32 sub_type, UINT32 status, struct nim_config *config) { UINT8 i; struct dev_manag_dev *dev_list = NULL; struct nim_device *ret_dev = NULL; struct nim_config *pnim_info = NULL; ENTER_DEV_MUTEX(); dev_list = &dev_manag_list[0]; for(i=0; i < DEV_MAX_CNT; i++) { if((dev_list[i].hld_type==HLD_DEV_TYPE_NIM)&&(dev_list[i].sub_type==sub_type)&&(dev_list[i].status&status)) { //Check whether NIM Config Info Match or not if((config!=NULL)&&(dev_list[i].config!=0)) { pnim_info = (struct nim_config *)(dev_list[i].config); if(0==MEMCMP(config, pnim_info, sizeof(struct nim_config))) ret_dev = (struct nim_device*)dev_list[i].dev_handle; } else ret_dev = (struct nim_device*)dev_list[i].dev_handle; break; } } LEAVE_DEV_MUTEX(); return ret_dev; }
INT32 epg_get_event_extented_desc_number(eit_event_info_t *ep) { eit_ext_desc_t *p, *p0; INT16 i=0; if (NULL==ep) return 0; #ifdef EPG_MULTI_LANG p = epg_get_ext_desc(ep); p0 = p; #else p = ep->eit_ext_desc; #endif while (p) { #ifdef EPG_MULTI_LANG if(MEMCMP(p->lang_code, p0->lang_code, 3) != 0) break; #endif if(p->text_char != NULL) { if (ComUniStrLen((UINT16*)p->text_char)>0) i++; } p=p->next; } return i; }
INT32 DB_get_node_by_id(DB_VIEW *v_attr, UINT32 id, UINT32 *node_addr) { UINT16 i; *node_addr = 0; for(i = 0; i < v_attr->node_num; i++) { if(0 == MEMCMP((UINT8 *)&id, v_attr->node_buf[i].node_id, NODE_ID_SIZE)) { MEMCPY((UINT8 *)node_addr, v_attr->node_buf[i].node_addr, NODE_ADDR_SIZE); break; } } if(*node_addr == 0) { NODE_API_PRINTF("DB_get_node_by_id(): node id %d not find!\n",id); return DBERR_API_NOFOUND; } /* if(SUCCESS != DO_read_node(id, node_addr,node_len, node)) { NODE_API_PRINTF("DB_get_node_by_id(): node_id = %d failed!\n",id); return DBERR_PACK; } */ return DB_SUCCES; }
static UINT8 gyca_check_flash_mail_head(UINT32 addr) { struct sto_device *flash_dev = NULL; UINT32 mailaddr = addr; UINT8 mail_head[GYCA_MAIL_HEAD_SIZE]; //flash_dev = (struct sto_device *)dev_get_by_type(NULL, HLD_DEV_TYPE_STO); flash_dev = (struct sto_device *)dev_get_by_id(HLD_DEV_TYPE_STO, 0); if(NULL == flash_dev) { GYCAS_PRINTF("%s: dev_get_by_name failed!\n", __FUNCTION__); return 1; } //if (SUCCESS != flash_dev->get_data(flash_dev, mail_head, mailaddr, GYCA_MAIL_HEAD_SIZE)) if (GYCA_MAIL_HEAD_SIZE != sto_get_data(flash_dev, mail_head, mailaddr, GYCA_MAIL_HEAD_SIZE)) { GYCAS_PRINTF("%s: sto_get_data failed!\n", __FUNCTION__); return 2; } gyca_mutex_lock(); if(MEMCMP(mail_head,gyca_mail_head, GYCA_MAIL_HEAD_SIZE)) { gyca_mutex_unlock(); return 3; } gyca_mutex_unlock(); return 0; }
void ide_fs_unmount(UINT32 param) { int i; char mount_name[16]; int result; struct statvfs sfs; int fd; char dirbuf[sizeof(struct dirent) + 32]; struct dirent *dire = (struct dirent *)dirbuf; unlink_device("/c", MNT_TYPE_IDE); unlink_device("/r", MNT_TYPE_IDE); fd = fs_opendir("/mnt"); while (fs_readdir(fd, dire) > 0) { fs_get_mount_name(MNT_TYPE_IDE, 0, 0, mount_name); if(!MEMCMP(&dire->d_name, &mount_name[5], 3)) { STRCPY(mount_name, "/mnt/"); strcat(mount_name, dire->d_name); FS_PRINTF("unmount: %s ...\n", mount_name); result = fs_statvfs(mount_name, &sfs); if (result < 0) { FS_PRINTF("%s is not mounted! err = %d\n", mount_name, result); FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_IDE, 0)); // IDE_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); continue; } result = fs_unmount(mount_name, 1); if (result < 0) { FS_PRINTF("%s unmounted failed! err = %d\n", mount_name, result); FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_FAILED, MNT_TYPE_IDE, 0)); // IDE_MESSAGE(MP_FS_UNMOUNT, UNMNT_FAILED); } else { FS_PRINTF("%s unmounted successed!\n", mount_name); } result = fs_rmdir(mount_name); if (result < 0) { FS_PRINTF("remove dir %s failed! err = %d\n", mount_name, result); } } } fs_closedir(fd); ide_hdd_cleanup(0); FS_NOTICE_MESSAGE(MP_FS_UNMOUNT, MNT_MSG_PARAM(UNMNT_UNMOUNT_OK, MNT_TYPE_IDE, 0)); // IDE_MESSAGE(MP_FS_UNMOUNT, UNMNT_UNMOUNT_OK); }
void sys_data_set_advdata(ad_sys_data *pData) { if(MEMCMP(&system_config.ad_data, pData, sizeof(ad_sys_data))) { MEMCPY(&system_config.ad_data, pData, sizeof(ad_sys_data)); sys_data_save(1); } }
int deviceConnectDisplayGetBufferChange() { if (MEMCMP((void *) vvadp.data.bufcomp, (void *) qdcgaGetTextMemAddr, qdcgaVarRagenSize)) { MEMCPY((void *) vvadp.data.bufcomp, (void *) qdcgaGetTextMemAddr, qdcgaVarRagenSize); return True; } else { return False; } }
UINT32 osdwnd_showwnd(PGUI_WINDOW pwnd,UINT32 param) { UINT32 i,bfind; PGUI_REGION prgn; PGUI_VSCR pvscr; PGUI_OBJWND wndobj; i = 0; if(gelib_get_wndmonitor()) { bfind = 0; wndobj = (PGUI_OBJWND)param; if(g_wndrects_cnt>0) { for(i=0;i<g_wndrects_idx;i++) { if(MEMCMP(&(wndobj->frame),&(g_wnd_rects[i]),sizeof(GUI_RECT)) == 0) { bfind = 1; break; } } } if((gelib_wndrects_valid())&&( bfind==0)) { MEMCPY(&(g_wnd_rects[g_wndrects_idx]),&(wndobj->frame),sizeof(GUI_RECT)); g_wndrects_idx++; g_wndrects_cnt++; } if(gelib_wndrects_full()) {//wndrects is not enough gelib_disable_wnd_monitors(1); } else if(gelib_wndrects_valid()==0) { osdwnd_reclaim_rects(); } if(gelib_wndrects_showon() && (g_osdwnd_onoff == 0)) { pvscr = OSD_GetTaskVscr(osal_task_get_current_id()); prgn = gelib_getdstrgn(pvscr->dst_layer,pvscr->dst_rgn); ge_show_onoff((struct ge_device *)gui_dev,(ge_surface_desc_t *)prgn->hsurf,1); if(gelib_getdual_support()) { prgn = gelib_getdstrgn(GUI_SLVGMA_SURF,0); ge_show_onoff_deo((struct ge_device *)gui_dev,(ge_surface_desc_t *)prgn->hsurf,1); } g_osdwnd_onoff = 1; } } return i; }
void sys_data_save(INT32 block) { //Save system_config here if (MEMCMP(&system_config_bak, &system_config, sizeof(system_config))) { save_tmp_data((UINT8*) &system_config, sizeof(system_config)); MEMCPY(&system_config_bak, &system_config, sizeof(system_config)); } }
bool ReadBuffer::BeginsWith(ReadBuffer& other) { if (length < other.length) return false; if (MEMCMP(buffer, other.length, other.buffer, other.length)) return true; else return false; }
static void cleartoel (GtkViScreen *vi, guint row, guint col) { CHAR_T *p, *e; if (MEMCMP(p = CharAt(vi,row,col), e = CharAt(vi,vi->rows,0), vi->cols - col)) { MEMMOVE(p, e, vi->cols - col); memset(FlagAt(vi,row,col), COLOR_STANDARD, vi->cols - col); mark_lines(vi, row, col, row+1, vi->cols); } }
UINT32 osdwnd_hidewnd(PGUI_WINDOW pwnd,UINT32 param) {//clear wnd UINT32 i; PGUI_VSCR pvscr; PGUI_REGION prgn; PGUI_OBJWND wndobj; //TODO:windows clear code if(gelib_get_wndmonitor()&&g_wndrects_cnt) { wndobj = (PGUI_OBJWND)param; for(i = 0;i < g_wndrects_idx;i++) { if(MEMCMP(&(wndobj->frame),&(g_wnd_rects[i]),sizeof(GUI_RECT)) == 0) { MEMSET(&(g_wnd_rects[i]),0x0,sizeof(GUI_RECT)); if(g_wndrects_cnt > 0) g_wndrects_cnt--; } } if(gelib_wndrects_showoff() && g_osdwnd_onoff) { pvscr = OSD_GetTaskVscr(osal_task_get_current_id()); prgn = gelib_getdstrgn(pvscr->dst_layer,pvscr->dst_rgn); ge_show_onoff((struct ge_device *)gui_dev,(ge_surface_desc_t *)prgn->hsurf,0); if(gelib_getdual_support()) { prgn = gelib_getdstrgn(GUI_SLVGMA_SURF,0); ge_show_onoff_deo((struct ge_device *)gui_dev,(ge_surface_desc_t *)prgn->hsurf,0); } g_osdwnd_onoff = 0; } } else if((g_wndrects_cnt == 0)&&(g_wnd_monitors == 1)) { if(gelib_wndrects_showoff() && g_osdwnd_onoff) { pvscr = OSD_GetTaskVscr(osal_task_get_current_id()); prgn = gelib_getdstrgn(pvscr->dst_layer,pvscr->dst_rgn); ge_show_onoff((struct ge_device *)gui_dev,(ge_surface_desc_t *)prgn->hsurf,0); g_osdwnd_onoff = 0; } } return 0; }
int is_router_mac_in(router_list_t *list, uint16_t vlan_id, struct ether_addr eth) { router_list_t *tmp = list; while(tmp != NULL) { if(in_vlan(tmp, vlan_id) && !MEMCMP(ð,&(tmp->mac), sizeof(struct ether_addr))) return 1; tmp = tmp->next; } return 0; }
/*Look if the source mac address is a broadcast addr or is all zeros*/ int watch_eth_broadcast(char* buffer, uint16_t vlan_id, struct ether_header* eptr, struct ip6_hdr* ipptr) { struct ether_addr* eth_addr = (struct ether_addr*) eptr->ether_shost; struct ether_addr* test = malloc(sizeof(struct ether_addr)); char str_ip[IP6_STR_SIZE]; int broad =0; bzero(test,6); if (MEMCMP(eth_addr, test,6) ==0) broad=1; else { memset(test,255,6); if(MEMCMP(eth_addr, test,6)==0) broad= 1; else { char* test2= "33:33:0:0:0:1"; if(strcmp(ether_ntoa(eth_addr), test2)==0) broad=1; } } if(broad) { ipv6_ntoa(str_ip, ipptr->ip6_src); snprintf (buffer, NOTIFY_BUFFER_SIZE, "VLAN%d: ethernet broadcast %s %s",vlan_id,ether_ntoa(eth_addr), str_ip); free(test); notify(1, buffer, "ethernet broadcast", eth_addr, str_ip, NULL); return 1; } else { free(test); return 0; } }
router_list_t * router_get(router_list_t *list, uint16_t vlan_id, struct in6_addr lla, struct ether_addr eth) { router_list_t *tmp = list; while(tmp != NULL) { if(in_vlan(tmp, vlan_id) && !MEMCMP(ð,&(tmp->mac), sizeof(struct ether_addr))) if(IN6_ARE_ADDR_EQUAL(&lla,&(tmp->lla))) return tmp; tmp = tmp->next; } return NULL; }
size_t CRowSolution<T>::findSolution(const T *pSolution, size_t i, size_t iMax, const CSolutionPerm *pSolPerm, size_t &lastCanonIdx, size_t *pNextSolutionIdx) const { const uchar *pCanonFlags = pSolPerm->canonFlags(); const size_t len = solutionSize() * sizeof(*pSolution); while (++i < iMax && MEMCMP(pSolution, firstSolution() + pSolPerm->GetAt(i) * solutionSize(), len)) { if (*(pCanonFlags + i) == 1) { if (lastCanonIdx == SIZE_MAX) *pNextSolutionIdx = i; lastCanonIdx = i; } } return i; }
static void check(u1 *plain, u1 *cipher, u1 *key, int Nk, char *title) { void *ctx; u1 data[Nb * 4]; MEMCPY(data, plain, Nb * 4); ctx = AES_Init(key, Nk); if(ctx == NULL) { printf("no memory\n"); return; } AES_Cipher(ctx, data); ps(data); if(MEMCMP(data, cipher, Nb * 4)) printf("%s-cipher is wrong\n", title); MEMCPY(data, cipher, Nb * 4); AES_InvCipher(ctx, data); ps(data); if(MEMCMP(data, plain, Nb * 4)) printf("%s-invcipher is wrong\n", title); AES_Finish(ctx); }
void sys_data_select_audio_language(UINT8 langid1, UINT8 langid2) { UINT8 szLangGroup[AUDIO_CODE_CNT][4]; /*default is 2,for support multicode*/ UINT8 i, multi_audio_cnt; UINT8 strm_lang_num, strm_multicode_num; UINT8 lang_code[4], lang_codem[4]; if (langid1 >= STREAM_ISO_639_NUM) langid1 = 0; if (langid2 >= STREAM_ISO_639_NUM) langid2 = langid1; multi_audio_cnt = 2; strm_lang_num = get_stream_lang_cnt(); strm_multicode_num = get_stream_langm_cnt(); MEMSET(lang_code,0,4); // add lang_code init MEMSET(lang_codem,0,4); MEMCPY(lang_code, stream_iso_639lang_abbr[langid1], 3); MEMCPY(lang_codem, lang_code, 3); for (i = 0; i < strm_multicode_num; i++) { if (MEMCMP(iso_639lang_multicode[i][0], lang_code, 3) == 0) { MEMCPY(lang_codem, iso_639lang_multicode[i][1], 3); multi_audio_cnt = 3; break; } } if (multi_audio_cnt == 2) { STRCPY(szLangGroup[0], lang_code); /*copy Country abrev.*/ STRCPY(szLangGroup[1], stream_iso_639lang_abbr[langid2]); } else if (multi_audio_cnt == 3) { STRCPY(szLangGroup[0], lang_code); STRCPY(szLangGroup[1], lang_codem); STRCPY(szLangGroup[2], stream_iso_639lang_abbr[langid2]); } system_config.lang.Audio_lang_1 = langid1; system_config.lang.Audio_lang_2 = langid2; //UIChChgSetAudLanguage ( szLangGroup, multi_audio_cnt ); api_set_audio_language( szLangGroup, multi_audio_cnt ); }
static INLINE int NameNH(MEMCMP)(NCHAR *a, HCHAR *b, ptrdiff_t e) { #if NSHIFT == HSHIFT return MEMCMP(a, b, sizeof(HCHAR)*e); #else for(;e;e--,b++,a++) { if(*b!=*a) { if(*b<*a) return -1; if(*b>*a) return 1; } } return 0; #endif }
/*idx -- the idx of extented node */ UINT8* epg_get_event_extented_detail(eit_event_info_t *ep,INT32 *len,INT32 idx) { INT32 i=0; eit_ext_desc_t *p,*p0; UINT8 *str; *len=0; if (NULL==ep) return NULL; #ifdef EPG_MULTI_LANG p = epg_get_ext_desc(ep); p0 = p; #else p = ep->eit_ext_desc; #endif if (NULL==p) return NULL; str=p->text_char; while (i<idx) { p=p->next; if (NULL==p) return NULL; #ifdef EPG_MULTI_LANG if(MEMCMP(p->lang_code, p0->lang_code, 3) != 0) return NULL; #endif str=p->text_char; i++; } if(str == NULL) return NULL; *len=ComUniStrLen((UINT16*)str); return str; }
int compare_string (gfc_charlen_type len1, const CHARTYPE *s1, gfc_charlen_type len2, const CHARTYPE *s2) { const UCHARTYPE *s; gfc_charlen_type len; int res; res = MEMCMP (s1, s2, ((len1 < len2) ? len1 : len2)); if (res != 0) return res; if (len1 == len2) return 0; if (len1 < len2) { len = len2 - len1; s = (UCHARTYPE *) &s2[len1]; res = -1; } else { len = len1 - len2; s = (UCHARTYPE *) &s1[len2]; res = 1; } while (len--) { if (*s != ' ') { if (*s > ' ') return res; else return -res; } s++; } return 0; }
/* ----------------- Lstrcmp ------------------ */ int __CDECL Lstrcmp( const PLstr a, const PLstr b ) { int r; L2STR(a); L2STR(b); if ( (r=MEMCMP( LSTR(*a), LSTR(*b), MIN(LLEN(*a),LLEN(*b))))!=0 ) return r; else { if (LLEN(*a) > LLEN(*b)) return 1; else if (LLEN(*a) == LLEN(*b)) return 0; else return -1; } } /* Lstrcmp */
/* ------------------ Lcmp ------------------- */ int __CDECL Lcmp( const PLstr a, const char *b ) { int r,blen; L2STR(a); blen = STRLEN(b); if ( (r=MEMCMP( LSTR(*a), b, MIN(LLEN(*a),blen)))!=0 ) return r; else { if (LLEN(*a) > blen) return 1; else if (LLEN(*a) == blen) return 0; else return -1; } } /* Lcmp */
/* -- are of the same type */ int __CDECL _Lstrcmp( const PLstr a, const PLstr b ) { int r; if ( (r=MEMCMP( LSTR(*a), LSTR(*b), MIN(LLEN(*a),LLEN(*b))))!=0 ) return r; else { if (LLEN(*a) > LLEN(*b)) return 1; else if (LLEN(*a) == LLEN(*b)) { if (LTYPE(*a) > LTYPE(*b)) return 1; else if (LTYPE(*a) < LTYPE(*b)) return -1; return 0; } else return -1; } } /* _Lstrcmp */
eit_ext_desc_t* epg_get_ext_desc(eit_event_info_t *ep) { eit_ext_desc_t *p; if (ep == NULL) return NULL; p = ep->eit_ext_desc; if(p == NULL) return NULL; while(p != NULL) { if(MEMCMP(p->lang_code, g_current_lang_code, 3) == 0) break; p = p->next; } if(p==NULL) p = ep->eit_ext_desc; return p; }