コード例 #1
0
ファイル: parser.c プロジェクト: dhanks/serpent
void         run_command (player * p, char *str)
{
   command     *com;
   char        *param;

   for (; *str == ' '; str++);
   trim_end (str);
   if (!*str)
      return;
   if (!isalpha (*str))
      com = root_commands[0];
   else
      com = root_commands[((tolower (*str) - 'a') + 1)];
   for (; com->key; com++)
      if ((param = match_command_key (com, str)) && com->level <= p->residency)
      {

	 if (com->sublist)
	    run_subcommand (p, param, com);
	 else
	    actually_do_command (p, com, param);
	 return;
      }
   param = next_space (str);
   if (*param)
      *param++ = '\0';
   vwritep (p, "No command %s available to you.\n", str);
   return;
}
コード例 #2
0
ファイル: parser.c プロジェクト: dhanks/serpent
void         run_subcommand (player * p, char *str, command * parent)
{
   command     *com;
   char        *param;

   trim_end (str);
   if (!parent->sublist)
   {
      writep (p, "No subcommands found!\n");
      vlog ("parser", "run_subcommand: No %s subcommands found!\n", parent->key);
      return;
   }
   if (!*str)
   {
      view_subcommands (p, parent);
      return;
   }
   param = next_space (str);
   if (*param)
      *param++ = '\0';
   com = find_subcommand (p, str, parent);
   if (com == NULL)
   {
      vwritep (p, "No command %s %s available to you.\n", parent->key, str);
      return;
   }
   else
      actually_do_command (p, com, param);
   return;
}
コード例 #3
0
ファイル: Token.cpp プロジェクト: SergeyStrukov/CCore
Token Tokenizer::next()
 {
  switch( GetCharClass(*text) )
    {
     case Char_Digit  : return next_number();
     case Char_Letter : return next_word();
     case Char_Punct  : return next_punct();
     case Char_Space  : return next_space();
     case Char_Other  : return next_other();
    }

  return Token();
 }
コード例 #4
0
inline bool search_tautogram (bool &found)
{
	char t, c;

	t = next_letter ();
	if (t == LAST)
		return false;

	found = true;
	c = next_space ();
	while (c != NEWLINE && found)
	{
		c = next_letter ();
		if (c != t)
			found = false;
		c = next_space ();
	}
	while (c != NEWLINE)
		c = next_space ();

	return true;
}
コード例 #5
0
ファイル: mail.c プロジェクト: talkers/ew-too
 void send_letter(player *p,char *str)
 {
   note *mail;
   char *subject,*scan,*first;
   int length;

   if (posted_count(p)>=p->max_mail) {
     tell_player(p,"Sorry, you have reached your mail limit.\n");
     return;
   }

   subject=next_space(str);

   if (!*subject) {
     tell_player(p,"Format: post <character(s)> <subject>\n");
     return;
   }

   *subject++=0;

   mail=create_note();

   first=first_char(p);
   scan=strstr(first,"post");
   if (scan && (scan!=first_char(p)) && (*(scan-1)=='a'))
     mail->flags |= ANONYMOUS;

   strcpy(mail->name,p->name);
   strncpy(mail->header,subject,MAX_TITLE-2);

   tell_player(p,"Enter main text of the letter...\n");
   *stack=0;	
   start_edit(p,MAX_ARTICLE_SIZE,end_mail,quit_mail,stack);
   if (p->edit_info) {
     p->edit_info->misc=(void *)mail;
     length=strlen(str)+1;
     mail->text.where=(char *)MALLOC(length);
     memcpy(mail->text.where,str,length);
   }
   else FREE(mail);
 }
