/[svn]/ircd-hybrid-7.2/src/s_conf.c
ViewVC logotype

Diff of /ircd-hybrid-7.2/src/s_conf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 592 by michael, Mon May 1 11:41:09 2006 UTC revision 593 by michael, Fri May 12 05:47:32 2006 UTC
# Line 87  extern char linebuf[]; Line 87  extern char linebuf[];
87  extern char conffilebuf[IRCD_BUFSIZE];  extern char conffilebuf[IRCD_BUFSIZE];
88  extern char yytext[];  extern char yytext[];
89  extern int yyparse(); /* defined in y.tab.c */  extern int yyparse(); /* defined in y.tab.c */
90  unsigned int scount = 0; /* used by yyparse(), etc */  int ypass = 1; /* used by yyparse()      */
 int ypass  = 1; /* used by yyparse()      */  
91    
92  /* internally defined functions */  /* internally defined functions */
93  static void lookup_confhost(struct ConfItem *);  static void lookup_confhost(struct ConfItem *);
# Line 1965  set_default_conf(void) Line 1964  set_default_conf(void)
1964  static void  static void
1965  read_conf(FBFILE *file)  read_conf(FBFILE *file)
1966  {  {
1967    scount = lineno = 0;    lineno = 0;
1968    
1969    set_default_conf(); /* Set default values prior to conf parsing */    set_default_conf(); /* Set default values prior to conf parsing */
1970    ypass = 1;    ypass = 1;
# Line 3061  conf_add_class_to_conf(struct ConfItem * Line 3060  conf_add_class_to_conf(struct ConfItem *
3060   * side effects - Add a connect block   * side effects - Add a connect block
3061   */   */
3062  int  int
3063  conf_add_server(struct ConfItem *conf, unsigned int lcount, const char *class_name)  conf_add_server(struct ConfItem *conf, const char *class_name)
3064  {  {
3065    struct AccessItem *aconf;    struct AccessItem *aconf;
3066    char *orig_host;    struct split_nuh_item nuh;
3067      char conf_user[USERLEN + 1];
3068      char conf_host[HOSTLEN + 1];
3069    
3070    aconf = map_to_conf(conf);    aconf = map_to_conf(conf);
3071    
3072    conf_add_class_to_conf(conf, class_name);    conf_add_class_to_conf(conf, class_name);
3073    
3074    if (lcount > MAXCONFLINKS || !aconf->host || !conf->name)    if (!aconf->host || !conf->name)
3075    {    {
3076      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");      sendto_realops_flags(UMODE_ALL, L_ALL, "Bad connect block");
3077      ilog(L_WARN, "Bad connect block");      ilog(L_WARN, "Bad connect block");
# Line 3085  conf_add_server(struct ConfItem *conf, u Line 3086  conf_add_server(struct ConfItem *conf, u
3086      return -1;      return -1;
3087    }    }
3088    
3089    orig_host = aconf->host;    nuh.nuhmask  = aconf->host;
3090    split_nuh(orig_host, NULL, &aconf->user, &aconf->host);    nuh.nickptr  = NULL;
3091    MyFree(orig_host);    nuh.userptr  = conf_user;
3092      nuh.hostptr  = conf_host;
3093    
3094      nuh.nicksize = 0;
3095      nuh.usersize = sizeof(conf_user);
3096      nuh.hostsize = sizeof(conf_host);
3097    
3098      split_nuh(&nuh);
3099    
3100      MyFree(aconf->host);
3101      aconf->host = NULL;
3102    
3103      DupString(aconf->user, conf_user); /* somehow username checking for servers
3104                                     got lost in H6/7, will have to be re-added */
3105      DupString(aconf->host, conf_host);
3106    
3107    lookup_confhost(conf);    lookup_confhost(conf);
3108    
3109    return 0;    return 0;
# Line 3447  find_user_host(struct Client *source_p, Line 3463  find_user_host(struct Client *source_p,
3463    {    {
3464      /* Explicit user@host mask given */      /* Explicit user@host mask given */
3465    
3466      if(hostp != NULL)                            /* I'm a little user@host */      if (hostp != NULL)                            /* I'm a little user@host */
3467      {      {
3468        *(hostp++) = '\0';                       /* short and squat */        *(hostp++) = '\0';                       /* short and squat */
3469        if (*user_host_or_nick)        if (*user_host_or_nick)
# Line 3578  match_conf_password(const char *password Line 3594  match_conf_password(const char *password
3594  */  */
3595  void  void
3596  cluster_a_line(struct Client *source_p, const char *command,  cluster_a_line(struct Client *source_p, const char *command,
3597                 int capab, int cluster_type, const char *pattern, ...)                 int capab, int cluster_type, const char *pattern, ...)
3598  {  {
3599    va_list args;    va_list args;
3600    char buffer[IRCD_BUFSIZE];    char buffer[IRCD_BUFSIZE];
3601    struct ConfItem *conf;    const dlink_node *ptr = NULL;
   dlink_node *ptr;  
3602    
3603    va_start(args, pattern);    va_start(args, pattern);
3604    vsnprintf(buffer, sizeof(buffer), pattern, args);    vsnprintf(buffer, sizeof(buffer), pattern, args);
# Line 3591  cluster_a_line(struct Client *source_p, Line 3606  cluster_a_line(struct Client *source_p,
3606    
3607    DLINK_FOREACH(ptr, cluster_items.head)    DLINK_FOREACH(ptr, cluster_items.head)
3608    {    {
3609      conf = ptr->data;      const struct ConfItem *conf = ptr->data;
3610    
3611      if (conf->flags & cluster_type)      if (conf->flags & cluster_type)
     {  
3612        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,        sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
3613                           "%s %s %s", command, conf->name, buffer);                           "%s %s %s", command, conf->name, buffer);
     }  
3614    }    }
3615  }  }
3616    
# Line 3629  cluster_a_line(struct Client *source_p, Line 3642  cluster_a_line(struct Client *source_p,
3642   * @                            *       *       *   * @                            *       *       *
3643   * !                            *       *       *   * !                            *       *       *
3644   */   */
   
3645  void  void
3646  split_nuh(char *mask, char **nick, char **user, char **host)  split_nuh(struct split_nuh_item *const iptr)
3647  {  {
3648    char *p = NULL, *q = NULL;    char *p = NULL, *q = NULL;
3649    
3650    if ((p = strchr(mask, '!')) != NULL)    if (iptr->nickptr)
3651        strlcpy(iptr->nickptr, "*", iptr->nicksize);
3652      if (iptr->userptr)
3653        strlcpy(iptr->userptr, "*", iptr->usersize);
3654      if (iptr->hostptr)
3655        strlcpy(iptr->hostptr, "*", iptr->hostsize);
3656    
3657      if ((p = strchr(iptr->nuhmask, '!')))
3658    {    {
3659      *p = '\0';      *p = '\0';
     if (nick != NULL)  
     {  
       if (*mask != '\0')  
         *nick = xstrldup(mask, NICKLEN);  
       else  
         DupString(*nick, "*");  
     }  
3660    
3661      if ((q = strchr(++p, '@')) != NULL)      if (iptr->nickptr && *iptr->nuhmask != '\0')
3662      {        strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
3663        *q = '\0';  
3664        if ((q = strchr(++p, '@'))) {
3665          *q++ = '\0';
3666    
3667        if (*p != '\0')        if (*p != '\0')
3668          *user = xstrldup(p, USERLEN+1);          strlcpy(iptr->userptr, p, iptr->usersize);
       else  
         DupString(*user, "*");  
3669    
3670        if (*++q != '\0')        if (*q != '\0')
3671          *host = xstrldup(q, HOSTLEN+1);          strlcpy(iptr->hostptr, q, iptr->hostsize);
       else  
         DupString(*host, "*");  
3672      }      }
3673      else      else
3674      {      {
3675        if (*p != '\0')        if (*p != '\0')
3676          *user = xstrldup(p, USERLEN+1);          strlcpy(iptr->userptr, p, iptr->usersize);
       else  
         DupString(*user, "*");  
   
       DupString(*host, "*");  
3677      }      }
3678    }    }
3679    else  /* No ! found so lets look for a user@host */    else
3680    {    {
3681      if ((p = strchr(mask, '@')) != NULL)        /* if found a @ */      /* No ! found so lets look for a user@host */
3682        if ((p = strchr(iptr->nuhmask, '@')))
3683      {      {
3684        if (nick != NULL)        /* if found a @ */
3685          DupString(*nick, "*");        *p++ = '\0';
       *p = '\0';  
3686    
3687        if (*mask != '\0')        if (*iptr->nuhmask != '\0')
3688          *user = xstrldup(mask, USERLEN+1);          strlcpy(iptr->userptr, iptr->nuhmask, iptr->usersize);
       else  
         DupString(*user, "*");  
3689    
3690        if (*++p != '\0')        if (*p != '\0')
3691          *host = xstrldup(p, HOSTLEN+1);          strlcpy(iptr->hostptr, p, iptr->hostsize);
       else  
         DupString(*host, "*");  
3692      }      }
3693      else                                        /* no @ found */      else
3694      {      {
3695        if (nick != NULL)        /* no @ found */
3696        {        if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
3697          if (strpbrk(mask, ".:"))          strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
         {  
           DupString(*nick, "*");  
           *host = xstrldup(mask, HOSTLEN+1);  
         }  
         else  
         {  
           *nick = xstrldup(mask, NICKLEN);  
           DupString(*host, "*");  
         }  
   
         DupString(*user, "*");  
       }  
3698        else        else
3699        {          strlcpy(iptr->nickptr, iptr->nuhmask, iptr->nicksize);
         DupString(*user, "*");  
         *host = xstrldup(mask, HOSTLEN+1);  
       }  
3700      }      }
3701    }    }
3702  }  }
# Line 3736  flags_to_ascii(unsigned int flags, const Line 3723  flags_to_ascii(unsigned int flags, const
3723    {    {
3724      if (flags & mask)      if (flags & mask)
3725        *p++ = bit_table[i];        *p++ = bit_table[i];
3726      else if(lowerit)      else if (lowerit)
3727        *p++ = ToLower(bit_table[i]);        *p++ = ToLower(bit_table[i]);
3728    }    }
3729    *p = '\0';    *p = '\0';

Legend:
Removed from v.592  
changed lines
  Added in v.593

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28