Component index
Section index

Component loadfile


	    loadfile is a simple component to handle text file.
	static void sample_loadfile()
	    // This is a minimal case to print a file. THis is short and does
	    // all the error reporting and testing.
	    <call loadfile>("/proc/net/route",false);
	    <f oneline>
	        fputs (line,stdout);
	    // Here is an example with more control
	    <call loadfile>("/proc/net/route",true);
	    <f missing>
	        tlmp_error ("No file /proc/net/route\n");
	    <f empty>
	        printf ("The file is empty\n");
	    <f start>
	        // Ok, we know the file is not empty, we format a nice table
	        printf ("This is the routing table\n");
	    <f end>
	        printf ("-------------\n");
	    <f oneline>
	        // Often a component pass "commodity" information
	        // Here it passes the line number. We use this to skip the first line.
	        // and we return -1 to print only the first 3 lines
	        if (noline > 0) printf ("%s\n",line);
	        return noline > 3 ? -1 : 0;