コード例 #6
0
ファイル: mail.c プロジェクト: talkers/ew-too
void relink_note(player *p,char *str)
{
  char *to;
  int id1,id2;
  note *n;
  to=next_space(str);
  *to++=0;
  id1=atoi(str);
  id2=atoi(to);
/*  if (!id1 || !id2) {
    tell_player(p,"Format : relink <number> <number>\n");
    return;
  } */
  n=find_note(id1);
  if (!n) {
    tell_player(p,"Can't find first note\n");
    return;
  }
  n->next_sent=id2;
  tell_player(p,"next_sent pointer twiddled.\n");
  return;
}
コード例 #7
0
ファイル: spacialized_size.c プロジェクト: oleiade/Ash
void		manage_size(char *str, int *pos, int *size, int size_buf)
{
  if (*pos > 1)
    {
      if (*pos + 1 < size_buf)
	{
	  if (!prec_space(str[*pos - 2], str[*pos - 1],
			  str[*pos], str[*pos + 1]))
	    (*size)++;
	  if (*pos + 3 < size_buf)
	    {
	      if (!next_space(str[*pos], str[*pos + 1], str[*pos + 2]))
		(*size)++;
	    }
	  else
	    (*size)++;
	}
      else
	(*size)++;
    }
  else
    (*size)++;
  (*pos)++;
}
コード例 #8
0
ファイル: mail.c プロジェクト: talkers/ew-too
void view_received(player *p,char *str)
{
    char *oldstack,middle[80],*page_input;
    int page,pages,*scan,*scan_count,mcount=0,ncount=1,n;
    note *mail;
    saved_player *sp;
    oldstack=stack;
    
    if (*str && !isdigit(*str) && p->residency&(LOWER_ADMIN|ADMIN)) {
	page_input=next_space(str);
	if (*page_input) *page_input++=0;
	sp=find_saved_player(str);
	if (!sp) {
	    tell_player(p,"No such player in save files.\n");
	    return;
	}
	else scan=sp->mail_received;
	str=page_input;
    }
    else {
	if (!p->saved) {
	    tell_player(p,"You have no save file, and therefore no mail either.\n");
	    return;
	}
	sp=p->saved;
	scan=sp->mail_received;
    }

    if (!scan) {
	tell_player(p,"You have received no mail.\n");
	return;
    }

    p->saved_flags &= ~NEW_MAIL;

    for(scan_count=scan;*scan_count;scan_count++) mcount++;

    page=atoi(str);
    if (page<=0) page=1;
    page--;

    pages=(mcount-1)/(TERM_LINES-2);
    if (page>pages) page=pages;

    if (mcount==1) strcpy(middle,"You have received one letter");
    else sprintf(middle,"You have received %s letters",
		 number2string(mcount));
    pstack_mid(middle);

    ncount=page*(TERM_LINES-2);

    scan += ncount;

    for(n=0,ncount++;n<(TERM_LINES-1);n++,ncount++,scan++) {
	if (!*scan) break;
	mail=find_note(*scan);
	if (!mail) {
	    stack=oldstack;
	    tell_player(p,"Found mail that owner had deleted ...\n");
	    reconfigure_received_list(sp);
	    if (sp!=p->saved) {
		tell_player(p,"Reconfigured ... try again\n");
		return;
	    }
	    view_received(p,str);
	    return;
	}
	if (p->residency&(LOWER_ADMIN|ADMIN)) sprintf(stack,"(%d) [%d] ",mail->id,ncount);
	else sprintf(stack,"[%d] ",ncount);
	while(*stack) *stack++;
	if (ncount<10) *stack++=' ';
	strcpy(stack,mail->header);
	while(*stack) *stack++;
	if (mail->flags&ANONYMOUS) {
	    if (p->residency&(LOWER_ADMIN|ADMIN)) sprintf(stack," <%s>\n",mail->name);
	    else strcpy(stack,"\n");
	}
	else sprintf(stack," (%s)\n",mail->name);
	while(*stack) *stack++;
    }  

    sprintf(middle,"Page %d of %d",page+1,pages+1);
    pstack_mid(middle);

    *stack++=0;
    tell_player(p,oldstack);

    stack=oldstack;
}
コード例 #9
0
void Reload_Sources(void)
{
    int i;
	vfsfile_t *f;
	char ln[2048];
    source_data *s;

	SB_ServerList_Lock();
    for (i=0; i < sourcesn; i++)
        Delete_Source(sources[i]);
    sourcesn = 0;

    // create dummy unbound source
    sources[0] = Create_Source();
    sources[0]->type = type_dummy;
    strlcpy (sources[0]->name, "Unbound", sizeof (sources[0]->name));
    sources[0]->servers = (server_data **) Q_malloc(MAX_UNBOUND*sizeof(server_data *));
	sources[0]->serversn = 0;
	sources[0]->servers_allocated = MAX_UNBOUND;

	sourcesn = 1;

	f = FS_OpenVFS(SOURCES_LIST_FILENAME, "rb", FS_ANY);
	if (!f) 
	{
        //Com_Printf ("sources file not found: %s\n", SOURCES_PATH);
		SB_ServerList_Unlock();
		return;
	}

    s = Create_Source();
    while (VFS_GETS(f, ln, sizeof(ln)))
    {
		char line[2048];
        char *p, *q;

        if (sscanf(ln, "%[ -~	]s", line) != 1) {
			continue;
		}

        p = next_nonspace(line);
        if (*p == '/')
            continue;   // comment
        q = next_space(p);

		if (!strncmp(p, "master", q-p)) {
            s->type = type_master;
		}
		else if (!strncmp(p, "file", q-p)) {
			s->type = type_file;
		}
		else if (!strncmp(p, "url", q-p)) {
			s->type = type_url;
		}
		else {
			continue;
		}

        p = next_nonspace(q);
        q = (*p == '\"') ? next_quote(++p) : next_space(p);

        if (q-p <= 0)
            continue;

        strlcpy (s->name, p, min(q-p+1, MAX_SOURCE_NAME+1));

        p = next_nonspace(q+1);
        q = next_space(p);
        *q = 0;

        if (q-p <= 0)
            continue;

        if (s->type == type_file)
            strlcpy (s->address.filename, p, sizeof (s->address.filename));
		else if (s->type == type_url)
			strlcpy (s->address.url, p, sizeof (s->address.url));
        else
            if (!NET_StringToAdr(p, &(s->address.address)))
                continue;

        sources[sourcesn] = Create_Source();
        i = sources[sourcesn]->unique;
        memcpy(sources[sourcesn], s, sizeof(source_data));
        sources[sourcesn]->unique = i;
        sourcesn++;
    }

    Delete_Source(s);
	VFS_CLOSE(f);

    //Com_Printf("Read %d sources for Server Browser\n", sourcesn);

    // update all file sources
    for (i=0; i < sourcesn; i++)
        if (sources[i]->type == type_file)
            Update_Source(sources[i]);
        else if (sources[i]->type == type_master || sources[i]->type == type_url)
            Precache_Source(sources[i]);

    rebuild_servers_list = 1;
    resort_sources = 1;
	SB_ServerList_Unlock();
}
コード例 #10
0
void get_equivalences(FILE *fp, int *p_line, char *p_line_string, 
                                int *p_num_of_chars)
{
#include "header.h"
int ipoint, iend, itsanum;
int idummy, ref;
int num_digi, sign;

double version;

/**************************************************************/
/****** Ignore titles for parameters                    *******/
/**************************************************************/


   while ( locate_string_in_string(TITLE_LINE,       p_line_string, *p_num_of_chars)
        || locate_string_in_string(ILLUSTRATION_LINE, p_line_string, *p_num_of_chars)
        || *p_num_of_chars == 0)
     {
        *p_num_of_chars=read_line(fp, p_line);
        idummy= string_from_int(p_line, p_line_string);
     }


/**************************************************************/
/****** Stay in the loop till we run out of parameter   *******/
/****** lines                                           *******/
/**************************************************************/

   num_equivalences=-1;
   while(*p_num_of_chars > 0)
     {

        num_equivalences++;
 
        ipoint= 0;

        version = get_doub(p_line, *p_num_of_chars, &ipoint, &itsanum);
        ref=  get_int(p_line, &ipoint, &itsanum, &num_digi,
                                               *p_num_of_chars, &sign);

/***************************************************************/
/******* Read in potential type that is to be checked **********/
/***************************************************************/

        ipoint= next_none_space(p_line, ipoint, *p_num_of_chars);
        iend= next_space(p_line, ipoint, *p_num_of_chars);

        strncpy (equivalence_list[num_equivalences].type, 
                                    p_line_string+ipoint, iend-ipoint);

        ipoint=iend;

/***************************************************************/
/******* Read in Non-bond equivalence **************************/
/***************************************************************/

        ipoint= next_none_space(p_line, ipoint, *p_num_of_chars);
        iend= next_space(p_line, ipoint, *p_num_of_chars);

        strncpy (equivalence_list[num_equivalences].nonbond, 
                                    p_line_string+ipoint, iend-ipoint);

        ipoint=iend;

/***************************************************************/
/******* Read in stretch equivalence ***************************/
/***************************************************************/

        ipoint= next_none_space(p_line, ipoint, *p_num_of_chars);
        iend= next_space(p_line, ipoint, *p_num_of_chars);

        strncpy (equivalence_list[num_equivalences].stretch,
                                    p_line_string+ipoint, iend-ipoint);

        ipoint=iend;

/***************************************************************/
/******* Read in angle equivalence *****************************/
/***************************************************************/

        ipoint= next_none_space(p_line, ipoint, *p_num_of_chars);
        iend= next_space(p_line, ipoint, *p_num_of_chars);

        strncpy (equivalence_list[num_equivalences].angle,
                                    p_line_string+ipoint, iend-ipoint);

        ipoint=iend;

/***************************************************************/
/******* Read in torsion equivalence ***************************/
/***************************************************************/

        ipoint= next_none_space(p_line, ipoint, *p_num_of_chars);
        iend= next_space(p_line, ipoint, *p_num_of_chars);

        strncpy (equivalence_list[num_equivalences].torsion,
                                    p_line_string+ipoint, iend-ipoint);

        ipoint=iend;

/***************************************************************/
/******* Read in oop equivalence *******************************/
/***************************************************************/

        ipoint= next_none_space(p_line, ipoint, *p_num_of_chars);
        iend= next_space(p_line, ipoint, *p_num_of_chars);

        strncpy (equivalence_list[num_equivalences].oop,
                                    p_line_string+ipoint, iend-ipoint);

        ipoint=iend;

/***************************************************************/
/****** Read in next parameter line  ***************************/
/***************************************************************/

        *p_num_of_chars=read_line(fp, p_line);
        idummy= string_from_int(p_line, p_line_string);
     }
return;
}
コード例 #11
0
ファイル: read_atom_data.c プロジェクト: adam1706/inter_vasp
   int read_atom_data(int *p_ichar, int *p_num_atoms, int at_end,
                      int num_of_chars, int *p_next_mol, atom *p_atom,
                      int *p_mol_number)

