Beispiel #1
0
v_partition
v_addPartition(
    v_kernel kernel,
    v_partition partition)
{
    v_partition found;

    assert(kernel != NULL);
    assert(C_TYPECHECK(kernel,v_kernel));
    assert(partition != NULL);
    assert(C_TYPECHECK(partition,v_partition));

    c_lockWrite(&kernel->lock);
    found = c_insert(kernel->partitions,partition);
    c_lockUnlock(&kernel->lock);

    if (found != partition) {
        assert(v_objectKind(found) == K_DOMAIN);
        if (v_objectKind(found) != K_DOMAIN) {
            partition = NULL;
        } else {
            partition = found;
        }
    }
    return partition;
}
Beispiel #2
0
/* vi_comment_out():
 *	Vi comment out current command
 *	[#]
 */
libedit_private el_action_t
/*ARGSUSED*/
vi_comment_out(EditLine *el, wint_t c __attribute__((__unused__)))
{

	el->el_line.cursor = el->el_line.buffer;
	c_insert(el, 1);
	*el->el_line.cursor = '#';
	re_refresh(el);
	return ed_newline(el, 0);
}
Beispiel #3
0
/* ed_insert():
 *	Add character to the line
 *	Insert a character [bound to all insert keys]
 */
libedit_private el_action_t
ed_insert(EditLine *el, wint_t c)
{
	int count = el->el_state.argument;

	if (c == '\0')
		return CC_ERROR;

	if (el->el_line.lastchar + el->el_state.argument >=
	    el->el_line.limit) {
		/* end of buffer space, try to allocate more */
		if (!ch_enlargebufs(el, (size_t) count))
			return CC_ERROR;	/* error allocating more */
	}

	if (count == 1) {
		if (el->el_state.inputmode == MODE_INSERT
		    || el->el_line.cursor >= el->el_line.lastchar)
			c_insert(el, 1);

		*el->el_line.cursor++ = c;
		re_fastaddc(el);		/* fast refresh for one char. */
	} else {
		if (el->el_state.inputmode != MODE_REPLACE_1)
			c_insert(el, el->el_state.argument);

		while (count-- && el->el_line.cursor < el->el_line.lastchar)
			*el->el_line.cursor++ = c;
		re_refresh(el);
	}

	if (el->el_state.inputmode == MODE_REPLACE_1)
		return vi_command_mode(el, 0);

	return CC_NORM;
}
Beispiel #4
0
v_cfNode
v_cfElementAddChild(
    v_cfElement element,
    v_cfNode child)
{
    v_cfNode ch;

    assert(C_TYPECHECK(element, v_cfElement));
    assert(C_TYPECHECK(child, v_cfNode));

    ch = v_cfNode(c_insert(element->children, 
                          c_object(child)));

    return ch;
}
Beispiel #5
0
/**************************************************************
 * Public functions
 **************************************************************/
v_cfAttribute
v_cfElementAddAttribute (
    v_cfElement element,
    v_cfAttribute attribute)
{
    v_cfAttribute attr;

    assert(C_TYPECHECK(element, v_cfElement));
    assert(C_TYPECHECK(attribute, v_cfAttribute));

    attr = v_cfAttribute(c_insert(element->attributes, 
                                 c_object(attribute)));

    return attr;
}
Beispiel #6
0
v_entity
v_addShareUnsafe(
    v_kernel kernel,
    v_entity e)
{
    v_entity found;

    assert(kernel != NULL);
    assert(C_TYPECHECK(kernel,v_kernel));
    assert(e != NULL);
    assert(C_TYPECHECK(e,v_entity));

    found = c_insert(kernel->shares,e);

    return found;
}
Beispiel #7
0
/* el_insertstr():
 *	Insert string at cursorI
 */
int
el_winsertstr(EditLine *el, const wchar_t *s)
{
	size_t len;

	if (s == NULL || (len = wcslen(s)) == 0)
		return -1;
	if (el->el_line.lastchar + len >= el->el_line.limit) {
		if (!ch_enlargebufs(el, len))
			return -1;
	}

	c_insert(el, (int)len);
	while (*s)
		*el->el_line.cursor++ = *s++;
	return 0;
}
Beispiel #8
0
/* vi_history_word():
 *	Vi append word from previous input line
 *	[_]
 * Who knows where this one came from!
 * '_' in vi means 'entire current line', so 'cc' is a synonym for 'c_'
 */
libedit_private el_action_t
/*ARGSUSED*/
vi_history_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
	const wchar_t *wp = HIST_FIRST(el);
	const wchar_t *wep, *wsp;
	int len;
	wchar_t *cp;
	const wchar_t *lim;

	if (wp == NULL)
		return CC_ERROR;

	wep = wsp = NULL;
	do {
		while (iswspace(*wp))
			wp++;
		if (*wp == 0)
			break;
		wsp = wp;
		while (*wp && !iswspace(*wp))
			wp++;
		wep = wp;
	} while ((!el->el_state.doingarg || --el->el_state.argument > 0)
	    && *wp != 0);

	if (wsp == NULL || (el->el_state.doingarg && el->el_state.argument != 0))
		return CC_ERROR;

	cv_undo(el);
	len = (int)(wep - wsp);
	if (el->el_line.cursor < el->el_line.lastchar)
		el->el_line.cursor++;
	c_insert(el, len + 1);
	cp = el->el_line.cursor;
	lim = el->el_line.limit;
	if (cp < lim)
		*cp++ = ' ';
	while (wsp < wep && cp < lim)
		*cp++ = *wsp++;
	el->el_line.cursor = cp;

	el->el_map.current = el->el_map.key;
	return CC_REFRESH;
}
Beispiel #9
0
v_participant
v_addParticipant(
    v_kernel kernel,
    v_participant p)
{
    v_participant found;

    assert(kernel != NULL);
    assert(C_TYPECHECK(kernel,v_kernel));
    assert(p != NULL);
    assert(C_TYPECHECK(p,v_participant));

    c_lockWrite(&kernel->lock);
    found = c_insert(kernel->participants,p);
    c_lockUnlock(&kernel->lock);

    return found;
}
Beispiel #10
0
/**************************************************************
 * Protected functions
 **************************************************************/
void
v_serviceNotify(
    v_service service,
    v_event event,
    c_voidp userData)
{
    v_group group;

    assert(service != NULL);
    assert(C_TYPECHECK(service, v_service));

    if (event != NULL) {
        switch (event->kind) {
        case V_EVENT_SERVICESTATE_CHANGED:
        break;
        case V_EVENT_NEW_GROUP:
            group = v_group(event->userData);

            if ((group != NULL) && (v_observer(service)->eventData != NULL)) {
                /* Update new group admin */
                c_insert((c_set)v_observer(service)->eventData, group);
            }
            /* This allows receiving the event by means of a waitset.*/
            v_observableNotify(v_observable(service), event);
        break;
        case V_EVENT_HISTORY_DELETE:
            /* This allows receiving the event by means of a waitset.*/
            v_observableNotify(v_observable(service), event);
        break;
        case V_EVENT_HISTORY_REQUEST:
            /* This allows receiving the event by means of a waitset.*/
            v_observableNotify(v_observable(service), event);
        break;
        case V_EVENT_CONNECT_WRITER:
        case V_EVENT_PERSISTENT_SNAPSHOT:
            /* This allows receiving the event by means of a waitset.*/
            v_observableNotify(v_observable(service), event);
        break;
        default:
        break;
        }
    }
    v_participantNotify(v_participant(service), event, userData);
}
Beispiel #11
0
c_bool
v_groupStreamSubscribeGroup(
    v_groupStream stream,
    v_group group)
{
    c_bool inserted;

    assert(C_TYPECHECK(stream, v_groupStream));
    assert(C_TYPECHECK(group, v_group));

    if (v_reader(stream)->qos->durability.kind == v_topicQosRef(group->topic)->durability.kind) {
        inserted = v_groupAddStream(group, stream);

        if(inserted == TRUE){
            c_insert(stream->groups, group);
        }
    }
    return TRUE;
}
Beispiel #12
0
void
v_participantResendManagerAddWriter(
    v_participant p,
    v_writer w)
{
    v_proxy wp, found;
    assert(C_TYPECHECK(p,v_participant));

    wp = v_proxyNew(v_objectKernel(w), v_publicHandle(v_public(w)), NULL);

    c_mutexLock(&p->resendMutex);
    found = c_insert(p->resendWriters, wp);
    assert((found->source.index == wp->source.index) &&
            (found->source.serial == wp->source.serial));
    c_condBroadcast(&p->resendCond);
    c_mutexUnlock(&p->resendMutex);

    c_free(wp);
}
Beispiel #13
0
static void
addAllGroups(
    c_set newGroups,
    v_groupSet groupSet)
{
    c_iter groups = NULL;
    v_group g;

    assert(C_TYPECHECK(groupSet, v_groupSet));

    groups = v_groupSetSelectAll(groupSet);
    g = v_group(c_iterTakeFirst(groups));
    while (g != NULL) {
        c_insert(newGroups, g);
        c_free(g);
        g = v_group(c_iterTakeFirst(groups));
    }
    c_iterFree(groups);
}
Beispiel #14
0
/* em_copy_prev_word():
 *	Copy current word to cursor
 */
libedit_private el_action_t
/*ARGSUSED*/
em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
	wchar_t *cp, *oldc, *dp;

	if (el->el_line.cursor == el->el_line.buffer)
		return CC_ERROR;

	oldc = el->el_line.cursor;
	/* does a bounds check */
	cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
	    el->el_state.argument, ce__isword);

	c_insert(el, (int)(oldc - cp));
	for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
		*dp++ = *cp;

	el->el_line.cursor = dp;/* put cursor at end */

	return CC_REFRESH;
}
Beispiel #15
0
v_topic
v__addTopic(
    v_kernel kernel,
    v_topic topic)
{
    v_topic found;

    assert(kernel != NULL);
    assert(C_TYPECHECK(kernel,v_kernel));
    assert(topic != NULL);
    assert(C_TYPECHECK(topic,v_topic));

    c_lockWrite(&kernel->lock);
    found = c_insert(kernel->topics,topic);
    c_lockUnlock(&kernel->lock);

    if (found != topic) {
        if (v_objectKind(found) != K_TOPIC) {
            return NULL;
        }
        topic = found;
    }
    return topic;
}