Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ hdrchk(1) — Sun WorkShop 4.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

HDRCHK(1)

NAME

hdrchk − checks a header file for conformance to headerfile standards(PSARC/1991/041). 

SYNOPSIS

hdrchk [filenames]

OUTPUT

The script outputs violations of headerfile standards. It quits after the first violation is found. 

OVERVIEW

hdrchk is a perl script which checks a header file for conformance to PSARC/1991/041.  Actually, it checks for a bit more uniformity with respect to uniform formatting than is specified by 1991/041, but these ‘nits’ are not excessive and do increase the uniformity and perceived quality of our headers.  1991/041 has also been referred to as KNF format. 

The hdrchk script makes sure that the header file has all the following necessary components:

• Format of comments. A comment, when present, when on a single line, should be  enclosed by /∗ and ∗/ and when multiline, should have each line beginning with an asterisk. 

• SCCS keyword. Verifies keywords are used; accepts either expanded or unexpanded keywords. 

• C++ definitions. Verifies that guards in the form of ifdef __cplusplus are present so a C++ file could include the header file without explicitly using "extern C{ ...". Nothing should follow the end guard, unless an exception. 

• End guards. Verifies that the file has end guards in the form of ifndef variables to prevent multiple inclusions of the header file. 

TEMPLATE

The template of the standard header file is as follows:

/∗
 ∗ Copyright (c) 1994 by Sun Microsystems, Inc.
 ∗/
 
/∗
 ∗ Template for header files.
 ∗
 ∗ This assumes the file is named <sys/foo.h>.  Don’t forget
 ∗ to change the _SYS_FOO_H symbol in all three places
 ∗ in this template to reflect the real name of your header
 ∗ file. Also note that this name should reflect the
 ∗ installed path to the file, not its location in
 ∗ the source.
 ∗/
 
#ifndef _SYS_FOO_H
#define _SYS_FOO_H
 
#pragma ident   "%Z%%M% %I%     %E% SMI"
 
/∗
 ∗ Include any headers you depend on.
 ∗/
#include <sys/bar.h>
 
#ifdef  __cplusplus
extern "C" {
#endif
 
/∗
 ∗ Main body of <sys/foo.h> header file goes here.
 ∗/
 
#ifdef  __cplusplus
}
#endif
 
#endif  /∗ _SYS_FOO_H ∗/
 

USAGE

A typical invocation of the script would be as follows:

example% hdrchk path/of/headerfile.h

hdrchk reads input from pipe when the input is redirected. The usage in that situation would be:

example% cat headerfile.h | hdrchk

SunOS 4.2  —  Last change: 26 August 1994

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026