| 1 | #define AUI_NO_UNDEFINE_MACROS
|
|---|
| 2 | #include "AutoUpdater.h"
|
|---|
| 3 |
|
|---|
| 4 | #include <shlwapi.h>
|
|---|
| 5 | #include <stdarg.h>
|
|---|
| 6 | #include <stdio.h>
|
|---|
| 7 | #include <stdlib.h>
|
|---|
| 8 | #include <string.h>
|
|---|
| 9 | #include <time.h>
|
|---|
| 10 | #include <wchar.h>
|
|---|
| 11 | #include <wininet.h>
|
|---|
| 12 |
|
|---|
| 13 | #ifndef __CYGWIN__
|
|---|
| 14 | #include <tchar.h>
|
|---|
| 15 | #endif
|
|---|
| 16 |
|
|---|
| 17 | #ifdef _MSC_VER
|
|---|
| 18 | #pragma comment(lib, "shlwapi.lib")
|
|---|
| 19 | #pragma comment(lib, "wininet.lib")
|
|---|
| 20 | #if defined(_CRT_NONSTDC_DEPRECATE) && !defined(_CRT_NONSTDC_NO_WARNINGS) && !defined(_POSIX_)
|
|---|
| 21 | #define wcsdup _wcsdup
|
|---|
| 22 | #endif
|
|---|
| 23 | #endif
|
|---|
| 24 |
|
|---|
| 25 | #ifdef __CYGWIN__
|
|---|
| 26 |
|
|---|
| 27 | # define _T(x) TEXT(x)
|
|---|
| 28 | # define GUID_NULL AUI_GUID_NULL
|
|---|
| 29 | # define IID_IDispatch AUI_IID_IDispatch
|
|---|
| 30 | # define strdup AUI_strdup
|
|---|
| 31 | # define wcsdup AUI_wcsdup
|
|---|
| 32 |
|
|---|
| 33 | const GUID AUI_GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0 }};
|
|---|
| 34 | const GUID AUI_IID_IDispatch = {0x00020400, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}};
|
|---|
| 35 |
|
|---|
| 36 | # if defined(UNICODE) || defined(_UNICODE)
|
|---|
| 37 | # define _tcslen wcslen
|
|---|
| 38 | # define _tcscpy wcscpy
|
|---|
| 39 | # define _tcscat wcscat
|
|---|
| 40 | # define _tcsdup AUI_wcsdup
|
|---|
| 41 | # define _tfopen(x, y) (NULL)
|
|---|
| 42 | # else
|
|---|
| 43 | # define _tcslen strlen
|
|---|
| 44 | # define _tcscpy strcpy
|
|---|
| 45 | # define _tcscat strcat
|
|---|
| 46 | # define _tcsdup AUI_strdup
|
|---|
| 47 | # define _tfopen fopen
|
|---|
| 48 | # endif
|
|---|
| 49 |
|
|---|
| 50 | #endif
|
|---|
| 51 |
|
|---|
| 52 | #if ! __STDC_WANT_SECURE_LIB__
|
|---|
| 53 | #define _tfopen_s(x, y, z) {*x = _tfopen(y, z);}
|
|---|
| 54 | #define _tcscpy_s(x, y, z) _tcscpy(x, z)
|
|---|
| 55 | #define _tcscat_s(x, y, z) _tcscat(x, z)
|
|---|
| 56 | #define _stprintf_s AUI_stprintf_s
|
|---|
| 57 | #endif
|
|---|
| 58 |
|
|---|
| 59 | char* AUI_strdup(const char* s) {
|
|---|
| 60 | size_t bytes = 0;
|
|---|
| 61 | char* buf = NULL;
|
|---|
| 62 | bytes = (strlen(s) + 1);
|
|---|
| 63 | buf = (char*)calloc(bytes, 1);
|
|---|
| 64 | if (!buf) {
|
|---|
| 65 | return NULL;
|
|---|
| 66 | }
|
|---|
| 67 | memcpy(buf, s, bytes);
|
|---|
| 68 | return buf;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | wchar_t* AUI_wcsdup(const wchar_t* s) {
|
|---|
| 72 | size_t bytes = 0;
|
|---|
| 73 | wchar_t* buf = NULL;
|
|---|
| 74 | bytes = (wcslen(s) + 1) * sizeof(wchar_t);
|
|---|
| 75 | buf = (wchar_t*)calloc(bytes, 1);
|
|---|
| 76 | if (!buf) {
|
|---|
| 77 | return NULL;
|
|---|
| 78 | }
|
|---|
| 79 | memcpy(buf, s, bytes);
|
|---|
| 80 | return buf;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | void /* TODO: return value */ AUI_stprintf_s(
|
|---|
| 84 | TCHAR *buffer,
|
|---|
| 85 | size_t count,
|
|---|
| 86 | const TCHAR *format,
|
|---|
| 87 | ...) {
|
|---|
| 88 | va_list ap;
|
|---|
| 89 | va_start(ap,format);
|
|---|
| 90 |
|
|---|
| 91 | #if __STDC_WANT_SECURE_LIB__
|
|---|
| 92 | _vstprintf_s(buffer, count, format, ap);
|
|---|
| 93 | #else
|
|---|
| 94 | # ifdef WIN32
|
|---|
| 95 | if (count == 0) {
|
|---|
| 96 | goto clean_up;
|
|---|
| 97 | } else if (count == 1) {
|
|---|
| 98 | buffer[0] = 0;
|
|---|
| 99 | goto clean_up;
|
|---|
| 100 | }
|
|---|
| 101 | memset(buffer, 0, count * sizeof(TCHAR));
|
|---|
| 102 | count--;
|
|---|
| 103 | # endif
|
|---|
| 104 | # if defined(UNICODE) || defined(_UNICODE)
|
|---|
| 105 | vswprintf(buffer, count, format, ap);
|
|---|
| 106 | # elif __STDC_VERSION__ >= 199901L
|
|---|
| 107 | vsnprintf(buffer, count, format, ap);
|
|---|
| 108 | # else
|
|---|
| 109 | vsprintf(buffer, format, ap);
|
|---|
| 110 | # endif
|
|---|
| 111 | #endif
|
|---|
| 112 |
|
|---|
| 113 | clean_up:
|
|---|
| 114 | va_end(ap);
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | typedef struct AUI_DownloadContext_ {
|
|---|
| 118 | double progress;
|
|---|
| 119 | TCHAR* file_path;
|
|---|
| 120 | TCHAR* url;
|
|---|
| 121 | FILE* fp;
|
|---|
| 122 |
|
|---|
| 123 | HINTERNET internet_handle;
|
|---|
| 124 | HANDLE request_complete_event;
|
|---|
| 125 | int url_handle_requested;
|
|---|
| 126 | int wait_request_complete;
|
|---|
| 127 | char buffer[1000];
|
|---|
| 128 | INTERNET_BUFFERS ib;
|
|---|
| 129 |
|
|---|
| 130 | HINTERNET url_handle;
|
|---|
| 131 | } AUI_DownloadContext;
|
|---|
| 132 |
|
|---|
| 133 | const char context_created_sign = '\x5a';
|
|---|
| 134 |
|
|---|
| 135 | typedef struct AUI_Context_ {
|
|---|
| 136 | char created_sign;
|
|---|
| 137 | TCHAR* description;
|
|---|
| 138 | TCHAR* url;
|
|---|
| 139 | TCHAR* temp_dir;
|
|---|
| 140 |
|
|---|
| 141 | int new_version_number;
|
|---|
| 142 |
|
|---|
| 143 | AUI_DownloadContext* update_information;
|
|---|
| 144 | AUI_DownloadContext* update_file;
|
|---|
| 145 |
|
|---|
| 146 | HANDLE thread_handle;
|
|---|
| 147 | DWORD thread_id;
|
|---|
| 148 | } AUI_Context;
|
|---|
| 149 |
|
|---|
| 150 | const AU_Result AUI_SUCCESS = {1, 0, 0};
|
|---|
| 151 | const AU_Result AUI_IO_PENDING = {0, 1, 0};
|
|---|
| 152 |
|
|---|
| 153 | AU_Result E(AU_Error error) {
|
|---|
| 154 | AU_Result result = {0, 0, 0};
|
|---|
| 155 | result.error = error;
|
|---|
| 156 | return result;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | int AUI_IsBadReadPointer(const void* pointer, size_t bytes) {
|
|---|
| 160 | return IsBadReadPtr(pointer, bytes);
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | int AUI_IsBadWritePointer(void* pointer, size_t bytes) {
|
|---|
| 164 | return IsBadWritePtr(pointer, bytes);
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | AU_Result AUI_CreateTemporaryDirectory(TCHAR** result) {
|
|---|
| 168 | TCHAR dir[MAX_PATH] = {0};
|
|---|
| 169 | TCHAR* temp_path = NULL;
|
|---|
| 170 | size_t temp_path_chars = 0;
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 | AUI_stprintf_s(
|
|---|
| 174 | dir,
|
|---|
| 175 | sizeof(dir) / sizeof(dir[0]),
|
|---|
| 176 | _T("AutoUpdater.%x.%x\\"),
|
|---|
| 177 | GetCurrentThreadId(),
|
|---|
| 178 | GetTickCount()
|
|---|
| 179 | );
|
|---|
| 180 |
|
|---|
| 181 | temp_path_chars = GetTempPath(0, NULL);
|
|---|
| 182 | temp_path = (TCHAR*)calloc(temp_path_chars * sizeof(TCHAR) + sizeof(_T('\\')) + sizeof(dir), 1);
|
|---|
| 183 | if (!temp_path) {
|
|---|
| 184 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 185 | }
|
|---|
| 186 | GetTempPath(temp_path_chars, temp_path);
|
|---|
| 187 | PathAppend(temp_path, dir);
|
|---|
| 188 | if (!CreateDirectory(temp_path, NULL)) {
|
|---|
| 189 | return E(AU_ERROR_SYSTEM);
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | *result = temp_path;
|
|---|
| 193 | return AUI_SUCCESS;
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | AU_Result AUI_Download(AUI_DownloadContext* context) {
|
|---|
| 197 | /* http://www.codeproject.com/KB/IP/asyncwininet.aspx */
|
|---|
| 198 | if (!context->url_handle && !context->url_handle_requested) {
|
|---|
| 199 | DWORD e = 0;
|
|---|
| 200 | HINTERNET result;
|
|---|
| 201 | context->url_handle_requested = 1;
|
|---|
| 202 | result = InternetOpenUrl(
|
|---|
| 203 | context->internet_handle,
|
|---|
| 204 | context->url,
|
|---|
| 205 | NULL,
|
|---|
| 206 | (DWORD)-1,
|
|---|
| 207 | INTERNET_FLAG_RELOAD,
|
|---|
| 208 | (DWORD_PTR)context);
|
|---|
| 209 |
|
|---|
| 210 | e = GetLastError();
|
|---|
| 211 | if (!result && e != ERROR_IO_PENDING) {
|
|---|
| 212 | return E(AU_ERROR_NETWORK);
|
|---|
| 213 | }
|
|---|
| 214 | context->wait_request_complete = 1;
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | if (context->wait_request_complete) {
|
|---|
| 218 | switch (WaitForSingleObject(context->request_complete_event, 0)) {
|
|---|
| 219 | case WAIT_OBJECT_0:
|
|---|
| 220 | break;
|
|---|
| 221 | case WAIT_TIMEOUT:
|
|---|
| 222 | return AUI_IO_PENDING;
|
|---|
| 223 | break;
|
|---|
| 224 | default:
|
|---|
| 225 | return E(AU_ERROR_NETWORK);
|
|---|
| 226 | break;
|
|---|
| 227 | }
|
|---|
| 228 | }
|
|---|
| 229 | context->wait_request_complete = 0;
|
|---|
| 230 |
|
|---|
| 231 | if (!context->url_handle) {
|
|---|
| 232 | return E(AU_ERROR_SYSTEM);
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | {
|
|---|
| 236 | DWORD e = 0;
|
|---|
| 237 | BOOL read_result = 0;
|
|---|
| 238 | SetLastError(0);
|
|---|
| 239 | memset(&(context->buffer), 0, sizeof(context->buffer));
|
|---|
| 240 | memset(&(context->ib), 0, sizeof(context->ib));
|
|---|
| 241 | context->ib.dwStructSize = sizeof(context->ib);
|
|---|
| 242 | context->ib.lpvBuffer = context->buffer;
|
|---|
| 243 | context->ib.dwBufferLength = sizeof(context->buffer);
|
|---|
| 244 | read_result = InternetReadFileEx(
|
|---|
| 245 | context->url_handle,
|
|---|
| 246 | &(context->ib),
|
|---|
| 247 | IRF_ASYNC | IRF_USE_CONTEXT | IRF_NO_WAIT,
|
|---|
| 248 | (DWORD_PTR)context);
|
|---|
| 249 | e = GetLastError();
|
|---|
| 250 | if (!read_result && e == ERROR_IO_PENDING) {
|
|---|
| 251 | context->wait_request_complete = 1;
|
|---|
| 252 | return AUI_IO_PENDING;
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | if (!read_result) {
|
|---|
| 256 | return E(AU_ERROR_NETWORK);
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | }
|
|---|
| 260 | if (context->ib.dwBufferLength == 0) {
|
|---|
| 261 | return AUI_SUCCESS;
|
|---|
| 262 | }
|
|---|
| 263 |
|
|---|
| 264 | if (fwrite(context->buffer, 1, context->ib.dwBufferLength, context->fp) != context->ib.dwBufferLength) {
|
|---|
| 265 | return E(AU_ERROR_SYSTEM);
|
|---|
| 266 | }
|
|---|
| 267 | return AUI_IO_PENDING;
|
|---|
| 268 | }
|
|---|
| 269 |
|
|---|
| 270 | void CALLBACK AUI_InternetStatusCallback(
|
|---|
| 271 | HINTERNET hInternet,
|
|---|
| 272 | DWORD_PTR dwContext,
|
|---|
| 273 | DWORD dwInternetStatus,
|
|---|
| 274 | LPVOID lpvStatusInformation,
|
|---|
| 275 | DWORD dwStatusInformationLength) {
|
|---|
| 276 |
|
|---|
| 277 | AUI_DownloadContext* context = (AUI_DownloadContext*)dwContext;
|
|---|
| 278 |
|
|---|
| 279 | switch (dwInternetStatus) {
|
|---|
| 280 | case INTERNET_STATUS_HANDLE_CREATED:
|
|---|
| 281 | {
|
|---|
| 282 | INTERNET_ASYNC_RESULT* async_result = (INTERNET_ASYNC_RESULT*)lpvStatusInformation;
|
|---|
| 283 | context->url_handle = (HINTERNET)(async_result->dwResult);
|
|---|
| 284 | }
|
|---|
| 285 | break;
|
|---|
| 286 | case INTERNET_STATUS_REQUEST_COMPLETE:
|
|---|
| 287 | SetEvent(context->request_complete_event);
|
|---|
| 288 | break;
|
|---|
| 289 | default:
|
|---|
| 290 | break;
|
|---|
| 291 | }
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 | AU_Result AUI_CreateDownloadContext(AUI_DownloadContext** context_output, const TCHAR* url, const TCHAR* file_path) {
|
|---|
| 295 | AUI_DownloadContext* context = NULL;
|
|---|
| 296 | *context_output = NULL;
|
|---|
| 297 |
|
|---|
| 298 | context = (AUI_DownloadContext*)calloc(sizeof(*context), 1);
|
|---|
| 299 | if (!context) {
|
|---|
| 300 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 301 | }
|
|---|
| 302 |
|
|---|
| 303 | context->url = _tcsdup(url);
|
|---|
| 304 | if (!context->url) {
|
|---|
| 305 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 306 | }
|
|---|
| 307 |
|
|---|
| 308 | context->file_path = _tcsdup(file_path);
|
|---|
| 309 | if (!context->file_path) {
|
|---|
| 310 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | _tfopen_s(&context->fp, context->file_path, _T("wb"));
|
|---|
| 314 |
|
|---|
| 315 | if (!context->fp) {
|
|---|
| 316 | return E(AU_ERROR_SYSTEM);
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | context->request_complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|---|
| 320 | if (!context->request_complete_event) {
|
|---|
| 321 | return E(AU_ERROR_SYSTEM);
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | context->internet_handle =
|
|---|
| 325 | InternetOpen(
|
|---|
| 326 | TEXT("saturday06's AutoUpdater"),
|
|---|
| 327 | INTERNET_OPEN_TYPE_PRECONFIG,
|
|---|
| 328 | NULL,
|
|---|
| 329 | NULL,
|
|---|
| 330 | INTERNET_FLAG_ASYNC);
|
|---|
| 331 |
|
|---|
| 332 | if (!context->internet_handle) {
|
|---|
| 333 | return E(AU_ERROR_SYSTEM);
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | if (InternetSetStatusCallback(context->internet_handle, AUI_InternetStatusCallback)
|
|---|
| 337 | == INTERNET_INVALID_STATUS_CALLBACK) {
|
|---|
| 338 | return E(AU_ERROR_SYSTEM);
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | *context_output = context;
|
|---|
| 342 |
|
|---|
| 343 | return AUI_SUCCESS;
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | AU_Result AUI_DestroyDownloadContext(AUI_DownloadContext* context) {
|
|---|
| 347 | if (context->fp) {
|
|---|
| 348 | fclose(context->fp);
|
|---|
| 349 | }
|
|---|
| 350 | if (context->internet_handle) {
|
|---|
| 351 | InternetCloseHandle(context->internet_handle);
|
|---|
| 352 | }
|
|---|
| 353 | if (context->request_complete_event) {
|
|---|
| 354 | CloseHandle(context->request_complete_event);
|
|---|
| 355 | }
|
|---|
| 356 | if (context->url_handle) {
|
|---|
| 357 | InternetCloseHandle(context->url_handle);
|
|---|
| 358 | }
|
|---|
| 359 | if (context->url) {
|
|---|
| 360 | free(context->url);
|
|---|
| 361 | }
|
|---|
| 362 | if (context->file_path) {
|
|---|
| 363 | free(context->file_path);
|
|---|
| 364 | }
|
|---|
| 365 | free(context);
|
|---|
| 366 | return AUI_SUCCESS;
|
|---|
| 367 | }
|
|---|
| 368 |
|
|---|
| 369 | DWORD CALLBACK AUI_WindowsUpdateThread(LPVOID context_) {
|
|---|
| 370 | /* AUI_UpdaterThread((AUI_Context*)context_); */
|
|---|
| 371 | return 0;
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | AU_Result AUI_CreateContext(AUI_Context* context, const AU_Option* option) {
|
|---|
| 375 | if (!option ||
|
|---|
| 376 | !(option->url) ||
|
|---|
| 377 | AUI_IsBadReadPointer(option, sizeof(*option)) ||
|
|---|
| 378 | AUI_IsBadReadPointer(option->url, 1)) {
|
|---|
| 379 | return E(AU_ERROR_INVALID_OPTION);
|
|---|
| 380 | }
|
|---|
| 381 |
|
|---|
| 382 | {
|
|---|
| 383 | size_t len = _tcslen(option->url) + 2;
|
|---|
| 384 | if (len == 0) {
|
|---|
| 385 | return E(AU_ERROR_INVALID_OPTION);
|
|---|
| 386 | }
|
|---|
| 387 | context->url = (TCHAR*)calloc(len, sizeof(TCHAR));
|
|---|
| 388 | if (!context->url) {
|
|---|
| 389 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 390 | }
|
|---|
| 391 | _tcscpy_s(context->url, len, option->url);
|
|---|
| 392 | if (context->url[_tcslen(context->url) - 1] != _T('/')) {
|
|---|
| 393 | _tcscat_s(context->url, len, _T("/"));
|
|---|
| 394 | }
|
|---|
| 395 | }
|
|---|
| 396 |
|
|---|
| 397 | return AUI_SUCCESS;
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | AU_Result AUI_DestroyContext(AUI_Context* context) {
|
|---|
| 401 | context->created_sign = 0;
|
|---|
| 402 |
|
|---|
| 403 | if (context->temp_dir) {
|
|---|
| 404 | free(context->temp_dir);
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | if (context->description) {
|
|---|
| 408 | free(context->description);
|
|---|
| 409 | }
|
|---|
| 410 | free(context->url);
|
|---|
| 411 | if (context->update_information) {
|
|---|
| 412 | AUI_DestroyDownloadContext(context->update_information);
|
|---|
| 413 | }
|
|---|
| 414 | if (context->update_file) {
|
|---|
| 415 | AUI_DestroyDownloadContext(context->update_file);
|
|---|
| 416 | }
|
|---|
| 417 | if (context->thread_handle) {
|
|---|
| 418 | WaitForSingleObject(context->thread_handle, INFINITE);
|
|---|
| 419 | CloseHandle(context->thread_handle);
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | /* clear memory */
|
|---|
| 423 | memset(context, 0, sizeof(*context));
|
|---|
| 424 |
|
|---|
| 425 | free(context);
|
|---|
| 426 | return AUI_SUCCESS;
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 | AU_Result AUI_GetInformation(AUI_Context* context, AU_Information* information) {
|
|---|
| 430 | AU_Result r;
|
|---|
| 431 | memset(information, 0, sizeof(*information));
|
|---|
| 432 | if (!context->temp_dir) {
|
|---|
| 433 | AU_Result result = AUI_CreateTemporaryDirectory(&context->temp_dir);
|
|---|
| 434 | if (result.error) {
|
|---|
| 435 | return result;
|
|---|
| 436 | }
|
|---|
| 437 | }
|
|---|
| 438 | if (!context->update_information) {
|
|---|
| 439 | TCHAR* url = NULL;
|
|---|
| 440 | TCHAR* file = NULL;
|
|---|
| 441 | TCHAR url_add[] = _T("update.txt");
|
|---|
| 442 | TCHAR file_add[] = _T("file.ogg");
|
|---|
| 443 | size_t url_len = 0;
|
|---|
| 444 | size_t file_len = 0;
|
|---|
| 445 |
|
|---|
| 446 | url_len = _tcslen(context->url) + 1 + _tcslen(url_add);
|
|---|
| 447 | url = (TCHAR*)calloc(url_len, sizeof(TCHAR));
|
|---|
| 448 | if (!url) {
|
|---|
| 449 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | file_len = _tcslen(context->temp_dir) + _tcslen(file_add);
|
|---|
| 453 | file = (TCHAR*)calloc(file_len, sizeof(TCHAR));
|
|---|
| 454 | if (!file) {
|
|---|
| 455 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 456 | }
|
|---|
| 457 |
|
|---|
| 458 | _tcscpy_s(url, url_len, context->url);
|
|---|
| 459 | _tcscat_s(url, url_len, url_add);
|
|---|
| 460 |
|
|---|
| 461 | _tcscpy_s(file, file_len, context->temp_dir);
|
|---|
| 462 | PathAppend(file, file_add);
|
|---|
| 463 |
|
|---|
| 464 | r = AUI_CreateDownloadContext(
|
|---|
| 465 | &context->update_information,
|
|---|
| 466 | url,
|
|---|
| 467 | file);
|
|---|
| 468 |
|
|---|
| 469 | if (r.error) {
|
|---|
| 470 | return r;
|
|---|
| 471 | }
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | r = AUI_Download(context->update_information);
|
|---|
| 475 | if (r.error) {
|
|---|
| 476 | return r;
|
|---|
| 477 | }
|
|---|
| 478 |
|
|---|
| 479 | return AUI_SUCCESS;
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | AU_Result AUI_StartUpdate(AUI_Context* context) {
|
|---|
| 483 | if (!context->temp_dir) {
|
|---|
| 484 | AU_Result result = AUI_CreateTemporaryDirectory(&context->temp_dir);
|
|---|
| 485 | if (result.error) {
|
|---|
| 486 | return result;
|
|---|
| 487 | }
|
|---|
| 488 | }
|
|---|
| 489 | return AUI_SUCCESS;
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | AU_Result AUI_Cancel(AUI_Context* context) {
|
|---|
| 493 | return AUI_SUCCESS;
|
|---|
| 494 | }
|
|---|
| 495 |
|
|---|
| 496 | AU_Result AUI_ContextToInternalContext(AUI_Context** internal_context_output, const AU_Context context) {
|
|---|
| 497 | AUI_Context* internal_context = (AUI_Context*)context;
|
|---|
| 498 | *internal_context_output = 0;
|
|---|
| 499 |
|
|---|
| 500 | if (AUI_IsBadReadPointer(internal_context, sizeof(internal_context))) {
|
|---|
| 501 | return E(AU_ERROR_INVALID_CONTEXT);
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | if (AUI_IsBadWritePointer(internal_context, sizeof(internal_context))) {
|
|---|
| 505 | return E(AU_ERROR_INVALID_CONTEXT);
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | if (internal_context->description != NULL && AUI_IsBadWritePointer(internal_context->description, 1)) {
|
|---|
| 509 | return E(AU_ERROR_INVALID_CONTEXT);
|
|---|
| 510 | }
|
|---|
| 511 |
|
|---|
| 512 | if (internal_context->url != NULL && AUI_IsBadWritePointer(internal_context->url, 1)) {
|
|---|
| 513 | return E(AU_ERROR_INVALID_CONTEXT);
|
|---|
| 514 | }
|
|---|
| 515 |
|
|---|
| 516 | if (internal_context->created_sign != context_created_sign) {
|
|---|
| 517 | return E(AU_ERROR_INVALID_CONTEXT);
|
|---|
| 518 | }
|
|---|
| 519 |
|
|---|
| 520 | *internal_context_output = internal_context;
|
|---|
| 521 | return AUI_SUCCESS;
|
|---|
| 522 | }
|
|---|
| 523 |
|
|---|
| 524 | /* -----------------------------------------------------------------------
|
|---|
| 525 | Interfaces
|
|---|
| 526 | ----------------------------------------------------------------------- */
|
|---|
| 527 |
|
|---|
| 528 | #define AUI_API_PRECONDITION \
|
|---|
| 529 | AUI_Context* internal_context = NULL; \
|
|---|
| 530 | { \
|
|---|
| 531 | AU_Result convert_result = AUI_ContextToInternalContext(&internal_context, context); \
|
|---|
| 532 | if (convert_result.error) { \
|
|---|
| 533 | return convert_result; \
|
|---|
| 534 | } \
|
|---|
| 535 | }
|
|---|
| 536 |
|
|---|
| 537 | AU_Result AU_CreateContext(AU_Context* pcontext, const AU_Option* option) {
|
|---|
| 538 | AU_Context context = NULL;
|
|---|
| 539 |
|
|---|
| 540 | if (AUI_IsBadWritePointer(pcontext, sizeof(*pcontext))) {
|
|---|
| 541 | return E(AU_ERROR_INVALID_CONTEXT);
|
|---|
| 542 | }
|
|---|
| 543 |
|
|---|
| 544 | {
|
|---|
| 545 | AUI_Context* internal_context = (AUI_Context*)calloc(sizeof(AUI_Context), 1);
|
|---|
| 546 | if (!internal_context) {
|
|---|
| 547 | return E(AU_ERROR_BAD_ALLOC);
|
|---|
| 548 | }
|
|---|
| 549 | internal_context->created_sign = context_created_sign;
|
|---|
| 550 | context = (AU_Context)internal_context;
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | {
|
|---|
| 554 | AU_Result result;
|
|---|
| 555 | AUI_API_PRECONDITION;
|
|---|
| 556 | result = AUI_CreateContext(internal_context, option);
|
|---|
| 557 | if (result.success) {
|
|---|
| 558 | *pcontext = context;
|
|---|
| 559 | }
|
|---|
| 560 | return result;
|
|---|
| 561 | }
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 564 | AU_Result AU_DestroyContext(AU_Context context) {
|
|---|
| 565 | AUI_API_PRECONDITION;
|
|---|
| 566 | return AUI_DestroyContext(internal_context);
|
|---|
| 567 | }
|
|---|
| 568 |
|
|---|
| 569 | AU_Result AU_GetInformation(AU_Context context, AU_Information* infomation) {
|
|---|
| 570 | AUI_API_PRECONDITION;
|
|---|
| 571 | return AUI_GetInformation(internal_context, infomation);
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | AU_Result AU_StartUpdate(AU_Context context) {
|
|---|
| 575 | AUI_API_PRECONDITION;
|
|---|
| 576 | return AUI_StartUpdate(internal_context);
|
|---|
| 577 | }
|
|---|
| 578 |
|
|---|
| 579 | AU_Result AU_Cancel(AU_Context context) {
|
|---|
| 580 | AUI_API_PRECONDITION;
|
|---|
| 581 | return AUI_Cancel(internal_context);
|
|---|
| 582 | }
|
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 | /* http://support.microsoft.com/kb/238393 */
|
|---|
| 586 | HRESULT AUI_AutoWrap(WORD autoType, VARIANT *pvResult, IDispatch *pDisp,
|
|---|
| 587 | const OLECHAR* ptcName, size_t cArgs, VARIANT* rargs)
|
|---|
| 588 | {
|
|---|
| 589 | DISPPARAMS dp = { NULL, NULL, 0, 0 };
|
|---|
| 590 | DISPID dispidNamed = DISPID_PROPERTYPUT;
|
|---|
| 591 | DISPID dispID;
|
|---|
| 592 | HRESULT hr = E_FAIL;
|
|---|
| 593 | VARIANT* args = NULL;
|
|---|
| 594 | OLECHAR* ptName = NULL;
|
|---|
| 595 |
|
|---|
| 596 | if(!pDisp) {
|
|---|
| 597 | goto clean_up;
|
|---|
| 598 | }
|
|---|
| 599 |
|
|---|
| 600 | ptName = wcsdup(ptcName);
|
|---|
| 601 | if (!ptName) {
|
|---|
| 602 | hr = E_FAIL;
|
|---|
| 603 | goto clean_up;
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | if (pvResult) {
|
|---|
| 607 | VariantInit(pvResult);
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | #ifdef __cplusplus
|
|---|
| 611 | hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
|
|---|
| 612 | #else
|
|---|
| 613 | hr = pDisp->lpVtbl->GetIDsOfNames(pDisp, &IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
|
|---|
| 614 | #endif
|
|---|
| 615 |
|
|---|
| 616 | if(FAILED(hr)) {
|
|---|
| 617 | goto clean_up;
|
|---|
| 618 | }
|
|---|
| 619 |
|
|---|
| 620 | if (cArgs > 0) {
|
|---|
| 621 | size_t i = 0;
|
|---|
| 622 | args = (VARIANT*)calloc(sizeof(VARIANT) * cArgs, 1);
|
|---|
| 623 | if (!args) {
|
|---|
| 624 | hr = E_FAIL;
|
|---|
| 625 | goto clean_up;
|
|---|
| 626 | }
|
|---|
| 627 | for (i = 0; i < cArgs; ++i) {
|
|---|
| 628 | args[cArgs - i - 1] = rargs[i];
|
|---|
| 629 | }
|
|---|
| 630 | }
|
|---|
| 631 |
|
|---|
| 632 | dp.cArgs = cArgs;
|
|---|
| 633 | dp.rgvarg = args;
|
|---|
| 634 |
|
|---|
| 635 | if(autoType & DISPATCH_PROPERTYPUT) {
|
|---|
| 636 | dp.cNamedArgs = 1;
|
|---|
| 637 | dp.rgdispidNamedArgs = &dispidNamed;
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 | #ifdef __cplusplus
|
|---|
| 641 | hr = pDisp->Invoke(
|
|---|
| 642 | dispID, IID_NULL, LOCALE_USER_DEFAULT, autoType,
|
|---|
| 643 | &dp, pvResult, NULL, NULL);
|
|---|
| 644 | #else
|
|---|
| 645 | hr = pDisp->lpVtbl->Invoke(
|
|---|
| 646 | pDisp,
|
|---|
| 647 | dispID,
|
|---|
| 648 | &IID_NULL,
|
|---|
| 649 | LOCALE_USER_DEFAULT,
|
|---|
| 650 | autoType,
|
|---|
| 651 | &dp,
|
|---|
| 652 | pvResult,
|
|---|
| 653 | NULL,
|
|---|
| 654 | NULL
|
|---|
| 655 | );
|
|---|
| 656 | #endif
|
|---|
| 657 |
|
|---|
| 658 | clean_up:
|
|---|
| 659 | if (args) {
|
|---|
| 660 | free(args);
|
|---|
| 661 | }
|
|---|
| 662 | if (ptName) {
|
|---|
| 663 | free(ptName);
|
|---|
| 664 | }
|
|---|
| 665 | if (cArgs > 0) {
|
|---|
| 666 | size_t i = 0;
|
|---|
| 667 | for (i = 0; i < cArgs; ++i) {
|
|---|
| 668 | VariantClear(&rargs[i]);
|
|---|
| 669 | }
|
|---|
| 670 | }
|
|---|
| 671 | return hr;
|
|---|
| 672 | }
|
|---|
| 673 |
|
|---|
| 674 |
|
|---|
| 675 | void AUI_IDispatchAddRef(IDispatch* pd) {
|
|---|
| 676 | if (!pd) {
|
|---|
| 677 | return;
|
|---|
| 678 | }
|
|---|
| 679 | #ifdef __cplusplus
|
|---|
| 680 | pd->AddRef();
|
|---|
| 681 | #else
|
|---|
| 682 | pd->lpVtbl->AddRef(pd);
|
|---|
| 683 | #endif
|
|---|
| 684 | }
|
|---|
| 685 |
|
|---|
| 686 | void AUI_IDispatchRelease(IDispatch* pd) {
|
|---|
| 687 | if (!pd) {
|
|---|
| 688 | return;
|
|---|
| 689 | }
|
|---|
| 690 | #ifdef __cplusplus
|
|---|
| 691 | pd->Release();
|
|---|
| 692 | #else
|
|---|
| 693 | pd->lpVtbl->Release(pd);
|
|---|
| 694 | #endif
|
|---|
| 695 | }
|
|---|
| 696 |
|
|---|
| 697 | void aaa() {
|
|---|
| 698 | HRESULT result = S_OK;
|
|---|
| 699 | VARIANT returnValue;
|
|---|
| 700 | VARIANT args[10];
|
|---|
| 701 | IDispatch* Microsoft_XMLDOM = NULL;
|
|---|
| 702 | IDispatch* documentElement = NULL;
|
|---|
| 703 | IDispatch* releaseNode = NULL;
|
|---|
| 704 | IDispatch* urlNode = NULL;
|
|---|
| 705 | IDispatch* descriptionNode = NULL;
|
|---|
| 706 |
|
|---|
| 707 | {
|
|---|
| 708 | result = CoInitialize(NULL);
|
|---|
| 709 | switch (result)
|
|---|
| 710 | {
|
|---|
| 711 | case S_OK :
|
|---|
| 712 | break;
|
|---|
| 713 | case S_FALSE:
|
|---|
| 714 | /* CoInitialize: The COM library is already initialized on this thread */
|
|---|
| 715 | break;
|
|---|
| 716 | case RPC_E_CHANGED_MODE:
|
|---|
| 717 | /* CoInitialize: A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). If running Windows 2000, this could also mean that a change from neutral-threaded apartment to single-threaded apartment occurred. */
|
|---|
| 718 | break;
|
|---|
| 719 | }
|
|---|
| 720 | }
|
|---|
| 721 |
|
|---|
| 722 | /* var Microsoft_XMLDOM = new ActiveXObject("Microsoft.XMLDOM") */
|
|---|
| 723 | {
|
|---|
| 724 | OLECHAR clsid_str[] = OLESTR("Microsoft.XMLDOM");
|
|---|
| 725 | CLSID clsid;
|
|---|
| 726 |
|
|---|
| 727 | result = CLSIDFromString(clsid_str, &clsid);
|
|---|
| 728 |
|
|---|
| 729 | switch (result)
|
|---|
| 730 | {
|
|---|
| 731 | case NOERROR:
|
|---|
| 732 | /* The CLSID was obtained successfully. */
|
|---|
| 733 | break;
|
|---|
| 734 | case E_INVALIDARG:
|
|---|
| 735 | return;
|
|---|
| 736 | break;
|
|---|
| 737 | case CO_E_CLASSSTRING:
|
|---|
| 738 | /* The class string was improperly formatted. */
|
|---|
| 739 | return;
|
|---|
| 740 | break;
|
|---|
| 741 | case REGDB_E_CLASSNOTREG:
|
|---|
| 742 | /* The CLSID corresponding to the class string was not found in the registry. */
|
|---|
| 743 | return;
|
|---|
| 744 | break;
|
|---|
| 745 | case REGDB_E_READREGDB:
|
|---|
| 746 | /* The registry could not be opened for reading. */
|
|---|
| 747 | return;
|
|---|
| 748 | break;
|
|---|
| 749 | default:
|
|---|
| 750 | return;
|
|---|
| 751 | break;
|
|---|
| 752 | }
|
|---|
| 753 |
|
|---|
| 754 | #ifdef __cplusplus
|
|---|
| 755 | result = CoCreateInstance(clsid, NULL, CLSCTX_SERVER, IID_IDispatch, (LPVOID*)&Microsoft_XMLDOM);
|
|---|
| 756 | #else
|
|---|
| 757 | result = CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (LPVOID*)&Microsoft_XMLDOM);
|
|---|
| 758 | #endif
|
|---|
| 759 |
|
|---|
| 760 | switch (result)
|
|---|
| 761 | {
|
|---|
| 762 | case S_OK:
|
|---|
| 763 | break;
|
|---|
| 764 | case REGDB_E_CLASSNOTREG:
|
|---|
| 765 | return;
|
|---|
| 766 | break;
|
|---|
| 767 | case CLASS_E_NOAGGREGATION:
|
|---|
| 768 | /* This class cannot be created as part of an aggregate */
|
|---|
| 769 | return;
|
|---|
| 770 | break;
|
|---|
| 771 | case E_NOINTERFACE:
|
|---|
| 772 | /* The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface */
|
|---|
| 773 | return;
|
|---|
| 774 | break;
|
|---|
| 775 | default:
|
|---|
| 776 | /* unknown error: */
|
|---|
| 777 | return;
|
|---|
| 778 | break;
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 | if (Microsoft_XMLDOM == NULL)
|
|---|
| 782 | {
|
|---|
| 783 | return;
|
|---|
| 784 | }
|
|---|
| 785 | }
|
|---|
| 786 |
|
|---|
| 787 |
|
|---|
| 788 | { /* Microsoft_XMLDOM.async = false */
|
|---|
| 789 | args[0].vt = VT_BOOL;
|
|---|
| 790 | args[0].boolVal = VARIANT_FALSE;
|
|---|
| 791 | result = AUI_AutoWrap(DISPATCH_PROPERTYPUT, NULL, Microsoft_XMLDOM, OLESTR("async"), 1, args);
|
|---|
| 792 | }
|
|---|
| 793 |
|
|---|
| 794 |
|
|---|
| 795 | { /* Microsoft_XMLDOM.load("file.xml") */
|
|---|
| 796 | args[0].vt = VT_BSTR;
|
|---|
| 797 | /* args[0].bstrVal = SysAllocString(OLESTR("c:/Documents and Settings/saturday06/My Documents/My Dropbox/jsxml.xml")); */
|
|---|
| 798 | /* args[0].bstrVal = SysAllocString(OLESTR("D:/Documents/My Dropbox/jsxml.xml")); */
|
|---|
| 799 | args[0].bstrVal = SysAllocString(OLESTR("updates.xml"));
|
|---|
| 800 | result = AUI_AutoWrap(DISPATCH_METHOD, &returnValue, Microsoft_XMLDOM, OLESTR("load"), 1, args);
|
|---|
| 801 | if (FAILED(result)) {
|
|---|
| 802 | abort();
|
|---|
| 803 | }
|
|---|
| 804 | if (!returnValue.boolVal) {
|
|---|
| 805 | abort();
|
|---|
| 806 | }
|
|---|
| 807 | VariantClear(&returnValue);
|
|---|
| 808 | }
|
|---|
| 809 |
|
|---|
| 810 | { /* Microsoft_XMLDOM.setProperty("SelectionLanguage", "XPath"); */
|
|---|
| 811 | args[0].vt = VT_BSTR;
|
|---|
| 812 | args[0].bstrVal = SysAllocString(OLESTR("SelectionLanguage"));
|
|---|
| 813 | if (!args[0].bstrVal) {
|
|---|
| 814 | abort();
|
|---|
| 815 | }
|
|---|
| 816 | args[1].vt = VT_BSTR;
|
|---|
| 817 | args[1].bstrVal = SysAllocString(OLESTR("XPath"));
|
|---|
| 818 | if (!args[1].bstrVal) {
|
|---|
| 819 | abort();
|
|---|
| 820 | }
|
|---|
| 821 | result = AUI_AutoWrap(DISPATCH_METHOD, NULL, Microsoft_XMLDOM, OLESTR("setProperty"), 2, args);
|
|---|
| 822 | if (FAILED(result)) {
|
|---|
| 823 | abort();
|
|---|
| 824 | }
|
|---|
| 825 | }
|
|---|
| 826 |
|
|---|
| 827 | { /* var documentElement = Microsoft_XMLDOM.documentElement */
|
|---|
| 828 | result = AUI_AutoWrap(DISPATCH_PROPERTYGET, &returnValue, Microsoft_XMLDOM, OLESTR("documentElement"), 0, NULL);
|
|---|
| 829 | if (FAILED(result)) {
|
|---|
| 830 | abort();
|
|---|
| 831 | }
|
|---|
| 832 | if (!returnValue.pdispVal) {
|
|---|
| 833 | abort();
|
|---|
| 834 | }
|
|---|
| 835 | documentElement = returnValue.pdispVal;
|
|---|
| 836 | VariantClear(&returnValue);
|
|---|
| 837 | }
|
|---|
| 838 |
|
|---|
| 839 | { /* var releaseNode = documentElement.selectSingleNode("..."); */
|
|---|
| 840 | #define DEBUG_CONDITION OLESTR("not(@debug) or @debug < 1")
|
|---|
| 841 | OLECHAR cond[] =
|
|---|
| 842 | OLESTR("/releases/release[") DEBUG_CONDITION OLESTR("][")
|
|---|
| 843 | OLESTR("not(@revision <= preceding-sibling::release[") DEBUG_CONDITION OLESTR("]/@revision) and ")
|
|---|
| 844 | OLESTR("not(@revision <= following-sibling::release[") DEBUG_CONDITION OLESTR("]/@revision)]");
|
|---|
| 845 | #undef DEBUG_CONDITION
|
|---|
| 846 |
|
|---|
| 847 | args[0].vt = VT_BSTR;
|
|---|
| 848 | args[0].bstrVal = SysAllocString(cond);
|
|---|
| 849 | if (!args[0].bstrVal) {
|
|---|
| 850 | abort();
|
|---|
| 851 | }
|
|---|
| 852 | result = AUI_AutoWrap(DISPATCH_METHOD, &returnValue, Microsoft_XMLDOM, OLESTR("selectSingleNode"), 1, args);
|
|---|
| 853 | if (FAILED(result)) {
|
|---|
| 854 | abort();
|
|---|
| 855 | }
|
|---|
| 856 | if (!returnValue.pdispVal) {
|
|---|
| 857 | abort();
|
|---|
| 858 | }
|
|---|
| 859 | releaseNode = returnValue.pdispVal;
|
|---|
| 860 | AUI_IDispatchAddRef(releaseNode);
|
|---|
| 861 | VariantClear(&returnValue);
|
|---|
| 862 | }
|
|---|
| 863 |
|
|---|
| 864 | { /* var urlNode = releaseNode.selectSingleNode("url"); */
|
|---|
| 865 | args[0].vt = VT_BSTR;
|
|---|
| 866 | args[0].bstrVal = SysAllocString(OLESTR("url"));
|
|---|
| 867 | if (!args[0].bstrVal) {
|
|---|
| 868 | abort();
|
|---|
| 869 | }
|
|---|
| 870 | result = AUI_AutoWrap(DISPATCH_METHOD, &returnValue, releaseNode, OLESTR("selectSingleNode"), 1, args);
|
|---|
| 871 | if (FAILED(result)) {
|
|---|
| 872 | abort();
|
|---|
| 873 | }
|
|---|
| 874 | if (!returnValue.pdispVal) {
|
|---|
| 875 | abort();
|
|---|
| 876 | }
|
|---|
| 877 | urlNode = returnValue.pdispVal;
|
|---|
| 878 | AUI_IDispatchAddRef(urlNode);
|
|---|
| 879 | VariantClear(&returnValue);
|
|---|
| 880 | }
|
|---|
| 881 |
|
|---|
| 882 | { /* urlNode.text; */
|
|---|
| 883 | result = AUI_AutoWrap(DISPATCH_PROPERTYGET, &returnValue, urlNode, OLESTR("text"), 0, NULL);
|
|---|
| 884 | if (FAILED(result)) {
|
|---|
| 885 | abort();
|
|---|
| 886 | }
|
|---|
| 887 | if (!returnValue.bstrVal) {
|
|---|
| 888 | abort();
|
|---|
| 889 | }
|
|---|
| 890 | MessageBoxW(NULL, returnValue.bstrVal, returnValue.bstrVal, MB_OK);
|
|---|
| 891 | VariantClear(&returnValue);
|
|---|
| 892 | }
|
|---|
| 893 |
|
|---|
| 894 | AUI_IDispatchRelease(urlNode);
|
|---|
| 895 | AUI_IDispatchRelease(releaseNode);
|
|---|
| 896 | AUI_IDispatchRelease(Microsoft_XMLDOM);
|
|---|
| 897 | }
|
|---|
| 898 |
|
|---|
| 899 |
|
|---|
| 900 | void InternalTest() {
|
|---|
| 901 | AU_Result r;
|
|---|
| 902 | AUI_DownloadContext* context;
|
|---|
| 903 |
|
|---|
| 904 | aaa();
|
|---|
| 905 |
|
|---|
| 906 | r = AUI_CreateDownloadContext(
|
|---|
| 907 | &context,
|
|---|
| 908 | _T("http://upload.wikimedia.org/wikipedia/commons/b/bd/Rondo_Alla_Turka.ogg"),
|
|---|
| 909 | _T("C:\\temp\\bbb.ogg"));
|
|---|
| 910 |
|
|---|
| 911 | if (r.error) {
|
|---|
| 912 | abort();
|
|---|
| 913 | }
|
|---|
| 914 |
|
|---|
| 915 | do {
|
|---|
| 916 | r = AUI_Download(context);
|
|---|
| 917 | } while (r.pending);
|
|---|
| 918 |
|
|---|
| 919 | AUI_DestroyDownloadContext(context);
|
|---|
| 920 |
|
|---|
| 921 | }
|
|---|