Skip to content

Instantly share code, notes, and snippets.

@matason
Created May 15, 2015 05:53
Show Gist options
  • Save matason/7c13c0f17a697a6cc97a to your computer and use it in GitHub Desktop.
Save matason/7c13c0f17a697a6cc97a to your computer and use it in GitHub Desktop.
Isolated httpfs test
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main (int argc, char *argv[]) {
FILE *f;
FILE *ret;
int c;
f = fopen(argv[1], "rbm");
if (!f) {
printf("%s\n", "fopen failed");
exit(1);
}
printf("%s\n", "fopen success");
int fd = fileno(f);
ret = fdopen(fd, "rb");
if (!ret) {
printf("%s\n", "fdopen failed");
exit(1);
}
printf("%s\n", "fdopen success");
// At this point I a single U+FFFD character.
while (!feof (ret)) {
int c = fgetc (ret);
putchar(c);
}
fclose(f);
fclose(ret);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment