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

260 lines
8.5 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>QlgGetPathFromFileID()--Get Path Name of Object from Its File ID (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: -->
<!-- file cleaned -->
<!-- Created by Yvonne Griffin for V5R1-->
<!-- 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>QlgGetPathFromFileID()--Get Path Name of Object from Its File ID (using
NLS-enabled path name)</h2>
<div class="box" style="width: 70%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;Qp0lstdi.h&gt;
Qlg_Path_Name_T *QlgGetPathFromFileID(Qlg_Path_Name_T <em>*buf</em>,
size_t <em>size</em>,Qp0lFID_t <em>fileid</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QP0LLIB2<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>QlgGetPathFromFileID()</strong> function, like the <strong>
Qp0lGetPathFromFileID()</strong> function, determines an absolute path name of
the file identified by <em>fileid</em> and stores it in <em>buf</em>. The
difference is that the <strong>QlgGetPathFromFileID()</strong> function points
to a Qlg_Path_Name_T structure, while <strong>Qp0lGetPathFromFileID()</strong>
points to a null-terminated character string.</p>
<p>Limited information on the <em>buf</em> parameter is provided here. For more
information on the <em>buf</em> parameter and for a discussion of other
parameters, authorities required, return values, and related information, see
<a href="getpthff.htm">Qp0lGetPathFromFileID()</a>--Get Path Name of Object
from Its File ID.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>buf</em></strong></dt>
<dd>(Output) A pointer to a Qlg_Path_Name_T structure that will be used to hold
an absolute path name or a pointer to an absolute path name of the file
identified by <em>fileid</em>. The path name is not null-terminated within the
structure. 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>size</em></strong></dt>
<dd>(Input) The number of bytes in the buffer <samp>buf</samp>.<br>
<br>
</dd>
<dt><strong><em>fileid</em></strong></dt>
<dd>(Input) The identifier of the file whose path name is to be returned. This
identifier is logged in audit journal entries to identify the file being
audited. See the <samp>Parent File ID</samp> and <samp>Object File ID</samp>
fields of the audit journal entries described in the <a href=
"../books/sc415302.pdf">iSeries Security Reference</a> <img src="wbpdf.gif"
alt="Link to PDF"> book.</dd>
</dl>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="getpthff.htm">Qp0lGetPathFromFileID()</a>--Get Path Name of Object
from Its File ID</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 determines the path name of a file, given its file ID.
In this example, the <em>fileid</em> is hardcoded. More realistically, the <em>
fileid</em> is obtained from the audit journal entry and passed to <strong>
QlgGetPathFromFileID()</strong>.</p>
<pre>
#include &lt;Qp0lstdi.h&gt;
#include &lt;stdio.h&gt;
#include &lt;qtqiconv.h&gt;
void Path_Print(Qlg_Path_Name_T *);
main()
{
Qp0lFID_t
fileid = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xCF, 0x00};
const char US_const[3]= "US";
const char Language_const[4]="ENU";
typedef struct pnstruct
{
Qlg_Path_Name_T qlg_struct;
char pn[1024]; /* This size must be large enough */
/* to contain the path name. */
};
struct pnstruct path;
/*******************************************************/
/* Initialize Qlg_Path_Name_T parameters */
/*******************************************************/
memset((void*)&amp;path, 0x00, sizeof(struct pnstruct));
memcpy(path.qlg_struct.Country_ID,US_const,2);
memcpy(path.qlg_struct.Language_ID,Language_const,3);
if (QlgGetPathFromFileID((Qlg_Path_Name_T *)&amp;path,
sizeof(struct pnstruct), fileid) == NULL)
perror("QlgGetPathFromFileID() error");
else
{
printf("Path retrieved successfully.\n");
Path_Print((Qlg_Path_Name_T *)&amp;path);
}
}
void Path_Print(Qlg_Path_Name_T *path_to_print_pointer)
{
/**************************************************************/
/* Print a path name that is in the Qlg_Path_Name_T format. */
/**************************************************************/
#define PATH_TYPE_POINTER 0x00000001 /* If flag is on, */
/* input structure contains a pointer */
/* to the path name, else the path */
/* name is in contiguous storage */
/* within the qlg structure. */
typedef union pn_input_type /* Format of input path name. */
{
char pn_char_type[256]; /* in contiguous storage */
char *pn_ptr_type; /* a pointer */
};
typedef struct pnstruct
{
Qlg_Path_Name_T qlg_struct;
union pn_input_type pn;
};
struct pnstruct *pns;
char *path_ptr;
size_t insz;
size_t outsz = 1000;
char outbuf[1000];
char *outbuf_ptr;
iconv_t cd;
size_t ret_iconv;
/* Indicates to convert from ccsid 13488 to 37. */
QtqCode_T toCode = {37,0,0,0,0,0};
QtqCode_T fromCode = {13488,0,0,1,0,0};
if (path_to_print_pointer != NULL)
{
/***********************************************************/
/* Point to and get the size of the path name. */
/***********************************************************/
pns = (struct pnstruct *)path_to_print_pointer;
if (path_to_print_pointer-&gt;Path_Type &amp; PATH_TYPE_POINTER)
path_ptr = pns-&gt;pn.pn_ptr_type;
else path_ptr = (char *)(pns-&gt;pn.pn_char_type);
insz = pns-&gt;qlg_struct.Path_Length; /* Get path length.*/
/***********************************************************/
/* Initialize the print buffer. */
/***********************************************************/
outbuf_ptr = (char *)outbuf;
memset(outbuf_ptr, 0x00, insz);
/***********************************************************/
/* Use iconv to convert the CCSID. */
/***********************************************************/
cd = QtqIconvOpen(&amp;toCode,
&amp;fromCode); /* Open a descriptor*/
if (cd.return_value == -1)
{ perror("Open conversion descriptor error");
return;
}
if (0 != ((iconv(cd,
(char **)&amp;(path_ptr),
&amp;insz,
(char **)&amp;(outbuf_ptr),
&amp;outsz))))
{
ret_iconv= iconv_close(cd);/* Close conversion descriptor*/
perror("Conversion error");
return;
}
/***********************************************************/
/* Print the name and close the conversion descriptior. */
/***********************************************************/
printf("The file's path is: %s\n",outbuf);
ret_iconv = iconv_close(cd);
} /* path_to_print_pointer != NULL */
} /* Path_Print */
</pre>
<p><strong>Output:</strong></p>
<pre>
Path retrieved successfully.
The file's path is: /myfile
</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>