Bump for 3.6-28
[LibreOffice.git] / sal / workben / t_readline.c
blobe44380d23d5edce60312f9d65551e9d41e4fde71
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * t_readline.c
4 */
6 #include "osl/file.h"
8 #include "osl/diagnose.h"
9 #include "rtl/ustring.h"
10 #include "rtl/byteseq.h"
12 #include <stdio.h>
14 /* main */
15 int main (int argc, char ** argv)
17 if (argc > 1)
19 oslFileError result;
20 oslFileHandle hFile = 0;
22 rtl_uString * pSystemPath = 0;
23 rtl_uString * pFileUrl = 0;
25 rtl_uString_newFromAscii (&pSystemPath, argv[1]);
27 result = osl_getFileURLFromSystemPath (pSystemPath, &pFileUrl);
28 rtl_uString_release (pSystemPath), pSystemPath = 0;
29 if (result != osl_File_E_None)
30 return (result);
32 result = osl_openFile (pFileUrl, &hFile, osl_File_OpenFlag_Read);
33 rtl_uString_release (pFileUrl), pFileUrl = 0;
34 if (result == osl_File_E_None)
36 sal_Sequence * pBuffer = 0;
37 for ( ;; )
39 sal_Int32 i, n;
41 result = osl_readLine (hFile, &pBuffer);
42 if (result != osl_File_E_None)
43 break;
44 for (i = 0, n = pBuffer->nElements; i < n; i++)
45 printf ("%c", (char)(pBuffer->elements[i]));
46 printf("\n");
49 rtl_byte_sequence_release (pBuffer), pBuffer = 0;
50 (void) osl_closeFile (hFile);
53 return 0;
56 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */