PERFORCE change 90246 for review

Robert Watson rwatson at FreeBSD.org
Mon Jan 23 22:05:04 GMT 2006


http://perforce.freebsd.org/chv.cgi?CH=90246

Change 90246 by rwatson at rwatson_peppercorn on 2006/01/23 22:04:25

	Converge towards style(9).

Affected files ...

.. //depot/projects/trustedbsd/openbsm/bin/praudit/praudit.c#3 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/bin/praudit/praudit.c#3 (text+ko) ====

@@ -1,18 +1,18 @@
 /*
  * Copyright (c) 2004, Apple Computer, Inc. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
+ *     notice, this list of conditions and the following disclaimer.
  * 2.  Redistributions in binary form must reproduce the above copyright
  *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
+ *     documentation and/or other materials provided with the distribution.
  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- * 
+ *     from this software without specific prior written permission.
+ *
  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,13 +26,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* 
- * Tool used to parse audit records conforming to the BSM structure
- */   
+/*
+ * Tool used to parse audit records conforming to the BSM structure.
+ */
 
 /*
  * praudit [-lrs] [-ddel] [filenames]
- */   
+ */
 
 #include <bsm/libbsm.h>
 
@@ -43,120 +43,112 @@
 extern char *optarg;
 extern int optind, optopt, opterr,optreset;
 
-static char *del = ","; /* default delimiter */
+static char *del = ",";	/* Default delimiter. */
 static int oneline = 0;
 static int raw = 0;
 static int shortfrm = 0;
 static int partial = 0;
 
-static void usage()
+static void
+usage()
 {
-	printf("Usage: praudit [-lrs] [-ddel] [filenames]\n");
+
+	fprintf(stderr, "Usage: praudit [-lrs] [-ddel] [filenames]\n");
 	exit(1);
 }
+
 /*
- * token printing for each token type 
+ * Token printing for each token type .
  */
-static int print_tokens(FILE *fp)
+static int
+print_tokens(FILE *fp)
 {
 	u_char *buf;
 	tokenstr_t tok;
 	int reclen;
    	int bytesread;
 
-	/* allow tail -f | praudit to work */
-        if (partial) {
-            u_char type = 0;
-            /* record must begin with a header token */
-            do {
-                type = fgetc(fp);
-            } while(type != AU_HEADER_32_TOKEN);
-            ungetc(type, fp);
-        }
+	/* Allow tail -f | praudit to work. */
+	if (partial) {
+		u_char type = 0;
+		/* Record must begin with a header token. */
+		do {
+			type = fgetc(fp);
+		} while(type != AU_HEADER_32_TOKEN);
+		ungetc(type, fp);
+	}
 
-	while((reclen = au_read_rec(fp, &buf)) != -1) {
-
+	while ((reclen = au_read_rec(fp, &buf)) != -1) {
 		bytesread = 0;
-
 		while (bytesread < reclen) {
-
-			if(-1 == au_fetch_tok(&tok, buf + bytesread, reclen - bytesread)) {
-				/* is this an incomplete record ? */
+			/* Is this an incomplete record? */
+			if (-1 == au_fetch_tok(&tok, buf + bytesread,
+			    reclen - bytesread))
 				break;
-			}
-
 			au_print_tok(stdout, &tok, del, raw, shortfrm);
 			bytesread += tok.len;
-
-			if(oneline) {
+			if (oneline)
 				printf("%s", del);
-			}
-			else {
+			else
 				printf("\n");
-			}
 		}
-
 		free(buf);
-
-		if(oneline) {
+		if (oneline)
 			printf("\n");
-		}
 	}
-
-	return 0;
+	return (0);
 }
 
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
 {
 	char ch;
 	int i;
 	FILE  *fp;
-	
-	while((ch = getopt(argc, argv, "lprsd:")) != -1) {
+
+	while ((ch = getopt(argc, argv, "lprsd:")) != -1) {
 		switch(ch) {
+		case 'l':
+			oneline = 1;
+			break;
 
-			case 'l': 
-					oneline = 1;
-					break;
+		case 'r':
+			if (shortfrm)
+				usage();	/* Exclusive from shortfrm. */
+			raw = 1;
+			break;
 
-			case 'r':
-					if(shortfrm)
-						usage(); /* exclusive from shortfrm */
-					raw = 1;
-					break;
+		case 's':
+			if (raw)
+				usage();	/* Exclusive from raw. */
+			shortfrm = 1;
+			break;
 
-			case 's':
-					if(raw)
-						usage(); /* exclusive from raw */
-					shortfrm = 1;
-					break;	
+		case 'd':
+			del = optarg;
+			break;
 
-			case 'd': 
-					del = optarg;
-					break;
+		case 'p':
+			partial = 1;
+			break;
 
-                        case 'p':
-                                        partial = 1;
-                                        break;
-
-			case '?':
-			default :
-					usage();
+		case '?':
+		default:
+			usage();
 		}
 	}
 
-	/* For each of the files passed as arguments dump the contents */
-	if(optind == argc) {
+	/* For each of the files passed as arguments dump the contents. */
+	if (optind == argc) {
 		print_tokens(stdin);
-		return 1;
+		return (1);
 	}
 	for (i = optind; i < argc; i++) {
 		fp = fopen(argv[i], "r");
-		if((fp == NULL) || (-1 == print_tokens(fp))) {
+		if ((fp == NULL) || (print_tokens(fp) == -1))
 			perror(argv[i]);
-		}
-		if(fp != NULL)
-			fclose(fp);	
+		if (fp != NULL)
+			fclose(fp);
 	}
-	return 1;
+	return (1);
 }
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list