File: dns_findname.c

package info (click to toggle)
rbldnsd 0.996a
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 468 kB
  • ctags: 799
  • sloc: ansic: 5,704; sh: 349; makefile: 183; awk: 33
file content (28 lines) | stat: -rw-r--r-- 660 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* $Id: dns_findname.c,v 1.2 2003/04/28 23:48:22 mjt Exp $
 * dns_findname() is an auxilary routine to find given name in a
 * given dns_nameval table.
 */

#include "dns.h"
#include <string.h>

const struct dns_nameval *
dns_findname(const struct dns_nameval *nv, const char *name) {
  char nm[60]; /* all names are less than 60 chars anyway */
  char *p = nm;
  while(*name) {
    if (*name >= 'a' && *name <= 'z')
      *p++ = *name++ - 'a' + 'A';
    else
      *p++ = *name++;
    if (p == nm + sizeof(nm) - 1)
      return NULL;
  }
  *p = '\0';
  while(nv->name)
    if (strcmp(nv->name, nm) == 0)
      return nv;
    else
      ++nv;
  return NULL;
}