Created
August 17, 2011 01:33
-
-
Save bwhitman/1150608 to your computer and use it in GitHub Desktop.
Lion printf insanity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DVLib.c gets very noisy when you do startWithSize here.. with "hack" printf that will get in the way of our cgi JPG binary output | |
// so we have to "mute" stdout temporarily via dup and freopen. first we save off stdout | |
int fd; | |
fpos_t pos; | |
fflush(stdout); | |
fgetpos(stdout, &pos); | |
fd = dup(fileno(stdout)); | |
// now we redirect stdout to /dev/null | |
freopen("/dev/null", "w", stdout); | |
// right here it gets noisy | |
[camera startWithSize:NSMakeSize(640, 480)]; | |
// and now we need to reset stdout back to normal | |
fflush(stdout); | |
dup2(fd, fileno(stdout)); | |
close(fd); | |
clearerr(stdout); | |
fsetpos(stdout, &pos); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment