QlgSymlink()--Make Symbolic Link (using NLS-enabled path name)


  Syntax
 #include <unistd.h>

 int QlgSymlink(
      Qlg_Path_Name_T *pname, Qlg_Path_Name_T *slink);  
  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes for symlink().

The QlgSymlink() function, like the symlink() function, creates the symbolic link named by slink with the value specified by pname. The difference is that the QlgSymlink() function takes a pointer to a Qlg_Path_Name_T structure, while symlink() takes a pointer to a character string.

Limited information on the *pname and the *slink parameter is provided here. For more information on these parameters and for a discussion of authorities required, return values, and related information, see symlink()--Make Symbolic Link.


Parameters

pname
(Input) A pointer to a Qlg_Path_Name_T structure that contains a value or a pointer to a value of the symbolic link. For more information on the Qlg_Path_Name_T structure, see Path name format.
slink
(Input) A pointer to a Qlg_Path_Name_T structure that contains a name or a pointer to a name of the symbolic link to be created. For more information on the Qlg_Path_Name_T structure, see Path name format.

Related Information


Example

See Code disclaimer information for information pertaining to code examples.

The following example uses QlgSymlink():

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <Qp0lstdi.h>

main() {
  char buf[30];
  int  fd;
 #define mypath_fn "readlink.file"
 #define mypath_sl "readlink.symlink"

  const char US_const[3]= "US";
  const char Language_const[4]="ENU";
  typedef struct pnstruct
  {
    Qlg_Path_Name_T qlg_struct;
    char pn[100]; /* This array size must be >=   */
                            /* the length of the path name or  */
                            /* this must be a pointer to the   */
                            /* path name.                      */
  };

  struct pnstruct path_fn;
  struct pnstruct path_sl;
  struct pnstruct path_buf;

   /***************************************************************/
   /*   Initialize Qlg_Path_Name_T parameters                     */
   /***************************************************************/
  memset((void*)&path_fn, 0x00, sizeof(struct pnstruct));
  path_fn.qlg_struct.CCSID = 37;
  memcpy(path_fn.qlg_struct.Country_ID,US_const,2);
  memcpy(path_fn.qlg_struct.Language_ID,Language_const,3);
  path_fn.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
  path_fn.qlg_struct.Path_Length = sizeof(mypath_fn)-1;
  path_fn.qlg_struct.Path_Name_Delimiter[0] = '/';
  memcpy(path_fn.pn,mypath_sl,sizeof(mypath_fn)-1);

  memset((void*)&path_sl, 0x00, sizeof(struct pnstruct));
  path_sl.qlg_struct.CCSID = 37;
  memcpy(path_sl.qlg_struct.Country_ID,US_const,2);
  memcpy(path_sl.qlg_struct.Language_ID,Language_const,3);
  path_sl.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
  path_sl.qlg_struct.Path_Length = sizeof(mypath_sl)-1;
  path_sl.qlg_struct.Path_Name_Delimiter[0] = '/';
  memcpy(path_sl.pn,mypath_sl,sizeof(mypath_sl)-1);

  if ((fd = QlgCreat((Qlg_Path_Name_T *)&path_fn, S_IWUSR))
            < 0)
    perror("QlgCreat() error");
  else {
    close(fd);
    if (QlgSymlink((Qlg_Path_Name_T *)&path_fn,
                    (Qlg_Path_Name_T *)&path_sl) != 0)
      perror("QlgSymlink() error");

    else {
      if (QlgReadlink((Qlg_Path_Name_T *)&path_sl,
                      (Qlg_Path_Name_T *)&path_buf,
                      sizeof(struct pnstruct))
          < 0)
        perror("QlgReadlink() error");

      else printf("QlgReadlink() returned '%s' for '%s'\n",
                  (Qlg_Path_Name_T *)&path_buf.pn,
                  (Qlg_Path_Name_T *)&path_sl.pn);

      QlgUnlink((Qlg_Path_Name_T *)&path_sl);
    }
    QlgUnlink((Qlg_Path_Name_T *)&path_fn);
  }
}

Output:

QlgReadlink() returned 'readlink.file' for 'readlink.symlink'

API introduced: V5R1
Top | UNIX-Type APIs | APIs by category