示例#1
0
文件: test.c 项目: kspaans/CS499
__attribute__((unused)) static void fstest_task(void) {
	int chan;
	char path[PATH_MAX+1];
	printf("path_max test\n");
	memset(path, 'a', PATH_MAX);
	path[PATH_MAX] = 0;
	printf(" mkchan: %d\n", mkchan(ROOT_DIRFD, path));
	printf(" open: %d\n", chan=open(ROOT_DIRFD, path));
	printf(" rmchan: %d\n", rmchan(ROOT_DIRFD, path));
	printf(" close: %d\n", close(chan));
	for(int i=0; i<100; ++i) {
		sprintf(path, "/tmp/test%d", i);
		ASSERTNOERR(mkchan(ROOT_DIRFD, path));
		ASSERTNOERR(chan=open(ROOT_DIRFD, path));
		ASSERTNOERR(rmchan(ROOT_DIRFD, path));
		ASSERTNOERR(close(chan));
	}
}
示例#2
0
void left(USERS *user, CHANNEL *chan, acetables *g_ape) // Vider la liste chainée de l'user
{
	userslist *list, *prev;

	CHANLIST *clist, *ctmp;
	RAW *newraw;
	json_item *jlist;
	
	FIRE_EVENT_NULL(left, user, chan, g_ape);
	
	if (!isonchannel(user, chan)) {
		return;
	}
	
	list = chan->head;
	prev = NULL;
	
	clist = user->chan_foot;
	ctmp = NULL;
	
	while (clist != NULL) {
		if (clist->chaninfo == chan) {
			if (ctmp != NULL) {
				ctmp->next = clist->next;
			} else {
				user->chan_foot = clist->next;
			}
			free(clist);
			break;
		}
		ctmp = clist;
		clist = clist->next;
	}
	
	
	while (list != NULL && list->userinfo != NULL) {
		if (list->userinfo == user) {
			if (prev != NULL) {
				prev->next = list->next;
			} else {
				chan->head = list->next;
			}
			free(list);
			list = NULL;
			if (chan->head != NULL && chan->interactive) {
				jlist = json_new_object();
				
				json_set_property_objN(jlist, "user", 4, get_json_object_user(user));
				json_set_property_objN(jlist, "pipe", 4, get_json_object_channel(chan));
				
				newraw = forge_raw(RAW_LEFT, jlist);
				post_raw_channel(newraw, chan, g_ape);
			} else if (chan->head == NULL) {
				rmchan(chan, g_ape);
			}
			break;
		}
		prev = list;
		list = list->next;
	}
	
}