/// It should search the job list for something matching the given proc. static bool find_job_by_name(const wchar_t *proc, std::vector<job_id_t> &ids, const parser_t &parser) { bool found = false; for (const auto &j : parser.jobs()) { if (j->command_is_empty()) continue; if (match_pid(j->command(), proc)) { if (!contains(ids, j->job_id)) { // If pids doesn't already have the pgid, add it. ids.push_back(j->job_id); } found = true; } // Check if the specified pid is a child process of the job. for (const process_ptr_t &p : j->processes) { if (p->actual_cmd.empty()) continue; if (match_pid(p->actual_cmd, proc)) { if (!contains(ids, j->job_id)) { // If pids doesn't already have the pgid, add it. ids.push_back(j->job_id); } found = true; } } } return found; }
/*! Process tp information when one tp is done \param[in] p_tp_list */ static RET_CODE default_process_pg_list(scan_tp_info_i_t *p_tp) { u16 i = 0; event_t evt = {SCAN_EVT_PG_FOUND}; scan_input_param_t *p_input_priv = NULL; p_input_priv = (scan_input_param_t *)class_get_handle_by_id(SCAN_IMPL_CLASS_ID); for(i = 0; i < p_tp->pg_num; i++) { scan_pg_info_t *p_pg = p_tp->p_pg_list + i; OS_PRINTF("\tPG[%d]: v_pid[%d], a_pid1[%d], pcr[%d], is_scr%d, is_scr_found %d, name[%s]\n", i, p_pg->video_pid,p_pg->audio[0].p_id,p_pg->pcr_pid, p_pg->is_scrambled, p_pg->is_scramble_found, p_pg->name); if(0 == p_pg->video_pid && 0 == p_pg->audio_ch_num) { continue; //it's dummy pg } //Check scramble status if(p_input_priv->is_free_only && p_pg->is_scrambled) { continue; } if(CHAN_TV == p_input_priv->chan_type && 0 == p_pg->video_pid) { continue; } else if(CHAN_RADIO == p_input_priv->chan_type && p_pg->video_pid != 0) { continue; } //Check pid parameter if(p_input_priv->pid_scan_enable && !match_pid(p_pg)) { continue; } // evt.data1 = (u32)p_pg; ap_frm_send_evt_to_ui(APP_SCAN, &evt); } return SUCCESS; }
static int match(const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const void *matchinfo, int offset, int *hotdrop) { const struct ipt_owner_info *info = matchinfo; if (!skb->sk || !skb->sk->sk_socket || !skb->sk->sk_socket->file) return 0; if(info->match & IPT_OWNER_UID) { if ((skb->sk->sk_socket->file->f_uid != info->uid) ^ !!(info->invert & IPT_OWNER_UID)) return 0; } if(info->match & IPT_OWNER_GID) { if ((skb->sk->sk_socket->file->f_gid != info->gid) ^ !!(info->invert & IPT_OWNER_GID)) return 0; } if(info->match & IPT_OWNER_PID) { if (!match_pid(skb, info->pid) ^ !!(info->invert & IPT_OWNER_PID)) return 0; } if(info->match & IPT_OWNER_SID) { if (!match_sid(skb, info->sid) ^ !!(info->invert & IPT_OWNER_SID)) return 0; } if(info->match & IPT_OWNER_COMM) { if (!match_comm(skb, info->comm) ^ !!(info->invert & IPT_OWNER_COMM)) return 0; } return 1; }
static int find_process(const wchar_t *proc, expand_flags_t flags, std::vector<completion_t> &out) { int found = 0; if (!(flags & EXPAND_SKIP_JOBS)) { ASSERT_IS_MAIN_THREAD(); const job_t *j; if (iswnumeric(proc) || (wcslen(proc)==0)) { /* This is a numeric job string, like '%2' */ if (flags & ACCEPT_INCOMPLETE) { job_iterator_t jobs; while ((j = jobs.next())) { wchar_t jid[16]; if (j->command_is_empty()) continue; swprintf(jid, 16, L"%d", j->job_id); if (wcsncmp(proc, jid, wcslen(proc))==0) { wcstring desc_buff = format_string(COMPLETE_JOB_DESC_VAL, j->command_wcstr()); append_completion(out, jid+wcslen(proc), desc_buff, 0); } } } else { int jid; wchar_t *end; errno = 0; jid = fish_wcstoi(proc, &end, 10); if (jid > 0 && !errno && !*end) { j = job_get(jid); if ((j != 0) && (j->command_wcstr() != 0)) { { append_completion(out, to_string<long>(j->pgid)); found = 1; } } } } } if (found) return 1; job_iterator_t jobs; while ((j = jobs.next())) { if (j->command_is_empty()) continue; size_t offset; if (match_pid(j->command(), proc, flags, &offset)) { if (flags & ACCEPT_INCOMPLETE) { append_completion(out, j->command_wcstr() + offset + wcslen(proc), COMPLETE_JOB_DESC, 0); } else { append_completion(out, to_string<long>(j->pgid)); found = 1; } } } if (found) { return 1; } jobs.reset(); while ((j = jobs.next())) { process_t *p; if (j->command_is_empty()) continue; for (p=j->first_process; p; p=p->next) { if (p->actual_cmd.empty()) continue; size_t offset; if (match_pid(p->actual_cmd, proc, flags, &offset)) { if (flags & ACCEPT_INCOMPLETE) { append_completion(out, wcstring(p->actual_cmd, offset + wcslen(proc)), COMPLETE_CHILD_PROCESS_DESC, 0); } else { append_completion(out, to_string<long>(p->pid), L"", 0); found = 1; } } } } if (found) { return 1; } } /* Iterate over all processes */ wcstring process_name; pid_t process_pid; process_iterator_t iterator; while (iterator.next_process(&process_name, &process_pid)) { size_t offset; if (match_pid(process_name, proc, flags, &offset)) { if (flags & ACCEPT_INCOMPLETE) { append_completion(out, process_name.c_str() + offset + wcslen(proc), COMPLETE_PROCESS_DESC, 0); } else { append_completion(out, to_string<long>(process_pid)); } } } return 1; }
void match_pid_set_wm_class(window *win, wm_class_context *ctx) { match_pid(win, ctx->atom, ctx->pid, set_wm_class, ctx); }
/*! Process tp information when one tp is done \param[in] sat_id satellite id \param[in] p_tp_list */ static RET_CODE impl_process_pg_list(scan_tp_info_i_t *p_tp) { u32 pg_cnt = 0; scan_pg_info_t *p_pg = NULL; u16 similar_pg_idx = 0; BOOL db_done = TRUE; u32 loopi = 0; //Check if new pg for(loopi = 0; loopi < SCAN_MAX_PG_PER_TP; loopi++) { if (pg_cnt == p_tp->pg_num) { break; } p_pg = p_tp->p_pg_list + loopi; OS_PRINTF("\tFound PG: s_id[%d], v_pid[%d], a_pid_0[%d]," " a_pid_1[%d],a_pid_2[%d], trace num[%d], name[%s]\n", p_pg->s_id, p_pg->video_pid, p_pg->audio[0].p_id,p_pg->audio[1].p_id, p_pg->audio[2].p_id, p_pg->audio_ch_num, p_pg->name); if(0 == p_pg->video_pid && 0 == p_pg->audio_ch_num && p_pg->service_type != DVB_NVOD_REF_SVC) { continue; //it's dummy pg } pg_cnt ++; //Check scramble status if(g_p_input_para->is_free_only && p_pg->is_scrambled) { continue; } if(CHAN_TV == g_p_input_para->chan_type && 0 == p_pg->video_pid && p_pg->service_type != DVB_NVOD_REF_SVC) { continue; } if (p_pg->service_type == DVB_NVOD_TIME_SHIFTED_SVC) { continue; } else if(CHAN_RADIO == g_p_input_para->chan_type && p_pg->video_pid != 0) { continue; } //Check pid parameter if(g_p_input_para->pid_scan_enable && !match_pid(p_pg)) { continue; } if(is_new_pg(p_pg, &similar_pg_idx)) { db_done = add_pg_into_db(p_pg); } else { db_done = edit_pg_into_db(p_pg, similar_pg_idx); } if(!db_done) { break; } } //reset pg depth g_p_scan_priv->pg_depth = 0; db_dvbs_save(g_p_scan_priv->pg_view_id); db_dvbs_save(g_p_scan_priv->tp_view_id); return db_done ? SUCCESS : ERR_NO_MEM; }