{
int is_end,idummy,place,itsanum,iloop,ndigi,sign;
int idum[10], igroup;
char *p_key;

/* check for end of molecule or file */
 
 p_key= "end";
 is_end= locate_string( p_key, p_ichar, num_of_chars);

 if (is_end && !at_end )
   {
/* first end encountered for a while, just end of molecule */
 
     (*p_next_mol)++;
     return 1;
   }
 else if (is_end && at_end )
   {
/* the end of the atom list */

     return 2;
   }
 else
   {
/* a normal atom data line */

/* copy over atom name */

   copy_int( p_ichar, &idum[0], 0, 3); 
   int_to_string(&idum[0], &(p_atom->label[0]), 4);

/* get x,y,z co-ordinates */

      place= 1;
      place= next_space (p_ichar, place, num_of_chars );

      p_atom->x = get_doub(p_ichar, num_of_chars, &place, &itsanum);
      p_atom->y = get_doub(p_ichar, num_of_chars, &place, &itsanum);
      p_atom->z = get_doub(p_ichar, num_of_chars, &place, &itsanum);

/* get group label */ 

      place= next_none_space( p_ichar, place, num_of_chars );

      if (place == -1 )
	{
       printf("Read error whilst trying to get the group from car file line:");
       put_string(stdout, p_ichar,200);
       return -1;
         }
      
       copy_int( p_ichar, &idum[0], place, place+3); 
       int_to_string(&idum[0],&(p_atom->group[0]), 4);

       place= next_space (p_ichar, place, num_of_chars );

/******* Get the group number, which can contain a string!! ***********/

      place++;

      if (place == -1 )
        {
       printf("Read error whilst trying to get the group number from car file line:");
       put_string(stdout, p_ichar,200);
       return -1;
         }

       copy_int( p_ichar, &idum[0], place, place+3);
       int_to_string(&idum[0],&(p_atom->group_no[0]), 4);

       place= next_space (p_ichar, place, num_of_chars );

/* get potential type */

      place= next_none_space( p_ichar, place, num_of_chars );

      if (place == -1 )
	{
       printf("Read error whilst trying to get the potential type from car file line:");
       put_string(stdout, p_ichar,200);
       return -1;
         }

       copy_int( p_ichar, &idum[0], place, place+2);
       int_to_string( &idum[0], &(p_atom->pot[0]), 2);

       place= next_space (p_ichar, place, num_of_chars );

/* get element type */

      place= next_none_space( p_ichar, place, num_of_chars );

      if (place == -1 )
	{
       printf("Read error whilst trying to get the element type from car file line:");
       put_string(stdout,p_ichar,200);
       return -1;
         }

       copy_int( p_ichar, &idum[0], place, place+1); 
       int_to_string( &idum[0], &(p_atom->elem[0]), 2);

       if (p_atom->elem[1] == ' ') p_atom->elem[1] = '\0';

       place= next_space (p_ichar, place, num_of_chars );

/* get partial charge */

       p_atom->part_chge= get_doub(p_ichar, num_of_chars, &place, &itsanum);

       if (!itsanum)
         {
            printf("Failed to find partial charge on car file line: \n");
            put_string(stdout, p_ichar,200);
         }

/* sort out molecule number and increment atom counter */

      *p_mol_number= *p_next_mol; 
      (*p_num_atoms)++;

      return 0;
   }
 
     
}