⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conf.c

📁 ipp打印机服务器原代码 注意:请将ipp.gz改为ipp.tar.gz 然后使用tar zxvf ipp.tar.gz解压 站长注意
💻 C
📖 第 1 页 / 共 4 页
字号:
	{	 /*          * No hosts...	  */          if (strcasecmp(name, "BrowseAllow") == 0)	    AllowIP(location, ~0, 0);	  else	    DenyIP(location, ~0, 0);	}	else if (value[0] == '*' || value[0] == '.' || !isdigit(value[0]))	{	 /*          * Host or domain name...	  */	  if (value[0] == '*')	    value ++;          if (strcasecmp(name, "BrowseAllow") == 0)	    AllowHost(location, value);	  else	    DenyHost(location, value);	}	else	{	 /*          * One of many IP address forms...	  */          memset(ip, 0, sizeof(ip));          ipcount = sscanf(value, "%d.%d.%d.%d", ip + 0, ip + 1, ip + 2, ip + 3);	  address = (((((ip[0] << 8) | ip[1]) << 8) | ip[2]) << 8) | ip[3];          if ((value = strchr(value, '/')) != NULL)	  {	    value ++;	    memset(mask, 0, sizeof(mask));            switch (sscanf(value, "%d.%d.%d.%d", mask + 0, mask + 1,	                   mask + 2, mask + 3))	    {	      case 1 :	          netmask = (0xffffffff << (32 - mask[0])) & 0xffffffff;	          break;	      case 4 :	          netmask = (((((mask[0] << 8) | mask[1]) << 8) |		              mask[2]) << 8) | mask[3];                  break;	      default :        	  LogMessage(L_ERROR, "Bad netmask value %s on line %d.",	        	     value, linenum);		  netmask = 0xffffffff;		  break;	    }	  }	  else	    netmask = netmasks[ipcount - 1];          if ((address & ~netmask) != 0)	  {	    LogMessage(L_WARN, "Discarding extra bits in %s address %08x for netmask %08x...",	               name, address, netmask);            address &= netmask;	  }          if (strcasecmp(name, "BrowseAllow") == 0)	    AllowIP(location, address, netmask);	  else	    DenyIP(location, address, netmask);	}      }    }    else if (strcasecmp(name, "BrowseRelay") == 0)    {     /*      * BrowseRelay [from] source [to] destination      */      if (NumRelays == 0)        relay = malloc(sizeof(dirsvc_relay_t));      else        relay = realloc(Relays, (NumRelays + 1) * sizeof(dirsvc_relay_t));      if (!relay)      {        LogMessage(L_ERROR, "Unable to allocate BrowseRelay at line %d - %s.",	           linenum, strerror(errno));        continue;      }      Relays = relay;      relay  += NumRelays;      memset(relay, 0, sizeof(dirsvc_relay_t));      if (strncasecmp(value, "from ", 5) == 0)      {       /*        * Strip leading "from"...	*/	value += 5;	while (isspace(*value))	  value ++;      }     /*      * Figure out what form the from address takes:      *      *    *.domain.com      *    .domain.com      *    host.domain.com      *    nnn.*      *    nnn.nnn.*      *    nnn.nnn.nnn.*      *    nnn.nnn.nnn.nnn      *    nnn.nnn.nnn.nnn/mm      *    nnn.nnn.nnn.nnn/mmm.mmm.mmm.mmm      */      if (value[0] == '*' || value[0] == '.' || !isdigit(value[0]))      {       /*        * Host or domain name...	*/	if (value[0] == '*')	  value ++;        strlcpy(name, value, sizeof(name));	if ((nameptr = strchr(name, ' ')) != NULL)	  *nameptr = '\0';        relay->from.type             = AUTH_NAME;	relay->from.mask.name.name   = strdup(name);	relay->from.mask.name.length = strlen(name);      }      else      {       /*        * One of many IP address forms...	*/        memset(ip, 0, sizeof(ip));        ipcount = sscanf(value, "%d.%d.%d.%d", ip + 0, ip + 1, ip + 2, ip + 3);	address = (((((ip[0] << 8) | ip[1]) << 8) | ip[2]) << 8) | ip[3];        for (; *value; value ++)	  if (*value == '/' || isspace(*value))	    break;        if (*value == '/')	{	  value ++;	  memset(mask, 0, sizeof(mask));          switch (sscanf(value, "%d.%d.%d.%d", mask + 0, mask + 1,	                 mask + 2, mask + 3))	  {	    case 1 :	        netmask = (0xffffffff << (32 - mask[0])) & 0xffffffff;	        break;	    case 4 :	        netmask = (((((mask[0] << 8) | mask[1]) << 8) |		            mask[2]) << 8) | mask[3];                break;	    default :        	LogMessage(L_ERROR, "Bad netmask value %s on line %d.",	        	   value, linenum);		netmask = 0xffffffff;		break;	  }	}	else	  netmask = netmasks[ipcount - 1];        relay->from.type            = AUTH_IP;	relay->from.mask.ip.address = address;	relay->from.mask.ip.netmask = netmask;      }     /*      * Skip value and trailing whitespace...      */      for (; *value; value ++)	if (isspace(*value))	  break;      while (isspace(*value))        value ++;      if (strncasecmp(value, "to ", 3) == 0)      {       /*        * Strip leading "to"...	*/	value += 3;	while (isspace(*value))	  value ++;      }     /*      * Get "to" address and port...      */      if (get_address(value, INADDR_BROADCAST, BrowsePort, &(relay->to)))      {        if (relay->from.type == AUTH_NAME)          LogMessage(L_INFO, "Relaying from %s to %x:%d",	             relay->from.mask.name.name,                     (unsigned)ntohl(relay->to.sin_addr.s_addr),                     ntohs(relay->to.sin_port));        else          LogMessage(L_INFO, "Relaying from %x/%x to %x:%d",                     relay->from.mask.ip.address, relay->from.mask.ip.netmask,                     (unsigned)ntohl(relay->to.sin_addr.s_addr),                     ntohs(relay->to.sin_port));	NumRelays ++;      }      else      {        if (relay->from.type == AUTH_NAME)	  free(relay->from.mask.name.name);        LogMessage(L_ERROR, "Bad relay address %s at line %d.", value, linenum);      }    }    else if (strcasecmp(name, "BrowsePoll") == 0)    {     /*      * BrowsePoll address[:port]      */      if (NumPolled == 0)        poll = malloc(sizeof(dirsvc_poll_t));      else        poll = realloc(Polled, (NumPolled + 1) * sizeof(dirsvc_poll_t));      if (!poll)      {        LogMessage(L_ERROR, "Unable to allocate BrowsePoll at line %d - %s.",	           linenum, strerror(errno));        continue;      }      Polled = poll;      poll   += NumPolled;     /*      * Get poll address and port...      */      if (get_address(value, INADDR_NONE, ippPort(), &polladdr))      {        LogMessage(L_INFO, "Polling %x:%d",	           (unsigned)ntohl(polladdr.sin_addr.s_addr),                   ntohs(polladdr.sin_port));	NumPolled ++;	memset(poll, 0, sizeof(dirsvc_poll_t));        address = ntohl(polladdr.sin_addr.s_addr);	sprintf(poll->hostname, "%d.%d.%d.%d", address >> 24,	        (address >> 16) & 255, (address >> 8) & 255, address & 255);        poll->port = ntohs(polladdr.sin_port);      }      else        LogMessage(L_ERROR, "Bad poll address %s at line %d.", value, linenum);    }    else if (strcasecmp(name, "User") == 0)    {     /*      * User ID to run as...      */      if (isdigit(value[0]))        User = atoi(value);      else      {        struct passwd *p;	/* Password information */        endpwent();	p = getpwnam(value);	if (p != NULL)	  User = p->pw_uid;	else	  LogMessage(L_WARN, "Unknown username \"%s\"",	             value);      }    }    else if (strcasecmp(name, "Group") == 0)    {     /*      * Group ID to run as...      */      if (isdigit(value[0]))        Group = atoi(value);      else      {        struct group *g;	/* Group information */        endgrent();	g = getgrnam(value);	if (g != NULL)	  Group = g->gr_gid;	else	  LogMessage(L_WARN, "Unknown groupname \"%s\"",	             value);      }    }    else if (strcasecmp(name, "SystemGroup") == 0)    {     /*      * System (admin) group(s)...      */      char	*valueptr,	/* Pointer into value */		quote;		/* Quote character */      for (i = NumSystemGroups; *value && i < MAX_SYSTEM_GROUPS; i ++)      {        if (*value == '\'' || *value == '\"')	{	 /*	  * Scan quoted name...	  */	  quote = *value++;	  for (valueptr = value; *valueptr; valueptr ++)	    if (*valueptr == quote)	      break;	}	else	{	 /*	  * Scan space or comma-delimited name...	  */          for (valueptr = value; *valueptr; valueptr ++)	    if (isspace(*valueptr) || *valueptr == ',')	      break;        }        if (*valueptr)          *valueptr++ = '\0';        SetString(SystemGroups + i, value);        value = valueptr;        while (*value == ',' || isspace(*value))	  value ++;      }      if (i)        NumSystemGroups = i;    }    else if (strcasecmp(name, "HostNameLookups") == 0)    {     /*      * Do hostname lookups?      */      if (strcasecmp(value, "off") == 0)        HostNameLookups = 0;      else if (strcasecmp(value, "on") == 0)        HostNameLookups = 1;      else if (strcasecmp(value, "double") == 0)        HostNameLookups = 2;      else	LogMessage(L_WARN, "Unknown HostNameLookups %s on line %d.",	           value, linenum);    }    else if (strcasecmp(name, "LogLevel") == 0)    {     /*      * Amount of logging to do...      */      if (strcasecmp(value, "debug2") == 0)        LogLevel = L_DEBUG2;      else if (strcasecmp(value, "debug") == 0)        LogLevel = L_DEBUG;      else if (strcasecmp(value, "info") == 0)        LogLevel = L_INFO;      else if (strcasecmp(value, "notice") == 0)        LogLevel = L_NOTICE;      else if (strcasecmp(value, "warn") == 0)        LogLevel = L_WARN;      else if (strcasecmp(value, "error") == 0)        LogLevel = L_ERROR;      else if (strcasecmp(value, "crit") == 0)        LogLevel = L_CRIT;      else if (strcasecmp(value, "alert") == 0)        LogLevel = L_ALERT;      else if (strcasecmp(value, "emerg") == 0)        LogLevel = L_EMERG;      else if (strcasecmp(value, "none") == 0)        LogLevel = L_NONE;      else        LogMessage(L_WARN, "Unknown LogLevel %s on line %d.", value, linenum);    }    else if (strcasecmp(name, "PrintcapFormat") == 0)    {     /*      * Format of printcap file?      */      if (strcasecmp(value, "bsd") == 0)        PrintcapFormat = PRINTCAP_BSD;      else if (strcasecmp(value, "solaris") == 0)        PrintcapFormat = PRINTCAP_SOLARIS;      else	LogMessage(L_WARN, "Unknown PrintcapFormat %s on line %d.",	           value, linenum);    }    else if (!strcasecmp(name, "ServerTokens"))    {     /*      * Set the string used for the Server header...      */      struct utsname plat;		/* Platform info */      uname(&plat);      if (!strcasecmp(value, "ProductOnly"))        SetString(&ServerHeader, "CUPS");      else if (!strcasecmp(value, "Major"))        SetString(&ServerHeader, "CUPS/1");      else if (!strcasecmp(value, "Minor"))        SetString(&ServerHeader, "CUPS/1.1");      else if (!strcasecmp(value, "Minimal"))        SetString(&ServerHeader, CUPS_MINIMAL);      else if (!strcasecmp(value, "OS"))        SetStringf(&ServerHeader, CUPS_MINIMAL " (%s)", plat.sysname);      else if (!strcasecmp(value, "Full"))        SetStringf(&ServerHeader, CUPS_MINIMAL " (%s) IPP/1.1", plat.sysname);      else if (!strcasecmp(value, "None"))        ClearString(&ServerHeader);      else        LogMessage(L_WARN, "Unknown ServerTokens %s on line %d.", value, linenum);    }#endif    else    {     /*      * Find a simple variable in the list...      */      for (i = NUM_VARS, var = variables; i > 0; i --, var ++)        if (strcasecmp(name, var->name) == 0)	  break;      if (i == 0)      {       /*        * Unknown directive!  Output an error message and continue...	*/        LogMessage(L_ERROR, "Unknown directive %s on line %d.", name,	           linenum);        continue;      }      switch (var->type)      {        case VAR_INTEGER :	    {	      int	n;	/* Number */	      char	*units;	/* Units */              n = strtol(value, &units, 0);	      if (units && *units)	      {        	if (tolower(units[0] & 255) == 'g')		  n *= 1024 * 1024 * 1024;        	else if (tolower(units[0] & 255) == 'm')		  n *= 1024 * 1024;		else if (tolower(units[0] & 255) == 'k')		  n *= 1024;		else if (tolower(units[0] & 255) == 't')		  n *= 262144;	      }	      *((int *)var->ptr) = n;	    }	    break;	case VAR_BOOLEAN :	    if (strcasecmp(value, "true") == 0 ||	        strcasecmp(value, "on") == 0 ||		strcasecmp(value, "enabled") == 0 ||		strcasecmp(value, "yes") == 0 ||		atoi(value) != 0)              *((int *)var->ptr) = TRUE;	    else if (strcasecmp(value, "false") == 0 ||	             strcasecmp(value, "off") == 0 ||		     strcasecmp(value, "disabled") == 0 ||		     strcasecmp(value, "no") == 0 ||		     strcasecmp(value, "0") == 0)              *((int *)var->ptr) = FALSE;	    else              LogMessage(L_ERROR, "Unknown boolean value %s on line %d.",	                 value, linenum);	    break;	case VAR_STRING :	    SetString((char **)var->ptr, value);	    break;      }    }  }    DEBUG_printf(("Function read_configuration()\n"));   return (1);}#if	0/* * 'read_location()' - Read a <Location path> definition. */static int				/* O - New line number or 0 on error */read_location(cups_file_t *fp,		/* I - Configuration file */              char        *location,	/* I - Location name/path */	      int         linenum)	/* I - Current line number */{  int		i;			/* Looping var */		*parent;		/* Parent location */  int		len;			/* Length of line */  char		line[HTTP_MAX_BUFFER],	/* Line buffer */		name[256],		/* Configuration directive */		*nameptr,		/* Pointer into name */		*value,			/* Value for directive */		*valptr;		/* Pointer into value */  unsigned	address,		/* Address value */		netmask;		/* Netmask value */  int		ip[4],			/* IP address components */		ipcount,		/* Number of components provided */ 		mask[4];		/* IP netmask components */  static unsigned	netmasks[4] =	/* Standard netmasks... */  {    0xff000000,    0xffff0000,    0xffffff00,    0xffffffff  };#if	0  location_t	*loc,			/* New location */#endif  if ((parent = AddLocation(location)) == NULL)    return (0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -