Beispiel #1
0
/*
 * v_chF -- [count]Fc
 *	Search backward in the line for the next occurrence of the
 *	specified character.
 *
 * PUBLIC: int v_chF __P((SCR *, VICMD *));
 */
int
v_chF(SCR *sp, VICMD *vp)
{
	size_t len;
	u_long cnt;
	int isempty;
	ARG_CHAR_T key;
	CHAR_T *endp, *p;

	/*
	 * !!!
	 * If it's a dot command, it doesn't reset the key for which
	 * we're searching, e.g. in "df1|f2|.|;", the ';' searches
	 * for a '2'.
	 */
	key = vp->character;
	if (!F_ISSET(vp, VC_ISDOT))
		VIP(sp)->lastckey = key;
	VIP(sp)->csearchdir = FSEARCH;

	if (db_eget(sp, vp->m_start.lno, &p, &len, &isempty)) {
		if (isempty)
			goto empty;
		return (1);
	}

	if (len == 0) {
empty:		notfound(sp, key);
		return (1);
	}

	endp = p - 1;
	p += vp->m_start.cno;
	for (cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1; cnt--;) {
		while (--p > endp && *p != key);
		if (p == endp) {
			notfound(sp, key);
			return (1);
		}
	}

	vp->m_stop.cno = (p - endp) - 1;

	/*
	 * All commands move to the end of the range.  Motion commands
	 * adjust the starting point to the character before the current
	 * one.
	 */
	vp->m_final = vp->m_stop;
	if (ISMOTION(vp))
		--vp->m_start.cno;
	return (0);
}
Beispiel #2
0
/*
 * v_chf -- [count]fc
 *	Search forward in the line for the next occurrence of the
 *	specified character.
 *
 * PUBLIC: int v_chf __P((SCR *, VICMD *));
 */
int
v_chf(SCR *sp, VICMD *vp)
{
	size_t len;
	u_long cnt;
	int isempty;
	ARG_CHAR_T key;
	CHAR_T *endp, *p, *startp;

	/*
	 * !!!
	 * If it's a dot command, it doesn't reset the key for which we're
	 * searching, e.g. in "df1|f2|.|;", the ';' searches for a '2'.
	 */
	key = vp->character;
	if (!F_ISSET(vp, VC_ISDOT))
		VIP(sp)->lastckey = key;
	VIP(sp)->csearchdir = fSEARCH;

	if (db_eget(sp, vp->m_start.lno, &p, &len, &isempty)) {
		if (isempty)
			goto empty;
		return (1);
	}

	if (len == 0) {
empty:		notfound(sp, key);
		return (1);
	}

	endp = (startp = p) + len;
	p += vp->m_start.cno;
	for (cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1; cnt--;) {
		while (++p < endp && *p != key);
		if (p == endp) {
			notfound(sp, key);
			return (1);
		}
	}

	vp->m_stop.cno = p - startp;

	/*
	 * Non-motion commands move to the end of the range.
	 * Delete and yank stay at the start, ignore others.
	 */
	vp->m_final = ISMOTION(vp) ? vp->m_start : vp->m_stop;
	return (0);
}
Beispiel #3
0
static void extract_section(struct rfc2045 *top_rfcp, const char *mimesection,
	const char *extract_filename, int argc, char **argv,
	void	(*extract_func)(struct rfc2045 *, const char *,
		int, char **))
{
	if (mimesection)
	{
		top_rfcp=rfc2045_find(top_rfcp, mimesection);
		if (!mimesection)
			notfound(mimesection);
		if (top_rfcp->firstpart)
		{
			fprintf(stderr, "reformime: MIME section %s is a compound section.\n", mimesection);
			exit(1);
		}
		(*extract_func)(top_rfcp, extract_filename, argc, argv);
		return;
	}

	/* Recursive */

	if (top_rfcp->firstpart)
	{
		for (top_rfcp=top_rfcp->firstpart; top_rfcp;
			top_rfcp=top_rfcp->next)
			extract_section(top_rfcp, mimesection,
				extract_filename, argc, argv, extract_func);
		return;
	}

	if (!top_rfcp->isdummy)
		(*extract_func)(top_rfcp, extract_filename, argc, argv);
}
Beispiel #4
0
void block::add_new_OUT(block* b,string text){
	if(notfound(_OUT,b))
	{
		_OUT.push_back(b);
		_OUTTEXT.push_back(text);
	}
}
Beispiel #5
0
int Response::response()
{
	sprintf(file,"%s%s",pwd,req.path);
	if(strstr(file,"/../")!=0) return -1;
	File f(file);
	if(f.fok)
	{
		if(f.isfile)
		{
			if(f.xok)
			{
				return exe();
			}else if(f.rok)
			{
				return sendfile(f);
			}else	return notfound();
		}else	return notfound();
	}else	return notfound();
	return -1;
}
Beispiel #6
0
StatSystem::StatPtr StatSystem::getStat(string name)
{
    string notfound(statNotFound);
    auto output = getUnitProperty(name);
    if (output->getId() != notfound)
        return output;
    output = getStatFrom(name,calculatedStats);
    if (output->getId() != notfound)
        return output;
    output = getStatFrom(name,jobStats());
    return output;
}
Beispiel #7
0
void print_decode(struct rfc2045 *p, const char *mimesection)
{
struct	rfc2045 *s;

	if (!mimesection)
		usage();

	s=rfc2045_find(p, mimesection);
	if (!s)
		notfound(mimesection);

	do_print_section(s, stdout);
}
Beispiel #8
0
    void multiCompare() const {
        // Test for found
        Token one(0);
        one.str("one");
        ASSERT_EQUALS(1, Token::multiCompare(&one, "one|two", 0));

        Token two(0);
        two.str("two");
        ASSERT_EQUALS(1, Token::multiCompare(&two, "one|two", 0));
        ASSERT_EQUALS(1, Token::multiCompare(&two, "verybig|two|", 0));

        // Test for empty string found
        Token notfound(0);
        notfound.str("notfound");
        ASSERT_EQUALS(0, Token::multiCompare(&notfound, "|one|two", 0));
        ASSERT_EQUALS(0, Token::multiCompare(&notfound, "one||two", 0));
        ASSERT_EQUALS(0, Token::multiCompare(&notfound, "one|two|", 0));

        // Test for not found
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&notfound, "one|two", 0)));

        Token s(0);
        s.str("s");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&s, "verybig|two", 0)));

        Token ne(0);
        ne.str("ne");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&ne, "one|two", 0)));

        Token a(0);
        a.str("a");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&a, "abc|def", 0)));

        Token abcd(0);
        abcd.str("abcd");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&abcd, "abc|def", 0)));

        Token def(0);
        def.str("default");
        ASSERT_EQUALS(static_cast<unsigned int>(-1), static_cast<unsigned int>(Token::multiCompare(&def, "abc|def", 0)));

        // %op%
        Token plus(0);
        plus.str("+");
        ASSERT_EQUALS(1, Token::multiCompare(&plus, "one|%op%", 0));
        ASSERT_EQUALS(1, Token::multiCompare(&plus, "%op%|two", 0));
        Token x(0);
        x.str("x");
        ASSERT_EQUALS(-1, Token::multiCompare(&x, "one|%op%", 0));
        ASSERT_EQUALS(-1, Token::multiCompare(&x, "%op%|two", 0));
    }
/*
 * Returns an LDAP error code.
 */
static int
cmp2( LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly)
{
    LDAPMessage		*e2, *res;
    char		*dn, *attrcmp;
    int			found=0, rc;
    ATTR		*a1, *a2;

    dn = ldap_get_dn( ld1, e1 );

    if ( ldaptool_verbose ) {
	if ( findonly ) {
	    printf( "Checking that %s exists on both servers\n", dn );
	} else {
	    printf("Comparing entry %s on both servers\n", dn );
	}
    }

    if ( ldap_search( ld2, dn, LDAP_SCOPE_BASE, "objectClass=*", NULL, 0 ) == -1 ) {
        return( ldaptool_print_lderror( ld2, "ldap_search",
		LDAPTOOL_CHECK4SSL_IF_APPROP ));
    }
/* XXXmcs: this code should be modified to display referrals and references */
    while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) == 
        LDAP_RES_SEARCH_ENTRY ) {
        e2 = ldap_first_entry( ld1, res );
	found = 1;
	if ( !findonly ) {
	    a1 = get_attrs( ld1, e1 );
	    a2 = get_attrs( ld2, e2 );
	    attrcmp = cmp_attrs( a1, a2 );
	    if ( strcmp( attrcmp, "") != 0 ) {
	        printf("\n%s%s\n", dn, attrcmp);
	    }
	}
        ldap_msgfree( res );
    }
    if ( !found ) {
	notfound( dn, findonly );
	differ = 1;
    }
    if ( rc == -1 ) {
        return( ldaptool_print_lderror( ld2, "ldap_result",
		LDAPTOOL_CHECK4SSL_IF_APPROP ));
    }
    ldap_msgfree( res );
    ldap_memfree( dn );
    return(rc);
}
Beispiel #10
0
void print_info(struct rfc2045 *p, const char *mimesection)
{
struct	rfc2045 *s;

	if (mimesection)
	{
		s=rfc2045_find(p, mimesection);
		if (!s)
			notfound(mimesection);
		printf("section: %s\n", mimesection);
		do_print_info(s);
		return;
	}
	rfc2045_decode(p, &do_print_info_multiple, 0);
}
Beispiel #11
0
StatSystem::StatPtr StatSystem::getStatFrom(string name, set<StatSystem::StatPtr> from)
{
    auto statItr = find_if(from.begin(),
                           from.end(),
                           IsStatNamed(name));
    if(statItr == from.end())
    {
        string notfound(statNotFound);
        return shared_ptr<Stat> (new Stat(notfound));
    }


    shared_ptr<Stat> stat = (*statItr);
    return stat;
}
Beispiel #12
0
void Controller::ReceiveMessage(Network::Message& message)
{
    // Handle global messages.
    if (Messages::GetType(message) == Messages::ID_REQUESTMESSAGE)
    {
        // Check whether it's valid for this mode.
        if (this->m_Mode != ControllerMode::Server)
            return;

        // Attempt to find the specified object in our local object storage.
        for (std::map<std::string, IdentifiableObject*>::const_iterator i = this->m_LocalObjects->begin();
                i != this->m_LocalObjects->end(); i++)
        {
            if (i->first == ((RequestMessage&)message).Identifier)
            {
                // We have found the matching object.  Send back a
                // CreateMessage that informs the client that the
                // object does exist.
                CreateMessage create(
                    this->m_ObjectTranslation.GetType(i->second),
                    i->first
                );
                this->SendMessage(create);
                return;
            }
        }

        // The specified object does not exist.  Tell the client
        // that the object isn't in existance.
        NotFoundMessage notfound(
            ((RequestMessage&)message).Identifier
        );
        this->SendMessage(notfound);
    }
    else if (Messages::GetType(message) == Messages::ID_CREATEMESSAGE)
    {
        // Check whether it's valid for this mode.
        if (this->m_Mode != ControllerMode::Client)
            return;

        // Handle the creation of the object.
        CreateMessage& create = (CreateMessage&)message;
        this->m_ObjectTranslation.CreateByType(*this, create.Type, create.Identifier);

        // Also notify the global handler.
        if (this->m_GlobalHandler != NULL)
            this->m_GlobalHandler->ReceiveMessage(message);
    }
    else if (Messages::GetType(message) == Messages::ID_NOTFOUNDMESSAGE)
    {
        // Check whether it's valid for this mode.
        if (this->m_Mode != ControllerMode::Client)
            return;

        // Mark the request as failed in the request cache.
        for (std::map<std::string, RequestState*>::const_iterator i = this->m_RequestCache->begin();
                i != this->m_RequestCache->end(); i++)
        {
            if (i->second == NULL)
                continue;
            if (i->first == ((NotFoundMessage&)message).Identifier)
                i->second->Status = REQUEST_STATUS_ERROR;
        }
    }
    else
    {
        // Pass off to the global handler to manage.
        if (this->m_GlobalHandler != NULL)
            this->m_GlobalHandler->ReceiveMessage(message);
    }
}
Beispiel #13
0
void sendDelete(char *file, int new_socket, int typeCon){
   struct stat file_stat;
    char *contents_chopped = file + 1;

    int ret;
    int fd;
    int sent_bytes = 0;
#ifdef DEBUG
    printf("%s\n", contents_chopped);
#endif

        ret = remove(contents_chopped);
        if (ret!=0){
            printf("Den vrethike arxeio. \n");
            notfound(new_socket, typeCon);
            return;
        }
        else{
        char head[13] = "Delete OK\r\n";
        if (write(new_socket, ok, 17) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };

        if (write(new_socket, "Server: Marios and Evanthia Server\r\n", 36) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };
        if (write(new_socket, "Content-Length: ", 16) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };

        if (write(new_socket, "11", 2) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };

        if (write(new_socket, "\r\n", 2) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };
        char cnc[25];
        printf("Epestrepse to arxeio: %s\n" ,contents_chopped );

        if (typeCon == 1) {
            strcpy(cnc, "Connection: keep-alive\r\n");

        } else {
            strcpy(cnc, "Connection: close\r\n");
        }

        if (write(new_socket, cnc, strlen(cnc)) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };

#ifdef DEBUG
        printf("Hello Pire Tipo\n");
        printf("%s\n", tipos);
        printf("%s\n", len);
#endif
        if (write(new_socket, "Content-Type: text/plain", 24) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };

        if (write(new_socket, "\r\n", 2) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };
        if (write(new_socket, "\r\n", 2) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };

        if (write(new_socket, head, strlen(head)) < 0) {
            printf("ERROR: couldn't write to socket\n");
            exit(EXIT_FAILURE);
        };
      }
    return;
}
Beispiel #14
0
void block::add_new_IN(block* b){
	if(notfound(_IN,b))
		_IN.push_back(b);
}