drm: const'ify ioctls table (v2)
[dragonfly.git] / contrib / tcpdump / print-beep.c
blobb476dbf96b61d05a8421a5eaaaff3980fbc53b8b
1 /*
2 * Copyright (C) 2000, Richard Sharpe
4 * This software may be distributed either under the terms of the
5 * BSD-style licence that accompanies tcpdump or under the GNU GPL
6 * version 2 or later.
8 * print-beep.c
12 #ifndef lint
13 static const char rcsid[] _U_ =
14 "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp $";
15 #endif
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
21 #include <tcpdump-stdinc.h>
23 #ifdef HAVE_MEMORY_H
24 #include <memory.h>
25 #endif
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
30 #include "interface.h"
31 #include "extract.h"
33 /* Check for a string but not go beyond length
34 * Return TRUE on match, FALSE otherwise
36 * Looks at the first few chars up to tl1 ...
39 static int l_strnstart(const char *, u_int, const char *, u_int);
41 static int
42 l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
45 if (tl1 > l2)
46 return 0;
48 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
51 void
52 beep_print(const u_char *bp, u_int length)
55 if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
56 printf(" BEEP MSG");
57 else if (l_strnstart("RPY ", 4, (const char *)bp, length))
58 printf(" BEEP RPY");
59 else if (l_strnstart("ERR ", 4, (const char *)bp, length))
60 printf(" BEEP ERR");
61 else if (l_strnstart("ANS ", 4, (const char *)bp, length))
62 printf(" BEEP ANS");
63 else if (l_strnstart("NUL ", 4, (const char *)bp, length))
64 printf(" BEEP NUL");
65 else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
66 printf(" BEEP SEQ");
67 else if (l_strnstart("END", 4, (const char *)bp, length))
68 printf(" BEEP END");
69 else
70 printf(" BEEP (payload or undecoded)");