#include <unistd.h> int QlgReadlink(Qlg_Path_Name_T *path, Qlg_Path_Name_T *buf, size_t bufsiz);Service Program Name: QP0LLIB1
The QlgReadlink() function, like the readlink() function, places the contents of the symbolic link path in the buffer buf. The difference is that the QlgReadlink() function uses pointers to Qlg_Path_Name_T structures, while readlink() uses pointers to character strings.
Limited information on the path parameter, the buf parameter, and the size parameter is provided here. For more information on these parameters and for a discussion on authorities required, return values, and related information, see readlink()--Read Value of Symbolic Link.
See Code disclaimer information for information pertaining to code examples.
The following example uses QlgReadlink():
#include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <Qp0lstdi.h> main() { int file_descriptor; #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 name_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_fn,sizeof(mypath_fn)-1); memset((void*)path name_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 ((file_descriptor = QlgCreat((Qlg_Path_Name_T *)path name_fn, S_IWUSR)) < 0) perror("QlgCreat() error"); else { close(file_descriptor); if (QlgSymlink((Qlg_Path_Name_T *)path name_fn, (Qlg_Path_Name_T *)path name_sl) != 0) perror("QlgSymlink() error"); else { if (QlgReadlink((Qlg_Path_Name_T *)path name_sl, (Qlg_Path_Name_T *)path name_buf, sizeof(path_buf)) < 0) perror("QlgReadlink() error"); else printf("QlgReadlink() returned '%s' for '%s'\n", path name_buf.pn, path name_sl.pn); QlgUnlink((Qlg_Path_Name_T *)path name_sl); } QlgUnlink((Qlg_Path_Name_T *)path name_fn); } }
Output:
QlgReadlink() returned 'readlink.file' for 'readlink.symlink'
Top | UNIX-Type APIs | APIs by category |