206 lines
6.6 KiB
HTML
206 lines
6.6 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
|
<title>QlgLink()--Create Link to File (using NLS-enabled path name)</title>
|
|
<!-- Begin Header Records -->
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<!-- Change History: -->
|
|
<!-- YYMMDD USERID Change description -->
|
|
<!-- file cleaned -->
|
|
<!-- Created by Yvonne Griffin for V5R1-->
|
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
|
<!-- This file has undergone html cleanup June 2002 by JET -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<!-- End Header Records --><!--Java sync-link-->
|
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
|
</script>
|
|
|
|
<a name="Top_Of_Page"></a>
|
|
|
|
<h2>QlgLink()--Create Link to File (using NLS-enabled path name)</h2>
|
|
|
|
<div class="box" style="width: 80%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <unistd.h>
|
|
|
|
int QlgLink(Qlg_Path_Name_T <em>*existing</em>, Qlg_Path_Name_T <em>*new</em>);
|
|
</pre>
|
|
|
|
Service Program Name: QP0LLIB1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Conditional; see Usage Notes for <a
|
|
href="link.htm">link()</a>.<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>QlgLink()</strong> function, like the <strong>link()</strong>
|
|
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 <strong>QlgLink()</strong> function supports pointers to
|
|
Qlg_Path_Name_T structures, while <strong>link()</strong> supports pointers to
|
|
character strings.</p>
|
|
|
|
<p>Limited information on the <em>existing</em> and the <em>new</em> parameters
|
|
is provided here. For more information on these parameters and for a discussion
|
|
of the authorities required, return values, and related information, see <a
|
|
href="link.htm">link()</a>--Create Link to File.</p>
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong><em>existing</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name
|
|
or a pointer to a path name of an existing file to which a new link is to be
|
|
created. For more information on the Qlg_Path_Name_T structure, see <a href=
|
|
"../apiref/pns.htm">Path name format</a>.<br>
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong><em>new</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name
|
|
or a pointer to a path name that is the name of the new link. For more
|
|
information on the Qlg_Path_Name_T structure, see <a href="../apiref/pns.htm">Path name
|
|
format</a>.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li><a href="link.htm">link()</a>--Create Link to File<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="qp0lunlk.htm">Qp0lUnlink()</a>--Remove Link to File (using
|
|
NLS-enabled path name)</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<h3>Example</h3>
|
|
|
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
|
for information pertaining to code examples.</p>
|
|
|
|
<p>The following example uses <strong>QlgLink()</strong>:</p>
|
|
|
|
<pre>
|
|
#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);
|
|
}
|
|
}
|
|
}
|
|
</pre>
|
|
|
|
<p><strong>Output:</strong></p>
|
|
|
|
<pre>
|
|
before QlgLink()
|
|
number of links is 1
|
|
after QlgLink()
|
|
number of links is 2
|
|
after first QlgUnlink()
|
|
number of links is 1
|
|
</pre>
|
|
|
|
<hr>
|
|
API introduced: V5R1
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|