2005-08-20 20:17:36 +04:00
|
|
|
/* $NetBSD: style,v 1.35 2005/08/20 16:17:36 rillig Exp $ */
|
1996-08-30 21:43:09 +04:00
|
|
|
|
1993-08-06 11:30:52 +04:00
|
|
|
/*
|
2000-03-02 11:51:54 +03:00
|
|
|
* The revision control tag appears first, with a blank line after it.
|
|
|
|
* Copyright text appears after the revision control tag.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The NetBSD source code style guide.
|
|
|
|
* (Previously known as KNF - Kernel Normal Form).
|
1993-08-06 11:30:52 +04:00
|
|
|
*
|
1994-03-26 06:24:50 +03:00
|
|
|
* from: @(#)style 1.12 (Berkeley) 3/18/94
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
1999-01-29 10:24:20 +03:00
|
|
|
/*
|
|
|
|
* An indent(1) profile approximating the style outlined in
|
|
|
|
* this document lives in /usr/share/misc/indent.pro. It is a
|
|
|
|
* useful tool to assist in converting code to KNF, but indent(1)
|
|
|
|
* output generated using this profile must not be considered to
|
|
|
|
* be an authoritative reference.
|
|
|
|
*/
|
1993-08-06 11:30:52 +04:00
|
|
|
|
2000-03-02 11:51:54 +03:00
|
|
|
/*
|
|
|
|
* Source code revision control identifiers appear after any copyright
|
|
|
|
* text. Use the appropriate macros from <sys/cdefs.h>. Usually only one
|
|
|
|
* source file per program contains a __COPYRIGHT() section.
|
|
|
|
* Historic Berkeley code may also have an __SCCSID() section.
|
|
|
|
* Only one instance of each of these macros can occur in each file.
|
|
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__COPYRIGHT("@(#) Copyright (c) 2000\n\
|
|
|
|
The NetBSD Foundation, inc. All rights reserved.\n");
|
2005-08-20 20:17:36 +04:00
|
|
|
__RCSID("$NetBSD: style,v 1.35 2005/08/20 16:17:36 rillig Exp $");
|
2000-03-02 11:51:54 +03:00
|
|
|
|
1993-08-06 11:30:52 +04:00
|
|
|
/*
|
|
|
|
* VERY important single-line comments look like this.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Most single-line comments look like this. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Multi-line comments look like this. Make them real sentences. Fill
|
|
|
|
* them so they look like real paragraphs.
|
|
|
|
*/
|
|
|
|
|
1994-03-26 06:24:50 +03:00
|
|
|
/*
|
2000-03-02 11:51:54 +03:00
|
|
|
* Attempt to wrap lines longer than 80 characters appropriately.
|
|
|
|
* Refer to the examples below for more information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* EXAMPLE HEADER FILE:
|
|
|
|
*
|
|
|
|
* A header file should protect itself against multiple inclusion.
|
|
|
|
* E.g, <sys/socket.h> would contain something like:
|
|
|
|
*/
|
|
|
|
#ifndef _SYS_SOCKET_H_
|
|
|
|
#define _SYS_SOCKET_H_
|
|
|
|
/*
|
|
|
|
* Contents of #include file go between the #ifndef and the #endif at the end.
|
|
|
|
*/
|
|
|
|
#endif /* !_SYS_SOCKET_H_ */
|
|
|
|
/*
|
|
|
|
* END OF EXAMPLE HEADER FILE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Kernel include files come first.
|
1994-03-26 06:24:50 +03:00
|
|
|
*/
|
|
|
|
#include <sys/types.h> /* Non-local includes in brackets. */
|
|
|
|
|
2000-03-02 11:51:54 +03:00
|
|
|
/*
|
|
|
|
* If it's a network program, put the network include files next.
|
|
|
|
* Group the includes files by subdirectory.
|
|
|
|
*/
|
1994-03-26 06:24:50 +03:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_dl.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <protocols/rwhod.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Then there's a blank line, followed by the /usr include files.
|
|
|
|
* The /usr include files should be sorted!
|
|
|
|
*/
|
2001-10-23 22:51:05 +04:00
|
|
|
#include <assert.h>
|
2003-04-17 06:59:29 +04:00
|
|
|
#include <errno.h>
|
1994-03-26 06:24:50 +03:00
|
|
|
#include <stdio.h>
|
2001-02-21 03:04:43 +03:00
|
|
|
#include <stdlib.h>
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Global pathnames are defined in /usr/include/paths.h. Pathnames local
|
|
|
|
* to the program go in pathnames.h in the local directory.
|
|
|
|
*/
|
1994-03-26 06:24:50 +03:00
|
|
|
#include <paths.h>
|
|
|
|
|
|
|
|
/* Then, there's a blank line, and the user include files. */
|
2000-03-02 11:51:54 +03:00
|
|
|
#include "pathnames.h" /* Local includes in double quotes. */
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
1994-03-26 06:24:50 +03:00
|
|
|
* ANSI function declarations for private functions (i.e. functions not used
|
2000-03-02 11:51:54 +03:00
|
|
|
* elsewhere) and the main() function go at the top of the source module.
|
|
|
|
* Don't associate a name with the types. I.e. use:
|
|
|
|
* void function(int);
|
|
|
|
* Use your discretion on indenting between the return type and the name, and
|
|
|
|
* how to wrap a prototype too long for a single line. In the latter case,
|
2000-09-04 12:01:16 +04:00
|
|
|
* lining up under the initial left parenthesis may be more readable.
|
2000-03-02 11:51:54 +03:00
|
|
|
* In any case, consistency is important!
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
2000-03-02 11:51:54 +03:00
|
|
|
static char *function(int, int, float, int);
|
|
|
|
static int dirinfo(const char *, struct stat *, struct dirent *,
|
|
|
|
struct statfs *, int *, char **[]);
|
|
|
|
static void usage(void);
|
|
|
|
int main(int, char *[]);
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros are capitalized, parenthesized, and should avoid side-effects.
|
2003-03-02 21:25:45 +03:00
|
|
|
* Spacing before and after the macro name may be any whitespace, though
|
|
|
|
* use of TABs should be consistent through a file.
|
1993-08-06 11:30:52 +04:00
|
|
|
* If they are an inline expansion of a function, the function is defined
|
2000-03-02 11:51:54 +03:00
|
|
|
* all in lowercase, the macro has the same name all in uppercase.
|
|
|
|
* If the macro is an expression, wrap the expression in parenthesis.
|
|
|
|
* If the macro is more than a single statement, use ``do { ... } while (0)'',
|
|
|
|
* so that a trailing semicolon works. Right-justify the backslashes; it
|
2000-03-10 15:01:15 +03:00
|
|
|
* makes it easier to read. The CONSTCOND comment is to satisfy lint(1).
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
2000-03-02 11:51:54 +03:00
|
|
|
#define MACRO(v, w, x, y) \
|
|
|
|
do { \
|
|
|
|
v = (x) + (y); \
|
|
|
|
w = (y) + 2; \
|
|
|
|
} while (/* CONSTCOND */ 0)
|
1993-08-06 11:30:52 +04:00
|
|
|
|
2000-09-04 12:01:16 +04:00
|
|
|
#define DOUBLE(x) ((x) * 2)
|
2000-03-02 11:51:54 +03:00
|
|
|
|
|
|
|
/* Enum types are capitalized. No comma on the last element. */
|
|
|
|
enum enumtype {
|
|
|
|
ONE,
|
|
|
|
TWO
|
|
|
|
} et;
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
2000-09-06 18:12:45 +04:00
|
|
|
* When declaring variables in structures, declare them organized by use in
|
|
|
|
* a manner to attempt to minimize memory wastage because of compiler alignment
|
2000-03-02 11:51:54 +03:00
|
|
|
* issues, then by size, and then by alphabetical order. E.g, don't use
|
|
|
|
* ``int a; char *b; int c; char *d''; use ``int a; int b; char *c; char *d''.
|
|
|
|
* Each variable gets its own type and line, although an exception can be made
|
|
|
|
* when declaring bitfields (to clarify that it's part of the one bitfield).
|
|
|
|
* Note that the use of bitfields in general is discouraged.
|
1993-08-06 11:30:52 +04:00
|
|
|
*
|
1994-03-26 06:24:50 +03:00
|
|
|
* Major structures should be declared at the top of the file in which they
|
|
|
|
* are used, or in separate header files, if they are used in multiple
|
|
|
|
* source files. Use of the structures should be by separate declarations
|
1993-08-06 11:30:52 +04:00
|
|
|
* and should be "extern" if they are declared in a header file.
|
2000-03-02 11:51:54 +03:00
|
|
|
*
|
|
|
|
* It may be useful to use a meaningful prefix for each member name.
|
|
|
|
* E.g, for ``struct softc'' the prefix could be ``sc_''.
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
|
|
|
struct foo {
|
2000-03-02 11:51:54 +03:00
|
|
|
struct foo *next; /* List of active foo */
|
|
|
|
struct mumble amumble; /* Comment for mumble */
|
|
|
|
int bar;
|
|
|
|
unsigned int baz:1, /* Bitfield; line up entries if desired */
|
|
|
|
fuz:5,
|
|
|
|
zap:2;
|
2003-09-28 01:17:31 +04:00
|
|
|
uint8_t flag;
|
1993-08-06 11:30:52 +04:00
|
|
|
};
|
|
|
|
struct foo *foohead; /* Head of global foo list */
|
1994-03-26 06:24:50 +03:00
|
|
|
|
|
|
|
/* Make the structure name match the typedef. */
|
2000-03-02 11:51:54 +03:00
|
|
|
typedef struct BAR {
|
|
|
|
int level;
|
1994-03-26 06:24:50 +03:00
|
|
|
} BAR;
|
2000-03-02 11:51:54 +03:00
|
|
|
|
2005-06-10 10:35:41 +04:00
|
|
|
/* C99 uintN_t is preferred over u_intN_t. */
|
|
|
|
uint32_t zero;
|
|
|
|
|
1993-08-06 11:30:52 +04:00
|
|
|
/*
|
|
|
|
* All major routines should have a comment briefly describing what
|
1994-03-26 06:24:50 +03:00
|
|
|
* they do. The comment before the "main" routine should describe
|
1993-08-06 11:30:52 +04:00
|
|
|
* what the program does.
|
|
|
|
*/
|
1994-03-26 06:24:50 +03:00
|
|
|
int
|
2000-03-02 11:51:54 +03:00
|
|
|
main(int argc, char *argv[])
|
1993-08-06 11:30:52 +04:00
|
|
|
{
|
|
|
|
long num;
|
|
|
|
int ch;
|
|
|
|
char *ep;
|
|
|
|
|
2001-02-20 01:46:47 +03:00
|
|
|
/*
|
|
|
|
* At the start of main(), call setprogname() to set the program
|
|
|
|
* name. This does nothing on NetBSD, but increases portability
|
|
|
|
* to other systems.
|
|
|
|
*/
|
|
|
|
setprogname(argv[0]);
|
|
|
|
|
1993-08-06 11:30:52 +04:00
|
|
|
/*
|
1994-03-26 06:24:50 +03:00
|
|
|
* For consistency, getopt should be used to parse options. Options
|
|
|
|
* should be sorted in the getopt call and the switch statement, unless
|
|
|
|
* parts of the switch cascade. Elements in a switch statement that
|
|
|
|
* cascade should have a FALLTHROUGH comment. Numerical arguments
|
|
|
|
* should be checked for accuracy. Code that cannot be reached should
|
|
|
|
* have a NOTREACHED comment.
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
2000-03-02 11:51:54 +03:00
|
|
|
while ((ch = getopt(argc, argv, "abn")) != -1) {
|
1993-08-06 11:30:52 +04:00
|
|
|
switch (ch) { /* Indent the switch. */
|
|
|
|
case 'a': /* Don't indent the case. */
|
|
|
|
aflag = 1;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case 'b':
|
|
|
|
bflag = 1;
|
|
|
|
break;
|
|
|
|
case 'n':
|
2003-04-17 06:59:29 +04:00
|
|
|
errno = 0;
|
1993-08-06 11:30:52 +04:00
|
|
|
num = strtol(optarg, &ep, 10);
|
2003-04-17 06:59:29 +04:00
|
|
|
if (num <= 0 || *ep != '\0' || (errno == ERANGE &&
|
|
|
|
(num == LONG_MAX || num == LONG_MIN)) )
|
2000-03-02 11:51:54 +03:00
|
|
|
errx(1, "illegal number -- %s", optarg);
|
1993-08-06 11:30:52 +04:00
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage();
|
1994-03-26 06:24:50 +03:00
|
|
|
/* NOTREACHED */
|
1993-08-06 11:30:52 +04:00
|
|
|
}
|
2000-03-02 11:51:54 +03:00
|
|
|
}
|
1993-08-06 11:30:52 +04:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Space after keywords (while, for, return, switch). No braces are
|
2000-03-02 11:51:54 +03:00
|
|
|
* used for control statements with zero or only a single statement,
|
|
|
|
* unless it's a long statement.
|
1993-08-06 11:30:52 +04:00
|
|
|
*
|
|
|
|
* Forever loops are done with for's, not while's.
|
|
|
|
*/
|
2000-03-02 11:51:54 +03:00
|
|
|
for (p = buf; *p != '\0'; ++p)
|
|
|
|
continue; /* Explicit no-op */
|
1993-08-06 11:30:52 +04:00
|
|
|
for (;;)
|
|
|
|
stmt;
|
2000-03-02 11:51:54 +03:00
|
|
|
|
1993-08-06 11:30:52 +04:00
|
|
|
/*
|
1994-03-26 06:24:50 +03:00
|
|
|
* Parts of a for loop may be left empty. Don't put declarations
|
|
|
|
* inside blocks unless the routine is unusually complicated.
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
|
|
|
for (; cnt < 15; cnt++) {
|
|
|
|
stmt1;
|
|
|
|
stmt2;
|
|
|
|
}
|
|
|
|
|
1994-03-26 06:24:50 +03:00
|
|
|
/* Second level indents are four spaces. */
|
|
|
|
while (cnt < 20)
|
2000-09-06 18:12:45 +04:00
|
|
|
z = a + really + long + statement + that + needs + two lines +
|
1993-08-06 11:30:52 +04:00
|
|
|
gets + indented + four + spaces + on + the + second +
|
1998-02-09 09:58:39 +03:00
|
|
|
and + subsequent + lines;
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
1994-03-26 06:24:50 +03:00
|
|
|
* Closing and opening braces go on the same line as the else.
|
2000-03-02 11:51:54 +03:00
|
|
|
* Don't add braces that aren't necessary except in cases where
|
|
|
|
* there are ambiguity or readability issues.
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
2000-03-02 11:51:54 +03:00
|
|
|
if (test) {
|
|
|
|
/*
|
|
|
|
* I have a long comment here.
|
|
|
|
*/
|
|
|
|
#ifdef zorro
|
|
|
|
z = 1;
|
|
|
|
#else
|
|
|
|
b = 3;
|
|
|
|
#endif
|
|
|
|
} else if (bar) {
|
1993-08-06 11:30:52 +04:00
|
|
|
stmt;
|
|
|
|
stmt;
|
|
|
|
} else
|
|
|
|
stmt;
|
2000-03-02 11:51:54 +03:00
|
|
|
|
1994-03-26 06:24:50 +03:00
|
|
|
/* No spaces after function names. */
|
2000-03-02 11:51:54 +03:00
|
|
|
if ((result = function(a1, a2, a3, a4)) == NULL)
|
|
|
|
exit(1);
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
2000-03-02 11:51:54 +03:00
|
|
|
* Unary operators don't require spaces, binary operators do.
|
|
|
|
* Don't excessively use parenthesis, but they should be used if
|
1999-01-21 02:13:54 +03:00
|
|
|
* statement is really confusing without them, such as:
|
|
|
|
* a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1;
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
1999-01-21 02:13:54 +03:00
|
|
|
a = ((b->c[0] + ~d == (e || f)) || (g && h)) ? i : (j >> 1);
|
1994-03-26 06:24:50 +03:00
|
|
|
k = !(l & FLAGS);
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
2003-08-05 17:26:13 +04:00
|
|
|
* Exits should be EXIT_SUCCESS on success, and EXIT_FAILURE on
|
|
|
|
* failure. Don't denote all the possible exit points, using the
|
2005-02-01 16:43:38 +03:00
|
|
|
* integers 1 through 127. Avoid obvious comments such as "Exit
|
|
|
|
* 0 on success.". Since main is a function that returns an int,
|
|
|
|
* prefer returning from it, than calling exit.
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
2005-02-01 16:43:38 +03:00
|
|
|
return EXIT_SUCCESS;
|
1993-08-06 11:30:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-09-01 10:51:09 +04:00
|
|
|
* The function type must be declared on a line by itself
|
2000-09-06 18:12:45 +04:00
|
|
|
* preceding the function.
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
|
|
|
static char *
|
2000-03-02 11:51:54 +03:00
|
|
|
function(int a1, int a2, float fl, int a4)
|
1993-08-06 11:30:52 +04:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* When declaring variables in functions declare them sorted by size,
|
2000-03-02 11:51:54 +03:00
|
|
|
* then in alphabetical order; multiple ones per line are okay.
|
|
|
|
* Function prototypes should go in the include file "extern.h".
|
1993-08-06 11:30:52 +04:00
|
|
|
* If a line overflows reuse the type keyword.
|
|
|
|
*
|
1994-03-26 06:24:50 +03:00
|
|
|
* DO NOT initialize variables in the declarations.
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
|
|
|
extern u_char one;
|
|
|
|
extern char two;
|
|
|
|
struct foo three, *four;
|
|
|
|
double five;
|
2000-03-02 11:51:54 +03:00
|
|
|
int *six, seven;
|
|
|
|
char *eight, *nine, ten, eleven, twelve, thirteen;
|
|
|
|
char fourteen, fifteen, sixteen;
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Casts and sizeof's are not followed by a space. NULL is any
|
|
|
|
* pointer type, and doesn't need to be cast, so use NULL instead
|
|
|
|
* of (struct foo *)0 or (struct foo *)NULL. Also, test pointers
|
2000-03-02 11:51:54 +03:00
|
|
|
* against NULL. I.e. use:
|
1993-08-06 11:30:52 +04:00
|
|
|
*
|
2000-03-02 11:51:54 +03:00
|
|
|
* (p = f()) == NULL
|
1993-08-06 11:30:52 +04:00
|
|
|
* not:
|
|
|
|
* !(p = f())
|
1994-03-26 06:24:50 +03:00
|
|
|
*
|
2000-03-02 11:51:54 +03:00
|
|
|
* Don't use `!' for tests unless it's a boolean.
|
|
|
|
* E.g. use "if (*p == '\0')", not "if (!*p)".
|
|
|
|
*
|
2005-02-03 03:27:55 +03:00
|
|
|
* Routines returning ``void *'' should not have their return
|
|
|
|
* values cast to more specific pointer types.
|
1994-03-26 06:24:50 +03:00
|
|
|
*
|
|
|
|
* Use err/warn(3), don't roll your own!
|
1993-08-06 11:30:52 +04:00
|
|
|
*/
|
|
|
|
if ((four = malloc(sizeof(struct foo))) == NULL)
|
1994-03-26 06:24:50 +03:00
|
|
|
err(1, NULL);
|
1993-08-06 11:30:52 +04:00
|
|
|
if ((six = (int *)overflow()) == NULL)
|
1994-03-26 06:24:50 +03:00
|
|
|
errx(1, "Number overflowed.");
|
2003-03-04 17:22:15 +03:00
|
|
|
|
|
|
|
/* No parentheses are needed around the return value. */
|
|
|
|
return eight;
|
1993-08-06 11:30:52 +04:00
|
|
|
}
|
|
|
|
|
1994-03-26 06:24:50 +03:00
|
|
|
/*
|
2000-03-02 11:51:54 +03:00
|
|
|
* Use ANSI function declarations. ANSI function braces look like
|
|
|
|
* old-style (K&R) function braces.
|
|
|
|
* As per the wrapped prototypes, use your discretion on how to format
|
|
|
|
* the subsequent lines.
|
1994-03-26 06:24:50 +03:00
|
|
|
*/
|
2000-03-02 11:51:54 +03:00
|
|
|
static int
|
|
|
|
dirinfo(const char *p, struct stat *sb, struct dirent *de, struct statfs *sf,
|
|
|
|
int *rargc, char **rargv[])
|
|
|
|
{ /* Insert an empty line if the function has no local variables. */
|
|
|
|
|
2001-10-23 22:45:13 +04:00
|
|
|
/*
|
|
|
|
* In system libraries, catch obviously invalid function arguments
|
|
|
|
* using _DIAGASSERT(3).
|
|
|
|
*/
|
|
|
|
_DIAGASSERT(p != NULL);
|
|
|
|
_DIAGASSERT(filedesc != -1);
|
|
|
|
|
2000-03-10 15:46:30 +03:00
|
|
|
if (stat(p, sb) < 0)
|
|
|
|
err(1, "Unable to stat %s", p);
|
|
|
|
|
|
|
|
/*
|
2005-08-20 13:03:29 +04:00
|
|
|
* To printf 64 bit quantities, use %lld and cast to (long long)
|
|
|
|
* or use %llu and cast to (unsigned long long).
|
2000-03-10 15:46:30 +03:00
|
|
|
*/
|
2005-08-20 20:17:36 +04:00
|
|
|
(void)printf("The size of %s is %lld\n", p, (long long)sb->st_size);
|
1993-08-06 11:30:52 +04:00
|
|
|
}
|
|
|
|
|
2000-03-02 11:51:54 +03:00
|
|
|
/*
|
|
|
|
* Functions that support variable numbers of arguments should look like this.
|
|
|
|
* (With the #include <stdarg.h> appearing at the top of the file with the
|
|
|
|
* other include files).
|
|
|
|
*/
|
1994-03-26 06:24:50 +03:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
vaf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
2000-03-02 11:51:54 +03:00
|
|
|
|
1994-03-26 06:24:50 +03:00
|
|
|
va_start(ap, fmt);
|
|
|
|
STUFF;
|
2000-03-02 11:51:54 +03:00
|
|
|
va_end(ap);
|
|
|
|
/* No return needed for void functions. */
|
1994-03-26 06:24:50 +03:00
|
|
|
}
|
|
|
|
|
1993-08-06 11:30:52 +04:00
|
|
|
static void
|
2000-03-02 11:51:54 +03:00
|
|
|
usage(void)
|
|
|
|
{
|
1993-08-06 11:30:52 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Use printf(3), not fputs/puts/putchar/whatever, it's faster and
|
|
|
|
* usually cleaner, not to mention avoiding stupid bugs.
|
2000-03-02 11:51:54 +03:00
|
|
|
* Use snprintf(3) or strlcpy(3)/strlcat(3) instead of sprintf(3);
|
|
|
|
* again to avoid stupid bugs.
|
1993-08-06 11:30:52 +04:00
|
|
|
*
|
|
|
|
* Usage statements should look like the manual pages. Options w/o
|
|
|
|
* operands come first, in alphabetical order inside a single set of
|
|
|
|
* braces. Followed by options with operands, in alphabetical order,
|
|
|
|
* each in braces. Followed by required arguments in the order they
|
|
|
|
* are specified, followed by optional arguments in the order they
|
2000-03-02 11:51:54 +03:00
|
|
|
* are specified. A bar (`|') separates either/or options/arguments,
|
1993-08-06 11:30:52 +04:00
|
|
|
* and multiple options/arguments which are specified together are
|
|
|
|
* placed in a single set of braces.
|
|
|
|
*
|
2001-02-20 01:46:47 +03:00
|
|
|
* Use getprogname() instead of hardcoding the program name.
|
2000-03-02 11:51:54 +03:00
|
|
|
*
|
1993-08-06 11:30:52 +04:00
|
|
|
* "usage: f [-ade] [-b b_arg] [-m m_arg] req1 req2 [opt1 [opt2]]\n"
|
|
|
|
* "usage: f [-a | -b] [-c [-de] [-n number]]\n"
|
|
|
|
*/
|
2001-02-20 01:46:47 +03:00
|
|
|
(void)fprintf(stderr, "usage: %s [-ab]\n", getprogname());
|
2005-08-20 12:58:57 +04:00
|
|
|
exit(EXIT_FAILURE);
|
1993-08-06 11:30:52 +04:00
|
|
|
}
|