File: dns_findname.c

package info (click to toggle)
rbldnsd 0.998b~pre1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 744 kB
  • ctags: 1,132
  • sloc: ansic: 8,212; python: 549; sh: 502; makefile: 249; awk: 33
file content (27 lines) | stat: -rw-r--r-- 601 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
/* 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;
}