コード例 #1
0
ファイル: chassis-filter.c プロジェクト: api1024/DBProxy
int
load_sql_filter_from_file(sql_filter *cur_filter)
{
    GKeyFile *blacklist_config = NULL;
    GError *gerr = NULL;
    gsize length = 0;
    int i = 0;
    gchar **groups = NULL;

    g_assert(cur_filter != NULL);

    g_rw_lock_reader_lock(&cur_filter->sql_filter_lock);
    if (!(blacklist_config = chassis_frontend_open_config_file(cur_filter->blacklist_file, &gerr)))
    {
        g_debug("[filter][load from file][failed][%s]", gerr->message);
        g_error_free(gerr);
        gerr = NULL;
        g_rw_lock_reader_unlock(&cur_filter->sql_filter_lock);
        return 1;
    }
    g_rw_lock_reader_unlock(&cur_filter->sql_filter_lock);

    groups = g_key_file_get_groups(blacklist_config, &length);
    for (i = 0; groups[i] != NULL; i++)
    {
        gchar *sql_rewrite_md5 = NULL;
        int is_enabled = 0;
        int filter_status = 0;

        gchar *filter = g_key_file_get_value(blacklist_config, groups[i], "filter", &gerr);
        if (gerr != NULL) { goto next; }

        is_enabled = g_key_file_get_integer(blacklist_config, groups[i], "is_enabled", &gerr);
        if (gerr != NULL) { goto next; }

        filter_status = g_key_file_get_integer(blacklist_config, groups[i], "filter_status", &gerr);
        if (gerr != NULL) { goto next; }

        sql_rewrite_md5 = g_compute_checksum_for_string(G_CHECKSUM_MD5, C_S(filter));
        g_rw_lock_writer_lock(&cur_filter->sql_filter_lock);
        sql_filter_hval *hval = sql_filter_lookup(cur_filter, sql_rewrite_md5);
        if (hval != NULL)
        {
            hval->flag = is_enabled;
            hval->filter_status = filter_status;
        }
        else
        {
            sql_filter_insert(cur_filter, filter, sql_rewrite_md5, is_enabled, filter_status);
        }
        g_rw_lock_writer_unlock(&cur_filter->sql_filter_lock);

next:
        if (filter !=NULL) { g_free(filter); }
        if (sql_rewrite_md5 != NULL) { g_free(sql_rewrite_md5); }

        if (gerr != NULL)
        {
            g_debug("[filter][load from file][failed][%s]", gerr->message);
            g_error_free(gerr);
            gerr = NULL;
        }
        else
            g_message("[filter][load from file %s][success]", cur_filter->blacklist_file);
    }
    g_strfreev(groups);

    g_key_file_free(blacklist_config);
    return 0;
}
コード例 #2
0
ファイル: keymap.c プロジェクト: keihino/qmk_firmware
 *                                        ,-------------.       ,-------------.
 *                                        | LGui | LAlt |       | Alt  | Esc  |
 *                                 ,------|------|------|       |------+--------+------.
 *                                 |      |      | Home |       | PgUp |        |      |
 *                                 |Space |Delete|------|       |------| Space  |Enter |
 *                                 |      |      | End  |       | PgDn |        |      |
 *                                 `--------------------'       `----------------------'
 */
// If it accepts an argument (i.e, is a function), it doesn't need KC_.
// Otherwise, it needs KC_*
[MAIN] = KEYMAP(  // layer 0 : default
        // left hand
        KC_GRV,         KC_1,         KC_2,        KC_3,      KC_4,   KC_5,   KC_6,
        KC_TAB,         KC_Q,         KC_W,        KC_E,      KC_R,   KC_T,   KC_ESC,
        KC_LCTL,        KC_A,         KC_S,        KC_D,      KC_F,   KC_G,
        KC_LSFT,        KC_Z,         KC_X,        KC_C,      KC_V,   KC_B,   C_S(KC_SPC),
        KC_NO,          KC_NO,        KC_NO,       KC_LEFT,   KC_UP,
                                                               KC_LGUI,       KC_LALT,
                                                                              KC_HOME,
                                                               KC_SPC,KC_DELT,KC_END,
        // right hand
        KC_7,           KC_8,   KC_9,   KC_0,   KC_MINS,KC_EQL,           KC_BSPC,
        MO(FN),         KC_Y,   KC_U,   KC_I,   KC_O,   KC_P,             KC_BSLS,
                        KC_H,   KC_J,   KC_K,   KC_L,   KC_SCLN,          KC_QUOT,
             KC_BSPC,     KC_N,   KC_M,   KC_COMM,KC_DOT, KC_SLSH,          KC_RSFT,
                                  KC_DOWN,  KC_RGHT,KC_LBRC,KC_RBRC,          TO(TENKEY,1),
             KC_LALT,        KC_ESC,
             KC_PGUP,
             KC_PGDN,KC_SPC, KC_ENT
    ),