dmesg.c (227081) | dmesg.c (250430) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 25 unchanged lines hidden (view full) --- 34 The Regents of the University of California. All rights reserved.\n"; 35#endif /* not lint */ 36 37#ifndef lint 38static const char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93"; 39#endif /* not lint */ 40#endif 41#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 25 unchanged lines hidden (view full) --- 34 The Regents of the University of California. All rights reserved.\n"; 35#endif /* not lint */ 36 37#ifndef lint 38static const char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93"; 39#endif /* not lint */ 40#endif 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/sbin/dmesg/dmesg.c 227081 2011-11-04 13:36:02Z ed $"); | 42__FBSDID("$FreeBSD: head/sbin/dmesg/dmesg.c 250430 2013-05-10 03:42:48Z eadler $"); |
43 44#include <sys/types.h> 45#include <sys/msgbuf.h> 46#include <sys/sysctl.h> 47 48#include <ctype.h> 49#include <err.h> 50#include <errno.h> 51#include <fcntl.h> 52#include <kvm.h> 53#include <limits.h> 54#include <locale.h> 55#include <nlist.h> 56#include <stdio.h> | 43 44#include <sys/types.h> 45#include <sys/msgbuf.h> 46#include <sys/sysctl.h> 47 48#include <ctype.h> 49#include <err.h> 50#include <errno.h> 51#include <fcntl.h> 52#include <kvm.h> 53#include <limits.h> 54#include <locale.h> 55#include <nlist.h> 56#include <stdio.h> |
57#include <stdbool.h> |
|
57#include <stdlib.h> 58#include <string.h> 59#include <unistd.h> 60#include <vis.h> 61#include <sys/syslog.h> 62 63static struct nlist nl[] = { 64#define X_MSGBUF 0 --- 9 unchanged lines hidden (view full) --- 74int 75main(int argc, char *argv[]) 76{ 77 struct msgbuf *bufp, cur; 78 char *bp, *ep, *memf, *nextp, *nlistf, *p, *q, *visbp; 79 kvm_t *kd; 80 size_t buflen, bufpos; 81 long pri; | 58#include <stdlib.h> 59#include <string.h> 60#include <unistd.h> 61#include <vis.h> 62#include <sys/syslog.h> 63 64static struct nlist nl[] = { 65#define X_MSGBUF 0 --- 9 unchanged lines hidden (view full) --- 75int 76main(int argc, char *argv[]) 77{ 78 struct msgbuf *bufp, cur; 79 char *bp, *ep, *memf, *nextp, *nlistf, *p, *q, *visbp; 80 kvm_t *kd; 81 size_t buflen, bufpos; 82 long pri; |
82 int all, ch; | 83 int ch, clear; 84 bool all; |
83 | 85 |
84 all = 0; | 86 all = false; 87 clear = false; |
85 (void) setlocale(LC_CTYPE, ""); 86 memf = nlistf = NULL; | 88 (void) setlocale(LC_CTYPE, ""); 89 memf = nlistf = NULL; |
87 while ((ch = getopt(argc, argv, "aM:N:")) != -1) | 90 while ((ch = getopt(argc, argv, "acM:N:")) != -1) |
88 switch(ch) { 89 case 'a': | 91 switch(ch) { 92 case 'a': |
90 all++; | 93 all = true; |
91 break; | 94 break; |
95 case 'c': 96 clear = true; 97 break; |
|
92 case 'M': 93 memf = optarg; 94 break; 95 case 'N': 96 nlistf = optarg; 97 break; 98 case '?': 99 default: --- 85 unchanged lines hidden (view full) --- 185 continue; 186 p = q + 1; 187 } 188 } 189 190 (void)strvisx(visbp, p, nextp - p, 0); 191 (void)printf("%s", visbp); 192 } | 98 case 'M': 99 memf = optarg; 100 break; 101 case 'N': 102 nlistf = optarg; 103 break; 104 case '?': 105 default: --- 85 unchanged lines hidden (view full) --- 191 continue; 192 p = q + 1; 193 } 194 } 195 196 (void)strvisx(visbp, p, nextp - p, 0); 197 (void)printf("%s", visbp); 198 } |
199 if (clear) 200 if (sysctlbyname("kern.msgbuf_clear", NULL, NULL, &clear, sizeof(int))) 201 err(1, "sysctl kern.msgbuf_clear"); 202 |
|
193 exit(0); 194} 195 196void 197usage(void) 198{ | 203 exit(0); 204} 205 206void 207usage(void) 208{ |
199 (void)fprintf(stderr, "usage: dmesg [-a] [-M core [-N system]]\n"); | 209 fprintf(stderr, "usage: dmesg [-ac] [-M core [-N system]]\n"); |
200 exit(1); 201} | 210 exit(1); 211} |