Exemplo n.º 1
0
void CleanUp_C(void)
{
	if(tr_function != NULL && tr_parameters != NULL)
	{
		trex_free(tr_function);
		trex_free(tr_parameters);

		tr_function = NULL;
		tr_parameters = NULL;
	}
}
Exemplo n.º 2
0
int main(int argc, char* argv[])
{
	const TRexChar *begin,*end;
	TRexChar sTemp[200];
	const TRexChar *error = NULL;
	TRex *x = trex_compile(_TREXC("(x{1,5})xx"),&error);
	if(x) {
		trex_sprintf(sTemp,_TREXC("xxxxxxx"));
		if(trex_search(x,sTemp,&begin,&end))
		{
			int i,n = trex_getsubexpcount(x);
			TRexMatch match;
			for(i = 0; i < n; i++)
			{
				TRexChar t[200];
				trex_getsubexp(x,i,&match);
				trex_sprintf(t,_TREXC("[%%d]%%.%ds\n"),match.len);
				trex_printf(t,i,match.begin);
			}
			trex_printf(_TREXC("match! %d sub matches\n"),trex_getsubexpcount(x));
		}
		else {
			trex_printf(_TREXC("no match!\n"));
		}
		trex_free(x);
	}
	else {
		trex_printf(_TREXC("compilation error [%s]!\n"),error?error:_TREXC("undefined"));
	}
	return 0;
}
Exemplo n.º 3
0
ret_code amb_init(ambiente_t* ambiente, const char* content, int length)
{
	ret_code ret = ERROR; 
	if (NULL!=content && NULL!=ambiente) {
		const TRexChar *begin, *end, *error;
		TRex* x;		
		CHECK(NULL!=(x=trex_compile(_TREXC("QtdMax=(\\d+)&PdvId=(\\d+)" \
				"&Recibo=(\\d)&Dormir=(\\d)&Cortesias=(\\d)&Credito=(\\d)&"),&error)));
		if (trex_search(x,_TREXC(content),&begin,&end)) {
			int n = trex_getsubexpcount(x);	
			if (n==7) {
				char *qtdMax, *pdvId, *credito;					
				rx_getnext(x, 1, &qtdMax);
				rx_getnext(x, 2, &pdvId);
				rx_getnext(x, 6, &credito);
				CHECK(NULL!=qtdMax);
				CHECK(NULL!=pdvId);
				CHECK(NULL!=credito);
				ambiente->credito = atoi(credito);
				ambiente->qtdMax = atoi(qtdMax);
				ambiente->pdvId = pdvId;
				free(credito);
				free(qtdMax);					
				ret = SUCCESS;
			}
			else {
				ret = ERROR;
			}
		} /* trex_search */
		trex_free(x);
	} /* NULL!=content */
	return ret;
}
Exemplo n.º 4
0
/**
 * \brief Free memory.
 */
void mess__base__free(void)
{
    int i;
    for (i = 0; i < MESS__NB_REGEXES; i++)
        trex_free(trex_regexes[i]);
    free (trex_regexes);
}
Exemplo n.º 5
0
void regfree(regex_t *preg) {
	if (!preg->regex_extended) {
		return;
	}

	trex_free(preg->regex_extended);
	preg->regex_extended = NULL;
}
Exemplo n.º 6
0
Arquivo: zrex.c Projeto: Prarrot/czmq
void
zrex_destroy (zrex_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zrex_t *self = *self_p;
        trex_free (self->trex);
        unsigned int index;
        for (index = 0; index < self->hits; index++)
            free (self->hit [index]);
        free (self);
        *self_p = NULL;
    }
}
Exemplo n.º 7
0
Arquivo: zrex.c Projeto: Prarrot/czmq
int
zrex_eq (zrex_t *self, const char *text, const char *expression)
{
    assert (self);
    assert (text);
    assert (expression);

    //  If we had any previous expression, destroy it
    if (self->trex) {
        trex_free (self->trex);
        self->trex = NULL;
    }
    //  Compile the new expression
    if (*expression)
        self->trex = trex_compile (expression, &self->strerror);
    else
        self->strerror = "Missing pattern";

    //  zrex_hits takes care of the rest for us
    return zrex_hits (self, text);

}
Exemplo n.º 8
0
/* TX */
static void reClearTX (RegExpInfo *re) {
  if (re->tx) trex_free(re->tx);
}