Example #1
0
static void
mask_edited (GtkCellRendererText *render, gchar *path, gchar *newStr, gpointer dat)
{
	GtkListStore *store = GTK_LIST_STORE (get_store ());
	GtkTreeIter iter;
	char *old;
	int flags;

	gtkutil_treemodel_string_to_iter (GTK_TREE_MODEL (store), path, &iter);
	gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &old, -1);
	
	if (!strcmp (old, newStr))	/* no change */
		;
	else if (ignore_exists (newStr))	/* duplicate, ignore */
		fe_message (_("That mask already exists."), FE_MSG_ERROR);
	else
	{
		/* delete old mask, and add new one with original flags */
		ignore_del (old);
		flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter);
		ignore_add (newStr, flags, TRUE);

		/* update tree */
		gtk_list_store_set (store, &iter, MASK_COLUMN, newStr, -1);
	}
	g_free (old);
	
}
Example #2
0
static void
ignore_store_new (int cancel, char *mask, gpointer data)
{
	if (cancel)
		return;
	/* check if it already exists */
	if (ignore_exists (mask))
	{
		fe_message (_("That mask already exists."), FE_MSG_ERROR);
		return;
	}

	GtkTreeView *view = static_cast<GtkTreeView *>(g_object_get_data(G_OBJECT(ignorewin), "view"));
	GtkListStore *store = GTK_LIST_STORE(get_store());
	GtkTreeIter iter;
	ignore::ignore_type flags = ignore::IG_DEFAULTS;

	ignore_add (mask, flags, TRUE);

	gtk_list_store_append (store, &iter);
	/* ignore everything by default */
	gtk_list_store_set (store, &iter, 0, mask, 1, TRUE, 2, TRUE, 3, TRUE,
						4, TRUE, 5, TRUE, 6, TRUE, 7, FALSE, -1);
	/* make sure the new row is visible and selected */
	GtkTreePathPtr path (gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter));
	gtk_tree_view_scroll_to_cell (view, path.get(), NULL, TRUE, 1.0, 0.0);
	gtk_tree_view_set_cursor (view, path.get(), NULL, FALSE);
}
Example #3
0
static void
option_toggled (GtkCellRendererToggle *render, gchar *path, gpointer data)
{
	GtkListStore *store = GTK_LIST_STORE (get_store ());
	GtkTreeIter iter;
	int col_id = GPOINTER_TO_INT (data);
	gboolean active;
	char *mask;
	int flags;

	gtkutil_treemodel_string_to_iter (GTK_TREE_MODEL (store), path, &iter);

	/* update model */
	gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, col_id, &active, -1);
	gtk_list_store_set (store, &iter, col_id, !active, -1);

	/* update ignore list */
	gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &mask, -1);
	flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter);
	if (ignore_add (mask, flags, TRUE) != 2)
		g_warning ("ignore treeview is out of sync!\n");
	
	g_free (mask);
}
Example #4
0
File: sob.c Project: UIKit0/sob
static void parse_arguments(int argn, char** argv)
{
	int i, produced = 0, skip_symbols = 0;
	int dump_tags = 0, dontsave = 0;
	int showrenames = 0;
	char* dump_tag_prefix = "";
	
	for (i=1; i<argn; i++) {
		if (argv[i][0] == '-') {
			if (!strcmp(argv[i], "--help")) {
				show_help();
				exit(0);
			} else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-V")) {
				printf("sob version 0.2 beta Copyright (C) 2008 Kostas Michalopoulos\n");
				printf("Visit http://www.badsectoracula.com/projects/sob/ for the latest version\n");
				exit(0);
			} else if (!strcmp(argv[i], "--skip-symbols-file")) {
				skip_symbols = 1;
				if (!quiet) printf("sob: warning: skipping default symbols file\n");
			} else if (!strcmp(argv[i], "--ignore-file") || !strcmp(argv[i], "-I")) {
				ignore_load_file(argv[++i]);
			} else if (!strcmp(argv[i], "--ignore") || !strcmp(argv[i], "-i")) {
				ignore_add(argv[++i]);
			} else if (!strcmp(argv[i], "--deignore") || !strcmp(argv[i], "-d")) {
				ignore_remove(argv[++i]);
			} else if (!strcmp(argv[i], "--quiet") || !strcmp(argv[i], "-q")) {
				quiet = 1;
			} else if (!strcmp(argv[i], "--output") || !strcmp(argv[i], "-o")) {
				outfile = argv[++i];
			} else if (!strcmp(argv[i], "--dont-save")) {
				dontsave = 1;
			} else if (!strcmp(argv[i], "--show-renames")) {
				showrenames = 1;
			} else if (!strcmp(argv[i], "--obfuscate-mask")) {
				opt_parse_obfuscate_mask_string(argv[++i]);
			} else if (!strcmp(argv[i], "--dump-tags")) {
				dump_tags = 1;
				dump_tag_prefix = argv[++i];
			} else {
				fprintf(stderr, "sob: unknown argument '%s'\n", argv[i]);
			}
		} else {
			char* swffile = outfile;
			swf_t* swf;
			if (!produced && !skip_symbols) {
				load_default_symbols(argv[0]);
			}
			produced = 1;
			swf = swf_read(argv[i]);
			if (!swf) {
				fprintf(stderr, "sob: failed to read swf file '%s'\n", argv[i]);
				exit(1);
			}
			if (!quiet) {
				printf("sob: processing %s swf '%s', version %i, body length %i\n",
					swf->compressed?"compressed":"uncompressed",
					swf->filename,
					swf->version,
					(int)swf->body_length);
				printf("sob: movie area=%i,%i -> %i,%i ",
					(int)(swf->rect.xmin/20), (int)(swf->rect.ymin/20),
					(int)(swf->rect.xmax/20), (int)(swf->rect.ymax/20));
				printf("rate=%i.%i frames=%i tags=%i\n", (int)(swf->rate>>8), (int)(swf->rate&0xFF),
					(int)swf->frame_count, (int)swf->tag_count);
			}
			
			if (dump_tags) {
				dump_swf_tags(swf, dump_tag_prefix);
				swf_free(swf);
				exit(0);
			}
			
			begin_obfuscation(swf);
			
			if (showrenames) {
				int i;
				for (i=0; i<swf->renames; i++) {
					printf("sob: rename: '%s' => '%s'\n", swf->rename[i].old_name, swf->rename[i].new_name);
				}
				printf("sob: %i renames total\n", swf->renames);
			}
			
			if (!swffile) {
				swffile = malloc(strlen(argv[i]) + 15);
				sprintf(swffile, "obfuscated_%s", argv[i]);
			}
			
			if (!dontsave) {
				if (!swf_write(swf, swffile)) {
					fprintf(stderr, "sob: failed to write swf file '%s'\n", swffile);
				} else {
					if (!quiet) printf("sob: wrote swf file '%s' with body length %i\n", swffile, (int)swf->body_length);
				}
			} else {
				if (!quiet) printf("sob: pretending i wrote swf file '%s' with body length %i\n", swffile, (int)swf->body_length);
			}
				
			
			if (!outfile) free(swffile);
			outfile = NULL;
			
			swf_free(swf);
		}
	}
