| 1 | #ifndef NUI_DISTRIBUTION
|
|---|
| 2 | # include "Headers.h"
|
|---|
| 3 | # if defined(_WIN32) || defined(__CYGWIN__)
|
|---|
| 4 | # include "MSW.h"
|
|---|
| 5 | # else
|
|---|
| 6 | # include "OSX.h"
|
|---|
| 7 | # endif
|
|---|
| 8 | #endif
|
|---|
| 9 |
|
|---|
| 10 | #define NUI_NO_UNDEFINE_MACROS
|
|---|
| 11 | #include "NetworkUpdater.h"
|
|---|
| 12 |
|
|---|
| 13 | typedef struct NUI_DownloadContext_ {
|
|---|
| 14 | int pending;
|
|---|
| 15 | int complete;
|
|---|
| 16 | TCHAR* file_path;
|
|---|
| 17 | TCHAR* url;
|
|---|
| 18 | FILE* fp;
|
|---|
| 19 | unsigned int downloaded;
|
|---|
| 20 | unsigned int total;
|
|---|
| 21 |
|
|---|
| 22 | #ifdef NUI_WINDOWS
|
|---|
| 23 | HINTERNET internet_handle;
|
|---|
| 24 | HANDLE request_complete_event;
|
|---|
| 25 | int url_handle_requested;
|
|---|
| 26 | int wait_request_complete;
|
|---|
| 27 | char* buffer;
|
|---|
| 28 | unsigned int buffer_bytes;
|
|---|
| 29 | HINTERNET url_handle;
|
|---|
| 30 | INTERNET_BUFFERS* ib; /* pointer for gcc -Wpadded */
|
|---|
| 31 | #else
|
|---|
| 32 | #endif
|
|---|
| 33 | } NUI_DownloadContext;
|
|---|
| 34 |
|
|---|
| 35 | typedef struct NUI_SharedData_ {
|
|---|
| 36 | NU_NetworkUpdater user;
|
|---|
| 37 |
|
|---|
| 38 | #ifdef NUI_WINDOWS
|
|---|
| 39 | CRITICAL_SECTION cs;
|
|---|
| 40 | #else
|
|---|
| 41 | #endif
|
|---|
| 42 | } NUI_SharedData;
|
|---|
| 43 |
|
|---|
| 44 | typedef struct NUI_CommonData_ {
|
|---|
| 45 | NUI_SharedData* shared;
|
|---|
| 46 |
|
|---|
| 47 | #ifdef NUI_WINDOWS
|
|---|
| 48 | HANDLE start_search_event;
|
|---|
| 49 | HANDLE start_update_event;
|
|---|
| 50 | HANDLE exit_thread_event;
|
|---|
| 51 | #else
|
|---|
| 52 | #endif
|
|---|
| 53 | } NUI_CommonData;
|
|---|
| 54 |
|
|---|
| 55 | typedef struct NUI_ThreadData_ {
|
|---|
| 56 | NUI_CommonData common;
|
|---|
| 57 | unsigned int new_revision;
|
|---|
| 58 | unsigned int current_revision;
|
|---|
| 59 | unsigned int download_debug;
|
|---|
| 60 | TCHAR* releases_file_url;
|
|---|
| 61 | NUI_DownloadContext* update_information;
|
|---|
| 62 | NUI_DownloadContext* update_file;
|
|---|
| 63 | TCHAR* description;
|
|---|
| 64 | TCHAR* temp_dir_path;
|
|---|
| 65 | TCHAR* updater_file_path;
|
|---|
| 66 | TCHAR* updater_config_file_path;
|
|---|
| 67 | TCHAR* extracter_file_path;
|
|---|
| 68 | TCHAR* archive_file_path;
|
|---|
| 69 | TCHAR* extracted_dir_path;
|
|---|
| 70 | TCHAR* releases_file_path;
|
|---|
| 71 | TCHAR* archive_file_url;
|
|---|
| 72 | int found;
|
|---|
| 73 | int ready;
|
|---|
| 74 | int pending;
|
|---|
| 75 | #ifdef NUI_WINDOWS
|
|---|
| 76 | HANDLE extracter_process;
|
|---|
| 77 | #else
|
|---|
| 78 | #endif
|
|---|
| 79 | } NUI_ThreadData;
|
|---|
| 80 |
|
|---|
| 81 | typedef struct NUI_NetworkUpdater_ {
|
|---|
| 82 | NUI_CommonData common;
|
|---|
| 83 | NU_NetworkUpdater* user;
|
|---|
| 84 | #ifdef NUI_WINDOWS
|
|---|
| 85 | HANDLE thread;
|
|---|
| 86 | #else
|
|---|
| 87 | #endif
|
|---|
| 88 | } NUI_NetworkUpdater;
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | char* NUI_strdup(const char* s);
|
|---|
| 92 | int NUI_IsBadReadPointer(const void* pointer, size_t bytes);
|
|---|
| 93 | int NUI_IsBadWritePointer(void* pointer, size_t bytes);
|
|---|
| 94 | int NUI_IsBadReadWritePointer(void* pointer, size_t bytes);
|
|---|
| 95 | TCHAR* NUI_PathAppendDup(const TCHAR* base, const TCHAR* append);
|
|---|
| 96 | void NUI_DeleteDirectory(const TCHAR* dir);
|
|---|
| 97 | void NUI_Lock(NUI_SharedData* object);
|
|---|
| 98 | void NUI_Unlock(NUI_SharedData* object);
|
|---|
| 99 | NU_Error NUI_Extract(NUI_ThreadData* object);
|
|---|
| 100 | NU_Error NUI_CreateTemporaryDirectory(TCHAR** result_dir);
|
|---|
| 101 | NU_Error NUI_Download(NUI_DownloadContext* object);
|
|---|
| 102 | NU_Error NUI_CreateDownloadContext(NUI_DownloadContext** context_output, const TCHAR* url, const TCHAR* file_path);
|
|---|
| 103 | NU_Error NUI_DestroyDownloadContext(NUI_DownloadContext* object);
|
|---|
| 104 | NU_Error NUI_Create(NUI_NetworkUpdater* object, const NU_Option* option);
|
|---|
| 105 | NU_Error NUI_Destroy(NUI_NetworkUpdater* object);
|
|---|
| 106 | NU_Error NUI_ReadReleasesFile(NUI_ThreadData* object);
|
|---|
| 107 | NU_Error NUI_StartSearch(NUI_NetworkUpdater* object);
|
|---|
| 108 | NU_Error NUI_StartUpdate(NUI_NetworkUpdater* object);
|
|---|
| 109 | NU_Error NUI_Cancel(NUI_NetworkUpdater* object);
|
|---|
| 110 | NU_Error NUI_NetworkUpdaterToInternal(NUI_NetworkUpdater** internal_context_output, NU_NetworkUpdater* object);
|
|---|
| 111 | NU_Error NUI_Update(NUI_ThreadData* object);
|
|---|
| 112 | NU_Error NUI_Search(NUI_ThreadData* object);
|
|---|
| 113 | NU_Error NUI_GetStatus(NUI_NetworkUpdater* object);
|
|---|
| 114 |
|
|---|
| 115 | #if defined(__GNUC__) && defined(__STRICT_ANSI__)
|
|---|
| 116 | # define strdup(x) NUI_strdup(x)
|
|---|
| 117 | # define wcsdup(x) NUI_wcsdup(x)
|
|---|
| 118 | # if defined(_WIN32) || defined(__CYGWIN__)
|
|---|
| 119 | # define _strdup(x) NUI_strdup(x)
|
|---|
| 120 | # define _wcsdup(x) NUI_wcsdup(x)
|
|---|
| 121 | # endif
|
|---|
| 122 | #elif defined(_WIN32)
|
|---|
| 123 | # define strdup(x) _strdup(x)
|
|---|
| 124 | # define wcsdup(x) _wcsdup(x)
|
|---|
| 125 | #endif
|
|---|
| 126 |
|
|---|