char *fnpars(const char *fn, int p, int v) 
Author Message
 char *fnpars(const char *fn, int p, int v)

A suggestion for filename-parsing.

When I doo my work on system after system, I find that it would be helpful to
hav a function that by the local rules split a filename-string into components.
Becauz this is so local, I would hav the standard require onlie the abuv
described declaration, and one operation, which applys on all (but one) of the
systems that I know enough of.

The required operation, with "p" and "v" 0, marks the beginning of the
filename part, after node, devise, directorie, ...:
        On DOS, Unix, VMS, this
                fnpars("f.c", 0, 0)
        yields a pointer to "f", but on the Guardian to "c".
Whatevver happens, the yielded pointer points to a character of the string,
or the NUL, or (on error) is NULL.

The structuredest file-spec that I know of belongs to VMS:
On VMS the required operation points to "f".  DOS has at least
and the required points to "f".  Unix is simpler:
--points to "f".  On the Guardian:
I skip CMS, becauz its scheme differs from anie other:
        filename filetype filemode
and "filemode" is a letter and a digit, wherof the letter works the same as
the aforesaid "disk"s.  My experiens with CMS and the rest suggests that we
consider CMS wrong.

The most useful operation, after the one required, probablie is marking the
"extension".  This is defind for all the abuv described naming schemes but the
Guardian, and poorlie for Unix.  For the Guardian, if at all implemented, the
pointer can point onlie to the NUL after the string.  As for Unix, "f.o" is
indeed well establishd, but not required by the filesystem.  Therefore, a
Unix-implementation needs to decide whether the first or the last dot marks
the extension.  SCCS-file names would suggest that the last.  The C-shell
agrees with that.

Then maibe it is useful to split the local part from the system-name.  On VMS
that is after "::" if that is in the string, and otherwize the hoal string.
On Unix this varies, and is there onlie in the right context.  For UUCP, it
is after the last "!", for "rcp"-form it is after the first colon, for DECNET
it is after "::" (borrowd from VMS).  Here "v" is useful, for there is no
knowing where the local part beginns unless a format is assumed, and one Unix
system can be linkd in all three wais.

There is further use for "v" in splitting a long directorie-portion into parts,
or deciding which ere the last dot marks the "extension" in Unix, if not the

Error is markd by returning nullpointer: the operation is not known, "fn" is
NULL, it points to an ill formatted string ... but in no case is existens of
anithing relevant to the parsing, which shall confine itself to the apparent

I would like it best, though, if for evveriething found in a VMS file-spec
there were an operation, and if not known to that system the pointer is left
in between, as it were.  That is, asking for the local part and the directorie
yields the same pointer when tryd on Unix, asking for verzion-number yields
pointer to NUL when tryd not on VMS (or TOPS-20), and so on.
Justice is incidental to law and order.  -- J. Edgar Hoover

Thu, 01 May 1997 07:31:08 GMT  
 [ 1 post ] 

 Relevant Pages 

1. char *strchr(const char *, int) ??!!!

2. int to char / char to int

3. char to int, int to char...

4. conversion int to char, char to int ?????

5. int std::system(const char*) function

6. int to const char *

7. C++ conversion (int to const char*) need help!!!!

8. Why not "const char *strerror(int);"??

9. how can you change a const int to char *

10. map<int,const char*> question

11. map<int,const char*> question

12. int gethostname(char FAR* name, int len)


Powered by phpBB® Forum Software