PHP Code:
	
	
/*
 *
 * copy file 1 to file2 and invert lower with upper ( and viceversa )
 *
 *
 */
#include <ctype.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <st***.h>
#define READBYTES 100
int main ( int numero_arg, char ** nome_arg ) {
    
    int fd,fd2,n,status,i;
    void * buf;
    char * punt;
    
    /////////////////////////// allocazione buffer temporano di swap tra read e write
    buf = malloc (READBYTES);
    if ( buf == NULL){
        
        fprintf(stderr,"Impossibile completare l'operazione\n");
        exit(-6);
    }
    
    
    if ( (fd = open (*(nome_arg + 1),O_RDONLY)) >= 0 ){
        
        fd2 = open (*(nome_arg + 2),O_WRONLY | O_TRUNC); // apertura file
        
        if (fd2 < 0) { // se non presente
            
            fprintf(stdout,"File destinazione non presente. Creazione in corso ..\n"); // crealo
            fd2 = open (*(nome_arg + 2),O_CREAT | O_WRONLY, S_IRWXU);
            
        }
        
        for (n=read (fd, buf, READBYTES);n>0;n=read (fd, buf, READBYTES)) {
        
            punt = (char *) buf;
            ////////////////////////////////////////////// verifica se minuscolo o maiuscolo
            for (i=0;i<n;i++){
                if (islower(*(punt + i))){
                    *(punt + i) = toupper (*(punt + i));
                } else {
                    *(punt + i) = tolower (*(punt + i));
                }
            }
            
            status = write ( fd2, buf, n); /////////////// scrittura valori nel nuovo file
            if ( status < n){
                
                fprintf(stderr, "Errore di scrittura\n");
                exit(-5);
            }
        }
        
        fprintf(stdout,"Conversione completata\n");
        
        
    } else {
        
        fprintf(stdout,"File di origine non esistente\n");
        exit(-2);
        
    }
    
    return 0;
} 

