summaryrefslogtreecommitdiffstats
path: root/src/appl/telnet/libtelnet/parsetos.c
blob: 303d7c3e52d2c8ff7c6ef03b099efa4df9c444e9 (plain)
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

/*
 * The routine parsetos() for UNICOS 6.0/6.1, as well as more traditional
 * Unix systems.  This is part of UNICOS 7.0 and later.
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <netdb.h>
#include <errno.h>
#define NEED_PARSETOS
#include "misc-proto.h"

#define	MIN_TOS	0
#define	MAX_TOS	255

int
parsetos(name, proto)
char	*name;
char	*proto;
{
#if 0
	register char	*c;
#endif
	int		tos;

#ifdef HAVE_GETTOSBYNAME
	struct tosent	*tosp;

	tosp = gettosbyname(name, proto);
	if (tosp)
		tos = tosp->t_tos;
	else
#endif
		tos = (int)strtol(name, (char **)NULL, 0);

	if (tos < MIN_TOS || tos > MAX_TOS) {
		return (-1);
	}
	return (tos);
}