Changeset 38029
- Timestamp:
- 07/27/10 22:19:29 (3 years ago)
- Location:
- lang/c/AutoUpdater/trunk
- Files:
-
- 4 modified
-
AutoUpdater.h (modified) (2 diffs)
-
recipes/Makefile.am (modified) (1 diff)
-
recipes/Template.c (modified) (32 diffs)
-
recipes/Test.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/c/AutoUpdater/trunk/AutoUpdater.h
r37979 r38029 46 46 47 47 /** 48 * �A�b�v�f�[�g��48 * AutoUpdater API�ŗ��p����A�b�v�f�[�g�t�@�C���Ƃ��̏����̐i�s���� 49 49 */ 50 typedef struct AU_ Information_ {50 typedef struct AU_Context_ { 51 51 int found; 52 52 const TCHAR* description; … … 59 59 size_t update_downloaded_bytes; 60 60 size_t update_total_bytes; 61 } AU_Information;62 63 /**64 * AutoUpdater API�ŗ��p����A�b�v�f�[�g�t�@�C���Ƃ��̏����̐i�s����65 */66 typedef struct AU_Context_ {67 int signature;68 61 } *AU_Context; 69 62 70 63 /** 71 64 * AU_Context������� */ 72 extern AU_Result AU_Create Context(AU_Context* new_context, const AU_Option* option);65 extern AU_Result AU_Create(AU_Context* new_context, const AU_Option* option); 73 66 74 67 /** 75 68 * AU_Context�̃f�[�^������� */ 76 extern AU_Result AU_Destroy Context(AU_Context context);69 extern AU_Result AU_Destroy(AU_Context context); 77 70 78 71 /** 79 72 * AU_Context�̃A�b�v�f�[�g��������� */ 80 extern AU_Result AU_ GetInformation(AU_Context context, AU_Information* infomation);73 extern AU_Result AU_Search(AU_Context context); 81 74 82 75 /** 83 76 * �f�[�^��E�����[�h���A 84 77 * ���v���Z�X�̏I�����Ƀ_�E�����[�h�����t�@�C����J�������ɂ��� */ 85 extern AU_Result AU_ StartUpdate(AU_Context context);78 extern AU_Result AU_Update(AU_Context context); 86 79 87 80 /** 88 * AU_ StartUpdate()�y��U_GetInformation()������Z������ */81 * AU_Update()�y��U_Search()������Z������ */ 89 82 extern AU_Result AU_Cancel(AU_Context context); 90 83 -
lang/c/AutoUpdater/trunk/recipes/Makefile.am
r38016 r38029 2 2 3 3 test_SOURCES = Test.cpp Template.c 4 test_CPPFLAGS = -I.. -DSTRICT -DUNICODE -D_UNICODE4 test_CPPFLAGS = -I.. -DSTRICT #-DUNICODE -D_UNICODE 5 5 test_CFLAGS = -O0 -g 6 6 test_CXXFLAGS = -O0 -g -
lang/c/AutoUpdater/trunk/recipes/Template.c
r38024 r38029 51 51 # define _tcsdup AUI_wcsdup 52 52 # define _tfopen(x, y) (NULL) 53 # define _tprintf wprintf 53 54 # else 54 55 # define _tcslen strlen … … 57 58 # define _tcsdup AUI_strdup 58 59 # define _tfopen fopen 60 # define _tprintf printf 59 61 # endif 60 62 … … 103 105 HINTERNET url_handle; 104 106 int complete; 105 INTERNET_BUFFERS* ib; /* pointer for -Wpadded */107 INTERNET_BUFFERS* ib; /* pointer for gcc -Wpadded */ 106 108 } AUI_DownloadContext; 107 109 108 const int AUI_CONTEXT_CREATED_SIGNATURE = 0x5aa5f00f;109 110 110 typedef struct AUI_Context_ { 111 int created_signature; 111 AU_Context user; 112 112 113 TCHAR* description; 113 114 114 TCHAR* temp_dir_path; 115 115 TCHAR* updater_file_path; … … 528 528 parameter is NULL. */ 529 529 { 530 530 puts("INTERNET_STATUS_CLOSING_CONNECTION"); 531 531 } 532 532 break; … … 535 535 pointed to by lpvStatusInformation. */ 536 536 { 537 537 puts("INTERNET_STATUS_CONNECTED_TO_SERVER"); 538 538 } 539 539 break; … … 542 542 lpvStatusInformation. */ 543 543 { 544 puts("INTERNET_STATUS_CONNECTING_TO_SERVER"); 544 545 } 545 546 break; … … 548 549 lpvStatusInformation parameter is NULL. */ 549 550 { 551 puts("INTERNET_STATUS_CONNECTION_CLOSED"); 550 552 } 551 553 break; … … 559 561 InternetCookieHistory structure. */ 560 562 { 563 puts("INTERNET_STATUS_COOKIE_HISTORY"); 561 564 } 562 565 break; … … 568 571 cookies received. */ 569 572 { 573 puts("INTERNET_STATUS_COOKIE_RECEIVED"); 570 574 } 571 575 break; … … 576 580 suppressed. */ 577 581 { 582 puts("INTERNET_STATUS_COOKIE_SENT"); 578 583 } 579 584 break; … … 582 587 /* Not implemented. */ 583 588 { 589 puts("INTERNET_STATUS_CTL_RESPONSE_RECEIVED"); 584 590 } 585 591 break; … … 588 594 /* Notifies the client application that a proxy has been detected. */ 589 595 { 596 puts("INTERNET_STATUS_DETECTING_PROXY"); 590 597 } 591 598 break; … … 597 604 handle being closed. */ 598 605 { 606 puts("INTERNET_STATUS_HANDLE_CLOSING"); 599 607 } 600 608 break; … … 606 614 HINTERNET handle. */ 607 615 { 608 INTERNET_ASYNC_RESULT* async_result = (INTERNET_ASYNC_RESULT*)lpvStatusInformation;609 context->url_handle = (HINTERNET)(async_result->dwResult);616 puts("INTERNET_STATUS_HANDLE_CREATED"); 617 context->url_handle = *(HINTERNET*)(lpvStatusInformation); 610 618 } 611 619 break; … … 615 623 from the server. */ 616 624 { 625 puts("INTERNET_STATUS_INTERMEDIATE_RESPONSE"); 617 626 } 618 627 break; … … 623 632 to a PCTSTR containing the host name. */ 624 633 { 634 /* (const TCHAR*)lpvStatusInformation != host name ? */ 635 puts("INTERNET_STATUS_NAME_RESOLVED"); 636 /* 637 _tprintf(_T("INTERNET_STATUS_NAME_RESOLVED %s\n"), 638 (const TCHAR*)lpvStatusInformation); 639 */ 625 640 } 626 641 break; … … 653 668 lpvStatusInformation parameter is NULL. */ 654 669 { 670 puts("INTERNET_STATUS_RECEIVING_RESPONSE"); 655 671 } 656 672 break; … … 664 680 specified INTERNET_FLAG_NO_AUTO_REDIRECT. */ 665 681 { 682 puts("INTERNET_STATUS_REDIRECT"); 666 683 } 667 684 break; … … 671 688 INTERNET_ASYNC_RESULT structure. */ 672 689 { 690 INTERNET_ASYNC_RESULT* async = (INTERNET_ASYNC_RESULT*)lpvStatusInformation; 673 691 SetEvent(context->request_complete_event); 692 _tprintf(_T("INTERNET_STATUS_REQUEST_COMPLETE dwError=0x%x, dwResult=0x%x\n"), 693 (unsigned int)async->dwError, (unsigned int)async->dwResult); 674 694 } 675 695 break; … … 679 699 contains the number of bytes sent. */ 680 700 { 701 _tprintf(_T("INTERNET_STATUS_REQUEST_SENT bytes=%d\n"), (int)*(DWORD*)lpvStatusInformation); 681 702 } 682 703 break; … … 686 707 to a PCTSTR containing the host name. */ 687 708 { 709 _tprintf(_T("INTERNET_STATUS_RESOLVING_NAME %s\n"), 710 (const TCHAR*)lpvStatusInformation); 688 711 } 689 712 break; … … 691 714 /* Successfully received a response from the server. */ 692 715 { 716 _tprintf(_T("INTERNET_STATUS_RESPONSE_RECEIVED bytes=%d\n"), 717 (int)*(DWORD*)lpvStatusInformation); 693 718 } 694 719 break; … … 697 722 lpvStatusInformation parameter is NULL. */ 698 723 { 724 puts("INTERNET_STATUS_SENDING_REQUEST"); 699 725 } 700 726 break; … … 810 836 */ 811 837 812 AU_Result AUI_Create Context(AUI_Context* context, const AU_Option* option) {838 AU_Result AUI_Create(AUI_Context* context, const AU_Option* option) { 813 839 AU_Result r; 814 840 if (!option || … … 916 942 } 917 943 918 AU_Result AUI_DestroyContext(AUI_Context* context) { 919 context->created_signature = 0; 920 944 AU_Result AUI_Destroy(AUI_Context* context) { 921 945 if (!context->ready) { 922 946 AUI_DeleteDirectory(context->temp_dir_path); … … 1170 1194 } 1171 1195 1172 AU_Result AUI_ GetInformation(AUI_Context* context, AU_Information* information) {1196 AU_Result AUI_Search(AUI_Context* context, AU_Information* information) { 1173 1197 AU_Result r; 1174 1198 memset(information, 0, sizeof(*information)); … … 1199 1223 extern const char AUI_UPDATER_DATA[]; 1200 1224 1201 AU_Result AUI_ StartUpdate(AUI_Context* context) {1225 AU_Result AUI_Update(AUI_Context* context) { 1202 1226 AU_Result r; 1203 1227 if (!context->found) { 1204 1228 AU_Information i; 1205 r = AUI_ GetInformation(context, &i);1229 r = AUI_Search(context, &i); 1206 1230 if (!r.success) { 1207 1231 return r; … … 1341 1365 } 1342 1366 1343 if (internal_context->created_signature != AUI_CONTEXT_CREATED_SIGNATURE) {1344 AUI_GOTO_ERROR_RETURN(AU_ERROR_INVALID_CONTEXT);1345 }1346 1347 1367 *internal_context_output = internal_context; 1348 1368 … … 1366 1386 } 1367 1387 1368 AU_Result AU_Create Context(AU_Context* pcontext, const AU_Option* option) {1388 AU_Result AU_Create(AU_Context* pcontext, const AU_Option* option) { 1369 1389 AU_Context context = NULL; 1370 1390 … … 1378 1398 return E(AU_ERROR_BAD_ALLOC); 1379 1399 } 1380 internal_context->created_signature = AUI_CONTEXT_CREATED_SIGNATURE;1381 1400 context = (AU_Context)internal_context; 1382 1401 } … … 1385 1404 AU_Result result; 1386 1405 AUI_API_PRECONDITION; 1387 result = AUI_Create Context(internal_context, option);1406 result = AUI_Create(internal_context, option); 1388 1407 if (result.success) { 1389 1408 *pcontext = context; … … 1393 1412 } 1394 1413 1395 AU_Result AU_Destroy Context(AU_Context context) {1414 AU_Result AU_Destroy(AU_Context context) { 1396 1415 AUI_API_PRECONDITION; 1397 return AUI_Destroy Context(internal_context);1398 } 1399 1400 AU_Result AU_ GetInformation(AU_Context context, AU_Information* infomation) {1416 return AUI_Destroy(internal_context); 1417 } 1418 1419 AU_Result AU_Search(AU_Context context, AU_Information* infomation) { 1401 1420 AUI_API_PRECONDITION; 1402 return AUI_ GetInformation(internal_context, infomation);1403 } 1404 1405 AU_Result AU_ StartUpdate(AU_Context context) {1421 return AUI_Search(internal_context, infomation); 1422 } 1423 1424 AU_Result AU_Update(AU_Context context) { 1406 1425 AUI_API_PRECONDITION; 1407 return AUI_ StartUpdate(internal_context);1426 return AUI_Update(internal_context); 1408 1427 } 1409 1428 -
lang/c/AutoUpdater/trunk/recipes/Test.cpp
r38010 r38029 42 42 AU_Option option; 43 43 option.url = _T("http://www.lunaport.net/test/updates.xml"); 44 result = AU_Create Context(&context, &option);44 result = AU_Create(&context, &option); 45 45 if (result.error) { 46 46 printf("error1: %d\n", result.error); … … 49 49 50 50 do { 51 result = AU_ GetInformation(context, &information);52 printf("AU_ GetInformation(): "51 result = AU_Search(context, &information); 52 printf("AU_Search(): " 53 53 "list_downloaded_bytes=%dbytes, description_downloaded_bytes=%dbytes\n", 54 54 information.list_downloaded_bytes, information.description_downloaded_bytes … … 68 68 69 69 do { 70 result = AU_ StartUpdate(context);70 result = AU_Update(context); 71 71 Sleep(100); 72 AU_ GetInformation(context, &information);73 printf("AU_ GetInformation(): "72 AU_Search(context, &information); 73 printf("AU_Search(): " 74 74 "update_downloaded_bytes=%dbytes\n", 75 75 information.update_downloaded_bytes … … 86 86 } while (false); 87 87 88 AU_Destroy Context(context);88 AU_Destroy(context); 89 89 90 90 return 0; … … 290 290 TCHAR url[] = TEXT("http://aaaaaaaaa"); 291 291 AU_Option o = {}; 292 assert(AU_Create Context(NULL, &o).error == AU_ERROR_INVALID_CONTEXT);292 assert(AU_Create(NULL, &o).error == AU_ERROR_INVALID_CONTEXT); 293 293 294 294 { 295 295 AU_Context context; 296 assert(AU_Create Context(&context, &o).error == AU_ERROR_INVALID_OPTION);296 assert(AU_Create(&context, &o).error == AU_ERROR_INVALID_OPTION); 297 297 o.url = url; 298 assert(AU_Create Context(&context, &o).success);299 300 //assert(AU_Create Context(&context, &o) == AU_OK);298 assert(AU_Create(&context, &o).success); 299 300 //assert(AU_Create(&context, &o) == AU_OK); 301 301 302 assert(AU_Destroy Context(context).success);302 assert(AU_Destroy(context).success); 303 303 } 304 304 305 305 { 306 306 AU_Context context; 307 assert(AU_Create Context(&context, &o).success);308 assert(AU_Destroy Context(context).success);307 assert(AU_Create(&context, &o).success); 308 assert(AU_Destroy(context).success); 309 309 } 310 310 … … 312 312 AU_Information i = {0}; 313 313 AU_Context s = (AU_Context)malloc(sizeof(AU_Context)); 314 assert(AU_ GetInformation(s, &i).error == AU_ERROR_INVALID_CONTEXT);315 assert(AU_ StartUpdate(s).error == AU_ERROR_INVALID_CONTEXT);314 assert(AU_Search(s, &i).error == AU_ERROR_INVALID_CONTEXT); 315 assert(AU_Update(s).error == AU_ERROR_INVALID_CONTEXT); 316 316 assert(AU_Cancel(s).error == AU_ERROR_INVALID_CONTEXT); 317 assert(AU_Destroy Context(s).error == AU_ERROR_INVALID_CONTEXT);317 assert(AU_Destroy(s).error == AU_ERROR_INVALID_CONTEXT); 318 318 free(s); 319 319 } … … 323 323 AU_Context s = (AU_Context)malloc(sizeof(AU_Context)); 324 324 memset(s, 0, sizeof(s)); 325 assert(AU_ GetInformation(s, &i).error == AU_ERROR_INVALID_CONTEXT);326 assert(AU_ StartUpdate(s).error == AU_ERROR_INVALID_CONTEXT);325 assert(AU_Search(s, &i).error == AU_ERROR_INVALID_CONTEXT); 326 assert(AU_Update(s).error == AU_ERROR_INVALID_CONTEXT); 327 327 assert(AU_Cancel(s).error == AU_ERROR_INVALID_CONTEXT); 328 assert(AU_Destroy Context(s).error == AU_ERROR_INVALID_CONTEXT);328 assert(AU_Destroy(s).error == AU_ERROR_INVALID_CONTEXT); 329 329 free(s); 330 330 } … … 332 332 //{ 333 333 // AU_Context* context; 334 // assert(AU_Create Context(&context, CURRENT_VERSION, "http://www.google.co.jp:12345foo") == AU_ERROR_INVALID_URL_FORMAT);335 // assert(AU_Destroy Context(context) == AU_OK);334 // assert(AU_Create(&context, CURRENT_VERSION, "http://www.google.co.jp:12345foo") == AU_ERROR_INVALID_URL_FORMAT); 335 // assert(AU_Destroy(context) == AU_OK); 336 336 //} 337 337 338 338 //{ 339 // assert(AU_Create Context(NULL, CURRENT_VERSION, "http://www.google.co.jp:123 45 /foo") == AU_ERROR_INVALID_URL_FORMAT);339 // assert(AU_Create(NULL, CURRENT_VERSION, "http://www.google.co.jp:123 45 /foo") == AU_ERROR_INVALID_URL_FORMAT); 340 340 //} 341 341 342 342 //{ 343 343 // AU_Context* context; 344 // assert(AU_Create Context(&context, CURRENT_VERSION, "http://www.google.co.jp:123 45 /foo") == AU_ERROR_INVALID_URL_FORMAT);345 // assert(AU_Destroy Context(context) == AU_OK);344 // assert(AU_Create(&context, CURRENT_VERSION, "http://www.google.co.jp:123 45 /foo") == AU_ERROR_INVALID_URL_FORMAT); 345 // assert(AU_Destroy(context) == AU_OK); 346 346 //} 347 347
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)