update dev300-m58
[ooovba.git] / sal / workben / t_readline.c
blob9cbc7d39cf2071c41949b1eb127d73394af7fd54
1 /*
2 * t_readline.c
3 */
5 #include "osl/file.h"
7 #include "osl/diagnose.h"
8 #include "rtl/ustring.h"
9 #include "rtl/byteseq.h"
11 #include <stdio.h>
13 /* main */
14 int main (int argc, char ** argv)
16 if (argc > 1)
18 oslFileError result;
19 oslFileHandle hFile = 0;
21 rtl_uString * pSystemPath = 0;
22 rtl_uString * pFileUrl = 0;
24 rtl_uString_newFromAscii (&pSystemPath, argv[1]);
26 result = osl_getFileURLFromSystemPath (pSystemPath, &pFileUrl);
27 rtl_uString_release (pSystemPath), pSystemPath = 0;
28 if (result != osl_File_E_None)
29 return (result);
31 result = osl_openFile (pFileUrl, &hFile, osl_File_OpenFlag_Read);
32 rtl_uString_release (pFileUrl), pFileUrl = 0;
33 if (result == osl_File_E_None)
35 sal_Sequence * pBuffer = 0;
36 for ( ;; )
38 sal_Int32 i, n;
40 result = osl_readLine (hFile, &pBuffer);
41 if (result != osl_File_E_None)
42 break;
43 #if 0
44 if (pBuffer->elements[0] == 0)
45 /* @@@ cannot distinguish empty line from EOF @@@ */
46 break;
47 #endif
48 for (i = 0, n = pBuffer->nElements; i < n; i++)
49 printf ("%c", (char)(pBuffer->elements[i]));
50 printf("\n");
53 rtl_byte_sequence_release (pBuffer), pBuffer = 0;
54 (void) osl_closeFile (hFile);
57 return 0;