int verify_amb(t_pipeline *line) { int pipe_found; int i; char *inhib; inhib = xmalloc((strlen(line->line) + 1) * sizeof(*inhib)); memset(inhib, 4, (strlen(line->line) + 1 + (pipe_found = 0))); i = -1; while (line->line[++i]) { if ((line->line[i] == '|') && (is_inhibited(line->line, inhib, i) == 0)) pipe_found++; if ((line->line[i] == '<') && (pipe_found) && (is_inhibited(line->line, inhib, i) == 0)) { my_putstr(AMB_L); FREE_RETURN(inhib, 0); } if ((line->line[i] == '>') && (pipe_found < line->nb_pipe) && (is_inhibited(line->line, inhib, i) == 0)) { my_putstr(AMB_R); FREE_RETURN(inhib, 0); } } FREE_RETURN(inhib, 1); }
int verify_pipe(char *s) { int i; int j; char *inhib; inhib = xmalloc((strlen(s) + 1) * sizeof(*inhib)); memset(inhib, 4, (strlen(s) + 2 + (i = -1))); while (s[++i]) if ((s[j = i] == '|') && (is_inhibited(s, inhib, i) == 0)) { while ((j >= 0) && ((s[j] == ' ') || (s[j] == '\t') || (s[j] == '|'))) j--; if (j == -1) { my_putstr(BAD_P); FREE_RETURN(inhib, 0); } while ((s[++i]) && ((s[i] == ' ') || (s[i] == '\t'))); if (((s[i] == '|') || (s[i] == '\n') || (s[i] == 0)) && (!is_inhibited(s, inhib, i) == 0)) { my_putstr(BAD_P); FREE_RETURN(inhib, 0); } } FREE_RETURN(inhib, 1); }
int verify_nbr(t_pipeline *line) { int i; char *inhib; inhib = xmalloc((strlen(line->line) + 1) * sizeof(*inhib)); memset(inhib, 4, (strlen(line->line) + 1)); i = 0; while (i < my_strlen(line->line) - 1) { if ((is_inhibited(line->line, inhib, i) == 0) && (line->line[i] == '>') && (line->line[i + 1] == '>') && (line->line[i + 2] == '>')) { my_putstr(BAD_R); FREE_RETURN(inhib, 0); } else if ((is_inhibited(line->line, inhib, i) == 0) && (line->line[i] == '<') && (line->line[i + 1] == '<') && (line->line[i + 2] == '<')) { my_putstr(BAD_L); FREE_RETURN(inhib, 0); } i++; } FREE_RETURN(inhib, 1); }
int is_between_quote(char *str, char *i, int pos) { int ini; int s_q; int d_q; s_q = 0; d_q = 0; ini = -1; while (++ini < pos) { if ((str[ini] == '\'') && !is_inhibited(str, i, ini) && !s_q) s_q = 1; else if ((str[ini] == '\'') && !is_inhibited(str, i, ini) && s_q && !d_q) s_q = 0; else if ((str[ini] == '\"') && !is_inhibited(str, i, ini) && !d_q) d_q = 2; else if ((str[ini] == '\"') && !is_inhibited(str, i, ini) && d_q && !s_q) d_q = 0; else is_inhibited(str, i, ini); } if (s_q && (str[ini] != '\'')) return (1); else if (d_q && (str[ini] != '"')) return (2); return (0); }
/** * urf_session_checker_inhibit: **/ guint urf_session_checker_inhibit (UrfSessionChecker *logind, const char *bus_name, const char *reason) { UrfLogindPrivate *priv = logind->priv; UrfInhibitor *inhibitor; g_return_val_if_fail (priv->proxy != NULL, 0); inhibitor = find_inhibitor_by_bus_name (logind, bus_name); if (inhibitor) return inhibitor->cookie; inhibitor = g_new0 (UrfInhibitor, 1); inhibitor->session_id = get_session_id (logind, bus_name); if (inhibitor->session_id == NULL) { g_free (inhibitor); return 0; } inhibitor->reason = g_strdup (reason); inhibitor->bus_name = g_strdup (bus_name); inhibitor->cookie = generate_unique_cookie (logind); priv->inhibitors = g_list_prepend (priv->inhibitors, inhibitor); logind->priv->inhibit = is_inhibited (logind); g_debug ("Inhibit: %s for %s", bus_name, reason); return inhibitor->cookie; }
/** * urf_session_checker_seat_active_changed: **/ static void urf_session_checker_seat_active_changed (UrfSeat *seat, const char *session_id, UrfSessionChecker *logind) { logind->priv->inhibit = is_inhibited (logind); g_debug ("Active Session changed: %s", session_id); }
/** * urf_session_checker_seat_active_changed: **/ static void urf_session_checker_seat_active_changed (UrfSeat *seat, const char *session_id, UrfSessionChecker *consolekit) { consolekit->priv->inhibit = is_inhibited (consolekit); g_debug ("Active Session changed: %s", session_id); }
int str_is_inhibited(char *str, char *inhib, int start, int end) { while (start <= end) { if (is_inhibited(str, inhib, start)) return (1); start++; } return (0); }
static void remove_inhibitor (UrfSessionChecker *logind, UrfInhibitor *inhibitor) { UrfLogindPrivate *priv = logind->priv; g_return_if_fail (priv->proxy != NULL); priv->inhibitors = g_list_remove (priv->inhibitors, inhibitor); logind->priv->inhibit = is_inhibited (logind); g_debug ("Remove inhibitor: %s", inhibitor->bus_name); free_inhibitor (inhibitor); }
static void remove_inhibitor (UrfSessionChecker *consolekit, UrfInhibitor *inhibitor) { UrfConsolekitPrivate *priv = consolekit->priv; g_return_if_fail (priv->proxy != NULL); priv->inhibitors = g_list_remove (priv->inhibitors, inhibitor); consolekit->priv->inhibit = is_inhibited (consolekit); g_debug ("Remove inhibitor: %s", inhibitor->bus_name); free_inhibitor (inhibitor); }
int is_inhibited(char *str, char *inhib, int pos) { int ini; int bs; int j; j = 0; bs = 0; ini = pos - 1; if (pos == 0) return (inhib[pos] = 0); if (inhib[pos] != 4) return ((int)inhib[pos]); if ((str[ini] == '\\') && (!is_inhibited(str, inhib, ini))) return (inhib[pos] = 3); if (((inhib[pos] = is_between_quote(str, inhib, pos)) == 2) && (str[pos] == '$')) inhib[pos] = 0; return ((int)inhib[pos]); }
int check_quote(char *str, char *inhib) { char c; int last; int ini; c = 0; last = my_strlen(str); if ((ini = is_inhibited(str, inhib, last))) { if (ini == 1) c = '\''; else if (ini == 2) c = '"'; else if (ini == 3) c = '\\'; my_fprintf(2, "Unmatched %c.\n", c); return (1); } return (0); }
int permute_trans (permute_t *perm, state_info_t *state, perm_cb_f cb, void *ctx) { perm->call_ctx = ctx; perm->real_cb = cb; perm->state = state; perm->nstored = perm->start_group_index = 0; int count = 0; state_data_t data = state_info_pins_state (state); if (inhibit) { int N = dm_nrows (perm->inhibit_matrix); int class_count[N]; for (int i = 0; i < N; i++) { class_count[i] = 0; if (is_inhibited(perm, class_count, i)) continue; if (perm->class_label >= 0) { class_count[i] = GBgetTransitionsMatching (perm->model, perm->class_label, i, data, permute_one, perm); } else if (perm->class_matrix != NULL) { class_count[i] = GBgetTransitionsMarked (perm->model, perm->class_matrix, i, data, permute_one, perm); } else { Abort ("inhibit set, but no known classification found."); } count += class_count[i]; } } else { count = GBgetTransitionsAll (perm->model, data, permute_one, perm); } switch (perm->permutation) { case Perm_Otf: randperm (perm->pad, perm->nstored, state->ref + perm->shiftorder); for (size_t i = 0; i < perm->nstored; i++) perm_do (perm, perm->pad[i]); break; case Perm_Random: for (size_t i = 0; i < perm->nstored; i++) perm_do (perm, perm->rand[perm->nstored][i]); break; case Perm_Dynamic: sort_r (perm->tosort, perm->nstored, sizeof(int), dyn_cmp, perm); perm_do_all (perm); break; case Perm_RR: sort_r (perm->tosort, perm->nstored, sizeof(int), rr_cmp, perm); perm_do_all (perm); break; case Perm_SR: sort_r (perm->tosort, perm->nstored, sizeof(int), rand_cmp, perm); perm_do_all (perm); break; case Perm_Sort: sort_r (perm->tosort, perm->nstored, sizeof(int), sort_cmp, perm); perm_do_all (perm); break; case Perm_Shift: perm_do_all (perm); break; case Perm_Shift_All: for (size_t i = 0; i < perm->nstored; i++) { size_t j = (perm->start_group_index + i); j = j < perm->nstored ? j : 0; perm_do (perm, j); } break; case Perm_None: break; default: Abort ("Unknown permutation!"); } return count; }