--- a/convert/eyuvtojpeg.c +++ b/convert/eyuvtojpeg.c @@ -25,6 +25,7 @@ #include #include #include +#include #include typedef unsigned char uint8; @@ -47,8 +48,9 @@ int main(int argc, char **argv) { FILE *fpointer; - char command[256]; - char src[256], dest[256]; + char command[4096]; + char src[4096], dest[4096], tempfile[4096]; + int ret; if ((strcmp(argv[1],"-?") == 0) || (strcmp(argv[1],"-h") == 0) || @@ -99,14 +101,16 @@ YUVtoPPM(); fprintf(stdout, "Writing PPM\n"); - fpointer = fopen("/tmp/foobar", "w"); + sprintf(tempfile, "%s.tmp", dest); + fpointer = fopen(tempfile, "w"); WritePPM(fpointer); fclose(fpointer); fprintf(stdout, "Converting to JPEG %s\n", dest); - sprintf(command, "cjpeg /tmp/foobar > %s", dest); - system(command); - return 0; + sprintf(command, "cjpeg %s > %s", tempfile, dest); + ret = system(command); + unlink(tempfile); + return ret; } --- a/convert/vidtoeyuv.c +++ b/convert/vidtoeyuv.c @@ -125,9 +125,9 @@ XImage *ximage; char *tdata; char *obase; - char ofname[256]; + char ofname[4096], tempfile[4096]; int height, width; - char command[256]; + char command[4096]; int nth; if ((argc != 7) && (argc != 8))usage (argv[0]); @@ -223,9 +223,11 @@ sprintf(ofname, "%s%d.yuv", obase, i); - outFile = fopen("/tmp/foobar", "w"); + sprintf(tempfile, "%s%d.yuv.tmp", obase, i); + outFile = fopen(tempfile, "w"); if (!outFile) { perror("Couldn't open output file."); + exit(1); } for (r=0; r %s", - width, height, ofname); + sprintf(command, "rawtoppm %d %d < %s | ppmtoyuv > %s", + width, height, tempfile, ofname); system(command); + unlink(tempfile); for (j=0; j %s", - width, height, ofname); + sprintf(command, "rawtoppm %d %d < %s | cjpeg > %s", + width, height, tempfile, ofname); system(command); + unlink(tempfile); } } --- a/convert/vidtoppm.c +++ b/convert/vidtoppm.c @@ -220,9 +220,11 @@ sprintf(ofname, "%s%d.ppm", obase, i); - outFile = fopen("/tmp/foobar", "w"); + sprintf(tempfile, "%s%d.ppm.tmp", obase, i); + outFile = fopen(tempfile, "w"); if (!outFile) { perror("Couldn't open output file."); + exit(1); } for (r=0; r %s", - width, height, ofname); + sprintf(command, "rawtoppm %d %d < %s > %s", + width, height, tempfile, ofname); system(command); + unlink(tempfile); } } --- a/convert/eyuvtoppm.c +++ b/convert/eyuvtoppm.c @@ -100,13 +100,9 @@ fpointer = fopen(dest, "w"); if (fpointer == NULL) { fprintf(stderr, "Problems opening %s!\n", dest); - fprintf(stderr, "Trying /tmp/foobar instead\n"); - strcpy(dest, "/tmp/foobar"); - fpointer = fopen(dest, "w"); - if (fpointer == NULL) { - fprintf(stderr, "Nope, exiting.\n"); - exit(1); - }} + perror(""); + exit(1); + } WritePPM(fpointer); fclose(fpointer);