Beispiel #1
0
static void
event_buttonpress(XEvent *e)
{
     XButtonEvent *ev = &e->xbutton;
     struct mousebind *m;
     struct barwin *b;
     struct client *c;

     screen_update_sel();
     status_flush_surface();

     SLIST_FOREACH(b, &W->h.barwin, next)
          if(b->win == ev->window)
          {
               W->last_clicked_barwin = b;

               SLIST_FOREACH(m, &b->mousebinds, next)
                    MOUSE_DO_BIND(m);

               SLIST_FOREACH(m, &b->statusmousebinds, next)
                    MOUSE_DO_BIND(m);

               break;
          }
     if((c = client_gb_win(ev->window)) && c != W->client
         && ev->button == 1 && W->cfocus & CFOCUS_CLICK)
          client_focus(c);
}
Beispiel #2
0
int
main(int argc, char *argv[])
{
	struct	 number *n;
	int	 i;

	for (i = 1; i < 500; i++) {
		n = calloc(1, sizeof(*n));
		if (n == NULL)
			err(1, "calloc");

		n->n_number = i;
		SLIST_INSERT_HEAD(&nhead, n, n_entry);
	}

	printf("List:\n");
	SLIST_FOREACH(n, &nhead, n_entry)
		printf(" %d", n->n_number);
	printf("\n");

	SLIST_MERGESORT(NHEAD, &nhead);

	printf("List sorted:\n");
	SLIST_FOREACH(n, &nhead, n_entry)
		printf(" %d", n->n_number);
	printf("\n");

	exit(EXIT_SUCCESS);
}
Beispiel #3
0
void
arena_sanity(struct s_arena *arena)
{
        assert_true(!!arena);
        struct s_cache *sc;
        struct s_block *b;
        SLIST_FOREACH(sc, &arena->caches, next)
        cache_sanity(arena, sc);
        SLIST_FOREACH(b, &arena->monolithic_blocks, link)
        block_sanity(arena, NULL, b);
}
Beispiel #4
0
Datei: ewmh.c Projekt: Engil/wmfs
void
ewmh_update_wmfs_props(void)
{
     struct screen *s;
     int i, ns = 0;
     long *cts = NULL;

     SLIST_FOREACH(s, &W->h.screen, next)
          ++ns;

     cts = xcalloc(ns, sizeof(long));

     for(i = 0; i < ns; ++i)
     {
          s = screen_gb_id(i);
          cts[i] = (s->seltag ? s->seltag->id : 0);
     }

     XChangeProperty(W->dpy, W->root, W->net_atom[wmfs_current_tag], XA_CARDINAL, 32,
                     PropModeReplace, (unsigned char*)cts, ns);

     if(W->client)
          XChangeProperty(W->dpy, W->root, W->net_atom[wmfs_focus], XA_WINDOW, 32,
                          PropModeReplace, (unsigned char*)&W->client->win, 1);

     free(cts);
}
Beispiel #5
0
void killChild(void) {
	struct sandbox *box;

	/* Kill all sandboxes. */
	SLIST_FOREACH(box, &sandboxes, next)
		pdkill(box->pd, SIGKILL);
}
Beispiel #6
0
void
cache_sanity(struct s_arena *arena, struct s_cache *sc)
{
        struct s_block *b;
        assert_true(sc->arena == arena);
        SLIST_FOREACH(b, &sc->blocks, link)
        block_sanity(arena, sc, b);
}
/*
 * Get list of physical devices for active table.
 * Get dev_t from pdev vnode and insert it into cmd_array.
 *
 * XXX. This function is called from lvm2tools to get information
 *      about physical devices, too e.g. during vgcreate.
 */
