164 lines
4.9 KiB
HTML
164 lines
4.9 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>Qp0lOpen()--Open File</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. -->
|
|
<!-- file cleaned -->
|
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- Change History: -->
|
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
|
<!-- 0206?? JET This file has undergone html cleanup -->
|
|
<!-- 050421 JTROUS Changes from API Review 1, V5R4 -->
|
|
<!--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>Qp0lOpen()--Open File</h2>
|
|
|
|
<div class="box" style="width: 80%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <Qp0lstdi.h>
|
|
|
|
int Qp0lOpen(Qlg_Path_Name_T <em>*Path_Name</em>,
|
|
int <em>oflag</em>, . . .);
|
|
</pre>
|
|
|
|
Service Program Name: QP0LLIB1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Theadsafe: Conditional; see Usage Notes for <a href="open.htm">open()</a>
|
|
API.<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>Qp0lOpen()</strong> function, similar to the <strong>
|
|
open()</strong> function, opens a file and returns a number called a <strong>
|
|
file descriptor</strong>. <strong>Qp0lOpen()</strong> differs from <strong>
|
|
open()</strong> in that the <em>Path_Name</em> parameter is a pointer to a
|
|
Qlg_Path_Name_T structure instead of a pointer to a character string.</p>
|
|
|
|
<p>Only the <em>Path_Name</em> parameter is described here. For a discussion of
|
|
the other parameters, authorities required, return values, and related
|
|
information, see <a href="open.htm">open()--Open File</a>.</p>
|
|
|
|
<p><strong>Note:</strong>: To use this API with large file APIs, you must
|
|
specify the O_LARGEFILE flag on the <em>oflag</em> parameter.</p>
|
|
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong><em>Path_Name</em></strong></dt>
|
|
|
|
<dd>(Input) The path name of the file to be opened. This path name is in the
|
|
Qlg_Path_Name_T format. For more information on this structure, see <a href=
|
|
"../apiref/pns.htm">Path Name Format</a>.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>fcntl.h</strong>> file (see <a href="unix13.htm">Header
|
|
Files for UNIX-Type Functions</a>)<br>
|
|
</li>
|
|
|
|
<li><a href="open.htm">open()</a>--Open File<br>
|
|
</li>
|
|
|
|
<li><a href="close.htm">close()</a>--Close File or Socket Descriptor</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 creates and opens an output file for exclusive access.
|
|
This program was stored in a source file with CCSID 37, so the constant string
|
|
"newfile" will be compiled in coded character set identifier (CCSID) 37.
|
|
Therefore, the country or region and language specified are United States
|
|
English, and the CCSID specified is 37.</p>
|
|
|
|
<pre>
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <Qp0lstdi.h>
|
|
|
|
main()
|
|
{
|
|
int fildes;
|
|
|
|
const char US_const[3]= "US";
|
|
const char Language_const[4]="ENU";
|
|
const char Path_Name_Del_const[2] = "/";
|
|
|
|
struct pnstruct
|
|
{
|
|
Qlg_Path_Name_T qlg_struct;
|
|
char pn[7];
|
|
};
|
|
struct pnstruct pns;
|
|
struct pnstruct *pns_ptr = NULL;
|
|
|
|
char fn[]="newfile";
|
|
|
|
memset((void*)&pns, 0x00, sizeof(struct pnstruct));
|
|
pns.qlg_struct.CCSID = 37;
|
|
memcpy(pns.qlg_struct.Country_ID,US_const,2);
|
|
memcpy(pns.qlg_struct.Language_ID,Language_const,3);;
|
|
pns.qlg_struct.Path_Type = 0;
|
|
pns.qlg_struct.Path_Length = sizeof(fn) - 1;
|
|
memcpy(pns.qlg_struct.Path_Name_Delimiter,
|
|
Path_Name_Del_const,1);
|
|
memcpy(pns.pn,fn,sizeof(fn));
|
|
|
|
pns_ptr = &pns;
|
|
if(fildes = Qp0lOpen((Qlg_Path_Name_T *)pns_ptr,
|
|
O_WRONLY|O_CREAT|O_EXCL, S_IRWXU)) == -1)
|
|
{
|
|
perror("Qp0lOpen() error");
|
|
}
|
|
|
|
}
|
|
</pre>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V4R4
|
|
|
|
<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>
|
|
|