예제 #1
0
int asterisk(char **wildcard, char **test) {
  int fit=1;

  (*wildcard)++;
  while (('\000' != (**test))
      && ('*' == **wildcard)) {
    (*wildcard)++;
  }

  while ('*' == (**wildcard))
    (*wildcard)++;

  if (('\0' == (**test)) && ('\0' != (**wildcard)))
    return (fit=0);
  if (('\0' == (**test)) && ('\0' == (**wildcard)))
    return (fit=1);
  else {
    if (0 == wildcardfit(*wildcard, (*test))) {
      do {
	(*test)++;
	while (((**wildcard)!= (**test))
	    && ('\0' != (**test)))
	  (*test)++;
      } while ((('\0' != **test)) ? (0 == wildcardfit(*wildcard, (*test))) : ( 0 != (fit = 0)));
    }
    if (('\0' == **test) && ('\0' == **wildcard))
      fit=1;
    return (fit);
  }
}
예제 #2
0
int
Wildcard::asterisk (const char **wildcard, const char **test)
{
  /* Warning: uses multiple returns */
  int fit = 1;

  /* erase the leading asterisk */
  (*wildcard)++; 
  while (('\000' != (**test))
	 && (('?' == **wildcard) 
	     || ('*' == **wildcard)))
    {
      if ('?' == **wildcard) 
	(*test)++;
      (*wildcard)++;
    }
  /* Now it could be that test is empty and wildcard contains */
  /* aterisks. Then we delete them to get a proper state */
  while ('*' == (**wildcard))
    (*wildcard)++;

  if (('\0' == (**test)) && ('\0' != (**wildcard)))
    return (fit = 0);
  if (('\0' == (**test)) && ('\0' == (**wildcard)))
    return (fit = 1); 
  else
    {
      /* Neither test nor wildcard are empty!          */
      /* the first character of wildcard isn't in [*?] */
      if (0 == wildcardfit(*wildcard, (*test)))
	{
	  do 
	    {
	      (*test)++;
	      /* skip as much characters as possible in the teststring */
	      /* stop if a character match occurs */
	      while (((**wildcard) != (**test)) 
		     && ('['  != (**wildcard))
		     && ('\0' != (**test)))
		(*test)++;
	    }
	  while ((('\0' != **test))? 
		 (0 == wildcardfit (*wildcard, (*test))) 
		 : (0 != (fit = 0)));
	}
      if (('\0' == **test) && ('\0' == **wildcard))
	fit = 1;
      return (fit);
    }
}
예제 #3
0
파일: other.cpp 프로젝트: hazcod/botnets
int HostMaskMatch(char *h)
{
   int i=0;

   while (authost[i][0])
      if (wildcardfit(authost[i++], h)) return 1;

   return 0;
}
예제 #4
0
파일: other.cpp 프로젝트: hazcod/botnets
int asterisk (char **wildcard, char **test)
{
  int fit = 1;

  (*wildcard)++; 
  while (('\000' != (**test))
	 && (('?' == **wildcard) 
	     || ('*' == **wildcard)))
    {
      if ('?' == **wildcard) 
	(*test)++;
      (*wildcard)++;
    }
  while ('*' == (**wildcard))
    (*wildcard)++;

  if (('\0' == (**test)) && ('\0' != (**wildcard)))
    return (fit = 0);
  if (('\0' == (**test)) && ('\0' == (**wildcard)))
    return (fit = 1); 
  else
    {
      if (0 == wildcardfit(*wildcard, (*test)))
	{
	  do                               // I HAD NIGHTMARES AFTER WRITING THIS PART
	    {
	      (*test)++;
	      while (((**wildcard) != (**test)) 
		     && ('['  != (**wildcard))
		     && ('\0' != (**test)))
		(*test)++;
	    }
	  while ((('\0' != **test))? 
		 (0 == wildcardfit (*wildcard, (*test))) 
		 : (0 != (fit = 0)));
	}
      if (('\0' == **test) && ('\0' == **wildcard))
	fit = 1;
      return (fit);
    }
}
예제 #5
0
/*
============
Cvar_List_f

============
*/
void Cvar_List_f (void)
{
	cvar_t *var;
	int i,j,c;
	char *wc;

	// RIOT - Quake 3-style cvarlist
	c = Cmd_Argc();

	if(c != 1 && c != 2)
	{
		Com_Printf ("usage: cvarlist [wildcard]\n");
		return;
	}

	if(c == 2)
		wc = Cmd_Argv(1);
	else
		wc = "*";

	i = 0;
	j=0;
	for (var = cvar_vars ; var ; var = var->next, i++)
	{
		if(wildcardfit(wc, var->name))
		{
			j++;
			if (var->flags & CVAR_ARCHIVE)
				Com_Printf ("*");
			else
				Com_Printf (" ");
			if (var->flags & CVAR_USERINFO)
				Com_Printf ("U");
			else
				Com_Printf (" ");
			if (var->flags & CVAR_SERVERINFO)
				Com_Printf ("S");
			else
				Com_Printf (" ");
			// NeVo - show both noset and latch
			if (var->flags & CVAR_NOSET)
				Com_Printf ("-");
			else
				Com_Printf (" ");
			if (var->flags & CVAR_LATCH)
				Com_Printf ("L");
			else
				Com_Printf (" ");
			Com_Printf (" %s \"%s\"\n", var->name, var->string);
		}
	}
	Com_Printf ("%i cvars %i matching\n", i, j);
}
예제 #6
0
void NDSDir::GetContent(char *mask) {

	Empty() ;
        
    
    // Read directory content

	char fullpath[81] ;
	strcpy(fullpath,((NDSFileSystem *)NDSFileSystem::GetInstance())->root_) ;
	strcat(fullpath,path_) ;

	Trace::Debug("Reading path content for %s",fullpath) ;
 
    DIR_ITER* directory = diropen (fullpath);

	if (directory == NULL) {
		Trace::Dump("Failed to open %s",fullpath) ;
		return ;
	}

    struct stat st;
    char filename[256];

	while (dirnext(directory, filename, &st) == 0) {
 		char current[128] ;
        strcpy(current,filename) ;
        char *c=current ;
		while(*c) {
            *c=tolower(*c) ;
            c++ ;
        }
        Trace::Dump("testing mask") ;
        
        if (wildcardfit (mask,current)) {
            strcpy(current,filename) ;
            Trace::Dump("Inserting %s/%s",path_,current) ;
			sprintf(fullpath,"%s/%s",path_,current) ;
			Path *path=new Path(fullpath) ;
			Insert(path) ;
		} else {
            Trace::Dump("skipping %s",current) ;
        }
	
    } ;   
	dirclose(directory);
	
};
예제 #7
0
void UnixDir::GetProjectContent() {
	
	Empty() ;
	const char* mask = (const char *) "*";
	DIR* directory; 
	struct dirent* entry; 
	
	directory = opendir (path_); 
	if (directory == NULL) {
		Trace::Error("Failed to open %s",path_) ;
		return ;
	}
	
	while ((entry = readdir (directory)) != NULL) {
 		char current[128] ;
        strcpy(current,entry->d_name) ;
        char *c=current ;
		while(*c) {
            *c=tolower(*c) ;
            c++ ;
        }
		//      Trace::Dump("testing mask") ;
        
        if (wildcardfit (mask,current)) {
            strcpy(current,entry->d_name) ;
			//            Trace::Dump("Inserting %s/%s",path_,current) ;
			
			
			//we dont want any dot files but we do want .. 
			if(current[0] == '.' && current[1] != '.'){
				//de nada
			} else {
				std::string fullpath=path_ ;
				if (path_[strlen(path_)-1]!='/') {
					fullpath+="/" ;
				}
				fullpath+=current ;
				Path *path=new Path(fullpath.c_str()) ;
				Insert(path) ;
			}
		} else {
			//          Trace::Dump("skipping %s",current) ;
        }
		
    } ;   
	closedir (directory);
} ;
예제 #8
0
파일: cmd.c 프로젝트: Slipyx/r1q2
/*
============
Cmd_ExecTrigger
============
*/
void Cmd_ExecTrigger (char *string)
{
	const cmd_trigger_t *trigger;
	char				*text;

	// execute matching triggers
	for(trigger = cmd_triggers; trigger; trigger = trigger->next)
	{
		text = Cmd_MacroExpandString(trigger->match);

		if (text && wildcardfit (text, string))
		{
			Cbuf_AddText(trigger->command);
			Cbuf_AddText("\n");
		}
	}
}
예제 #9
0
void GP2XDir::GetContent(char *mask) {

	Empty() ;

 
	DIR* directory; 
	struct dirent* entry; 

 
	directory = opendir (path_); 
	if (directory == NULL) {
		Trace::Error("Failed to open %s",path_) ;
		return ;
	}

	while ((entry = readdir (directory)) != NULL) {
 		char current[128] ;
        strcpy(current,entry->d_name) ;
        char *c=current ;
		while(*c) {
            *c=tolower(*c) ;
            c++ ;
        }
        
        if (wildcardfit (mask,current)) {
            strcpy(current,entry->d_name) ;
			std::string fullpath=path_ ;
			if (path_[strlen(path_)-1]!='/') {
				fullpath+="/" ;
			}
			fullpath+=current ;
			Path *path=new Path(fullpath.c_str()) ;
			Insert(path) ;
		} else {
        }
	
    } ;   
	closedir (directory);
	
};
예제 #10
0
char *get_folderflag(IMAPD_STATE *state, char *name) {
  const char *myname="get_folderflag";
  IMAPD_FOLDER *curfolder;
  IMAPD_MSG *curmsg;
  char retflags[512];
  char *search;
  int haschildren=0;
  int marked=0;

  search = (char *) malloc (sizeof(char *) * (strlen(name)+2));
  sprintf(search, "%s*", name);
  
  curfolder = (IMAPD_FOLDER *) malloc (sizeof(IMAPD_FOLDER *));
  curfolder = state->firstfolder;

  while (curfolder) {
    if (strcmp(name, curfolder->name)!=0 && wildcardfit(search, curfolder->name)) {
      haschildren = 1;
      break;
    }
    curfolder = curfolder->nextfolder;
  }

  curmsg = (IMAPD_MSG *) malloc (sizeof(IMAPD_MSG *));
  curmsg = state->firstmsg;
  while (curmsg) {
    if (curmsg->f_flags[FLAG_SEEN] != '0') {
      marked=1;
      break;
    }
    curmsg = curmsg->nextmsg;
  }

  free(search);
  sprintf(retflags, "%s%s", 
      (haschildren==1) ? ((marked==1)? "\\Marked ": "\\Unmarked "): "",
      (haschildren==1)? "\\HasChildren": "\\HasNoChildren");
  return retflags;
}
예제 #11
0
파일: protocol.cpp 프로젝트: hazcod/botnets
int private_msg(char* params, irc_reply_data* hostd, void* conn)
{
	IRC* irc=(IRC*)conn;
	char *a[MAX_TOKENS];
	params++;
	char fcmd[1024];
	strcpy(fcmd,params);
	int t=SplitParams(a,params,MAX_TOKENS);
	if (fcmd[0] == prefix)
	{
		SWITCHES switches=GetSwitches(a,t);

		for (int u=0;u<MAX_TOKENS;u++)
		{
			if (a[u])
			{
				//lulwhat() -h1t3m-
			}
		}
		if (!a[0])
			return 1;
		if (a[0][0] == prefix)
		{
			a[0]++;
			if (irc->is_logged_in(hostd->nick,hostd->ident,hostd->host))
			{
				if (!strcmp(hostd->target,irc->current_nick()))
					hostd->target=hostd->nick;
				IRC_CommandParse(a,t,fcmd,hostd,irc,switches);
			}
			else
			{
				if (!strcmp(hostd->target,irc->current_nick()))
				{
					hostd->target=hostd->nick;
				}
				if (!strcmp(a[0],get_auth))
				{
					if (a[1]==NULL)
						return 1;
					char h[256];
					_snprintf(h,sizeof(h),"%s!%s@%s",hostd->nick,hostd->ident,hostd->host);
					BOOL host_ok=FALSE;
					for (int i=0; i < authsize; i++) {
#ifndef NO_WILDCARD
						if (wildcardfit(authost[i], h)) { 
							host_ok = TRUE;
							break;
						}
#else
						if (strcmp(h, authost[i]) == 0) {
							host_ok = TRUE;
							break;
						}
#endif
					}
					if (!host_ok || strcmp(Decode(password), a[1]) != 0) {

						return 1;
					}
					if (irc->add_login(hostd->nick,hostd->ident,hostd->host) == -1)
					{
						if (!switches.silent)
							irc->pmsg(hostd->target,str_auth_full,main_title);
					}
					else
					{
						if (!switches.silent)
							irc->pmsg(hostd->target,str_auth_good,main_title);
					}
					return 1;
				}
			}
		} 
	}
	else
	{
		if (lstrcmpi(hostd->target,irc->current_nick()))
			return 1;
		if (!lstrcmpi("\1VERSION\1",a[0]))
		{
			return 1;
		}
		if (!lstrcmpi("\1PING",a[0]) && a[1])
		{
			return 1;
		}
	}
	return 0;
}