Created
October 22, 2014 09:34
-
-
Save nikuuchi/a7f86ada284a63867650 to your computer and use it in GitHub Desktop.
emscripten.hを使ってみた時のメモ
This file contains hidden or 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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <emscripten.h> | |
| void onLoadCallback(const char *filename) { | |
| FILE *fp; | |
| char s[256]; | |
| if((fp = fopen(filename, "r")) == NULL) { | |
| printf("file open error!!\n"); | |
| exit(1); | |
| } | |
| while (fgets(s, 256, fp) != NULL) { | |
| printf("%s", s); | |
| } | |
| fclose(fp); | |
| } | |
| void onErrorCallback(const char *err) { | |
| printf("%s", err); | |
| } | |
| int main() { | |
| emscripten_async_wget("http://www.google.com", "file.txt", onLoadCallback, onErrorCallback); | |
| return 0; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブラウザ上でscriptタグ使って読み込むと使えることを確認
ただし、wgetで読み込むURLはsame origin policyの影響を受ける
コンパイル時のオプション