#include <unistd.h> int QlgLink(Qlg_Path_Name_T *existing, Qlg_Path_Name_T *new);Service Program Name: QP0LLIB1
The QlgLink() function, like the link() function, provides an alternative path name for the existing file so that the file can be accessed by either the existing name or the new name. The difference is that the QlgLink() function supports pointers to Qlg_Path_Name_T structures, while link() supports pointers to character strings.
Limited information on the existing and the new parameters is provided here. For more information on these parameters and for a discussion of the authorities required, return values, and related information, see link()--Create Link to File.
See Code disclaimer information for information pertaining to code examples.
The following example uses QlgLink():
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> #include <Qp0lstdi.h> main() { int file_descriptor; struct stat info; #define mypath_fn "link.example.file" #define mypath_ln "link.example.link" 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 must */ /* be a pointer to the path name. */ }; struct pnstruct path_fn; struct pnstruct path_ln; /***************************************************************/ /* 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_fn,sizeof(mypath_fn)-1); memset((void*)&path_ln, 0x00, sizeof(struct pnstruct)); path_ln.qlg_struct.CCSID = 37; memcpy(path_ln.qlg_struct.Country_ID,US_const,2); memcpy(path_ln.qlg_struct.Language_ID,Language_const,3); path_ln.qlg_struct.Path_Type = QLG_CHAR_SINGLE; path_ln.qlg_struct.Path_Length = sizeof(mypath_ln)-1; path_ln.qlg_struct.Path_Name_Delimiter[0] = '/'; memcpy(path_ln.pn,mypath_ln,sizeof(mypath_ln)-1); if ((file_descriptor = QlgCreat((Qlg_Path_Name_T *)&path_fn, S_IWUSR)) < 0) perror("QlgCreat() error"); else { close(file_descriptor); puts("before QlgLink()"); QlgStat((Qlg_Path_Name_T *)&path_fn,&info); printf(" number of links is %hu\n",info.st_nlink); if (QlgLink((Qlg_Path_Name_T *)&path_fn, (Qlg_Path_Name_T *)&path_ln) != 0) { perror("QlgLink() error"); QlgUnlink((Qlg_Path_Name_T *)&path_fn); } else { puts("after QlgLink()"); QlgStat((Qlg_Path_Name_T *)&path_fn,&info); printf(" number of links is %hu\n",info.st_nlink); QlgUnlink((Qlg_Path_Name_T *)&path_ln); puts("after first QlgUnlink()"); QlgLstat((Qlg_Path_Name_T *)&path_fn,&info); printf(" number of links is %hu\n",info.st_nlink); QlgUnlink((Qlg_Path_Name_T *)&path_fn); } } }
Output:
before QlgLink() number of links is 1 after QlgLink() number of links is 2 after first QlgUnlink() number of links is 1
Top | UNIX-Type APIs | APIs by category |