tests/test-vfs-read-line.c (1719B) - raw
1 /* 2 * Mail Notification 3 * Copyright (C) 2003-2008 Jean-Yves Lefort <jylefort@brutele.be> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #include "mn-vfs.h" 21 22 int 23 main (int argc, char **argv) 24 { 25 GnomeVFSResult result; 26 GnomeVFSHandle *handle; 27 MNVFSReadLineContext *context = NULL; 28 const char *line; 29 30 g_log_set_fatal_mask(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL); 31 32 if (argc != 2) 33 g_critical("wrong number of arguments"); 34 35 if (! gnome_vfs_init()) 36 g_critical("unable to initialize GnomeVFS"); 37 38 result = gnome_vfs_open(&handle, argv[1], GNOME_VFS_OPEN_READ); 39 if (result != GNOME_VFS_OK) 40 g_critical("unable to open %s: %s", argv[1], gnome_vfs_result_to_string(result)); 41 42 while ((result = mn_vfs_read_line(&context, handle, &line)) == GNOME_VFS_OK) 43 g_print("line: %s\n", line); 44 45 if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) 46 g_critical("error while reading %s: %s", argv[1], gnome_vfs_result_to_string(result)); 47 48 mn_vfs_read_line_context_free(context); 49 gnome_vfs_close(handle); 50 51 return 0; 52 }