|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-063020E5-51C0-45C3-8B8B-015385FA0928" xml:lang="en"><title>Redirect |
|
13 Printf Example</title><shortdesc>Redirect standard I/O to a file</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>This example illustrates how to redirect standard I/O to a file. The <codeph>libc</codeph> library |
|
15 provides <xref href="GUID-6A17B64B-44DC-33F0-B18A-25004500C831.dita"><apiname>freopen()</apiname></xref> API to redirect all standard IOs (namely |
|
16 - stderr, stdin or stdout). Application first prints launching information |
|
17 at the console and then opens one file to redirect standard output using <xref href="GUID-6A17B64B-44DC-33F0-B18A-25004500C831.dita"><apiname>freopen()</apiname></xref>. |
|
18 Calling <xref href="GUID-6A17B64B-44DC-33F0-B18A-25004500C831.dita"><apiname>freopen()</apiname></xref> once more, the user can change the filename |
|
19 during execution. This helps to redirect application <xref href="GUID-919E1C29-029A-38E2-B844-141A6E02ADA2.dita"><apiname>printf()</apiname></xref> messages |
|
20 into a log file. </p> |
|
21 <section id="GUID-026FD8D6-6C4A-5958-B289-775D4AE1E756-GENID-1-10-1-12-1-1-5-1-3-1-11-1-16-1-3-2"><title>Download</title> <p>Click |
|
22 on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-b83a4952-b5e5-4ef5-a1c9-ee48705964a1.zip" scope="external">redirectprintf.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-b83a4952-b5e5-4ef5-a1c9-ee48705964a1.html" scope="peer">browse</xref> to view the example code. </p> </section> |
|
23 <section id="GUID-7E7C4564-B10E-41F9-8A9D-D8A6C5E9C51C-GENID-1-10-1-12-1-1-5-1-3-1-11-1-16-1-3-3"><title>Design and |
|
24 Implementation</title> <p>The following sections provide information about |
|
25 the implementation of the example. </p> <p><b>Capabilities</b> </p>The program |
|
26 capabilities are defined in <filepath>redirectprintf.mmp</filepath> : <codeph>CAPABILITY |
|
27 NONE</codeph>. </section> |
|
28 <section id="GUID-67A72761-1D92-46D1-B1C9-7455978BDE4E-GENID-1-10-1-12-1-1-5-1-3-1-11-1-16-1-3-4"><title>Building and |
|
29 Using</title> To build the example application, go to the redirectprintf\group |
|
30 directory and build the application. The definition for the whole application |
|
31 can be found in the bld.inf file in the group subdirectory of the applications |
|
32 main directory.<p>The application is simple console based application. It |
|
33 has its own default icon and can be launched from the UI both |
|
34 in the emulator and in the device. The application can be launched by: Executing |
|
35 redirectprintf from eshell. Clicking default icon with display text redirectprintf |
|
36 within the install folder launcher application. </p> </section> |
|
37 </conbody></concept> |