CVS: Concurrent Versions System 189 Listing 5.3 Prompt
190 Chapter 5 Basic Web Application Strategies You can manually specify the -b option if you cvs add a file, but that soon becomes a kludge to remember and use consistently. It would be easier if CVS could enforce the binary type on some file extensions. Luckily, this is easy using the administrative file cvswrappers.This file allows you to set up actions that will transform files on each commit or checkout. It s similar to the loginfo file in that it will be invoked on a commit, but, unlike directives in the loginfo file, it can execute actions that will alter the file in question.To treat images and archive files as binary,the cvswrappers file could look like this: *.gif -kb *.jp[e]g -kb *.png -kb *.gz -kb *.ta -kb *.zip -kb This will automatically append the -kb to all CVS commands involving files matched by the specified filter.The -k option prevents CVS from trying to use keyword expansion; the -b switch indicates a binary file and disables the ability to produce text diffs for this file. Sometimes you need to interface external command-line tools with the Web. Many UNIX programs expect input on standard input and output the results of the computation to standard output for example, sort.The easiest way to pass input and read output of the program is by using popen() and PHP streams. popen() opens a unidirectional pipe to a program and allows you to pass data to its standard input.And as you already know,you can use fopen() to read the standard input,to which the external program will write.A simple example could look like this: // Open a writing pipe to the sort command $fpout = popen( sort , w ); // Open stdin with PHP-Streams $fpin = fopen( php://stdin , r ); // Output some characters to sort fputs($fpout, an ); fputs($fpout, cn ); fputs($fpout, bn ); // Close the pipe to sort - sort will now process the input // and write it to stdout pclose($fpout); // Sort s stdout is stdin for us - so read it until feof(). while($c = fread($fpin, 1)) { print($c); }
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP MySQL Web Hosting services