INT32 sim_get_scte_subt_pid(UINT32 monitor_id, UINT8 *pid_count, UINT16 *subt_pid, UINT8 *pid_lan_count, UINT32 lan[][6]) { INT16 dmx_idx; UINT16 prog_number; UINT8 tbl_idx; if(pid_count==NULL || subt_pid == NULL || pid_lan_count == NULL || lan == NULL) return ERR_FAILURE; if( !monitor_id_valid(monitor_id) ) return ERR_FAILUE; if( monitor_exist[monitor_id] != 1) return ERR_FAILUE; dmx_idx = simcb_array[monitor_id].dmx_idx; prog_number = simcb_array[monitor_id].param; tbl_idx = get_table_index(dmx_idx, MONITE_TB_PMT, prog_number); if(tbl_idx==0xFF) return ERR_FAILUE; osal_semaphore_capture(sm_semaphore, OSAL_WAIT_FOREVER_TIME); *pid_count = dmx_psi_info[dmx_idx].pmt[tbl_idx].scte_subt_count; MEMCPY(subt_pid, dmx_psi_info[dmx_idx].pmt[tbl_idx].scte_subt_pid, *pid_count*sizeof(UINT16)); MEMCPY(pid_lan_count, dmx_psi_info[dmx_idx].pmt[tbl_idx].scte_subt_lan_cnt, *pid_count*sizeof(UINT8)); MEMCPY(lan, dmx_psi_info[dmx_idx].pmt[tbl_idx].scte_subt_lan, *pid_count*6*sizeof(UINT32)); osal_semaphore_release(sm_semaphore); return SUCCESS; }
INT32 sim_get_video_pid(UINT32 monitor_id, UINT16 *video_pid) { INT16 dmx_idx; UINT16 prog_number; UINT8 tbl_idx; if( !monitor_id_valid(monitor_id) ) return ERR_FAILUE; if( monitor_exist[monitor_id] != 1) return ERR_FAILUE; //dmx_idx = (monitor_id&DMX_INDEX_MASK)>>24; //pmt_pid = (monitor_id&SEC_PID_MASK); dmx_idx = simcb_array[monitor_id].dmx_idx; prog_number = simcb_array[monitor_id].param; tbl_idx = get_table_index(dmx_idx, MONITE_TB_PMT, prog_number); if(tbl_idx==0xFF) return ERR_FAILUE; osal_semaphore_capture(sm_semaphore, OSAL_WAIT_FOREVER_TIME); *video_pid = dmx_psi_info[dmx_idx].pmt[tbl_idx].video_pid; osal_semaphore_release(sm_semaphore); return SUCCESS; }
/** * Removes a key-value mapping from the specified hash table and sets the out * parameter to value. * * @param[in] table the table from which the key-value pair is being removed * @param[in] key the key of the value being returned * @param[out] out pointer to where the removed value is stored, or NULL * if it is to be ignored * * @return CC_OK if the mapping was successfully removed, or CC_ERR_KEY_NOT_FOUND * if the key was not found. */ enum cc_stat hashtable_remove(HashTable *table, void *key, void **out) { if (!key) return remove_null_key(table, out); const size_t i = get_table_index(table, key); TableEntry *e = table->buckets[i]; TableEntry *prev = NULL; TableEntry *next = NULL; while (e) { next = e->next; if (e->key && table->key_cmp(key, e->key) == 0) { void *value = e->value; if (!prev) table->buckets[i] = next; else prev->next = next; table->mem_free(e); table->size--; if (out) *out = value; return CC_OK; } prev = e; e = next; } return CC_ERR_KEY_NOT_FOUND; }
INT32 sim_get_pmt(UINT32 monitor_id,struct prog_info* info) { UINT16 dmx_idx; UINT16 prog_number; UINT8 tbl_idx; if(info==NULL) return ERR_FAILUE; if( !monitor_id_valid(monitor_id) ) return ERR_FAILUE; if( monitor_exist[monitor_id] != 1) return ERR_FAILUE; //dmx_idx = (monitor_id&DMX_INDEX_MASK)>>24; //pmt_pid = (monitor_id&SEC_PID_MASK); dmx_idx = simcb_array[monitor_id].dmx_idx; prog_number = simcb_array[monitor_id].param; tbl_idx = get_table_index(dmx_idx, MONITE_TB_PMT, prog_number); if(tbl_idx==0xFF) return ERR_FAILUE; osal_semaphore_capture(sm_semaphore, OSAL_WAIT_FOREVER_TIME); MEMCPY(info, &(dmx_psi_info[dmx_idx].pmt[tbl_idx]), sizeof(struct prog_info)); osal_semaphore_release(sm_semaphore); return SUCCESS; }
GPtrArray* sql_parse(network_mysqld_con* con, GPtrArray* tokens, GHashTable *rule_table) { gint db, table; GArray* columns = NULL; guint sql_type = get_table_index(tokens, &db, &table); if (table == -1) return NULL; gchar* table_name = NULL; table_name = g_strdup_printf("%s", ((sql_token*)tokens->pdata[table])->text->str); shard_rule* rule = g_hash_table_lookup(rule_table, table_name); if (rule == NULL) { g_free(table_name); return NULL; } if(sql_type == 1) { /*select and delete*/ columns = get_shard_value_select(tokens, rule, table+1); } else if(sql_type == 2) { /*update*/ columns = get_shard_value_update(tokens, rule, table+1); } else if(sql_type == 3) { /*insert*/ columns = get_shard_value_insert(tokens, rule, table+1); } g_free(table_name); GPtrArray* sqls = combine_sql(tokens, table, columns, rule); g_array_free(columns, TRUE); return sqls; }
/** * Checks whether or not the HashTable contains the specified key. * * @param[in] table the table on which the search is being performed * @param[in] key the key that is being searched for * * @return true if the table contains the key. */ bool hashtable_contains_key(HashTable *table, void *key) { TableEntry *entry = table->buckets[get_table_index(table, key)]; while (entry) { if (table->key_cmp(key, entry->key) == 0) return true; entry = entry->next; } return false; }
uint32_t rcar_rom_get_lcs(uint32_t *lcs) { static const uintptr_t rom_get_lcs_table[API_TABLE_MAX] = { 0xEB10DFE0U, /* H3 Ver.1.0/Ver.1.1 */ 0xEB117150U, /* H3 Ver.2.0 */ 0xEB110578U, /* M3 Ver.1.0 */ 0xEB10018CU /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3 */ }; rom_get_lcs_api_f get_lcs; uint32_t index; index = get_table_index(); get_lcs = (rom_get_lcs_api_f) rom_get_lcs_table[index]; return get_lcs(lcs); }
uint32_t rcar_rom_secure_boot_api(uint32_t *key, uint32_t *cert, rom_read_flash_f read_flash) { static const uintptr_t rom_api_table[API_TABLE_MAX] = { 0xEB10DD64U, /* H3 Ver.1.0/Ver.1.1 */ 0xEB116ED4U, /* H3 Ver.2.0 */ 0xEB1102FCU, /* M3 Ver.1.0 */ 0xEB100180U /* H3 Ver.3.0, M3 Ver.1.1 or later, M3N, E3 */ }; rom_secure_boot_api_f secure_boot; uint32_t index; index = get_table_index(); secure_boot = (rom_secure_boot_api_f) rom_api_table[index]; return secure_boot(key, cert, read_flash); }
/** * Gets a value associated with the specified key and sets the out * parameter to it. * * @param[in] table the table from which the mapping is being returned * @param[in] key the key that is being looked up * @param[out] out pointer to where the value is stored * * @return CC_OK if the key was found, or CC_ERR_KEY_NOT_FOUND if not. */ enum cc_stat hashtable_get(HashTable *table, void *key, void **out) { if (!key) return get_null_key(table, out); size_t index = get_table_index(table, key); TableEntry *bucket = table->buckets[index]; while (bucket) { if (bucket->key && table->key_cmp(bucket->key, key) == 0) { *out = bucket->value; return CC_OK; } bucket = bucket->next; } return CC_ERR_KEY_NOT_FOUND; }
INT32 sim_get_audio_info(UINT32 monitor_id, UINT16 *audio_pid, UINT8 audio_lang[][3], UINT8 *max_audio_count) { INT16 dmx_idx; UINT16 prog_number; UINT8 tbl_idx; int i; if( !monitor_id_valid(monitor_id) ) return ERR_FAILUE; if( monitor_exist[monitor_id] != 1) return ERR_FAILUE; //dmx_idx = (monitor_id&DMX_INDEX_MASK)>>24; //pmt_pid = (monitor_id&SEC_PID_MASK); dmx_idx = simcb_array[monitor_id].dmx_idx; prog_number = simcb_array[monitor_id].param; tbl_idx = get_table_index(dmx_idx, MONITE_TB_PMT, prog_number); if(tbl_idx==0xFF) return ERR_FAILUE; osal_semaphore_capture(sm_semaphore, OSAL_WAIT_FOREVER_TIME); if(audio_pid != NULL || audio_lang != NULL) { for(i=0; i<*max_audio_count&&i<dmx_psi_info[dmx_idx].pmt[tbl_idx].audio_count; i++) { if(audio_pid != NULL) audio_pid[i] = dmx_psi_info[dmx_idx].pmt[tbl_idx].audio_pid[i]; if(audio_lang != NULL) MEMCPY(audio_lang[i], dmx_psi_info[dmx_idx].pmt[tbl_idx].audio_lang[i],3); } *max_audio_count = i; } else { *max_audio_count = dmx_psi_info[dmx_idx].pmt[tbl_idx].audio_count; } osal_semaphore_release(sm_semaphore); return SUCCESS; }
Table::Table() { QSqlQuery query; QMap<QString, int>::iterator it; int count; int t; query.exec("select itemnumber from item"); while (query.next()) { QString itemnumber = query.value(0).toString(); t = get_table_index(itemnumber); column[t].insert(itemnumber, 0); } for (t = 0; t < TABLESIZE; t++) { count = 0; for (it = column[t].begin(); it != column[t].end(); it++) { column[t][it.key()] = count++; } } }
INT32 sim_get_ca_info(UINT32 monitor_id, CA_INFO *ca_ptr, UINT8 *max_ca_count) { INT16 dmx_idx; UINT16 prog_number; UINT8 tbl_idx = 0xFF; if( !monitor_id_valid(monitor_id) ) return ERR_FAILUE; if( monitor_exist[monitor_id] != 1) return ERR_FAILUE; dmx_idx = simcb_array[monitor_id].dmx_idx; prog_number = simcb_array[monitor_id].param; tbl_idx = get_table_index(dmx_idx, MONITE_TB_PMT, prog_number); if(tbl_idx==0xFF) return ERR_FAILUE; osal_semaphore_capture(sm_semaphore, OSAL_WAIT_FOREVER_TIME); if(ca_ptr!=NULL && *max_ca_count>0) { if(*max_ca_count > dmx_psi_info[dmx_idx].pmt[tbl_idx].CA_count) { *max_ca_count = dmx_psi_info[dmx_idx].pmt[tbl_idx].CA_count; } MEMCPY(ca_ptr, dmx_psi_info[dmx_idx].pmt[tbl_idx].CA_info,(*max_ca_count)*sizeof(CA_INFO)); } else { *max_ca_count = dmx_psi_info[dmx_idx].pmt[tbl_idx].CA_count; } osal_semaphore_release(sm_semaphore); return SUCCESS; }
INT32 sim_get_ecm_pid(UINT32 monitor_id, UINT16 *pid_buffer_ptr, UINT8 *max_ecm_count) { INT16 dmx_idx; UINT16 prog_number; UINT8 tbl_idx = 0xFF; int i = 0; if( !monitor_id_valid(monitor_id) ) return ERR_FAILUE; if( monitor_exist[monitor_id] != 1) return ERR_FAILUE; dmx_idx = simcb_array[monitor_id].dmx_idx; prog_number = simcb_array[monitor_id].param; tbl_idx = get_table_index(dmx_idx, MONITE_TB_PMT, prog_number); if(tbl_idx==0xFF) return ERR_FAILUE; osal_semaphore_capture(sm_semaphore, OSAL_WAIT_FOREVER_TIME); if(pid_buffer_ptr!=NULL && *max_ecm_count>0) { for(i=0; i<dmx_psi_info[dmx_idx].pmt[tbl_idx].CA_count && i<*max_ecm_count; i++) { pid_buffer_ptr[i] = dmx_psi_info[dmx_idx].pmt[tbl_idx].CA_info[i].CA_pid; } *max_ecm_count = i; } else { *max_ecm_count = dmx_psi_info[dmx_idx].pmt[tbl_idx].CA_count; } osal_semaphore_release(sm_semaphore); return SUCCESS; }
long get_title_index(char *title) { return get_table_index(title,"titles","titleid","title"); }
long get_series_index(char *seriesname) { return get_table_index(seriesname,"series","seriesid","seriesname"); }
long get_tag_index(char *tagname) { return get_table_index(tagname,"tags","tagid","tagname"); }
long get_author_index(char *authorname) { return get_table_index(authorname,"authors","authorid","authorname"); }