/* *libproc * *common utilities needed to process /proc. * *A library interface for finding process information from /proc. *This is also an interface into various things which haven't yet been integrated into sysfs, * as appropriate. * *This is a test of the libproc utils. Copyright (C) 2004 Joseph Pingenot This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "libproc-utils.h" #define file "libproc-utils-test.testfile" int main (void) { int err; void* ptr; char* string; ptr = readfile_init(file, &err); if(ptr == NULL){ printf("ptr was NULL; err is %x\n", err); }else{ printf("ptr was not NULL; err is %x.\n", err); } string = readfile_getline(ptr, "foo", &err); if(string == NULL) { printf("Strange. \"foo\" was not found. Are you sure input file %s is right?\n", file); }else{ printf("readfile_getline returned \"%s\". Is this \"bar\"?\n", string); } string = readfile_getline(ptr, "bar", &err); if(string == NULL) { printf("Strange. \"bar\" was not found. Are you sure input file %s is right?\n", file); }else{ printf("readfile_getline returned \"%s\". Is this \"foo\"?\n", string); } string = readfile_getline(ptr, "nim", &err); if(string == NULL) { printf("Strange. \"nim\" was not found. Are you sure input file %s is right?\n", file); }else{ printf("readfile_getline returned \"%s\". Is this \"by\"?\n", string); } /*And discard.*/ readfile_end(ptr); return 0; }