rendered paste body#include <unistd.h>#include <sys/types.h>#include <sys/wait.h>#include <sys/stat.h>#include <fcntl.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <pthread.h>void * any (void * pl){}void * artista (void * pl){}int main(int argc, char *argv[]){ /* Declaracion de variables */ int tipo, fd, fecha, fecha2; char nom[]="nom", any[]="any", error[]="error", and[]="i", or[]="o"; pthread_t tid, tid2, tid3; /* Creamos el archivo de salida */ fd = open("cerca.out", O_RDONLY|O_CREAT|O_APPEND, 0700); close(fd); /* Miramos que tipo de sentencia nos han introducido */ if(strcmp(argv[1], nom)==0) { if(strcmp(argv[3], and)==0) tipo = 3; else if(strcmp(argv[3], or)==0) tipo = 4; else tipo = 1; } else if(strcmp(argv[1], any)==0) { tipo = 2; } else { tipo = 5; } /* Ejecutamos los procesos segun el tipo */ switch(tipo) { case 1: pthread_create(&tid, NULL, artista, (void *)&argv[2]); pthread_join(tid, NULL); printf("Tipo 1\n"); break; case 2: fecha = atoi(argv[2]); fecha2 = atoi(argv[5]); pthread_create(&tid, NULL, any, (void *)&fecha); pthread_create(&tid2, NULL, any, (void *)&fecha2); pthread_join(tid, NULL); pthread_join(tid2, NULL); printf("Tipo 2\n"); break; case 3: fecha = atoi(argv[5]); pthread_create(&tid, NULL, artista, (void *)&argv[2]); pthread_create(&tid2, NULL, any, (void *)&fecha); pthread_join(tid, NULL); pthread_join(tid2, NULL); printf("Tipo 3\n"); break; case 4: fecha = atoi(argv[5]); pthread_create(&tid, NULL, artista, (void *)&argv[2]); pthread_create(&tid2, NULL, any, (void *)&fecha); pthread_create(&tid3, NULL, artista, (void *)&argv[8]); pthread_join(tid, NULL); pthread_join(tid2, NULL); pthread_join(tid3, NULL); printf("Tipo 4\n"); break; case 5: printf("Error\n"); break; } return 0;}