diff --git a/site/source/docs/api_reference/emscripten.h.rst b/site/source/docs/api_reference/emscripten.h.rst index 9c3208c46..15ca9934e 100644 --- a/site/source/docs/api_reference/emscripten.h.rst +++ b/site/source/docs/api_reference/emscripten.h.rst @@ -1077,10 +1077,10 @@ Typedefs Emterpreter-Async functions =========================== -Emterpreter-async functions are asynchronous functions that appear synchronously in C, the linker flags `-s EMTERPRETIFY -s EMTERPRETIFY_ASYNC=1` are required to use these functions. See `Emterpreter `_ for more details. +Emterpreter-async functions are asynchronous functions that appear synchronously in C, the linker flags ``-s EMTERPRETIFY -s EMTERPRETIFY_ASYNC=1`` are required to use these functions. See `Emterpreter `_ for more details. -Functions ---------- +Sleeping +-------- .. c:function:: void emscripten_sleep(unsigned int ms) @@ -1094,6 +1094,60 @@ Functions this sleep. Note that this method **does** still block the main loop, as otherwise it could recurse, if you are calling this method from it. Even so, you should use this method carefully: the order of execution is potentially very confusing this way. +Network +------- + +.. c:function:: void emscripten_wget_data(const char* url, void** pbuffer, int* pnum, int *perror); + + Synchronously fetches data off the network, and stores it to a buffer in memory, which is allocated for you. **You must free the buffer, or it will leak!** + + :param url: The URL to fetch from + :param pbuffer: An out parameter that will be filled with a pointer to a buffer containing the data that is downloaded. This space has been malloced for you, **and you must free it, or it will leak!** + :param pnum: An out parameter that will be filled with the size of the downloaded data. + :param perror: An out parameter that will be filled with a non-zero value if an error occurred. + +IndexedDB +--------- + +.. c:function:: void emscripten_idb_load(const char *db_name, const char *file_id, void** pbuffer, int* pnum, int *perror); + + Synchronously fetches data from IndexedDB, and stores it to a buffer in memory, which is allocated for you. **You must free the buffer, or it will leak!** + + :param db_name: The name of the database to load from + :param file_id: The name of the file to load + :param pbuffer: An out parameter that will be filled with a pointer to a buffer containing the data that is downloaded. This space has been malloced for you, **and you must free it, or it will leak!** + :param pnum: An out parameter that will be filled with the size of the downloaded data. + :param perror: An out parameter that will be filled with a non-zero value if an error occurred. + +.. c:function:: void emscripten_idb_store(const char *db_name, const char *file_id, void* ptr, int num, int *perror); + + Synchronously stores data to IndexedDB. + + :param db_name: The name of the database to store to + :param file_id: The name of the file to store + :param buffer: A pointer to the data to store + :param num: How many bytes to store + :param perror: An out parameter that will be filled with a non-zero value if an error occurred. + +.. c:function:: void emscripten_idb_delete(const char *db_name, const char *file_id, int *perror); + + Synchronously deletes data from IndexedDB. + + :param db_name: The name of the database to delete from + :param file_id: The name of the file to delete + :param perror: An out parameter that will be filled with a non-zero value if an error occurred. + +.. c:function:: void emscripten_idb_exists(const char *db_name, const char *file_id, int* pexists, int *perror); + + Synchronously checks if a file exists in IndexedDB. + + :param db_name: The name of the database to check in + :param file_id: The name of the file to check + :param perror: An out parameter that will be filled with a non-zero value if the file exists in that database. + :param perror: An out parameter that will be filled with a non-zero value if an error occurred. + +.. c:function:: void emscripten_idb_load(const char *db_name, const char *file_id, void** pbuffer, int* pnum, int *perror); + Asyncify functions ================== diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index 8836996bb..c1dd3e52a 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -174,7 +174,7 @@ void emscripten_wget(const char* url, const char* file); // wget data "sync" (EMTERPRETIFY_ASYNC) -void emscripten_wget_data(const char* url, void** pbuffer, int* num, int *error); +void emscripten_wget_data(const char* url, void** pbuffer, int* pnum, int *perror); // IDB @@ -186,10 +186,10 @@ void emscripten_idb_async_exists(const char *db_name, const char *file_id, void* // IDB "sync" (EMTERPRETIFY_ASYNC) -void emscripten_idb_load(const char *db_name, const char *file_id, void** pbuffer, int* num, int *error); -void emscripten_idb_store(const char *db_name, const char *file_id, void* ptr, int num, int *error); -void emscripten_idb_delete(const char *db_name, const char *file_id, int *error); -void emscripten_idb_exists(const char *db_name, const char *file_id, int* exists, int *error); +void emscripten_idb_load(const char *db_name, const char *file_id, void** pbuffer, int* pnum, int *perror); +void emscripten_idb_store(const char *db_name, const char *file_id, void* buffer, int num, int *perror); +void emscripten_idb_delete(const char *db_name, const char *file_id, int *perror); +void emscripten_idb_exists(const char *db_name, const char *file_id, int* pexists, int *perror); // other async utilities