int
dm_table_deps_ioctl(prop_dictionary_t dm_dict)
{
	dm_dev_t *dmv;
	dm_table_t *tbl;
	dm_table_entry_t *table_en;

	prop_array_t cmd_array;
	const char *name, *uuid;
	uint32_t flags, minor;

	int table_type;

	name = NULL;
	uuid = NULL;
	dmv = NULL;
	flags = 0;

	prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
	prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
	prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
	prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);

	/* create array for dev_t's */
	cmd_array = prop_array_create();

	if ((dmv = dm_dev_lookup(name, uuid, minor)) == NULL) {
		DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
		return ENOENT;
	}
	prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
	prop_dictionary_set_cstring(dm_dict, DM_IOCTL_NAME, dmv->name);
	prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);

	aprint_debug("Getting table deps for device: %s\n", dmv->name);

	/*
	 * if DM_QUERY_INACTIVE_TABLE_FLAG is passed we need to query
	 * INACTIVE TABLE
	 */
	if (flags & DM_QUERY_INACTIVE_TABLE_FLAG)
		table_type = DM_TABLE_INACTIVE;
	else
		table_type = DM_TABLE_ACTIVE;

	tbl = dm_table_get_entry(&dmv->table_head, table_type);

	SLIST_FOREACH(table_en, tbl, next)
	    table_en->target->deps(table_en, cmd_array);

	dm_table_release(&dmv->table_head, table_type);
	dm_dev_unbusy(dmv);

	prop_dictionary_set(dm_dict, DM_IOCTL_CMD_DATA, cmd_array);
	prop_object_release(cmd_array);

	return 0;
}
Beispiel #8
0
static unsigned praef_clock_num_sources(praef_clock* clock) {
  unsigned count = 0;
  praef_clock_source* source;

  SLIST_FOREACH(source, &clock->sources, next)
    ++count;

  return count;
}
Beispiel #9
0
static VALUE
ary_from_toklist(struct rcstoklist *tl)
{
	VALUE ret;
	struct rcstoken *t;

	ret = rb_ary_new();
	SLIST_FOREACH(t, tl, link)
		rb_ary_push(ret, str_from_tok(t));
	return ret;
}
Beispiel #10
0
/* tick every second and check for watch dog packets and lost connections */
static void
ncp_timer(void *arg){
	struct ncp_conn *conn;

	if(ncp_conn_locklist(LK_SHARED | LK_NOWAIT, NULL) == 0) {
		SLIST_FOREACH(conn, &conn_list, nc_next)
			ncp_check_conn(conn);
		ncp_conn_unlocklist(NULL);
	}
	ncp_timer_handle = timeout(ncp_timer,NULL,NCP_TIMER_TICK);
}
Beispiel #11
0
Datei: ewmh.c Projekt: Engil/wmfs
/*
 * _NET_CLIENT_LIST
 */
void
ewmh_get_client_list(void)
{
     Window *list;
     struct client *c;
     int win_n = 0;

     SLIST_FOREACH(c, &W->h.client, next)
          ++win_n;

     list = xcalloc(win_n, sizeof(Window));

     win_n = 0;
     SLIST_FOREACH(c, &W->h.client, next)
          list[win_n++] = c->win;

     XChangeProperty(W->dpy, W->root, W->net_atom[net_client_list], XA_WINDOW, 32,
                     PropModeReplace, (unsigned char *)list, win_n);

     XFree(list);
}
Beispiel #12
0
static void pipe_wake_cb(struct queue *q, void *data, int filter)
{
	/* If you allocate structs like this on odd byte boundaries, you
	 * deserve what you get.  */
	uintptr_t kludge = (uintptr_t) data;
	int which = kludge & 1;
	Pipe *p = (Pipe*)(kludge & ~1ULL);
	struct fd_tap *tap_i;

	spin_lock(&p->tap_lock);
	SLIST_FOREACH(tap_i, &p->data_taps[which], link)
		fire_tap(tap_i, filter);
	spin_unlock(&p->tap_lock);
}
Beispiel #13
0
void
uicb_tag_new(Uicb cmd)
{
     struct screen *s = W->screen;
     struct infobar *i;

     tag_new(s, (char*)cmd);

     s->flags |= SCREEN_TAG_UPDATE;

     SLIST_FOREACH(i, &s->infobars, next)
          infobar_elem_reinit(i);

     s->flags ^= SCREEN_TAG_UPDATE;
}
Beispiel #14
0
Datei: event.c Projekt: HFT/wmfs
static void
event_buttonpress(XEvent *e)
{
     XButtonEvent *ev = &e->xbutton;
     struct mousebind *m;
     struct barwin *b;

     screen_update_sel();
     status_flush_surface();

     SLIST_FOREACH(b, &W->h.barwin, next)
          if(b->win == ev->window)
          {
               W->last_clicked_barwin = b;

               SLIST_FOREACH(m, &b->mousebinds, next)
                    MOUSE_DO_BIND(m);

               SLIST_FOREACH(m, &b->statusmousebinds, next)
                    MOUSE_DO_BIND(m);

               break;
          }
}
Beispiel #15
0
int
main(int argc, const char *argv[])
{
	char		 testword[] = "Testi";
	struct gram	*np = NULL;

	setlocale(LC_ALL, "");

	ngram(testword, sizeof(testword), 2);
	SLIST_FOREACH(np, &grams_head, grams)
		fprintf(stdout, "%s\n", np->buf);

	free_gramlist();

	return 0;
}
Beispiel #16
0
void
export_keep()
{
	Plistnumbered	*plisthead;
	Pkglist		*plist;

	if ((plisthead = rec_pkglist(EXPORT_KEEP_LIST)) == NULL)
		errx(EXIT_FAILURE, MSG_EMPTY_LOCAL_PKGLIST);
	/* yes we could output directly from the sql reading, but we would lose
	 * some genericity.
	 */
	SLIST_FOREACH(plist, plisthead->P_Plisthead, next)
		printf("%s\n", plist->full);

	free_pkglist(&plisthead->P_Plisthead, LIST);
	free(plisthead);
}
Beispiel #17
0
void
uicb_tag_del(Uicb cmd)
{
     struct infobar *i;
     struct tag *t = W->screen->seltag;
     (void)cmd;

     if(SLIST_EMPTY(&t->clients)
        && TAILQ_NEXT(TAILQ_FIRST(&W->screen->tags), next))
     {
          tag_screen(W->screen, TAILQ_NEXT(t, next));
          tag_remove(t);

          W->screen->flags |= SCREEN_TAG_UPDATE;

          SLIST_FOREACH(i, &W->screen->infobars, next)
               infobar_elem_reinit(i);

          W->screen->flags ^= SCREEN_TAG_UPDATE;
     }
}
Beispiel #18
0
/*
 * Return > 0 if table is at least one table entry (returns number of entries)
 * and return 0 if there is not. Target count returned from this function
 * doesn't need to be true when userspace user receive it (after return
 * there can be dm_dev_resume_ioctl), therfore this isonly informative.
 */
