예제 #1
0
파일: token.c 프로젝트: zatamite/gnoetry
Token *
token_lookup_break (void)
{
    static Token *brk = NULL;
    if (brk == NULL)
        brk = token_lookup ("*break*");
    return brk;
}
예제 #2
0
파일: token.c 프로젝트: zatamite/gnoetry
Token *
token_lookup_wildcard (void)
{
    static Token *wild = NULL;
    if (wild == NULL)
        wild = token_lookup ("*wildcard*");
    return wild;
}
예제 #3
0
파일: token.c 프로젝트: zatamite/gnoetry
PyObject *
py_token_lookup (PyObject *self, PyObject *args)
{
    Token *token;
    char *raw;
    if (! PyArg_ParseTuple (args, "s", &raw))
        return NULL;
    token = token_lookup (raw);
    return token_to_py (token);
}
예제 #4
0
파일: play.c 프로젝트: JeroenDeDauw/teg
/* Read the file descriptor and call the apropiate function */
TEG_STATUS play_teg( int fd )
{
	int i,j;
	PARSER p;
	char str[PROT_MAX_LEN];
	DELIM igualador={ '=', '=', '=' };
	DELIM separador={ ';', ';', ';' };

	p.igualador = &igualador;
	p.separador = &separador;

	str[0]=0;

	if( g_game.fog_of_war )
		g_game.player_fow = NULL;

	j=net_readline( fd, str, PROT_MAX_LEN );

	if( j<1 ) {
		PSPLAYER pJ;
		if( player_whoisfd( fd, &pJ ) == TEG_STATUS_SUCCESS )
			player_del_hard( pJ );
		else
			fd_remove(fd);

		return TEG_STATUS_CONNCLOSED;
	}

	if( g_game.fog_of_war ) {
		if( player_whoisfd( fd, &g_game.player_fow ) != TEG_STATUS_SUCCESS )
			g_game.player_fow = NULL;
	}

	p.data = str;

	do {
		if( (i=parser_call( &p )) ) {
			if( token_lookup( fd,&p ) == TEG_STATUS_CONNCLOSED ) {
				return TEG_STATUS_CONNCLOSED;
			}
		}
	} while( i && p.hay_otro);

	return TEG_STATUS_SUCCESS;
}
예제 #5
0
파일: lex_yy.c 프로젝트: wacke/g21k
  int check_id( void )
{
  char *ptr;
  TOKEN_CELL *token;
  SYMBOL *symbol;

  if ( strlen(yytext) > IDENTIFIER_LENGTH )
    yytext[IDENTIFIER_LENGTH] = '\0';

  if ( (token = token_lookup(yytext)) != NULL )
  {
    yylval.lval = token->value;
    LEX_RETURN( token->type );
  }
  else
  {
    strcpy( last_identifier, yytext);
    yylval.symbol = NULL;
    LEX_RETURN( IDENTIFIER );
  }
symbol;
ptr;
}
예제 #6
0
파일: lex.c 프로젝트: ajwans/cyrus-imapd
int yylex(lexstate_t * lvalp, void * client)
{
  int ch;
  char buffer[ACAP_MAX_QSTR_LEN];	/* big enough for everything */

  char *buff_ptr = buffer; /* ptr into the buffer */
  char *buff_end = buffer + ACAP_MAX_QSTR_LEN -1;

  unsigned long count=0;

  int result = SIEVE_OK;

  int synchronizing;  /* wheather we are in the process of reading a
			 synchronizing string or not */

  struct protstream *stream=(struct protstream *) client;
  
  while (1)
  {

    /* get a character
       this may block on a read if there is nothing
       in the buffer */

    ch = prot_getc(stream);

    if (ch == -1)
	return SIEVE_FAIL;

    switch (lexer_state)
    {
    

    case LEXER_STATE_RECOVER:
      if (ch == '\r')
	lexer_state=LEXER_STATE_RECOVER_CR;
      break;
    case LEXER_STATE_RECOVER_CR:
      if (ch == '\n')
	lexer_state=LEXER_STATE_NORMAL;
      return EOL;
    case LEXER_STATE_CR:
      if (ch == '\n') {
	lexer_state=LEXER_STATE_NORMAL;
	return EOL;
      }
      /* otherwise, life is bad */
      ERR_PUSHBACK();
    case LEXER_STATE_QSTR:
      if (ch == '\"') {
	/* End of the string */
	lvalp->str = NULL;
	result = string_allocate(buff_ptr - buffer, buffer, &lvalp->str);
	if (result != SIEVE_OK)
	    ERR_PUSHBACK();
	lexer_state=LEXER_STATE_NORMAL;
	return STRING;
      }
      if (ch == '\0'
	  || 0x7F < ((unsigned char)ch))
	ERR_PUSHBACK();
      /* Otherwise, we're appending a character */
      if (buff_end <= buff_ptr)
	ERR_PUSHBACK();		/* too long! */
      if (ch == '\\') {
	ch=prot_getc(stream);

	if (result != SIEVE_OK)
	  ERR();
	if (ch != '\"' && ch != '\\')
	  ERR_PUSHBACK();
      }
      *buff_ptr++ = ch;
      break;
    case LEXER_STATE_LITERAL:
      if (('0' <= ch) && (ch <= '9')) {
	unsigned long   newcount = count * 10 + (ch - '0');

	if (newcount < count)
	  ERR_PUSHBACK();	/* overflow */
	/*
	 * XXX This should be fatal if non-synchronizing.
	 */
	count = newcount;
	break;
      }
      synchronizing = FALSE;

      if (ch != '}')
	ERR_PUSHBACK();
      ch=prot_getc(stream);
      if (ch < 0)
	ERR();
      if (ch != '\r')
	ERR_PUSHBACK();
      ch=prot_getc(stream);
      if (ch < 0)
	ERR();
      if (ch != '\n')
	ERR_PUSHBACK();

      lvalp->str = NULL;
      result = string_allocate(count, NULL, &lvalp->str);
      if (result != SIEVE_OK)
	ERR_PUSHBACK();

      /* there is a literal string on the wire. let's read it */
      {
	char           *it = string_DATAPTR(lvalp->str),
	               *end = it + count;

	while (it < end) {
	  *it=prot_getc(stream);
	  it++;
	}
	*it = '\0';
      }
      lexer_state=LEXER_STATE_NORMAL;
      return STRING;
    case LEXER_STATE_NUMBER:
      if (('0' <= ch) && (ch <= '9')) {
	unsigned long   newcount = count * 10 + (ch - '0');

	if (newcount < count)
	  ERR_PUSHBACK();	/* overflow */
	count = newcount;
      } else {
	lvalp->number = count;
	lexer_state=LEXER_STATE_NORMAL;
	prot_ungetc(ch, stream);
	return NUMBER;
      }
      break;
    case LEXER_STATE_NORMAL:
      if (isalpha((unsigned char) ch)) {
	lexer_state=LEXER_STATE_ATOM;
	*buff_ptr++ = tolower(ch);
	break;
      }
      switch (ch) {
      case '(':
	return '(';
      case ')':
	return ')';
      case ' ':
	return ' ';
      case '\"':
	lexer_state=LEXER_STATE_QSTR;
	break;
      case '*':
	return '*';
      case '0': /* fall through all numbers */
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      case '6':
      case '7':
      case '8':
      case '9':
	count = ch - '0';
	lexer_state=LEXER_STATE_NUMBER;
	break;
      case '{':
	count = 0;
	synchronizing = TRUE;
	lexer_state=LEXER_STATE_LITERAL;
	break;
      case '\r':
	lexer_state=LEXER_STATE_CR;
	break;
      case '\n':
	lexer_state=LEXER_STATE_NORMAL;
	return EOL;
	break;
      default:
	ERR_PUSHBACK();
      }
      break;
    case LEXER_STATE_ATOM:
      if (!isalpha((unsigned char) ch)) {
	int token;

	buffer[ buff_ptr - buffer] = '\0';

	/* We've got the atom. */
	token = token_lookup((char *) buffer, (int) (buff_ptr - buffer));

	if (token!=-1) {
	  lexer_state=LEXER_STATE_NORMAL;
	  prot_ungetc(ch, stream);

	  return token;
	} else
	  ERR_PUSHBACK();
      }
      if (buff_end <= buff_ptr)
	ERR_PUSHBACK();		/* atom too long */
      *buff_ptr++ = tolower(ch);
      break;
    }

  } /* while (1) */

  /* never reached */
}
예제 #7
0
파일: lex.c 프로젝트: gnb/cyrus-imapd
int timlex(mystring_t **outstr, unsigned long *outnum,  struct protstream *stream)
{

  int ch;

  char *buff_ptr;
  char *buff_end;
  unsigned long tmpnum = 0;
  unsigned long count=0;

  int result = TIMSIEVE_OK;


  buff_ptr = buffer; /* ptr into the buffer */
  buff_end = buffer + maxscriptsize - 10; /* ptr to end of buffer */

  
  while (1)
  {

    /* get a character
       this may block on a read if there is nothing
       in the buffer */

    ch=prot_getc(stream);

    if (ch==EOF) {
	/* Lost connection */
	return EOF;
    }

    switch (lexer_state)
    {
    

    case LEXER_STATE_RECOVER:
      if (ch == '\n') {
	lexer_state=LEXER_STATE_NORMAL;
      }
      if (ch == '\r') 
	lexer_state=LEXER_STATE_RECOVER_CR;
      break;
    case LEXER_STATE_RECOVER_CR:
      if (ch == '\n')
	lexer_state=LEXER_STATE_NORMAL;
      break;
    case LEXER_STATE_CR:
      if (ch == '\n') {
	lexer_state=LEXER_STATE_NORMAL;
	return EOL;
      }
      /* otherwise, life is bad */
      ERR_PUSHBACK();
    case LEXER_STATE_QSTR:
      if (ch == '\"') {
	/* End of the string */
	if (outstr!=NULL)
	{
	  *outstr = NULL;
	  result = string_allocate(buff_ptr - buffer, buffer, outstr);
	  if (result != TIMSIEVE_OK)
	    ERR_PUSHBACK();
	}
	  /*} */
	lexer_state=LEXER_STATE_NORMAL;
	return STRING;
      }
      /* illegal character */
      if (ch == '\0'
	  || ch == '\r'
	  || ch == '\n'
	  || 0x7F < ((unsigned char)ch))
      {
	ERR_PUSHBACK();
      }

      /* Otherwise, we're appending a character */
      if (buff_end <= buff_ptr)
	ERR_PUSHBACK();		/* too long! */
      if (ch == '\\') {
	ch=prot_getc(stream);

	if (result != TIMSIEVE_OK)
	  ERR();
	if (ch != '\"' && ch != '\\')
	  ERR_PUSHBACK();
      }
      *buff_ptr++ = ch;
      break;
    case LEXER_STATE_LITERAL:
      if (('0' <= ch) && (ch <= '9')) {
	unsigned long   newcount = count * 10 + (ch - '0');

	if (newcount < count)
	  ERR_PUSHBACK();	/* overflow */
	/*
	 * XXX This should be fatal if non-synchronizing.
	 */
	count = newcount;
	break;
      }
      if (ch != '+')
	ERR_PUSHBACK();
      ch=prot_getc(stream);
      if (ch != '}')
	ERR_PUSHBACK();
      ch=prot_getc(stream);
      if (ch < 0)
	ERR();
      if (ch != '\r')
	ERR_PUSHBACK();
      ch=prot_getc(stream);
      if (ch < 0)
	ERR();
      if (ch != '\n')
	ERR_PUSHBACK();

      if (count > maxscriptsize) {
	  /* too big, eat the input */
	  for(;count > 0;count--) {
	      if(prot_getc(stream)==EOF)
		  break;
	  }
	  
	  ERR();
      }

      if (outstr!=NULL)
      {
	*outstr = NULL;
	result = string_allocate(count, NULL, outstr);
	if (result != TIMSIEVE_OK)
	  ERR_PUSHBACK();
      }

      /* there is a literal string on the wire. let's read it */
      if (outstr!=NULL) {
	char           *it = string_DATAPTR(*outstr),
	               *end = it + count;

	while (it < end) {
	  *it=prot_getc(stream);
	  it++;
	}
      } else {
	/* just read the chars and throw them away */
	unsigned long lup;

	for (lup=0;lup<count;lup++)
	  (void)prot_getc(stream);
      }
      lexer_state=LEXER_STATE_NORMAL;
      return STRING;
    case LEXER_STATE_NUMBER:

	if (Uisdigit(ch)) {
	    unsigned long   newcount = tmpnum * 10 + (ch - '0');

	    if (newcount < tmpnum)
		ERR_PUSHBACK();	/* overflow */
	    tmpnum = newcount;
	} else {
	    lexer_state=LEXER_STATE_NORMAL;
	    prot_ungetc(ch, stream);

	    if (outnum) *outnum = tmpnum;

	    return NUMBER;
	}
	
	break;
    case LEXER_STATE_NORMAL:
      if (Uisalpha(ch)) {
	lexer_state=LEXER_STATE_ATOM;
	*buff_ptr++ = tolower(ch);
	break;
      }
      if (Uisdigit(ch)) {
	lexer_state=LEXER_STATE_NUMBER;
	tmpnum = ch -'0';
	break;
      }
      switch (ch) {
      case '(':
	return '(';
      case ')':
	return ')';
      case ' ':
	return ' ';
      case '\"':
	lexer_state=LEXER_STATE_QSTR;
	break;
      case '*':
	return '*';
      case '{':
	count = 0;
	lexer_state=LEXER_STATE_LITERAL;
	break;
      case '\r':
	lexer_state=LEXER_STATE_CR;
	break;
      case '\n':
	lexer_state=LEXER_STATE_NORMAL;
	return EOL;
	break;
      default:
	return ch;
      }
      break;
    case LEXER_STATE_ATOM:
      if (!Uisalpha(ch)) {
	int token;

	buffer[ buff_ptr - buffer] = '\0';

	/* We've got the atom. */
	token = token_lookup((char *) buffer, (int) (buff_ptr - buffer));

	if (token!=-1) {
	  lexer_state=LEXER_STATE_NORMAL;
	  prot_ungetc(ch, stream);

	  return token;
	} else
	  ERR_PUSHBACK();
      }
      if (buff_end <= buff_ptr)
	ERR_PUSHBACK();		/* atom too long */
      *buff_ptr++ = tolower(ch);
      break;
    }

  } /* while (1) */

  /* never reached */
}
예제 #8
0
void
token_filter_init_from_py_dict (TokenFilter *filter,
                                PyObject    *py_dict)
{
    int x;

    g_return_if_fail (filter != NULL);
    
    token_filter_init (filter);

    if (py_dict == NULL)
        return;

    if (py_dict_get_int (py_dict, "break_preference", &x))
        filter->break_preference = (FilterResults) x;
    
    if (py_dict_get_int (py_dict, "punctuation_preference", &x))
        filter->punctuation_preference = (FilterResults) x;

    py_dict_get_int (py_dict, "min_syllables", &filter->min_syllables);

    py_dict_get_int (py_dict, "max_syllables", &filter->max_syllables);

    py_dict_get_string (py_dict, "meter_left", &filter->meter_left);

    py_dict_get_string (py_dict, "meter_right", &filter->meter_right);

    py_dict_get_double (py_dict, "metric_error_lower_threshold",
                        &filter->metric_error_lower_threshold);

    py_dict_get_double (py_dict, "metric_error_upper_threshold",
                        &filter->metric_error_upper_threshold);

    if (PyMapping_HasKeyString (py_dict, "rhymes_with")) {
        PyObject *py_val = PyMapping_GetItemString (py_dict, "rhymes_with");
        if (py_val != Py_None) {
            if (py_token_check (py_val)) {
                filter->rhymes_with = token_from_py (py_val);
            } else if (PyString_Check (py_val)) {
                filter->rhymes_with = token_lookup (PyString_AsString (py_val));
            } else {
                g_warning ("Unknown type for 'rhymes_with'");
            }
        }
        Py_DECREF (py_val);
    }

    if (py_dict_get_int (py_dict, "rhyme_type_lower_threshold", &x))
        filter->rhyme_type_lower_threshold = (RhymeType) x;

    if (py_dict_get_int (py_dict, "rhyme_type_upper_threshold", &x))
        filter->rhyme_type_upper_threshold = (RhymeType) x;

    if (py_dict_get_int (py_dict, "leading_preference", &x))
        filter->leading_preference = (FilterResults) x;

    if (py_dict_get_int (py_dict, "trailing_preference", &x))
        filter->trailing_preference = (FilterResults) x;

    if (py_dict_get_int (py_dict, "has_rhyme_threshold", &x))
        filter->has_rhyme_threshold = x;
    
    py_dict_get_double (py_dict, "rhyme_p_threshold", &filter->rhyme_p_threshold);

    token_filter_optimize (filter);
}
예제 #9
0
파일: main.c 프로젝트: ko/dcc
static int token_scanner(FILE *fp, token_t * token)
{
    token_t localtok = {0};
    int i, c, cnext, toktype;
    int rc = 0;

    c = getc(fp);
    while (isspace(c))
        c = getc(fp);

    switch(c) {
    case '/':
        // we're at a comment or a division
        cnext = getc(fp);
        if (cnext == '*' || cnext == '/')
            ; // handle the comment
        else
            ungetc(cnext, fp);
    case '+': case '=': 
    case '(': case ')': case '{': case '}':
    case ';':
        localtok.value.String[0] = c;
        localtok.value.String[1] = 0;
        rc = token_lookup(localtok.value.String, &toktype);
        localtok.type = toktype;
        break;

    case '"':
        localtok.type = T_STRING;
        // TODO finish this implementation
        break;

    case '1': case '2': case '3': case '4': case '5':
    case '6': case '7': case '8': case '9': case '0':
        // Assume integer
        localtok.type = T_INTEGER;
        localtok.value.Int = c - '0';
        while (isdigit(cnext = getc(fp))) 
            localtok.value.Int = localtok.value.Int * 10 + cnext - '0';

#if 0
        // TODO finish this implementation
        //
        // Possible double or float
        // Assume only double because floats are TBA
        if (cnext == '.') {
            localtok.type = T_DOUBLE;
            localtok.value.Double = localtok.value.Double;
        }  
#endif
        ungetc(cnext, fp);
        break;

    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
    case 'y': case 'z':
        localtok.value.String[0] = c; 
        for (i = 1; isalpha(cnext = getc(fp)); i++) 
            localtok.value.String[i] = cnext;
        ungetc(cnext, fp);
        rc = token_lookup(localtok.value.String, &toktype);
        if (rc == 0) 
            localtok.type = toktype;
        else 
            // not a reserved word. must be an identifier
            localtok.type = T_IDENTIFIER;
        break;

    case EOF:
        localtok.type = R_END;
        return R_END;

    default:
        localtok.value.Int = c;
        localtok.type = R_UNDEFINED;
    }

    *token = localtok;
    return rc;
}
예제 #10
0
파일: token.c 프로젝트: verias/SRMud
OBJ_DATA *generate_token(CHAR_DATA *ch)
{
	char buf[MIL];
	OBJ_DATA *obj;
	int i, token;
	CHAR_DATA *to, *to_next;

	obj = create_object(get_obj_index(OBJ_VNUM_TOKEN),0);

	//for randomizing tokens
	for( i=0; i < MAX_TOKEN; i++)
	{

		 if(ch->inserted->value[0] < 4 && (chance(7)))
		//we win an exp token
		 {
		obj->value[0] = token_lookup("experience");
		obj->value[1] = 100;
		obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win);
		obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win);
		obj->value[4] =	0;
		obj->name = str_dup(token_table[obj->value[0]].name);
		free_string(obj->short_descr);
		obj->short_descr = str_dup(token_table[obj->value[0]].short_descr);
		free_string(obj->description);
		obj->description = str_dup(token_table[obj->value[0]].long_descr);
		obj_to_char(obj,ch);
		if(ch->inserted->value[0] < 4)
		{
		send_to_one(ch,"WooHoo!!! You won an experience token.");
		for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to != ch && to->in_room == ch->in_room)
			{
				send_to_one(to,"%s just won an experience token.",PERS(ch,to));
			}
		}
		}
		 else
		 send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name);
		return obj;
		
	 }
	else if(ch->inserted->value[0] != 3 && (chance(20)))//20 percent chance you get a quest token
	{
			obj->value[0] = token_lookup("quest");
		obj->value[1] = number_range(0,100);
		obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win);
		obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win);
		obj->value[4] =	0;
		obj->name = str_dup(token_table[obj->value[0]].name);
		free_string(obj->short_descr);
		obj->short_descr = str_dup(token_table[obj->value[0]].short_descr);
		free_string(obj->description);
		obj->description = str_dup(token_table[obj->value[0]].long_descr);
		obj_to_char(obj,ch);
		if(ch->inserted->value[0] < 3)
		{
		send_to_one(ch,"Hot Damn! You won a quest token.");
				for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to->in_room == ch->in_room && to != ch)
			{
				send_to_one(to,"%s just won a quest token.",PERS(ch,to));
			}
		}
		}
		else if( ch->inserted->value[0] > 3)
		{
			send_to_one(ch,"Damn you just won back a quest token.");
				for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to->in_room == ch->in_room && to != ch)
			{
				send_to_one(to,"%s just won a quest token.",PERS(ch,to));
			}
		}
		}
			 else
			 send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name);
		return obj;
		
	 }
	 else if(ch->inserted->value[0] != 2  && (chance(25))) //25 percent chance you get a train token
		 {
		 //we win a train token
		obj->value[0] = token_lookup("train");
		obj->value[1] = number_range(0,100);
		obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win);
		obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win);
		obj->value[4] =	0;
		obj->name = str_dup(token_table[obj->value[0]].name);
		free_string(obj->short_descr);
		obj->short_descr = str_dup(token_table[obj->value[0]].short_descr);
		free_string(obj->description);
		obj->description = str_dup(token_table[obj->value[0]].long_descr);
		obj_to_char(obj,ch);
		if(ch->inserted->value[0] < 2)
		{
		send_to_one(ch,"Nifty, you won a train token.");
				for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to->in_room == ch->in_room && to != ch)
			{
				send_to_one(to,"%s just won a train token.",PERS(ch,to));
			}
		}
		}
		else if( ch->inserted->value[0] > 2)
		{
			send_to_one(ch,"Shit you just won back a train token.");
				for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to->in_room == ch->in_room && to != ch)
			{
				send_to_one(to,"%s just won a train token.",PERS(ch,to));
			}
		}
		}
			 else
			 send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name);
		return obj;
		
	 }
 	 else if(ch->inserted->value[0] != 1 && (chance(35))) //35 percent chance you get a practice token
		 {
		 //we win a prac token
		obj->value[0] = token_lookup("practice");
		obj->value[1] = number_range(0,100);
		obj->value[2] = number_fuzzy(token_table[obj->value[0]].max_win);
		obj->value[3] = number_fuzzy(token_table[obj->value[0]].min_win);
		obj->value[4] =	0;
		obj->name = str_dup(token_table[obj->value[0]].name);
		free_string(obj->short_descr);
		obj->short_descr = str_dup(token_table[obj->value[0]].short_descr);
		free_string(obj->description);
		obj->description = str_dup(token_table[obj->value[0]].long_descr);
		obj_to_char(obj,ch);
		if(ch->inserted->value[0] < 1 )
		{
				send_to_one(ch,"You won a practice token.");
		for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to->in_room == ch->in_room && to != ch)
			{
				send_to_one(to,"%s just won a practice token.",PERS(ch,to));
			}
		}
		}
		else if (ch->inserted->value[0] > 1)
		{
				send_to_one(ch,"Bah, you won back a practice token.");
		for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to->in_room == ch->in_room && to != ch)
			{
				send_to_one(to,"%s just won a practice token.",PERS(ch,to));
			}
		}
		}
			 else
			 send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name);
		return obj;
	 }
	 else if(ch->inserted->value[0] !=0 && (chance(15)))
		 {
			 //win back a normal token
			 obj->value[0] = token_lookup("normal");
			 obj->value[1] = number_range(0,100);
			 obj->value[2] = number_range(250,400);
			 obj->value[3] = number_range(25,249);
			 obj->value[4] = 0;
			 obj->name = str_dup(token_table[obj->value[0]].name);
			 free_string(obj->short_descr);
			 obj->short_descr  = str_dup(token_table[obj->value[0]].short_descr);
			 free_string(obj->description);
			 obj->description = str_dup(token_table[obj->value[0]].long_descr);
			 obj_to_char(obj,ch);
			 if(ch->inserted->value[0] > 1)
			 {
			 send_to_one(ch,"You just won back a normal token.");
		for(to = ch->in_room->people; to; to = to_next)
		{
			to_next = to->next_in_room;
			if(to->in_room == ch->in_room && to != ch)
			{
				send_to_one(to,"%s just won a normal token.",PERS(ch,to));
			}
		}
			 }
			 else
			 send_to_one(ch,"You lost your %s token.",token_table[ch->inserted->value[0]].name);
			 return obj;
		 
	 }
	}
	return NULL;
}