Component index
Section index

Component savefile


Search

	/*
	    savefile is a simple component to update files.
	*/
	<mod>
	static void sample_savefile()
	{
	    // We just overwrite the content
	    <call savefile>("/tmp/x.log",false);
	    <f dowrite>
	        // savefile does the sanity check and call us with a FILE handle
	        fprintf (fout,"This is the content\n");
	    </f>
	    </call>
	
	    // We add a few lines
	    <call savefile>("/tmp/x.log",true);
	    <f dowrite>
	        fprintf (fout,"This is more content\n");
	    </f>
	    <f openfail>
	        tlmp_error ("Can't append to /tmp/x.log\n");
	    </f>
	    <f end>
	        printf ("File /tmp/x.log was updated\n");
	    </f>
	    <f start>
	        // Ok, the file is open in append mode. dowrite will be called
	        printf ("Start the update\n");
	    </f>
	    </call>
	}
	</mod>