ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/symlinku.htm

200 lines
6.4 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!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>QlgSymlink()--Make Symbolic Link (using NLS-enabled path name)</title>
<!-- 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. -->
<!-- Begin Header Records --><!-- file cleaned -->
<!-- Created by Yvonne Griffin for V5R1-->
<!-- This file has undergone html cleanup June 2002 by JET -->
<!-- End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<a name="Top_Of_Page"></a>
<!--Java sync-link-->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<h2>QlgSymlink()--Make Symbolic Link (using NLS-enabled path name)</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;unistd.h&gt;
int QlgSymlink(
Qlg_Path_Name_T <em>*pname</em>, Qlg_Path_Name_T <em>*slink</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QP0LLIB1<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Conditional; see Usage Notes for <a href=
"symlink.htm">symlink()</a>.<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>QlgSymlink()</strong> function, like the <strong>
symlink()</strong> function, creates the symbolic link named by <em>slink</em>
with the value specified by <em>pname</em>. The difference is that the <strong>
QlgSymlink()</strong> function takes a pointer to a Qlg_Path_Name_T structure,
while <strong>symlink()</strong> takes a pointer to a character string.</p>
<p>Limited information on the <em>*pname</em> and the <em>*slink</em> parameter
is provided here. For more information on these parameters and for a discussion
of authorities required, return values, and related information, see <a href=
"symlink.htm">symlink()</a>--Make Symbolic Link.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>pname</em></strong></dt>
<dd>(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 <a href="../apiref/pns.htm">Path name format</a>.<br>
</dd>
<dt><strong><em>slink</em></strong></dt>
<dd>(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 <a href="../apiref/pns.htm">Path name format</a>.</dd>
</dl>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="symlink.htm">symlink()</a>--Make Symbolic Link</li>
<li><a href="linku.htm">QlgLink()</a>--Create Link to File (using NLS-enabled
path name)</li>
<li><a href="readlinku.htm">QlgReadlink()</a>--Read Value of Symbolic Link
(using NLS-enabled path name)</li>
<li><a href="qp0lunlk.htm">Qp0lUnlink()</a>--Remove Link to File</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>QlgSymlink()</strong>:</p>
<pre>
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;Qp0lstdi.h&gt;
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 &gt;= */
/* 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*)&amp;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*)&amp;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 *)&amp;path_fn, S_IWUSR))
&lt; 0)
perror("QlgCreat() error");
else {
close(fd);
if (QlgSymlink((Qlg_Path_Name_T *)&amp;path_fn,
(Qlg_Path_Name_T *)&amp;path_sl) != 0)
perror("QlgSymlink() error");
else {
if (QlgReadlink((Qlg_Path_Name_T *)&amp;path_sl,
(Qlg_Path_Name_T *)&amp;path_buf,
sizeof(struct pnstruct))
&lt; 0)
perror("QlgReadlink() error");
else printf("QlgReadlink() returned '%s' for '%s'\n",
(Qlg_Path_Name_T *)&amp;path_buf.pn,
(Qlg_Path_Name_T *)&amp;path_sl.pn);
QlgUnlink((Qlg_Path_Name_T *)&amp;path_sl);
}
QlgUnlink((Qlg_Path_Name_T *)&amp;path_fn);
}
}
</pre>
<p><strong>Output:</strong></p>
<pre>
QlgReadlink() returned 'readlink.file' for 'readlink.symlink'
</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>