Contents of argv[0]

Peter da Silva peter at ficc.uu.net
Thu Aug 17 03:47:17 AEST 1989


You don't want basename(). You want something like:

	parse_file(name, buffer)
	char *name;
	struct filename *buffer;

		Parses the elements of name into the buffer. name will
		be modified as necessary to null-terminate the elements
		of buffer. Returns the actual number of elements found
		in the name... missing or meaningless elements will contain
		null pointers.

	int build_file(buffer, filename);
	char *buffer;
	struct filename *filename;

		Converts the filename into a character string acceptable
		to the host operating system. Missing elements will be
		defaulted or ignored. Meaningless elements will be
		ignored. Returns the length of the resulting name.

With:

struct filename {
	char *machine;
	char *volume;
	char *project;
	char *user;
	char *path[MAXPATH];
	char *filename;
	char *extension;
	char *version;
};

On UNIX this would extract path and filename. On MS-DOS this would extract
the volume, path, filename, and extension. On RSX this would extract the
volume, project, user, filename, and extension. And so on...

There should also be an additional function:

	struct filename *file_defaults();

Which just returns a filename containing the default values for the current
host, current directory, and so on, with nulls in meaningless elements.

Any elements I'm missing?
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Business: peter at ficc.uu.net, +1 713 274 5180. | "The sentence I am now
Personal: peter at sugar.hackercorp.com.   `-_-' |  writing is the sentence
Quote: Have you hugged your wolf today?  'U`  |  you are now reading"



More information about the Comp.lang.c mailing list