Пример #1
0
static int getRejectFlags()
{
	char buf[8192];
	FILE *f = fopen("/etc/ppp/pppoe.conf", "r" );
	if ( !f )
	{
		eDebug("couldn't open '/etc/ppp/pppoe.conf' for read");
		return 0;
	}
	size_t readed = fread(buf, 1, sizeof(buf), f );
	if ( !readed )
	{
		eDebug("couldn't read '/etc/ppp/pppoe.conf'");
		return 0;
	}
	int flags=0;
	char *p = getOptionString(buf, "REJECT_WWW=");
	if ( p && !strncasecmp(p,"yes",3) )
		flags|=1;
	p = getOptionString(buf, "REJECT_TELNET=");
	if ( p && !strncasecmp(p,"yes",3) )
		flags|=2;
	p = getOptionString(buf, "REJECT_SAMBA=");
	if ( p && !strncasecmp(p,"yes",3) )
		flags|=4;
	p = getOptionString(buf, "REJECT_FTP=");
	if ( p && !strncasecmp(p,"yes",3) )
		flags|=8;
	fclose(f);
	return flags;
}
Пример #2
0
      // this checks if it expects number or string type arguments.
      // it returns a string describing the error, if any.
   string CommandOption::checkArguments()
   {
      if (required && (count == 0))
         return "Required option " + getOptionString() + " was not found.";

      return string();
   }
Пример #3
0
   string CommandOptionWithStringArg::checkArguments()
   {
      string errstr = CommandOption::checkArguments();

      if (!errstr.empty())
         return errstr;

      vector<string>::size_type vecindex;
      for(vecindex = 0; vecindex < value.size(); vecindex++)
      {
         if (!isAlphaString(value[vecindex]))
         {
            string errstr("Argument for ");
            errstr += getOptionString();
            errstr += string(" should be an alphabetic string.");
            return errstr;
         }
      }
      return errstr;
   }