int main(int argc, char *argv[]) { struct ppm_t ppm; struct fb_t *fb; if(argc < 3) { printf("Usage: %s <fb dev> <ppm image>\n", argv[0]); return 1; } //TODO: Uncomment //if((fb = fb_open(argv[1])) == NULL) // return 2; //fb_display(fb); if(ppm_open(argv[2], &ppm)) return 3; ppm_display(&ppm); render(NULL, &ppm, 0, 0); //TODO: Uncomment //fb_close(fb); ppm_close(&ppm); }
/********************thread function*****************/ void* new_client(void *a){ //variables para la conexion y lectura de datos int connect_d = (int)a; int status = 1; char c = 0; //datos para la creacion de archivos char name[NAME_TAM]; char* type = ".ppm"; //ppm para ser manipulado ppm_t ppm_data; printf("New client, total: %d\n", client_counter+1); client_counter++; //crear el archivo temporal sprintf(name, "%d", connect_d); strcat(name, type); printf("Archivo por crear: %s\n", name); FILE* file = fopen(name, "w"); if (!file) { error("No se creo el archivo original"); } //ejecucion normal say(connect_d,"Welcome, ppm compress server\r\n"); if(say(connect_d,"Envía el archivo\r\n")!=-1){ status = read(connect_d, &c, 1); while(status){ //printf("Char from client = %c\n", c); fprintf(file, "%c", c); status = read(connect_d, &c, 1); } } fclose(file); //reduccion de tamaño, uso de la librearia ppm.h if (ppm_open(name, &ppm_data) != OK) { error("Hubo un error"); } ppm_save_c(name, &ppm_data); ppm_dispose(&ppm_data); file = fopen(name, "r"); if (!file) { error("No se puede abrir el archivo comprimido"); } while(c != EOF){ c = fgetc(file); if(isprint(c) || isspace(c) || ispunct(c)){ write(connect_d, &c, 1); //printf("%c", c); } } fclose(file); */ remove(name); client_counter--; return NULL; }