Changeset 38029

Show
Ignore:
Timestamp:
07/27/10 22:19:29 (3 years ago)
Author:
saturday06
Message:

asdfadf

Location:
lang/c/AutoUpdater/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/c/AutoUpdater/trunk/AutoUpdater.h

    r37979 r38029  
    4646 
    4747/** 
    48  * �A�b�v�f�[�g�� 
     48 * AutoUpdater API�ŗ��p����A�b�v�f�[�g�t�@�C���Ƃ��̏����̐i�s���� 
    4949 */ 
    50 typedef struct AU_Information_ { 
     50typedef struct AU_Context_ { 
    5151    int found; 
    5252    const TCHAR* description; 
     
    5959    size_t update_downloaded_bytes; 
    6060    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; 
    6861} *AU_Context; 
    6962 
    7063/** 
    7164 * AU_Context������� */ 
    72 extern AU_Result AU_CreateContext(AU_Context* new_context, const AU_Option* option); 
     65extern AU_Result AU_Create(AU_Context* new_context, const AU_Option* option); 
    7366 
    7467/** 
    7568 * AU_Context�̃f�[�^������� */ 
    76 extern AU_Result AU_DestroyContext(AU_Context context); 
     69extern AU_Result AU_Destroy(AU_Context context); 
    7770 
    7871/** 
    7972 * AU_Context�̃A�b�v�f�[�g��������� */ 
    80 extern AU_Result AU_GetInformation(AU_Context context, AU_Information* infomation); 
     73extern AU_Result AU_Search(AU_Context context); 
    8174 
    8275/** 
    8376 * �f�[�^��E�����[�h���A 
    8477 * ���v���Z�X�̏I�����Ƀ_�E�����[�h�����t�@�C����J�������ɂ��� */ 
    85 extern AU_Result AU_StartUpdate(AU_Context context); 
     78extern AU_Result AU_Update(AU_Context context); 
    8679 
    8780/** 
    88  * AU_StartUpdate()�y��U_GetInformation()������Z������ */ 
     81 * AU_Update()�y��U_Search()������Z������ */ 
    8982extern AU_Result AU_Cancel(AU_Context context); 
    9083 
  • lang/c/AutoUpdater/trunk/recipes/Makefile.am

    r38016 r38029  
    22 
    33test_SOURCES   = Test.cpp Template.c 
    4 test_CPPFLAGS  = -I.. -DSTRICT -DUNICODE -D_UNICODE 
     4test_CPPFLAGS  = -I.. -DSTRICT #-DUNICODE -D_UNICODE 
    55test_CFLAGS    = -O0 -g 
    66test_CXXFLAGS  = -O0 -g 
  • lang/c/AutoUpdater/trunk/recipes/Template.c

    r38024 r38029  
    5151#    define _tcsdup AUI_wcsdup 
    5252#    define _tfopen(x, y) (NULL) 
     53#    define _tprintf wprintf 
    5354#  else 
    5455#    define _tcslen strlen 
     
    5758#    define _tcsdup AUI_strdup 
    5859#    define _tfopen fopen 
     60#    define _tprintf printf 
    5961#  endif 
    6062 
     
    103105    HINTERNET url_handle; 
    104106    int complete; 
    105     INTERNET_BUFFERS* ib; /* pointer for -Wpadded */ 
     107    INTERNET_BUFFERS* ib; /* pointer for gcc -Wpadded */ 
    106108} AUI_DownloadContext; 
    107109 
    108 const int AUI_CONTEXT_CREATED_SIGNATURE = 0x5aa5f00f; 
    109  
    110110typedef struct AUI_Context_ { 
    111     int created_signature; 
     111    AU_Context user; 
     112 
    112113    TCHAR* description; 
    113  
    114114    TCHAR* temp_dir_path; 
    115115    TCHAR* updater_file_path; 
     
    528528           parameter is NULL. */  
    529529        { 
    530  
     530            puts("INTERNET_STATUS_CLOSING_CONNECTION"); 
    531531        } 
    532532        break; 
     
    535535           pointed to by lpvStatusInformation. */ 
    536536        { 
    537  
     537            puts("INTERNET_STATUS_CONNECTED_TO_SERVER"); 
    538538        } 
    539539        break; 
     
    542542           lpvStatusInformation. */ 
    543543        { 
     544            puts("INTERNET_STATUS_CONNECTING_TO_SERVER"); 
    544545        } 
    545546        break; 
     
    548549           lpvStatusInformation parameter is NULL. */ 
    549550        { 
     551            puts("INTERNET_STATUS_CONNECTION_CLOSED"); 
    550552        } 
    551553        break; 
     
    559561           InternetCookieHistory structure. */ 
    560562        { 
     563            puts("INTERNET_STATUS_COOKIE_HISTORY"); 
    561564        } 
    562565        break; 
     
    568571           cookies received. */ 
    569572        { 
     573            puts("INTERNET_STATUS_COOKIE_RECEIVED"); 
    570574        } 
    571575        break; 
     
    576580           suppressed. */ 
    577581        { 
     582            puts("INTERNET_STATUS_COOKIE_SENT"); 
    578583        } 
    579584        break; 
     
    582587        /* Not implemented. */ 
    583588        { 
     589            puts("INTERNET_STATUS_CTL_RESPONSE_RECEIVED"); 
    584590        } 
    585591        break; 
     
    588594        /* Notifies the client application that a proxy has been detected. */ 
    589595        { 
     596            puts("INTERNET_STATUS_DETECTING_PROXY"); 
    590597        } 
    591598        break; 
     
    597604           handle being closed. */ 
    598605        { 
     606            puts("INTERNET_STATUS_HANDLE_CLOSING"); 
    599607        } 
    600608        break; 
     
    606614           HINTERNET handle. */ 
    607615        { 
    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); 
    610618        } 
    611619        break; 
     
    615623           from the server. */ 
    616624        { 
     625            puts("INTERNET_STATUS_INTERMEDIATE_RESPONSE"); 
    617626        } 
    618627        break; 
     
    623632           to a PCTSTR containing the host name. */ 
    624633        { 
     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                */ 
    625640        } 
    626641        break; 
     
    653668           lpvStatusInformation parameter is NULL. */ 
    654669        { 
     670            puts("INTERNET_STATUS_RECEIVING_RESPONSE"); 
    655671        } 
    656672        break; 
     
    664680           specified INTERNET_FLAG_NO_AUTO_REDIRECT. */ 
    665681        { 
     682            puts("INTERNET_STATUS_REDIRECT"); 
    666683        } 
    667684        break; 
     
    671688           INTERNET_ASYNC_RESULT structure. */ 
    672689        { 
     690            INTERNET_ASYNC_RESULT* async = (INTERNET_ASYNC_RESULT*)lpvStatusInformation; 
    673691            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); 
    674694        } 
    675695        break; 
     
    679699           contains the number of bytes sent. */ 
    680700        { 
     701            _tprintf(_T("INTERNET_STATUS_REQUEST_SENT bytes=%d\n"), (int)*(DWORD*)lpvStatusInformation); 
    681702        } 
    682703        break; 
     
    686707           to a PCTSTR containing the host name. */ 
    687708        { 
     709            _tprintf(_T("INTERNET_STATUS_RESOLVING_NAME %s\n"),  
     710                (const TCHAR*)lpvStatusInformation); 
    688711        } 
    689712        break; 
     
    691714        /* Successfully received a response from the server. */ 
    692715        { 
     716            _tprintf(_T("INTERNET_STATUS_RESPONSE_RECEIVED bytes=%d\n"),  
     717                     (int)*(DWORD*)lpvStatusInformation); 
    693718        } 
    694719        break; 
     
    697722           lpvStatusInformation parameter is NULL. */ 
    698723        { 
     724            puts("INTERNET_STATUS_SENDING_REQUEST"); 
    699725        } 
    700726        break; 
     
    810836*/ 
    811837 
    812 AU_Result AUI_CreateContext(AUI_Context* context, const AU_Option* option) { 
     838AU_Result AUI_Create(AUI_Context* context, const AU_Option* option) { 
    813839    AU_Result r; 
    814840    if (!option   || 
     
    916942} 
    917943 
    918 AU_Result AUI_DestroyContext(AUI_Context* context) { 
    919     context->created_signature = 0; 
    920  
     944AU_Result AUI_Destroy(AUI_Context* context) { 
    921945    if (!context->ready) { 
    922946        AUI_DeleteDirectory(context->temp_dir_path); 
     
    11701194} 
    11711195 
    1172 AU_Result AUI_GetInformation(AUI_Context* context, AU_Information* information) { 
     1196AU_Result AUI_Search(AUI_Context* context, AU_Information* information) { 
    11731197    AU_Result r; 
    11741198    memset(information, 0, sizeof(*information)); 
     
    11991223extern const char AUI_UPDATER_DATA[]; 
    12001224 
    1201 AU_Result AUI_StartUpdate(AUI_Context* context) { 
     1225AU_Result AUI_Update(AUI_Context* context) { 
    12021226    AU_Result r; 
    12031227    if (!context->found) { 
    12041228        AU_Information i; 
    1205         r = AUI_GetInformation(context, &i); 
     1229        r = AUI_Search(context, &i); 
    12061230        if (!r.success) { 
    12071231            return r; 
     
    13411365    } 
    13421366 
    1343     if (internal_context->created_signature != AUI_CONTEXT_CREATED_SIGNATURE) { 
    1344         AUI_GOTO_ERROR_RETURN(AU_ERROR_INVALID_CONTEXT); 
    1345     } 
    1346  
    13471367    *internal_context_output = internal_context; 
    13481368 
     
    13661386} 
    13671387 
    1368 AU_Result AU_CreateContext(AU_Context* pcontext, const AU_Option* option) { 
     1388AU_Result AU_Create(AU_Context* pcontext, const AU_Option* option) { 
    13691389    AU_Context context = NULL; 
    13701390 
     
    13781398            return E(AU_ERROR_BAD_ALLOC); 
    13791399        } 
    1380         internal_context->created_signature = AUI_CONTEXT_CREATED_SIGNATURE; 
    13811400        context = (AU_Context)internal_context; 
    13821401    } 
     
    13851404        AU_Result result; 
    13861405        AUI_API_PRECONDITION; 
    1387         result = AUI_CreateContext(internal_context, option); 
     1406        result = AUI_Create(internal_context, option); 
    13881407        if (result.success) { 
    13891408            *pcontext = context; 
     
    13931412} 
    13941413 
    1395 AU_Result AU_DestroyContext(AU_Context context) { 
     1414AU_Result AU_Destroy(AU_Context context) { 
    13961415    AUI_API_PRECONDITION; 
    1397     return AUI_DestroyContext(internal_context); 
    1398 } 
    1399  
    1400 AU_Result AU_GetInformation(AU_Context context, AU_Information* infomation) { 
     1416    return AUI_Destroy(internal_context); 
     1417} 
     1418 
     1419AU_Result AU_Search(AU_Context context, AU_Information* infomation) { 
    14011420    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 
     1424AU_Result AU_Update(AU_Context context) { 
    14061425    AUI_API_PRECONDITION; 
    1407     return AUI_StartUpdate(internal_context); 
     1426    return AUI_Update(internal_context); 
    14081427} 
    14091428 
  • lang/c/AutoUpdater/trunk/recipes/Test.cpp

    r38010 r38029  
    4242        AU_Option option; 
    4343                option.url = _T("http://www.lunaport.net/test/updates.xml"); 
    44         result = AU_CreateContext(&context, &option); 
     44        result = AU_Create(&context, &option); 
    4545        if (result.error) { 
    4646            printf("error1: %d\n", result.error); 
     
    4949 
    5050        do { 
    51             result = AU_GetInformation(context, &information); 
    52             printf("AU_GetInformation(): " 
     51            result = AU_Search(context, &information); 
     52            printf("AU_Search(): " 
    5353                "list_downloaded_bytes=%dbytes, description_downloaded_bytes=%dbytes\n", 
    5454                information.list_downloaded_bytes, information.description_downloaded_bytes 
     
    6868 
    6969        do { 
    70             result = AU_StartUpdate(context); 
     70            result = AU_Update(context); 
    7171            Sleep(100); 
    72             AU_GetInformation(context, &information); 
    73             printf("AU_GetInformation(): " 
     72            AU_Search(context, &information); 
     73            printf("AU_Search(): " 
    7474                "update_downloaded_bytes=%dbytes\n", 
    7575                information.update_downloaded_bytes 
     
    8686    } while (false); 
    8787 
    88     AU_DestroyContext(context); 
     88    AU_Destroy(context); 
    8989 
    9090    return 0; 
     
    290290    TCHAR url[] = TEXT("http://aaaaaaaaa"); 
    291291        AU_Option o = {}; 
    292     assert(AU_CreateContext(NULL, &o).error == AU_ERROR_INVALID_CONTEXT); 
     292    assert(AU_Create(NULL, &o).error == AU_ERROR_INVALID_CONTEXT); 
    293293 
    294294    { 
    295295        AU_Context context; 
    296         assert(AU_CreateContext(&context, &o).error == AU_ERROR_INVALID_OPTION); 
     296        assert(AU_Create(&context, &o).error == AU_ERROR_INVALID_OPTION); 
    297297        o.url = url; 
    298         assert(AU_CreateContext(&context, &o).success); 
    299  
    300         //assert(AU_CreateContext(&context, &o) == AU_OK); 
     298        assert(AU_Create(&context, &o).success); 
     299 
     300        //assert(AU_Create(&context, &o) == AU_OK); 
    301301         
    302         assert(AU_DestroyContext(context).success); 
     302        assert(AU_Destroy(context).success); 
    303303    } 
    304304 
    305305    { 
    306306        AU_Context context; 
    307         assert(AU_CreateContext(&context, &o).success); 
    308         assert(AU_DestroyContext(context).success); 
     307        assert(AU_Create(&context, &o).success); 
     308        assert(AU_Destroy(context).success); 
    309309    } 
    310310 
     
    312312        AU_Information i = {0}; 
    313313        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); 
    316316        assert(AU_Cancel(s).error == AU_ERROR_INVALID_CONTEXT);         
    317         assert(AU_DestroyContext(s).error == AU_ERROR_INVALID_CONTEXT);         
     317        assert(AU_Destroy(s).error == AU_ERROR_INVALID_CONTEXT);         
    318318        free(s); 
    319319    } 
     
    323323        AU_Context s = (AU_Context)malloc(sizeof(AU_Context)); 
    324324        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); 
    327327        assert(AU_Cancel(s).error == AU_ERROR_INVALID_CONTEXT);         
    328         assert(AU_DestroyContext(s).error == AU_ERROR_INVALID_CONTEXT);         
     328        assert(AU_Destroy(s).error == AU_ERROR_INVALID_CONTEXT);         
    329329        free(s); 
    330330    } 
     
    332332    //{ 
    333333    //    AU_Context* context; 
    334     //    assert(AU_CreateContext(&context, CURRENT_VERSION, "http://www.google.co.jp:12345foo") == AU_ERROR_INVALID_URL_FORMAT); 
    335     //    assert(AU_DestroyContext(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); 
    336336    //} 
    337337 
    338338    //{ 
    339     //    assert(AU_CreateContext(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);         
    340340    //} 
    341341 
    342342    //{ 
    343343    //    AU_Context* context; 
    344     //    assert(AU_CreateContext(&context, CURRENT_VERSION, "http://www.google.co.jp:123 45 /foo") == AU_ERROR_INVALID_URL_FORMAT); 
    345     //    assert(AU_DestroyContext(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); 
    346346    //} 
    347347