Example #1
0
/* NB: does chdir internally */
static pid_list *scan_proc_pids(inode_list *ilist)
{
	DIR *d;
	struct dirent *de;
	pid_t pid;
	pid_list *plist;

	xchdir("/proc");
	d = opendir("/proc");
	if (!d)
		return NULL;

	plist = NULL;
	while ((de = readdir(d)) != NULL) {
		pid = (pid_t)bb_strtou(de->d_name, NULL, 10);
		if (errno)
			continue;
		if (chdir(de->d_name) < 0)
			continue;
		plist = scan_link("cwd", pid, ilist, plist);
		plist = scan_link("exe", pid, ilist, plist);
		plist = scan_link("root", pid, ilist, plist);
		plist = scan_dir_links("fd", pid, ilist, plist);
		plist = scan_dir_links("lib", pid, ilist, plist);
		plist = scan_dir_links("mmap", pid, ilist, plist);
		plist = scan_pid_maps("maps", pid, ilist, plist);
		xchdir("/proc");
	}
	closedir(d);
	return plist;
}
Example #2
0
/* NB: does chdir internally */
static void scan_proc_pids(void)
{
	DIR *d;
	struct dirent *de;
	pid_t pid;

	xchdir("/proc");
	d = opendir("/proc");
	if (!d)
		return;

	while ((de = readdir(d)) != NULL) {
		pid = (pid_t)bb_strtou(de->d_name, NULL, 10);
		if (errno)
			continue;
		if (chdir(de->d_name) < 0)
			continue;
		scan_link("cwd", pid);
		scan_link("exe", pid);
		scan_link("root", pid);

		scan_dir_links("fd", pid);
		scan_dir_links("lib", pid);
		scan_dir_links("mmap", pid);

		scan_pid_maps("maps", pid);
		xchdir("/proc");
	}
	closedir(d);
}
Example #3
0
gint button_press_event(GtkWidget *widget, GdkEventButton *event)
{
	GtkTextIter iter;
	guint offset;
	gint buffer_x, buffer_y;
	GdkRectangle location;
	gboolean too_far=FALSE;

	
	LOG(LOG_DEBUG, "IN : button_press_event()");

	if((event->type == GDK_BUTTON_PRESS) &&
		(event->button == 1)){

		// If you don't convert position as buffer origin, 
		// position will be invalid when scrolling
		gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget),
						      GTK_TEXT_WINDOW_TEXT,
						      (gint)(event->x),
						      (gint)(event->y),
						      &buffer_x,
						      &buffer_y);

		gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget),
						   &iter,
						   buffer_x,
						   buffer_y);

		offset = gtk_text_iter_get_offset(&iter);

		gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget),
					&iter,
					&location);
		if((buffer_x >= location.x + font_width) || (buffer_x <= location.x - font_width))
			too_far = TRUE;
		else
			too_far = FALSE;
	

		if(scan_link(offset) && !too_far){	
			if(follow_link(offset) == TRUE)
				return(TRUE);
		}

	} else 	if((event->type == GDK_BUTTON_PRESS) &&
		((event->button == 2) || (event->button == 3))){
		gtk_item_factory_popup(GTK_ITEM_FACTORY(text_item_factory), 
				       event->x_root, event->y_root, 
				       event->button, event->time);
		LOG(LOG_DEBUG, "OUT : button_press_event() = TRUE");
		return(TRUE);

	}

	//gdk_window_get_pointer(widget->window, &x, &y, &mask);
	LOG(LOG_DEBUG, "OUT : button_press_event() = FALSE");
	return(FALSE);
}
Example #4
0
static void scan_dir_links(const char *dname, pid_t pid)
{
	DIR *d;
	struct dirent *de;
	char *lname;

	d = opendir(dname);
	if (!d)
		return;

	while ((de = readdir(d)) != NULL) {
		lname = concat_subpath_file(dname, de->d_name);
		if (lname == NULL)
			continue;
		scan_link(lname, pid);
		free(lname);
	}
	closedir(d);
}
Example #5
0
static pid_list *scan_dir_links(const char *dname, pid_t pid,
				inode_list *ilist, pid_list *plist)
{
	DIR *d;
	struct dirent *de;
	char *lname;

	d = opendir(dname);
	if (!d)
		return plist;
	while ((de = readdir(d)) != NULL) {
		lname = concat_subpath_file(dname, de->d_name);
		if (lname == NULL)
			continue;
		plist = scan_link(lname, pid, ilist, plist);
		free(lname);
	}
	closedir(d);
	return plist;
}
Example #6
0
gint motion_notify_event(GtkWidget *widget, GdkEventMotion *event)
{
	gint x, y;
	GdkModifierType mask;
	GtkTextIter iter;
	guint offset;
	gint buffer_x, buffer_y;
	GdkRectangle location;
	gboolean too_far=FALSE;
	
#ifdef __WIN32__
	HCURSOR hCursor;
#else
	GdkCursor *cursor;
#endif

//	LOG(LOG_DEBUG, "IN : motion_notify_event(x=%f,y=%f (%d %d))", event->x, event->y, buffer_x, buffer_y);

	// If you don't convert position as buffer origin, 
	// position will be invalid when scrolling
	gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget),
					      GTK_TEXT_WINDOW_TEXT,
					      (gint)(event->x),
					      (gint)(event->y),
					      &buffer_x,
					      &buffer_y);

	gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget),
					   &iter,
					   buffer_x,
					   buffer_y);
	offset = gtk_text_iter_get_offset(&iter);

	gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget),
					&iter,
					&location);
	if((buffer_x > location.x + font_width) || (buffer_x < location.x - font_width))
		too_far = TRUE;
	else
		too_far = FALSE;
	
#ifdef __WIN32__
	if(scan_link(offset) && !too_far){
		hCursor = LoadCursor(NULL, IDC_HAND);
		// Because IDC_HAND can not be used in NT
		if(hCursor == 0)
			hCursor = LoadCursor(NULL, IDC_ARROW);
	} else {
		hCursor = LoadCursor(NULL, IDC_IBEAM);
	}
	SetCursor(hCursor);
#else
	if(scan_link(offset) && !too_far){
		cursor = gdk_cursor_new (CURSOR_LINK);
	} else {
		cursor = gdk_cursor_new(CURSOR_NORMAL);
	}
	gdk_window_set_cursor(gtk_text_view_get_window(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT), cursor);
	gdk_cursor_unref(cursor);

	gdk_window_get_pointer(widget->window, &x, &y, &mask);
#endif

//	LOG(LOG_DEBUG, "OUT : motion_notify_event()");

	if(event->state & GDK_BUTTON1_MASK)
		return(FALSE);
	else 
		return(TRUE);
}