1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<META http-equiv="Content-Style-Type" content="text/css">
7<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
8<title>CNTInitHandle</title>
9</head>
10
11<body>
12
13<h1>CNTInitHandle</h1>
14
15<h2>Syntax</h2>
16<dl><dd><pre><code>
17#include &lt;revolution/cnt.h&gt;
18
19s32 CNTInitHandle(u32 contentIdx, CNTHandle* CntHandle, MEMAllocator* allocator);
20</code></pre></dd></dl>
21
22<h2>Arguments</h2>
23<p>
24<TABLE border="1" >
25  <tr>
26<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>contentIdx</EM></STRONG></CODE></TD>
27<TD width="520">The number of the content file you want to open. Must be in the range of 2 to 511.</TD>
28  </tr>
29<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>CntHandle</EM></STRONG></CODE></TD>
30<TD width="520">Pointer to the <CODE>CNTHandle</CODE> structure to be initialized.</TD>
31  </tr>
32  <tr>
33<TD valign="top" width="120" bgcolor="#ffffe8"><CODE><STRONG><EM>allocator</EM></STRONG></CODE></TD>
34<TD width="520">Pointer to the memory allocator for storing FST. <b>The allocator must be 32-byte aligned.</b>The memory is released when <a href="CNTReleaseHandle.html"><CODE>CNTReleaseHandle</CODE></a> is called.</TD>
35  </tr>
36</TABLE>
37</p>
38
39<h2>Return Values</h2>
40<p>
41For a NAND application, returns one of the following codes:
42<p>
43<code>
44CNT_RESULT_OK<br>
45CNT_RESULT_ACCESS<br>
46CNT_RESULT_ALLOC_FAILED<br>
47CNT_RESULT_AUTHENTICATION<br>
48CNT_RESULT_CORRUPT<br>
49CNT_RESULT_ECC_CRIT<br>
50CNT_RESULT_INVALID<br>
51CNT_RESULT_MAXFD<br>
52CNT_RESULT_OUT_OF_MEMORY<br>
53CNT_RESULT_UNKNOWN<br>
54CNT_RESULT_FATAL<br>
55</code>
56</p>
57</p>
58<p>
59For disc applications, returns <code>CNT_RESULT_INVALID</code> if the <CODE>/content{index}</CODE> directory does not exist under <CODE>DvdRoot</CODE>.
60</p>
61
62<H2>Description</H2>
63<p>
64Opens the content file and initializes the <CODE>CNTHandle</CODE> structure. Because the application (<CODE>.elf</CODE> file) uses Content File No. 1, the content file numbers start from 2.<br>Once the memory allocator is passed, <CODE>CNTHandle</CODE> stores it internally, so the user does not need to pass it to the API again. Be careful not to release the allocator while the program is running. When using multithreads, do not share the <CODE>CNTHandle</CODE> structure among threads. Although you can write a program to guarantee that while one thread is accessing a file no other thread can access that file, we recommend using a new <CODE>CNTHandle</CODE> structure for each a new thread.
65</p>
66<p>
67One file descriptor is consumed each time the <CODE>CNTHandle</CODE> structure is initialized. This file descriptor is the same file system item as that used in the NAND API. As a result, the number of available <CODE>CNTHandle</CODE> structures will decrease when files are open in the NAND API.
68</p>
69<p>
70You can use the <a href="CNTGetFSTSize.html">CNTGetFSTSize</a> function to get the size of the heap region you will need for opening the content file.
71</p>
72<p>
73<STRONG>Note:</STRONG> This function may put the current thread to sleep. Refer to <a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a>.
74</p>
75
76<h2>See Also</h2>
77<p>
78<code><a href="./CNTGetFSTSize.html">CNTGetFSTSize</a></code>, <code><a href="./CNTReleaseHandle.html">CNTReleaseHandle</a></code>, <code><a href="../os/Interrupt/intro.html">Interrupts and Callback Functions</a></code>
79</p>
80<H2>Revision History</H2>
81<p>
822008/02/15 Added text about the heap region needed for opening the content file.<br>2007/11/20 Standardized the use of the term &quot;content file&quot;.<BR>2007/10/11 Corrected typos.<br>2007/09/12 Added information about the sleep status of threads.<br>2007/04/27 Added a description about the 32-byte alignment of memory allocators.<br>2006/12/12 Added result code descriptions for disc applications.<br>2006/12/04 Added a list of result codes.<br>2006/10/26 Added description of file descriptors.<br>2006/08/15 Initial version.
83</p>
84
85<hr><p>CONFIDENTIAL</p></body>
86</html>
87