Example #5
0
/*
 * @brief The main thread run, receiving and processing messages in an infinite
 * loop
 */
static void *run(void *arg)
{
    (void) arg;

    msg_init_queue(msg_buffer, TRANSCEIVER_MSG_BUFFER_SIZE);

    while (1) {
        DEBUG("transceiver: Waiting for next message\n");
        msg_t m;
        msg_receive(&m);
        /* only makes sense for messages for upper layers */
        transceiver_command_t *cmd = (transceiver_command_t *) m.content.ptr;
        DEBUG("transceiver: Transceiver: Message received, type: %02X\n", m.type);

        switch (m.type) {
            case RCV_PKT_CC1020:
            case RCV_PKT_CC1100:
            case RCV_PKT_CC2420:
            case RCV_PKT_MC1322X:
            case RCV_PKT_NATIVE:
            case RCV_PKT_AT86RF231:
                receive_packet(m.type, m.content.value);
                break;

            case SND_PKT:
                response = send_packet(cmd->transceivers, cmd->data);
                m.content.value = response;
                msg_reply(&m, &m);
                break;

            case GET_CHANNEL:
                *((int32_t *) cmd->data) = get_channel(cmd->transceivers);
                msg_reply(&m, &m);
                break;

            case SET_CHANNEL:
                *((int32_t *) cmd->data) = set_channel(cmd->transceivers, cmd->data);
                msg_reply(&m, &m);
                break;

            case GET_ADDRESS:
                *((radio_address_t *) cmd->data) = get_address(cmd->transceivers);
                msg_reply(&m, &m);
                break;

            case SET_ADDRESS:
                *((radio_address_t *) cmd->data) = set_address(cmd->transceivers, cmd->data);
                msg_reply(&m, &m);
                break;

            case GET_LONG_ADDR:
                *((transceiver_eui64_t *) cmd->data) = get_long_addr(cmd->transceivers);
                msg_reply(&m, &m);
                break;

            case SET_LONG_ADDR:
                *((transceiver_eui64_t *) cmd->data) = set_long_addr(cmd->transceivers, cmd->data);
                msg_reply(&m, &m);
                break;

            case SET_MONITOR:
                set_monitor(cmd->transceivers, cmd->data);
                break;

            case POWERDOWN:
                powerdown(cmd->transceivers);
                break;

            case SWITCH_RX:
                switch_to_rx(cmd->transceivers);
                break;

            case GET_PAN:
                *((int32_t *) cmd->data) = get_pan(cmd->transceivers);
                msg_reply(&m, &m);
                break;

            case SET_PAN:
                *((int32_t *) cmd->data) = set_pan(cmd->transceivers, cmd->data);
                msg_reply(&m, &m);
                break;

#ifdef DBG_IGNORE
            case DBG_IGN:
                *((int16_t *) cmd->data) = ignore_add(cmd->transceivers, cmd->data);
                msg_reply(&m, &m);
                break;
#endif

            default:
                DEBUG("transceiver: Unknown message received\n");
                break;
        }
    }

    return NULL;
}
Example #6
0
int
flood_check (char *nick, char *ip, server *serv, session *sess, int what)	/*0=ctcp  1=priv */
{
	/*
	   serv
	   int ctcp_counter; 
	   time_t ctcp_last_time;
	   prefs
	   unsigned int ctcp_number_limit;
	   unsigned int ctcp_time_limit;
	 */
	char buf[512];
	char real_ip[132];
	int i;
	time_t current_time;
	current_time = time (NULL);

	if (what == 0)
	{
		if (serv->ctcp_last_time == 0)	/*first ctcp in this server */
		{
			serv->ctcp_last_time = time (NULL);
			serv->ctcp_counter++;
		} else
		{
			if (difftime (current_time, serv->ctcp_last_time) < prefs.ctcp_time_limit)	/*if we got the ctcp in the seconds limit */
			{
				serv->ctcp_counter++;
				if (serv->ctcp_counter == prefs.ctcp_number_limit)	/*if we reached the maximun numbers of ctcp in the seconds limits */
				{
					serv->ctcp_last_time = current_time;	/*we got the flood, restore all the vars for next one */
					serv->ctcp_counter = 0;
					for (i = 0; i <= 128; i++)
						if (ip[i] == '@')
							break;
					snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]);
					/*ignore_add (char *mask, int priv, int noti, int chan,
					   int ctcp, int invi, int unignore, int no_save) */

					snprintf (buf, sizeof (buf),
								 "You are being CTCP flooded from %s, ignoring %s\n",
								 nick, real_ip);
					PrintText (sess, buf);

					/*FIXME: only ignore ctcp or all?, its ignoring ctcps for now */
					ignore_add (real_ip, 0, 0, 0, 1, 0, 0, 0);
					return 0;
				}
			}
		}
	} else
	{
		if (serv->msg_last_time == 0)
		{
			serv->msg_last_time = time (NULL);
			serv->ctcp_counter++;
		} else
		{
			if (difftime (current_time, serv->msg_last_time) <
				 prefs.msg_time_limit)
			{
				serv->msg_counter++;
				if (serv->msg_counter == prefs.msg_number_limit)	/*if we reached the maximun numbers of ctcp in the seconds limits */
				{
					snprintf (buf, sizeof (buf),
					 "You are being MSG flooded from %s, setting autodialog OFF.\n",
								 ip);
					PrintText (sess, buf);
					serv->msg_last_time = current_time;	/*we got the flood, restore all the vars for next one */
					serv->msg_counter = 0;
					/*ignore_add (char *mask, int priv, int noti, int chan,
					   int ctcp, int invi, int unignore, int no_save) */

					/*FIXME: only ignore ctcp or all?, its ignoring ctcps for now */
					prefs.autodialog = 0;
					return 0;
				}
			}
		}
	}
	return 1;
}