dmesg.c (1.4) | dmesg.c (1.5) |
---|---|
1/* $OpenBSD: dmesg.c,v 1.4 1997/01/15 23:41:10 millert Exp $ */ | 1/* $OpenBSD: dmesg.c,v 1.5 1997/03/29 20:28:20 tholo Exp $ */ |
2/* $NetBSD: dmesg.c,v 1.8 1995/03/18 14:54:49 cgd Exp $ */ 3 4/*- 5 * Copyright (c) 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 29 unchanged lines hidden (view full) --- 39"@(#) Copyright (c) 1991, 1993\n\ 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93"; 46#else | 2/* $NetBSD: dmesg.c,v 1.8 1995/03/18 14:54:49 cgd Exp $ */ 3 4/*- 5 * Copyright (c) 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 29 unchanged lines hidden (view full) --- 39"@(#) Copyright (c) 1991, 1993\n\ 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93"; 46#else |
47static char rcsid[] = "$OpenBSD: dmesg.c,v 1.4 1997/01/15 23:41:10 millert Exp $"; | 47static char rcsid[] = "$OpenBSD: dmesg.c,v 1.5 1997/03/29 20:28:20 tholo Exp $"; |
48#endif 49#endif /* not lint */ 50 51#include <sys/cdefs.h> 52#include <sys/msgbuf.h> 53 54#include <err.h> 55#include <fcntl.h> --- 68 unchanged lines hidden (view full) --- 124 errx(1, "magic number incorrect"); 125 if (cur.msg_bufx >= MSG_BSIZE) 126 cur.msg_bufx = 0; 127 128 /* 129 * The message buffer is circular; start at the read pointer, and 130 * go to the write pointer - 1. 131 */ | 48#endif 49#endif /* not lint */ 50 51#include <sys/cdefs.h> 52#include <sys/msgbuf.h> 53 54#include <err.h> 55#include <fcntl.h> --- 68 unchanged lines hidden (view full) --- 124 errx(1, "magic number incorrect"); 125 if (cur.msg_bufx >= MSG_BSIZE) 126 cur.msg_bufx = 0; 127 128 /* 129 * The message buffer is circular; start at the read pointer, and 130 * go to the write pointer - 1. 131 */ |
132 p = cur.msg_bufc + cur.msg_bufx; 133 ep = cur.msg_bufc + cur.msg_bufx - 1; 134 for (newl = skip = 0; p != ep; ++p) { 135 if (p == cur.msg_bufc + MSG_BSIZE) | 132 p = ep = cur.msg_bufc + (cur.msg_bufx - 1 + MSG_BSIZE) % MSG_BSIZE; 133 newl = skip = 0; 134 do { 135 if (++p == cur.msg_bufc + MSG_BSIZE) |
136 p = cur.msg_bufc; 137 ch = *p; 138 /* Skip "\n<.*>" syslog sequences. */ 139 if (skip) { 140 if (ch == '>') 141 newl = skip = 0; 142 continue; 143 } --- 4 unchanged lines hidden (view full) --- 148 if (ch == '\0') 149 continue; 150 newl = ch == '\n'; 151 (void)vis(buf, ch, 0, 0); 152 if (buf[1] == 0) 153 (void)putchar(buf[0]); 154 else 155 (void)printf("%s", buf); | 136 p = cur.msg_bufc; 137 ch = *p; 138 /* Skip "\n<.*>" syslog sequences. */ 139 if (skip) { 140 if (ch == '>') 141 newl = skip = 0; 142 continue; 143 } --- 4 unchanged lines hidden (view full) --- 148 if (ch == '\0') 149 continue; 150 newl = ch == '\n'; 151 (void)vis(buf, ch, 0, 0); 152 if (buf[1] == 0) 153 (void)putchar(buf[0]); 154 else 155 (void)printf("%s", buf); |
156 } | 156 } while (p != ep); |
157 if (!newl) 158 (void)putchar('\n'); 159 exit(0); 160} 161 162void 163usage() 164{ 165 (void)fprintf(stderr, "usage: dmesg [-M core] [-N system]\n"); 166 exit(1); 167} | 157 if (!newl) 158 (void)putchar('\n'); 159 exit(0); 160} 161 162void 163usage() 164{ 165 (void)fprintf(stderr, "usage: dmesg [-M core] [-N system]\n"); 166 exit(1); 167} |