int
dm_table_get_target_count(dm_table_head_t * head, uint8_t table_id)
{
	dm_table_entry_t *table_en;
	dm_table_t *tbl;
	uint32_t target_count;
	uint8_t id;

	target_count = 0;

	id = dm_table_busy(head, table_id);

	tbl = &head->tables[id];

	SLIST_FOREACH(table_en, tbl, next)
	    target_count++;

	dm_table_unbusy(head);

	return target_count;
}
Beispiel #19
0
int
main(int argc, char **argv)
{
	char errbuf[_POSIX2_LINE_MAX], dummy;
	size_t	size;
	struct cmdentry *cmd = NULL;

	(void) setlocale(LC_ALL, "");

	SLIST_INIT(&commands);
	argc--, argv++;
	if (argc > 0) {
		if (argv[0][0] == '-') {
			struct cmdtab *p;

			p = lookup(&argv[0][1]);
			if (p == (struct cmdtab *)-1)
				errx(1, "%s: ambiguous request", &argv[0][1]);
			if (p == (struct cmdtab *)0)
				errx(1, "%s: unknown request", &argv[0][1]);
			curcmd = p;
			argc--, argv++;
		}
		parse_cmd_args (argc, argv);
		
	}
	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
	if (kd != NULL) {
		/*
		 * Try to actually read something, we may be in a jail, and
		 * have /dev/null opened as /dev/mem.
		 */
		if (kvm_nlist(kd, namelist) != 0 || namelist[0].n_value == 0 ||
		    kvm_read(kd, namelist[0].n_value, &dummy, sizeof(dummy)) !=
		    sizeof(dummy)) {
			kvm_close(kd);
			kd = NULL;
		}
	}
	if (kd == NULL) {
		/*
		 * Maybe we are lacking permissions? Retry, this time with bogus
		 * devices. We can now use sysctl only.
		 */
		use_kvm = 0;
		kd = kvm_openfiles(_PATH_DEVNULL, _PATH_DEVNULL, _PATH_DEVNULL,
		    O_RDONLY, errbuf);
		if (kd == NULL) {
			error("%s", errbuf);
			exit(1);
		}
	}
	signal(SIGHUP, die);
	signal(SIGINT, die);
	signal(SIGQUIT, die);
	signal(SIGTERM, die);

	/*
	 * Initialize display.  Load average appears in a one line
	 * window of its own.  Current command's display appears in
	 * an overlapping sub-window of stdscr configured by the display
	 * routines to minimize update work by curses.
	 */
	initscr();
	CMDLINE = LINES - 1;
	wnd = (*curcmd->c_open)();
	if (wnd == NULL) {
		warnx("couldn't initialize display");
		die(0);
	}
	wload = newwin(1, 0, 1, 20);
	if (wload == NULL) {
		warnx("couldn't set up load average window");
		die(0);
	}
	gethostname(hostname, sizeof (hostname));
	size = sizeof(clkinfo);
	if (sysctlbyname("kern.clockrate", &clkinfo, &size, NULL, 0)
	    || size != sizeof(clkinfo)) {
		error("kern.clockrate");
		die(0);
	}
	hertz = clkinfo.stathz;
	(*curcmd->c_init)();
	curcmd->c_flags |= CF_INIT;
	labels();

	if (curcmd->c_cmd != NULL)
		SLIST_FOREACH (cmd, &commands, link)
			if (!curcmd->c_cmd(cmd->cmd, cmd->argv))
				warnx("command is not understood");

	dellave = 0.0;
	display();
	noecho();
	crmode();
	keyboard();
	/*NOTREACHED*/

	return EXIT_SUCCESS;
}