Changeset View
Changeset View
Standalone View
Standalone View
head/tools/tools/npe/npestats/main.c
Show All 23 Lines | |||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||||
* THE POSSIBILITY OF SUCH DAMAGES. | * THE POSSIBILITY OF SUCH DAMAGES. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include <sys/param.h> | |||||
#include <err.h> | |||||
#include <signal.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <signal.h> | |||||
#include <strings.h> | #include <strings.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <err.h> | |||||
#include "npestats.h" | #include "npestats.h" | ||||
static struct { | static struct { | ||||
const char *tag; | const char *tag; | ||||
const char *fmt; | const char *fmt; | ||||
} tags[] = { | } tags[] = { | ||||
{ "default", | { "default", | ||||
"align,fcs,macrx,overrun,learn,large,stp,badsrc,underflow,collision1,collisionM,deferred,late,excessive,mactx,carrier,toobig" | "align,fcs,macrx,overrun,learn,large,stp,badsrc,underflow,collision1,collisionM,deferred,late,excessive,mactx,carrier,toobig" | ||||
}, | }, | ||||
}; | }; | ||||
static const char * | static const char * | ||||
getfmt(const char *tag) | getfmt(const char *tag) | ||||
{ | { | ||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
int i; | int i; | ||||
for (i = 0; i < N(tags); i++) | for (i = 0; i < nitems(tags); i++) | ||||
if (strcasecmp(tags[i].tag, tag) == 0) | if (strcasecmp(tags[i].tag, tag) == 0) | ||||
return tags[i].fmt; | return tags[i].fmt; | ||||
return tag; | return tag; | ||||
#undef N | |||||
} | } | ||||
static int signalled; | static int signalled; | ||||
static void | static void | ||||
catchalarm(int signo __unused) | catchalarm(int signo __unused) | ||||
{ | { | ||||
signalled = 1; | signalled = 1; | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |