Constructs an ASCII path from the specified elements.
#include <fsio.h>
int deconstruct (
const char *path,
char *server,
char *volume,
char *directory,
char *name,
char *extension,
int *elements,
int *flags);
(IN) Points to a path to parse into one or more elements.
(OUT) Points to the null-terminated name of the server. You can set it to NULL.
(OUT) Points to the null-terminated name of the volume. You can set it to NULL.
(OUT) Points to the null-terminated name of the directory. This string can contain more than one element and always ends in a backwards slash (\) if there is at least one element. You can set it to NULL.
(OUT) Points to the null-terminated name of the file with its extension, if any.
(OUT) Points to the null-terminated file extension. You can set it to NULL.
(OUT) Points to the number of elements in the parsed path.
(OUT) Points to the format and type of the path. The following flags are ORed together.
If successful, returns 0; otherwise returns -1 and sets errno to one of the following:
The deconstruct function accepts a null-terminated string in code page 437 (8-bit ASCII) and parses this string out into one or more of the arguments listed, all of which are optional (NULL may be passed) except for the name parameter. The caller needs an idea of the resulting length each output argument requires and needs to allocate accordingly.
#include <string.h>
#include <unistd.h>
#define FORMAT "path = %s\nserver = %s\nvolume = %s\n" \
"directory = %s\nfilename = %s\nextension = %s\n" \
"elements = %d\nflags = 0x%X\n"
void foo( const char *pathname )
/* assume "Taliesin/Sys:\System\LibC.NLM" */
{
char server[48+1], volume[256+1], directory[512+1],
filename[256+1], extension[256+1], path[1024+1];
(void) deconstruct(pathname, server, volume, directory, filename,
extension, &elements, &flags);
printf(FORMAT, pathname, server, volume, directory, filename,
extension, elements, flags);
memset(path, 0, strlen(path));
flags = PATH_UNC | PATH_UNIX;
(void) construct(path, server, volume, directory, filename, NULL,
flags);
printf(FORMAT, path, server, volume, directory, filename,
extension, elements, flags);
}
After the call to deconstruct the printed output would be...
path = Taliesin/Sys:\System\LibC.NLM
server = Taliesin
volume = Sys
directory = System\
filename = LibC.NLM
extension = NLM
elements = 4
flags = 0xE4
...and after the call to construct the printed output would be:
path = //Taliesin/Sys/System/LibC.NLM
server = Taliesin
volume = Sys
directory = System\
filename = LibC.NLM
extension = NLM
elements = 4
flags = 0x03