示例#1
0
static gint
unsolicited_msg_handler_cmp (MMAtUnsolicitedMsgHandler *handler,
                             GRegex *regex)
{
    return g_strcmp0 (g_regex_get_pattern (handler->regex),
                      g_regex_get_pattern (regex));
}
示例#2
0
文件: filter.c 项目: nshi/falcon
static inline gboolean falcon_filter_regex_equal(gconstpointer a,
                                                 gconstpointer b)
{
	const GRegex *regex_a = (const GRegex *)a;
	const GRegex *regex_b = (const GRegex *)b;
	return (g_strcmp0(g_regex_get_pattern(regex_a),
	                  g_regex_get_pattern(regex_b)) == 0);
}
示例#3
0
const gchar *
_gtk_source_regex_get_pattern (GtkSourceRegex *regex)
{
	g_assert (regex->resolved);

	return g_regex_get_pattern (regex->u.regex.regex);
}
GRegex *
terminal_search_dialog_get_regex (GtkWidget *dialog)
{
  TerminalSearchDialogPrivate *priv;
  GRegexCompileFlags compile_flags;
  const char *text, *pattern;

  g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);

  priv = TERMINAL_SEARCH_DIALOG_GET_PRIVATE (dialog);
  g_return_val_if_fail (priv, NULL);

  pattern = text = terminal_search_dialog_get_search_text (dialog);

  compile_flags = G_REGEX_OPTIMIZE;

  if (!GET_FLAG (match_case_checkbutton))
    compile_flags |= G_REGEX_CASELESS;

  if (GET_FLAG (regex_checkbutton))
    compile_flags |= G_REGEX_MULTILINE;
  else
    pattern = g_regex_escape_string (text, -1);

  if (GET_FLAG (entire_word_checkbutton)) {
    const char *old_pattern = pattern;
    pattern = g_strdup_printf ("\\b%s\\b", pattern);
    if (old_pattern != text)
      g_free ((char *) old_pattern);
  }

  if (!priv->regex || priv->regex_compile_flags != compile_flags ||
      g_strcmp0 (pattern, g_regex_get_pattern (priv->regex)) != 0) {
    priv->regex_compile_flags = compile_flags;
    if (priv->regex)
      g_regex_unref (priv->regex);

    /* TODO Error handling */
    priv->regex = g_regex_new (pattern, compile_flags, 0, NULL);
  }

  if (pattern != text)
    g_free ((char *) pattern);

  return priv->regex;
}
示例#5
0
static void
logview_filter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
  LogviewFilterPrivate* priv = LOGVIEW_FILTER (object)->priv;

  switch (prop_id) {
    case PROP_REGEX:
      g_value_set_string (value, g_regex_get_pattern (priv->regex));
      break;
    case PROP_NAME:
      g_value_set_string (value, priv->name);
      break;
    case PROP_TEXTTAG:
      g_value_set_object (value, priv->tag);
      break;
  }
}
示例#6
0
static void termit_search_prepare_regex(const gchar* searchRegex)
{
    gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook));
    TERMIT_GET_TAB_BY_INDEX(pTab, page);
    if (strlen(searchRegex) == 0) {
        vte_terminal_search_set_gregex(VTE_TERMINAL(pTab->vte), NULL);
    } else {
        GRegex* currSearchRegex = vte_terminal_search_get_gregex(VTE_TERMINAL(pTab->vte));
        if (!currSearchRegex || strcmp(searchRegex, g_regex_get_pattern(currSearchRegex)) != 0) {
            GError* err = NULL;
            GRegex* regex = g_regex_new(searchRegex, 0, 0, &err);
            if (err) {
                TRACE("failed to compile regex [%s]: skipping", searchRegex);
                return;
            }
            vte_terminal_search_set_gregex(VTE_TERMINAL(pTab->vte), regex);
        }
    }
}
示例#7
0
void moloch_config_init()
{
    int i;
    char *str;
    static char *rotates[] = {"hourly", "daily", "weekly", "monthly"};

    HASH_INIT(s_, config.dontSaveTags, moloch_string_hash, moloch_string_cmp);

    moloch_config_load();

    if (config.debug) {
        LOG("nodeClass: %s", config.nodeClass);
        LOG("elasticsearch: %s", config.elasticsearch);
        LOG("prefix: %s", config.prefix);
        LOG("interface: %s", config.interface);
        if (config.pcapDir) {
            str = g_strjoinv(";", config.pcapDir);
            LOG("pcapDir: %s", str);
            g_free(str);
        }
        LOG("bpf: %s", config.bpf);
        LOG("yara: %s", config.yara);
        LOG("geoipFile: %s", config.geoipFile);
        LOG("geoipASNFile: %s", config.geoipASNFile);
        LOG("rirFile: %s", config.rirFile);
        LOG("dropUser: %s", config.dropUser);
        LOG("dropGroup: %s", config.dropGroup);

        if (config.smtpIpHeaders) {
            str = g_strjoinv(";", config.smtpIpHeaders);
            LOG("smtpIpHeaders: %s", str);
            g_free(str);
        }

        if (config.pluginsDir) {
            str = g_strjoinv(";", config.pluginsDir);
            LOG("pluginsDir: %s", str);
            g_free(str);
        }

        if (config.plugins) {
            str = g_strjoinv(";", config.plugins);
            LOG("plugins: %s", str);
            g_free(str);
        }

        if (config.parsersDir) {
            str = g_strjoinv(";", config.parsersDir);
            LOG("parsersDir: %s", str);
            g_free(str);
        }

        LOG("maxFileSizeG: %lf", config.maxFileSizeG);
        LOG("maxFileSizeB: %ld", config.maxFileSizeB);
        LOG("maxFileTimeM: %u", config.maxFileTimeM);
        LOG("icmpTimeout: %u", config.icmpTimeout);
        LOG("udpTimeout: %u", config.udpTimeout);
        LOG("tcpTimeout: %u", config.tcpTimeout);
        LOG("tcpSaveTimeout: %u", config.tcpSaveTimeout);
        LOG("maxStreams: %u", config.maxStreams);
        LOG("maxPackets: %u", config.maxPackets);
        LOG("minFreeSpaceG: %u", config.minFreeSpaceG);
        LOG("dbBulkSize: %u", config.dbBulkSize);
        LOG("dbFlushTimeout: %u", config.dbFlushTimeout);
        LOG("maxESConns: %u", config.maxESConns);
        LOG("maxESRequests: %u", config.maxESRequests);
        LOG("logEveryXPackets: %u", config.logEveryXPackets);
        LOG("packetsPerPoll: %u", config.packetsPerPoll);
        LOG("pcapBufferSize: %u", config.pcapBufferSize);
        LOG("pcapWriteSize: %u", config.pcapWriteSize);
        LOG("maxFreeOutputBuffers: %u", config.maxFreeOutputBuffers);

        LOG("logUnknownProtocols: %s", (config.logUnknownProtocols?"true":"false"));
        LOG("logESRequests: %s", (config.logESRequests?"true":"false"));
        LOG("logFileCreation: %s", (config.logFileCreation?"true":"false"));
        LOG("parseSMTP: %s", (config.parseSMTP?"true":"false"));
        LOG("parseSMB: %s", (config.parseSMB?"true":"false"));
        LOG("parseQSValue: %s", (config.parseQSValue?"true":"false"));
        LOG("parseCookieValue: %s", (config.parseCookieValue?"true":"false"));
        LOG("compressES: %s", (config.compressES?"true":"false"));

        LOG("rotateIndex = %s", rotates[config.rotate]);
        LOG("offlineFilenameRegex: %s", g_regex_get_pattern(config.offlineRegex));

        MolochString_t *tstring;
        HASH_FORALL(s_, config.dontSaveTags, tstring,
          LOG("dontSaveTags: %s", tstring->str);
        );
示例#8
0
static liHandlerResult vhost_map_regex(liVRequest *vr, gpointer param, gpointer *context) {
	guint i;
	vhost_map_regex_data *mrd = param;
	GArray *list = mrd->list;
	gboolean debug = _OPTION(vr, mrd->plugin, 0).boolean;
	liValue *v = NULL;
	vhost_map_regex_entry *entry = NULL;

	UNUSED(context);

	/* loop through all rules to find a match */
	for (i = 0; i < list->len; i++) {
		entry = &g_array_index(list, vhost_map_regex_entry, i);

		if (!g_regex_match(entry->regex, vr->request.uri.host->str, 0, NULL))
			continue;

		v = entry->action;

		break;
	}

	if (NULL != v) {
		if (debug) {
			VR_DEBUG(vr, "vhost_map_regex: host %s matches pattern \"%s\"", vr->request.uri.host->str, g_regex_get_pattern(entry->regex));
		}
		li_action_enter(vr, v->data.val_action.action);
	} else if (NULL != mrd->default_action) {
		if (debug) {
			VR_DEBUG(vr, "vhost_map_regex: host %s didn't match, executing default action", vr->request.uri.host->str);
		}
		li_action_enter(vr, mrd->default_action->data.val_action.action);
	} else {
		if (debug) {
			VR_DEBUG(vr, "vhost_map_regex: neither did %s match nor default action specified, doing nothing", vr->request.uri.host->str);
		}
	}

	return LI_HANDLER_GO_ON;
}
示例#9
0
static VALUE
rg_pattern(VALUE self)
{
    return CSTR2RVAL(g_regex_get_pattern(_SELF(self)));
}
示例#10
0
文件: filter.c 项目: nshi/falcon
static inline guint falcon_filter_regex_hash(gconstpointer key)
{
	const GRegex *regex = (const GRegex *)key;
	return g_str_hash(g_regex_get_pattern(regex));
}
示例#11
0
static void
gregex_to_repr(fvalue_t *fv, ftrepr_t rtype, char *buf)
{
    g_assert(rtype == FTREPR_DFILTER);
    strcpy(buf, g_regex_get_pattern(fv->value.re));
}
示例#12
0
static int
gregex_repr_len(fvalue_t *fv, ftrepr_t rtype)
{
    g_assert(rtype == FTREPR_DFILTER);
    return (int)strlen(g_regex_get_pattern(fv->value.re));
}
示例#13
0
文件: filter.c 项目: sinoory/webv8
gboolean adblock_filter_check_rule (AdblockFilter* self, GRegex* regex, const gchar* pattern, const gchar* request_uri, const gchar* page_uri, GError** error) {
	gboolean result = FALSE;
	GRegex* _tmp0_;
	const gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_;
	AdblockOptions* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_ = NULL;
	gchar* opts;
	gboolean _tmp7_ = FALSE;
	const gchar* _tmp8_;
	gboolean _tmp11_;
	GRegex* _tmp19_;
	const gchar* _tmp20_ = NULL;
	const gchar* _tmp21_;
	GError * _inner_error_ = NULL;
#line 39 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 39 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	g_return_val_if_fail (regex != NULL, FALSE);
#line 39 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	g_return_val_if_fail (pattern != NULL, FALSE);
#line 39 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	g_return_val_if_fail (request_uri != NULL, FALSE);
#line 39 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	g_return_val_if_fail (page_uri != NULL, FALSE);
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp0_ = regex;
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp1_ = request_uri;
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp2_ = g_regex_match_full (_tmp0_, _tmp1_, (gssize) (-1), 0, 0, NULL, &_inner_error_);
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp3_ = _tmp2_;
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	if (_inner_error_ != NULL) {
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		g_propagate_error (error, _inner_error_);
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		return FALSE;
#line 332 "filter.c"
	}
#line 40 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	if (!_tmp3_) {
#line 41 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		result = FALSE;
#line 41 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		return result;
#line 340 "filter.c"
	}
#line 43 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp4_ = self->priv->optslist;
#line 43 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp5_ = pattern;
#line 43 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp6_ = adblock_options_lookup (_tmp4_, _tmp5_);
#line 43 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	opts = _tmp6_;
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp8_ = opts;
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	if (_tmp8_ != NULL) {
#line 354 "filter.c"
		const gchar* _tmp9_;
		gboolean _tmp10_ = FALSE;
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		_tmp9_ = opts;
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		_tmp10_ = g_regex_match_simple (",third-party", _tmp9_, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY);
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		_tmp7_ = _tmp10_;
#line 363 "filter.c"
	} else {
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		_tmp7_ = FALSE;
#line 367 "filter.c"
	}
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp11_ = _tmp7_;
#line 44 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	if (_tmp11_) {
#line 373 "filter.c"
		gboolean _tmp12_ = FALSE;
		const gchar* _tmp13_;
		gboolean _tmp18_;
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		_tmp13_ = page_uri;
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		if (_tmp13_ != NULL) {
#line 381 "filter.c"
			GRegex* _tmp14_;
			const gchar* _tmp15_;
			gboolean _tmp16_ = FALSE;
			gboolean _tmp17_;
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			_tmp14_ = regex;
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			_tmp15_ = page_uri;
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			_tmp16_ = g_regex_match_full (_tmp14_, _tmp15_, (gssize) (-1), 0, 0, NULL, &_inner_error_);
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			_tmp17_ = _tmp16_;
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			if (_inner_error_ != NULL) {
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
				g_propagate_error (error, _inner_error_);
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
				_g_free0 (opts);
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
				return FALSE;
#line 402 "filter.c"
			}
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			_tmp12_ = _tmp17_;
#line 406 "filter.c"
		} else {
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			_tmp12_ = FALSE;
#line 410 "filter.c"
		}
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		_tmp18_ = _tmp12_;
#line 46 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
		if (_tmp18_) {
#line 47 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			result = FALSE;
#line 47 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			_g_free0 (opts);
#line 47 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
			return result;
#line 422 "filter.c"
		}
	}
#line 48 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp19_ = regex;
#line 48 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp20_ = g_regex_get_pattern (_tmp19_);
#line 48 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_tmp21_ = request_uri;
#line 48 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	adblock_debug ("blocked by pattern regexp=%s -- %s", _tmp20_, _tmp21_, NULL);
#line 49 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	result = TRUE;
#line 49 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	_g_free0 (opts);
#line 49 "/home/luyue/new/Webkit2Browser/Source/midori/extensions/adblock/filter.vala"
	return result;
#line 439 "filter.c"
}