deconstruct

Constructs an ASCII path from the specified elements.

Library:LibC
Classification:Novell
Service:File and Directory I/O

Syntax

  #include <fsio.h> 
   
  int deconstruct (
     const char   *path,
     char         *server,
     char         *volume,
     char         *directory,
     char         *name,
     char         *extension,
     int          *elements,
     int          *flags);
  

Parameters

path

(IN) Points to a path to parse into one or more elements.

server

(OUT) Points to the null-terminated name of the server. You can set it to NULL.

volume

(OUT) Points to the null-terminated name of the volume. You can set it to NULL.

directory

(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.

name

(OUT) Points to the null-terminated name of the file with its extension, if any.

extension

(OUT) Points to the null-terminated file extension. You can set it to NULL.

elements

(OUT) Points to the number of elements in the parsed path.

flags

(OUT) Points to the format and type of the path. The following flags are ORed together.

Flag

Value

Description

PATH_UNIX

0x00000002

Indicates only forward slashes used as delimiters.

PATH_NETWARE

0x00000004

Indicates a slash and colon followed by slashes.

PATH_MACINTOSH

0x00000008

Indicates only colons used as delimiters.

PATH_ROOTED

0x00000010

Starts with a delimiter.

PATH_VOLROOTED

0x00000020

Indicates the path contains a volume plus a colon.

PATH_EXTENSION

0x00000040

Indicates the path contains a period.

PATH_HIERARCHY

0x00000080

Indicates at least one subdirectory element.

PATH_SHORTNAME

0x00000100

Indicates only 8.3 names in path.

PATH_LONGNAME

0x00000200

Indicates at least one element is greater than 8.3.

PATH_ENDED

0x00000400

Indicates path ends in a delimiter.

PATH_DOSDRIVE

0x00001000

Indicates a single-letter drive, colon, and path.

PATH_MIXEDCASE

0x00002000

Indicates at least one element is in mixed case.

PATH_DOTS

0x00004000

Indicates the path contains dots.

PATH_SLASH

0x00008000

Indicates the path contains a slash.

PATH_BACKSLASH

0x00010000

Indicates the path contains a backslash.

PATH_COLON

0x00020000

Indicates the path contains a colon.

PATH_ILLEGAL

0x80000000

Indicates the path contains an illegal character or combination.

PATH_MIXED

(PATH_SHORT | PATH_LONG)

Indicates the path contains both short names (8.3) and long names (a name longer than 8.3).

Return Values

If successful, returns 0; otherwise returns -1 and sets errno to one of the following:

Decimal

Constant

Description

1

ENOENT

The path parameter did not end in a name after the last directory.

9

EINVAL

The path parameter is NULL.

Remarks

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.

See Also

construct

Example

  #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