-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenver.c
49 lines (41 loc) · 822 Bytes
/
genver.c
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* This inserts a dash into alpha-beta release version numbers so they are
* properly compared by report()/chkver(). A '-' is less than an 'a' in ascii
* but not in BIND's verion numbering scheme; this must be compensated for.
*
* This fix is applied to both the version member of the servers structure and
* the condition member of the configuration entry structure.
*/
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include"dnsqry.h"
char*
genver(char*aver)
{
register const char *p;
register char*op;
char*ret;
ret=malloc(strlen(aver)*2+1);
if(!ret)
vexit("malloc");
op=ret;
for(p=aver;*p;p++)
{
if(isalpha(*p))
{
if(isupper(*p))
*op++=tolower(*p);
else
{
*op++='-';
*op++=toupper(*p);
}
}
else
*op++=*p;
}
*op=0;
free(aver);
return ret;
}