bool RegExp::IsMatch(const WCHAR *target, bool *is_mid) { if (!epsilon_tbl) return false; RegStates total_states(max_state); RegStates ep_states(max_state); RegStates tmp_states(max_state); RegStates sv_states(max_state); if (is_mid) *is_mid = false; tmp_states.AddState(0); GetEpStates(tmp_states, &total_states); while (!total_states.IsZero()) { WCHAR ch = *target++; RegStates *normal = GetRegStates(NORMAL_TBL, ch); RegStates *rev = GetRegStates(REV_TBL, ch); GetEpStates(total_states, &ep_states); total_states.ShiftLeft(); if (is_mid && !ch) sv_states = total_states; if (normal) { total_states &= *normal; } else { total_states.Reset(); } if (rev) { rev->GetReverse(&tmp_states); ep_states &= tmp_states; } total_states |= ep_states; if (total_states.HasCommonBits(end_states)) return true; if (!ch) { if (is_mid) { auto norm = GetRegStates(NORMAL_TBL, '/'); if (norm && sv_states.HasCommonBits(*norm)) { *is_mid = true; } } break; } } return false; }
/* * * query_server - creates a structure of arrays consisting of a server * and all the queues and jobs that reside in that server * * pbs_sd - connection to pbs_server * * returns a pointer to the server_info struct * */ server_info *query_server(int pbs_sd) { struct batch_status *server; /* info about the server */ server_info *sinfo; /* scheduler internal form of server info */ queue_info **qinfo; /* array of queues on the server */ resource *res; /* ptr to cycle through sources on server */ int local_errno = 0; /* get server information from pbs server */ if ((server = pbs_statserver_err(pbs_sd, NULL, NULL, &local_errno)) == NULL) { fprintf(stderr, "pbs_statserver failed: %d\n", local_errno); return NULL; } /* convert batch_status structure into server_info structure */ if ((sinfo = query_server_info(server)) == NULL) { pbs_statfree(server); return NULL; } /* get the nodes, if any */ sinfo -> nodes = query_nodes(pbs_sd, sinfo); /* get the queues */ if ((sinfo -> queues = query_queues(pbs_sd, sinfo)) == NULL) { pbs_statfree(server); free_server(sinfo, 0); return NULL; } /* count the queues and total up the individual queue states * for server totals. (total up all the state_count structs) */ qinfo = sinfo -> queues; while (*qinfo != NULL) { sinfo -> num_queues++; total_states(&(sinfo -> sc), &((*qinfo) -> sc)); qinfo++; } if ((sinfo -> jobs = (job_info **) malloc(sizeof(job_info *) * (sinfo -> sc.total + 1))) == NULL) { free_server(sinfo, 1); perror("Memory allocation error"); return NULL; } set_jobs(sinfo); sinfo -> running_jobs = job_filter(sinfo -> jobs, sinfo -> sc.total, check_run_job, NULL); res = sinfo -> res; while (res != NULL) { if (res -> assigned == UNSPECIFIED) res -> assigned = calc_assn_resource(sinfo -> running_jobs, res -> name); res = res -> next; } sinfo -> timesharing_nodes = node_filter(sinfo -> nodes, sinfo -> num_nodes, is_node_timeshared, NULL); pbs_statfree(server); return sinfo; }