freebsd-dev/sbin/ipf/libipf/getproto.c
Cy Schubert 44bc301921 ipfilter userland: Style(9) requires a space after return
Reported by:    jrtc27
Fixes:          2582ae5740
MFC after:      1 month
2022-01-03 19:37:25 -08:00

36 lines
490 B
C

/* $FreeBSD$ */
/*
* Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* $Id$
*/
#include "ipf.h"
#include <ctype.h>
int getproto(char *name);
int
getproto(char *name)
{
struct protoent *p;
char *s;
for (s = name; *s != '\0'; s++)
if (!ISDIGIT(*s))
break;
if (*s == '\0')
return (atoi(name));
if (!strcasecmp(name, "ip"))
return (0);
p = getprotobyname(name);
if (p != NULL)
return (p->p_proto);
return (-1);
}