From: utzoo!decvax!minow
Newsgroups: net.unix-wizards
Title: Re: Naming Conventions for System Libraries
Article-I.D.: decvax.293
Posted: Wed Sep 22 18:19:44 1982
Received: Thu Sep 23 04:34:33 1982
References: sri-unix.3409

Vax-11 C and Decus C both allow '$' freely in identifiers.  This is
needed to access VMS system library functions.  Decus C maps '_' to
(radix-50) '.' in external symbols.  This letter is, however, reserved
for operating-system globals (such as those in the RSX-11M file service
library), so '_' has been eliminated from the library wherever possible.

For example, _doprnt() has been named $$dopn.

While I'm on the subject, there are a few useful library routines in
Decus C which I would recommend for inclusion on Unix:

fgetname(iop, char_buffer)	Writes the name used to fopen() the
				FILE *iop argument.  This is implemented
				on Vax-11C, along with getname(chan, buffer).

fwild(file_name, open_mode)	Sets up the file system to open a wild-card
				file.  Returns a FILE *.  The next file is
				opened by calling fnext(iop).

isalloc(mem_ptr)		TRUE if mem_ptr was allocated by malloc().
msize(mem_ptr)			The number of bytes allocated (undefined
				if isalloc(mem_ptr) is FALSE).

Fwild/fnext would typically be used as follows:

	int	nfiles;
	FILE	*fd;

	if ((fd = fwild("foo.*", "r")) == NULL) {
		perror("foo.*");
		exit(1);		/* Couldn't parse/setup file	*/
	}
	for (nfiles = 0; fnext(fd) != NULL; nfiles++) {
		fgetname(fd, file_name);	/* Currently open file	*/
		/* Normal processing of fd using getc, fgets, etc.	*/
	}
	if (nfiles == 0)
		printf("No files matching foo.*\n");

Fwild/fnext is fairly simple to implement on VMS, RSTS, and RSX, fairly
painful on RT11.  I have no idea whether it is even possible on Unix
(but you could always fork a shell, feed it the file name, pass that
through echo, and build a table of the matches).

Martin Minow
decvax!minow