PennMUSH Community

Changeset 1203

Show
Ignore:
Timestamp:
01/19/08 23:14:05 (8 months ago)
Author:
shawnw
Message:

@sitelock/delete NNN

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/devel/CHANGES.183

    r1202 r1203  
    2828 * '@hook/override cmd=#1234' will look at all attributes on the object 
    2929   for a matching $command. By Talvo. 
     30 * @sitelock/delete NNN will remove the sitelock rule with that number. 
    3031 
    3132Functions: 
  • 1.8.3/branches/devel/src/access.c

    r1143 r1203  
    586586  struct access *ap, *next, *prev = NULL; 
    587587  int n = 0; 
     588  int rulenum = 0, deletethis = -1; 
     589 
     590  if (is_strict_integer(pattern)) 
     591    deletethis = parse_integer(pattern); 
    588592 
    589593  /* We only want to be able to delete entries added with @sitelock */ 
    590   for (ap = access_top; ap; ap = ap->next) 
     594  for (ap = access_top; ap; ap = ap->next) { 
     595    rulenum++; 
    591596    if (strcmp(ap->host, "@sitelock") == 0) { 
    592597      prev = ap; 
     
    594599      break; 
    595600    } 
    596  
     601  } 
     602   
    597603  while (ap) { 
     604    rulenum++; 
    598605    next = ap->next; 
    599     if (strcasecmp(pattern, ap->host) == 0) { 
     606    if (deletethis == -1 ? (strcasecmp(pattern, ap->host) == 0) 
     607    : deletethis == rulenum) { 
    600608      n++; 
    601609      if (ap->re) 
    602         free(ap->re); 
     610   free(ap->re); 
    603611      mush_free(ap, "sitelock.rule"); 
    604612      if (prev) 
    605         prev->next = next; 
     613   prev->next = next; 
    606614      else 
    607         access_top = next; 
     615    access_top = next; 
     616      if (deletethis >= 0) 
     617    break; 
    608618    } else { 
    609619      prev = ap; 
     
    611621    ap = next; 
    612622  } 
    613  
     623   
    614624  return n; 
    615625}