Changeset 38013

Show
Ignore:
Timestamp:
07/25/10 13:43:35 (3 years ago)
Author:
saturday06
Message:

sedai

Location:
lang/c/AutoUpdater/trunk/recipes
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • lang/c/AutoUpdater/trunk/recipes/AutoUpdater.vcproj

    r37982 r38013  
    199199                                > 
    200200                        </File> 
     201                        <File 
     202                                RelativePath=".\XDef.h" 
     203                                > 
     204                        </File> 
    201205                </Filter> 
    202206                <Filter 
  • lang/c/AutoUpdater/trunk/recipes/Copy.c

    r38010 r38013  
     1#ifndef _UNICODE 
     2#error 
     3#endif 
     4 
    15#include <windows.h> 
    2  
    3 #define _T(x) TEXT(x) 
     6#include <tchar.h> 
     7#include <commctrl.h> 
     8 
    49 
    510/* http://msdn.microsoft.com/en-us/library/bb531404.aspx */ 
    611/* swap _M_IX86 and _M_X64 */ 
    7 #ifdef UNICODE 
    812#if defined _M_X64 
    913#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 
     
    1418#else 
    1519#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 
    16 #endif 
    1720#endif 
    1821 
  • lang/c/AutoUpdater/trunk/recipes/Copy.vcproj

    r37991 r38013  
    6363                        <Tool 
    6464                                Name="VCLinkerTool" 
     65                                AdditionalDependencies="comctl32.lib" 
    6566                                LinkIncremental="2" 
    6667                                GenerateManifest="true" 
  • lang/c/AutoUpdater/trunk/recipes/Makefile.am

    r38010 r38013  
    33test_SOURCES   = Test.cpp Template.c 
    44test_CPPFLAGS  = -I.. -DSTRICT #-DUNICODE -D_UNICODE 
     5test_CFLAGS    = -O0 -g 
     6test_CXXFLAGS  = -O0 -g 
    57test_LDADD     = -lole32 -loleaut32 -luuid -lwininet -lshlwapi 
    68 
  • lang/c/AutoUpdater/trunk/recipes/Template.c

    r38010 r38013  
    7979    bytes = strlen(s) + 1; 
    8080    buf = (char*)calloc(bytes, 1); 
    81         if (!buf) { 
     81    if (!buf) { 
    8282        return NULL; 
    83         } 
     83    } 
    8484    memcpy(buf, s, bytes); 
    8585    return buf; 
     
    9191    bytes = (wcslen(s) + 1) * sizeof(wchar_t); 
    9292    buf = (wchar_t*)calloc(bytes, 1); 
    93         if (!buf) { 
     93    if (!buf) { 
    9494        return NULL; 
    95         } 
     95    } 
    9696    memcpy(buf, s, bytes); 
    9797    return buf; 
     
    103103    TCHAR* url; 
    104104    FILE* fp; 
    105  
    106105    HINTERNET internet_handle; 
    107106    HANDLE request_complete_event; 
    108107    int url_handle_requested; 
    109108    int wait_request_complete; 
    110     char buffer[1000]; 
    111     INTERNET_BUFFERS ib; 
    112  
     109    char buffer[1024]; 
    113110    HINTERNET url_handle; 
    114111    int complete; 
     112    INTERNET_BUFFERS* ib; /* pointer for -Wpadded */ 
    115113} AUI_DownloadContext; 
    116114 
     
    151149 
    152150AU_Result E(AU_Error error) { 
    153         AU_Result result; 
     151    AU_Result result; 
    154152    result.success = 0; 
    155153    result.pending = 0; 
    156         result.error = error; 
     154    result.error = error; 
    157155    return result; 
    158156} 
     
    170168    TCHAR* result = NULL; 
    171169    size_t result_len = 0; 
    172      
     170 
    173171    result_len = _tcslen(base) + 1 + _tcslen(append) + 1; 
    174172    result = (TCHAR*)calloc(result_len * sizeof(TCHAR), 1); 
     
    206204 
    207205    if (!WideCharToMultiByte( 
    208             CP_ACP, 
    209             0, 
    210             w, 
    211             -1, 
    212             m, 
    213             bytes, 
    214             NULL, 
    215             NULL 
    216             )) { 
    217         free(m); 
    218         return NULL; 
     206        CP_ACP, 
     207        0, 
     208        w, 
     209        -1, 
     210        m, 
     211        bytes, 
     212        NULL, 
     213        NULL 
     214        )) { 
     215            free(m); 
     216            return NULL; 
    219217    } 
    220218 
     
    244242 
    245243    if (!MultiByteToWideChar( 
    246             CP_ACP, 
    247             0, 
    248             m, 
    249             -1, 
    250             w, 
    251             count 
    252             )) { 
    253         free(w); 
    254         return NULL; 
    255     } 
    256      
     244        CP_ACP, 
     245        0, 
     246        m, 
     247        -1, 
     248        w, 
     249        count 
     250        )) { 
     251            free(w); 
     252            return NULL; 
     253    } 
     254 
    257255    return w; 
    258256} 
     
    286284 
    287285    *result = NULL; 
    288      
     286 
    289287    system_temp_path_chars = GetTempPath(0, NULL); 
    290288    system_temp_path = (TCHAR*)calloc(system_temp_path_chars * sizeof(TCHAR), 1); 
     
    302300        args[1] = (unsigned int)GetTickCount(); 
    303301        if (!FormatMessage( 
    304                 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, 
    305                 _T("AutoUpdater.%1!x!.%2!x!"), 
    306                 0, 
    307                 0, 
    308                 (TCHAR*)&allocated, 
    309                 0, 
    310                 (va_list*)args)) { 
    311             return E(AU_ERROR_BAD_ALLOC); 
     302            FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, 
     303            _T("AutoUpdater.%1!x!.%2!x!"), 
     304            0, 
     305            0, 
     306            (TCHAR*)&allocated, 
     307            0, 
     308            (va_list*)args)) { 
     309                return E(AU_ERROR_BAD_ALLOC); 
    312310        } 
    313311        dir = (TCHAR*)allocated; 
     
    335333/* http://support.microsoft.com/kb/238393 */ 
    336334HRESULT AUI_AutoWrap(WORD autoType, VARIANT *pvResult, IDispatch *pDisp, 
    337                  const OLECHAR* ptcName, size_t cArgs, VARIANT* rargs) 
     335                     const OLECHAR* ptcName, size_t cArgs, VARIANT* rargs) 
    338336{ 
    339337    DISPPARAMS dp = { NULL, NULL, 0, 0 }; 
     
    354352    } 
    355353 
    356         if (pvResult) { 
    357                 VariantInit(pvResult); 
    358         } 
     354    if (pvResult) { 
     355        VariantInit(pvResult); 
     356    } 
    359357 
    360358#ifdef __cplusplus 
     
    389387 
    390388#ifdef __cplusplus 
    391     hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_USER_DEFAULT, autoType, 
    392              &dp, pvResult, NULL, NULL); 
     389    hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_USER_DEFAULT, 
     390                       autoType, &dp, pvResult, NULL, NULL); 
    393391#else 
    394     hr = pDisp->lpVtbl->Invoke(pDisp, dispID, &IID_NULL, LOCALE_USER_DEFAULT, autoType, 
    395              &dp, pvResult, NULL, NULL); 
     392    hr = pDisp->lpVtbl->Invoke(pDisp, dispID, &IID_NULL, LOCALE_USER_DEFAULT,  
     393                               autoType, &dp, pvResult, NULL, NULL); 
    396394#endif 
    397395 
     
    418416    } 
    419417#ifdef __cplusplus 
    420         pd->AddRef(); 
     418    pd->AddRef(); 
    421419#else 
    422         pd->lpVtbl->AddRef(pd); 
     420    pd->lpVtbl->AddRef(pd); 
    423421#endif 
    424422} 
     
    429427    } 
    430428#ifdef __cplusplus 
    431         pd->Release(); 
     429    pd->Release(); 
    432430#else 
    433         pd->lpVtbl->Release(pd); 
     431    pd->lpVtbl->Release(pd); 
    434432#endif 
    435433} 
     
    456454            return E(AU_ERROR_NETWORK); 
    457455        } 
    458                 context->wait_request_complete = 1; 
     456        context->wait_request_complete = 1; 
    459457    } 
    460458 
     
    473471    context->wait_request_complete = 0; 
    474472 
    475         if (!context->url_handle) { 
    476                 return E(AU_ERROR_SYSTEM); 
    477         } 
     473    if (!context->url_handle) { 
     474        return E(AU_ERROR_SYSTEM); 
     475    } 
    478476 
    479477    { 
     
    483481        memset(&(context->buffer), 0, sizeof(context->buffer)); 
    484482        memset(&(context->ib), 0, sizeof(context->ib)); 
    485         context->ib.dwStructSize = sizeof(context->ib); 
    486         context->ib.lpvBuffer = context->buffer; 
    487         context->ib.dwBufferLength = sizeof(context->buffer); 
     483        context->ib->dwStructSize = sizeof(context->ib); 
     484        context->ib->lpvBuffer = context->buffer; 
     485        context->ib->dwBufferLength = sizeof(context->buffer); 
    488486        read_result = InternetReadFileEx( 
    489                           context->url_handle, 
    490                           &(context->ib), 
    491                           IRF_ASYNC | IRF_USE_CONTEXT | IRF_NO_WAIT, 
    492                           (DWORD_PTR)context); 
     487            context->url_handle, 
     488            context->ib, 
     489            IRF_ASYNC | IRF_USE_CONTEXT | IRF_NO_WAIT, 
     490            (DWORD_PTR)context); 
    493491        e = GetLastError(); 
    494492        if (!read_result && e == ERROR_IO_PENDING) { 
     
    500498            return E(AU_ERROR_NETWORK); 
    501499        } 
    502          
    503     } 
    504     if (context->ib.dwBufferLength == 0) { 
     500 
     501    } 
     502    if (context->ib->dwBufferLength == 0) { 
    505503        fclose(context->fp); 
    506504        context->fp = NULL; 
     
    509507    } 
    510508 
    511     if (fwrite(context->buffer, 1, context->ib.dwBufferLength, context->fp) != context->ib.dwBufferLength) { 
     509    if (fwrite(context->buffer, 1, context->ib->dwBufferLength, context->fp) != context->ib->dwBufferLength) { 
    512510        return E(AU_ERROR_SYSTEM); 
    513511    } 
     
    515513} 
    516514 
     515/* http://msdn.microsoft.com/en-us/library/aa385121.aspx */ 
    517516void CALLBACK AUI_InternetStatusCallback( 
    518517    HINTERNET hInternet, 
     
    524523    AUI_DownloadContext* context = (AUI_DownloadContext*)dwContext; 
    525524 
     525    (void)hInternet; 
     526    (void)dwStatusInformationLength; 
     527 
    526528    switch (dwInternetStatus) { 
    527     case INTERNET_STATUS_HANDLE_CREATED:  
     529    case INTERNET_STATUS_CLOSING_CONNECTION: 
     530        /* Closing the connection to the server. The lpvStatusInformation  
     531           parameter is NULL. */  
     532        { 
     533 
     534        } 
     535        break; 
     536    case INTERNET_STATUS_CONNECTED_TO_SERVER: 
     537        /* Successfully connected to the socket address (SOCKADDR)  
     538           pointed to by lpvStatusInformation. */ 
     539        { 
     540 
     541        } 
     542        break; 
     543    case INTERNET_STATUS_CONNECTING_TO_SERVER: 
     544        /* Connecting to the socket address (SOCKADDR) pointed to by  
     545           lpvStatusInformation. */ 
     546        { 
     547        } 
     548        break; 
     549    case INTERNET_STATUS_CONNECTION_CLOSED: 
     550        /* Successfully closed the connection to the server. The  
     551           lpvStatusInformation parameter is NULL. */ 
     552        { 
     553        } 
     554        break; 
     555#if 0 
     556    case INTERNET_STATUS_COOKIE_HISTORY: 
     557        /* Retrieving content from the cache. Contains data about past  
     558           cookie events for the URL such as if cookies were accepted,  
     559           rejected, downgraded, or leashed. 
     560 
     561           The lpvStatusInformation parameter is a pointer to an  
     562           InternetCookieHistory structure. */ 
     563        { 
     564        } 
     565        break; 
     566    case INTERNET_STATUS_COOKIE_RECEIVED: 
     567        /* Indicates the number of cookies that were accepted, rejected,  
     568           downgraded (changed from persistent to session cookies), or  
     569           leashed (will be sent out only in 1st party context). The  
     570           lpvStatusInformation parameter is a DWORD with the number of  
     571           cookies received. */ 
     572        { 
     573        } 
     574        break; 
     575    case INTERNET_STATUS_COOKIE_SENT: 
     576        /* Indicates the number of cookies that were either sent or  
     577           suppressed, when a request is sent. The lpvStatusInformation  
     578           parameter is a DWORD with the number of cookies sent or  
     579           suppressed. */ 
     580        { 
     581        } 
     582        break; 
     583#endif 
     584    case INTERNET_STATUS_CTL_RESPONSE_RECEIVED: 
     585        /* Not implemented. */ 
     586        { 
     587        } 
     588        break; 
     589#if 0 
     590    case INTERNET_STATUS_DETECTING_PROXY: 
     591        /* Notifies the client application that a proxy has been detected. */ 
     592        { 
     593        } 
     594        break; 
     595#endif 
     596    case INTERNET_STATUS_HANDLE_CLOSING: 
     597        /* This handle value has been terminated. pvStatusInformation  
     598           contains the address of the handle being closed. The  
     599           lpvStatusInformation parameter contains the address of the  
     600           handle being closed. */ 
     601        { 
     602        } 
     603        break; 
     604    case INTERNET_STATUS_HANDLE_CREATED: 
     605        /* Used by InternetConnect to indicate it has created the new  
     606           handle. This lets the application call InternetCloseHandle  
     607           from another thread, if the connect is taking too long. The  
     608           lpvStatusInformation parameter contains the address of an  
     609           HINTERNET handle. */ 
    528610        { 
    529611            INTERNET_ASYNC_RESULT* async_result = (INTERNET_ASYNC_RESULT*)lpvStatusInformation; 
     
    531613        } 
    532614        break; 
    533     case INTERNET_STATUS_CONNECTION_CLOSED: 
     615#if 0 
     616    case INTERNET_STATUS_INTERMEDIATE_RESPONSE: 
     617        /* Received an intermediate (100 level) status code message  
     618           from the server. */ 
     619        { 
     620        } 
     621        break; 
     622#endif 
     623    case INTERNET_STATUS_NAME_RESOLVED: 
     624        /* Successfully found the IP address of the name contained in  
     625           lpvStatusInformation. The lpvStatusInformation parameter points  
     626           to a PCTSTR containing the host name. */ 
     627        { 
     628        } 
     629        break; 
     630#if 0 
     631    case INTERNET_STATUS_P3P_HEADER: 
     632        /* The response has a P3P header in it. */ 
     633        { 
     634        } 
     635        break; 
     636    case INTERNET_STATUS_P3P_POLICYREF: 
     637        /* Not implemented. */ 
     638        { 
     639        } 
     640        break; 
     641#endif 
     642    case INTERNET_STATUS_PREFETCH: 
     643        /* Not implemented. */ 
     644        { 
     645        } 
     646        break; 
     647#if 0 
     648    case INTERNET_STATUS_PRIVACY_IMPACTED: 
     649        /* Not implemented. */ 
     650        { 
     651        } 
     652        break; 
     653#endif 
     654    case INTERNET_STATUS_RECEIVING_RESPONSE: 
     655        /* Waiting for the server to respond to a request. The  
     656           lpvStatusInformation parameter is NULL. */ 
     657        { 
     658        } 
     659        break; 
     660    case INTERNET_STATUS_REDIRECT: 
     661        /* An HTTP request is about to automatically redirect the request.  
     662           The lpvStatusInformation parameter points to the new URL.  
     663           At this point, the application can read any data returned  
     664           by the server with the redirect response and can query the  
     665           response headers. It can also cancel the operation by closing  
     666           the handle. This callback is not made if the original request  
     667           specified INTERNET_FLAG_NO_AUTO_REDIRECT. */ 
     668        { 
     669        } 
    534670        break; 
    535671    case INTERNET_STATUS_REQUEST_COMPLETE: 
    536         SetEvent(context->request_complete_event); 
    537         break; 
     672        /* An asynchronous operation has been completed. The  
     673           lpvStatusInformation parameter contains the address of an  
     674           INTERNET_ASYNC_RESULT structure. */ 
     675        { 
     676            SetEvent(context->request_complete_event); 
     677        } 
     678        break; 
     679    case INTERNET_STATUS_REQUEST_SENT: 
     680        /* Successfully sent the information request to the server. The  
     681           lpvStatusInformation parameter points to a DWORD value that  
     682           contains the number of bytes sent. */ 
     683        { 
     684        } 
     685        break; 
     686    case INTERNET_STATUS_RESOLVING_NAME: 
     687        /* Looking up the IP address of the name contained in  
     688           lpvStatusInformation. The lpvStatusInformation parameter points  
     689           to a PCTSTR containing the host name. */ 
     690        { 
     691        } 
     692        break; 
     693    case INTERNET_STATUS_RESPONSE_RECEIVED: 
     694        /* Successfully received a response from the server. */ 
     695        { 
     696        } 
     697        break; 
     698    case INTERNET_STATUS_SENDING_REQUEST: 
     699        /* Sending the information request to the server. The  
     700           lpvStatusInformation parameter is NULL. */ 
     701        { 
     702        } 
     703        break; 
     704#if 0 
     705    case INTERNET_STATUS_STATE_CHANGE: 
     706        /* Moved between a secure (HTTPS) and a nonsecure (HTTP) site.  
     707           The user must be informed of this change; otherwise, the user  
     708           is at risk of disclosing sensitive information involuntarily.  
     709           When this flag is set, the lpvStatusInformation parameter points  
     710           to a status DWORD that contains additional flags. */ 
     711        { 
     712        } 
     713        break; 
     714#endif 
    538715    default: 
    539716        break; 
     
    550727    } 
    551728 
     729    context->ib = (INTERNET_BUFFERS*)calloc(sizeof(*context->ib), 1); 
     730    if (!context->ib) { 
     731        return E(AU_ERROR_BAD_ALLOC); 
     732    } 
     733 
    552734    context->url = _tcsdup(url); 
    553735    if (!context->url) { 
     
    562744    _tfopen_s(&context->fp, context->file_path, _T("wb")); 
    563745 
    564         if (!context->fp) { 
    565                 return E(AU_ERROR_SYSTEM); 
    566         } 
     746    if (!context->fp) { 
     747        return E(AU_ERROR_SYSTEM); 
     748    } 
    567749 
    568750    context->request_complete_event = CreateEvent(NULL, FALSE, FALSE, NULL); 
    569         if (!context->request_complete_event) { 
    570                 return E(AU_ERROR_SYSTEM); 
    571         } 
     751    if (!context->request_complete_event) { 
     752        return E(AU_ERROR_SYSTEM); 
     753    } 
    572754 
    573755    context->internet_handle =  
    574756        InternetOpen( 
    575             TEXT("saturday06's AutoUpdater"),  
    576             INTERNET_OPEN_TYPE_PRECONFIG,  
    577             NULL,  
    578             NULL,  
    579             INTERNET_FLAG_ASYNC); 
     757        TEXT("saturday06's AutoUpdater"),  
     758        INTERNET_OPEN_TYPE_PRECONFIG,  
     759        NULL,  
     760        NULL,  
     761        INTERNET_FLAG_ASYNC); 
    580762 
    581763    if (!context->internet_handle) { 
     
    584766 
    585767    if (InternetSetStatusCallback(context->internet_handle, AUI_InternetStatusCallback) 
    586             == INTERNET_INVALID_STATUS_CALLBACK) { 
    587         return E(AU_ERROR_SYSTEM); 
     768        == INTERNET_INVALID_STATUS_CALLBACK) { 
     769            return E(AU_ERROR_SYSTEM); 
    588770    } 
    589771 
     
    596778    if (AUI_IsBadReadPointer(context, sizeof(context)) ||  
    597779        AUI_IsBadWritePointer(context, sizeof(context))) { 
    598         return E(AU_ERROR_SYSTEM); 
     780            return E(AU_ERROR_SYSTEM); 
     781    } 
     782    if (context->ib) { 
     783        free(context->ib); 
    599784    } 
    600785    if (context->fp) { 
     
    623808/* 
    624809DWORD CALLBACK AUI_WindowsUpdateThread(LPVOID context_) { 
    625     AUI_UpdaterThread((AUI_Context*)context_); 
    626     return 0; 
     810AUI_UpdaterThread((AUI_Context*)context_); 
     811return 0; 
    627812} 
    628813*/ 
     
    634819        AUI_IsBadReadPointer(option, sizeof(*option)) || 
    635820        AUI_IsBadReadPointer(option->url, 1)) { 
    636         return E(AU_ERROR_INVALID_OPTION); 
     821            return E(AU_ERROR_INVALID_OPTION); 
    637822    } 
    638823 
     
    693878void AUI_DeleteDirectory(const TCHAR* dir) { 
    694879    TCHAR* glob = NULL; 
    695         WIN32_FIND_DATA find_data; 
     880    WIN32_FIND_DATA find_data; 
    696881    HANDLE hFind = NULL; 
    697882 
     
    701886 
    702887    glob = AUI_PathAppendDup(dir, _T("*")); 
    703         hFind = FindFirstFile(glob, &find_data); 
    704         if( INVALID_HANDLE_VALUE == hFind ) { 
    705                 return; 
    706         } 
    707  
    708         do { 
     888    hFind = FindFirstFile(glob, &find_data); 
     889    if( INVALID_HANDLE_VALUE == hFind ) { 
     890        return; 
     891    } 
     892 
     893    do { 
    709894        TCHAR* dir2 = NULL; 
    710895 
     
    719904        dir2 = AUI_PathAppendDup(dir, find_data.cFileName); 
    720905 
    721                 if (FILE_ATTRIBUTE_DIRECTORY & find_data.dwFileAttributes) { 
     906        if (FILE_ATTRIBUTE_DIRECTORY & find_data.dwFileAttributes) { 
    722907            AUI_DeleteDirectory(dir2); 
    723908        } else { 
    724909            DeleteFile(dir2); 
    725                 } 
     910        } 
    726911 
    727912        free(dir2); 
     
    729914    } while(FindNextFile(hFind, &find_data)); 
    730915 
    731         FindClose(hFind); 
     916    FindClose(hFind); 
    732917    free(glob); 
    733         return; 
     918    return; 
    734919} 
    735920 
     
    788973    IDispatch* releaseNode = NULL; 
    789974    IDispatch* urlNode = NULL; 
    790     IDispatch* descriptionNode = NULL; 
     975    /* IDispatch* descriptionNode = NULL; */ 
    791976 
    792977    r = E(AU_ERROR_SYSTEM); 
     
    8311016            PVOID cast = 0; 
    8321017            result = CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, &cast); 
    833                         Microsoft_XMLDOM = (IDispatch*)cast; 
     1018            Microsoft_XMLDOM = (IDispatch*)cast; 
    8341019        } 
    8351020#endif 
     
    8621047    } 
    8631048 
    864      
     1049 
    8651050    { /* Microsoft_XMLDOM.async = false */ 
    8661051        args[0].vt = VT_BOOL; 
     
    8691054    } 
    8701055 
    871      
     1056 
    8721057    { /* Microsoft_XMLDOM.load("file.xml") */ 
    8731058        args[0].vt = VT_BSTR; 
    8741059        /* args[0].bstrVal = SysAllocString(OLESTR("c:/Documents and Settings/saturday06/My Documents/My Dropbox/jsxml.xml")); */ 
    875                 /* args[0].bstrVal = SysAllocString(OLESTR("D:/Documents/My Dropbox/jsxml.xml")); */ 
     1060        /* args[0].bstrVal = SysAllocString(OLESTR("D:/Documents/My Dropbox/jsxml.xml")); */ 
    8761061        args[0].bstrVal = AUI_TCharToBStrDup(context->releases_file_path); 
    8771062        result = AUI_AutoWrap(DISPATCH_METHOD, &returnValue, Microsoft_XMLDOM, OLESTR("load"), 1, args); 
     
    8791064            goto clean_up; 
    8801065        } 
    881                 if (!returnValue.boolVal) { 
    882                         goto clean_up; 
    883                 } 
     1066        if (!returnValue.boolVal) { 
     1067            goto clean_up; 
     1068        } 
    8841069        VariantClear(&returnValue); 
    8851070    } 
     
    8881073        args[0].vt = VT_BSTR; 
    8891074        args[0].bstrVal = SysAllocString(OLESTR("SelectionLanguage")); 
    890                 if (!args[0].bstrVal) { 
    891                         goto clean_up; 
    892                 } 
     1075        if (!args[0].bstrVal) { 
     1076            goto clean_up; 
     1077        } 
    8931078        args[1].vt = VT_BSTR; 
    8941079        args[1].bstrVal = SysAllocString(OLESTR("XPath")); 
    895                 if (!args[1].bstrVal) { 
    896                         goto clean_up; 
    897                 } 
     1080        if (!args[1].bstrVal) { 
     1081            goto clean_up; 
     1082        } 
    8981083        result = AUI_AutoWrap(DISPATCH_METHOD, NULL, Microsoft_XMLDOM, OLESTR("setProperty"), 2, args); 
    8991084        if (FAILED(result)) { 
     
    9011086        } 
    9021087    } 
    903      
     1088 
    9041089    { /* var documentElement = Microsoft_XMLDOM.documentElement */ 
    9051090        result = AUI_AutoWrap(DISPATCH_PROPERTYGET, &returnValue, Microsoft_XMLDOM, OLESTR("documentElement"), 0, NULL); 
     
    9191104        memset(xpath, 0, sizeof(xpath)); 
    9201105        wsprintf(xpath, /* TODO */ 
    921                  _T("/releases/release[not(@debug) or @debug <= %d][") 
    922                  _T("not(@revision <= preceding-sibling::release[not(@debug) or @debug <= %d]/@revision) and ") 
    923                  _T("not(@revision <= following-sibling::release[not(@debug) or @debug <= %d]/@revision)]") 
     1106            _T("/releases/release[not(@debug) or @debug <= %d][") 
     1107            _T("not(@revision <= preceding-sibling::release[not(@debug) or @debug <= %d]/@revision) and ") 
     1108            _T("not(@revision <= following-sibling::release[not(@debug) or @debug <= %d]/@revision)]") 
    9241109            , context->download_debug, context->download_debug, context->download_debug 
    9251110            ); 
     
    9411126        VariantClear(&returnValue); 
    9421127    } 
    943      
     1128 
    9441129    { /* var urlNode = releaseNode.selectSingleNode("url"); */ 
    9451130        args[0].vt = VT_BSTR; 
     
    9841169    r = AUI_SUCCESS; 
    9851170clean_up: 
    986         AUI_IDispatchRelease(urlNode); 
    987         AUI_IDispatchRelease(releaseNode); 
     1171    AUI_IDispatchRelease(urlNode); 
     1172    AUI_IDispatchRelease(releaseNode); 
    9881173    AUI_IDispatchRelease(Microsoft_XMLDOM); 
    9891174 
     
    10741259 
    10751260        _tfopen_s(&f, context->updater_config_file_path, _T("wb")); 
    1076                 if (!f) { 
     1261        if (!f) { 
    10771262            return E(AU_ERROR_SYSTEM); 
    1078                 } 
     1263        } 
    10791264 
    10801265        { 
     
    11041289                0, 
    11051290                (va_list*)args)) { 
    1106                 return E(AU_ERROR_BAD_ALLOC); 
     1291                    return E(AU_ERROR_BAD_ALLOC); 
    11071292            } 
    11081293            data = AUI_TCharToWideCharDup((TCHAR*)allocated); 
     
    11171302            } 
    11181303        } 
    1119                 fclose(f); 
     1304        fclose(f); 
    11201305    } 
    11211306 
     
    11271312        memset(&pi, 0, sizeof(pi)); 
    11281313        CreateProcess(context->updater_file_path, NULL, NULL, NULL, FALSE, 0, NULL, context->temp_dir_path, &si, &pi); 
    1129             CloseHandle(pi.hThread); 
    1130             CloseHandle(pi.hProcess); 
     1314        CloseHandle(pi.hThread); 
     1315        CloseHandle(pi.hProcess); 
    11311316    } 
    11321317 
     
    11371322 
    11381323AU_Result AUI_Cancel(AUI_Context* context) { 
     1324    (void)context; 
    11391325    return AUI_SUCCESS; 
    11401326} 
     
    11431329    AUI_Context* internal_context = (AUI_Context*)context; 
    11441330    *internal_context_output = 0; 
    1145          
    1146         if (AUI_IsBadReadPointer(internal_context, sizeof(internal_context))) { 
    1147                 return E(AU_ERROR_INVALID_CONTEXT); 
    1148         } 
    1149  
    1150         if (AUI_IsBadWritePointer(internal_context, sizeof(internal_context))) { 
    1151                 return E(AU_ERROR_INVALID_CONTEXT); 
    1152         } 
    1153  
    1154         if (internal_context->description != NULL && AUI_IsBadWritePointer(internal_context->description, 1)) { 
    1155                 return E(AU_ERROR_INVALID_CONTEXT); 
    1156         } 
    1157  
    1158         if (internal_context->releases_file_path != NULL && AUI_IsBadWritePointer(internal_context->releases_file_path, 1)) { 
    1159                 return E(AU_ERROR_INVALID_CONTEXT); 
    1160         } 
    1161  
    1162         if (internal_context->created_signature != AUI_CONTEXT_CREATED_SIGNATURE) { 
    1163                 return E(AU_ERROR_INVALID_CONTEXT); 
    1164         } 
     1331 
     1332    if (AUI_IsBadReadPointer(internal_context, sizeof(internal_context))) { 
     1333        return E(AU_ERROR_INVALID_CONTEXT); 
     1334    } 
     1335 
     1336    if (AUI_IsBadWritePointer(internal_context, sizeof(internal_context))) { 
     1337        return E(AU_ERROR_INVALID_CONTEXT); 
     1338    } 
     1339 
     1340    if (internal_context->description != NULL && AUI_IsBadWritePointer(internal_context->description, 1)) { 
     1341        return E(AU_ERROR_INVALID_CONTEXT); 
     1342    } 
     1343 
     1344    if (internal_context->releases_file_path != NULL && AUI_IsBadWritePointer(internal_context->releases_file_path, 1)) { 
     1345        return E(AU_ERROR_INVALID_CONTEXT); 
     1346    } 
     1347 
     1348    if (internal_context->created_signature != AUI_CONTEXT_CREATED_SIGNATURE) { 
     1349        return E(AU_ERROR_INVALID_CONTEXT); 
     1350    } 
    11651351 
    11661352    *internal_context_output = internal_context; 
     
    11691355 
    11701356/* ----------------------------------------------------------------------- 
    1171     Interfaces 
    1172    ----------------------------------------------------------------------- */ 
     1357Interfaces 
     1358----------------------------------------------------------------------- */ 
    11731359 
    11741360#define AUI_API_PRECONDITION                       \ 
    1175         AUI_Context* internal_context = NULL;          \ 
    1176     {                                              \ 
    1177             AU_Result convert_result = AUI_ContextToInternalContext(&internal_context, context);  \ 
    1178             if (convert_result.error) {                \ 
    1179                 return convert_result;                 \ 
    1180             }                                          \ 
    1181     } 
     1361    AUI_Context* internal_context = NULL;          \ 
     1362{                                              \ 
     1363    AU_Result convert_result = AUI_ContextToInternalContext(&internal_context, context);  \ 
     1364    if (convert_result.error) {                \ 
     1365    return convert_result;                 \ 
     1366    }                                          \ 
     1367} 
    11821368 
    11831369AU_Result AU_CreateContext(AU_Context* pcontext, const AU_Option* option) { 
    11841370    AU_Context context = NULL; 
    1185          
     1371 
    11861372    if (AUI_IsBadWritePointer(pcontext, sizeof(*pcontext))) { 
    11871373        return E(AU_ERROR_INVALID_CONTEXT); 
  • lang/c/AutoUpdater/trunk/recipes/configure.ac

    r38010 r38013  
    88AC_CONFIG_SRCDIR([XDef.h]) 
    99 
    10 CFLAGS="-O0 -g" 
    11 CXXFLAGS="-O0 -g" 
     10CFLAGS="-O0" 
     11CXXFLAGS="-O0" 
    1212 
    1313AC_PROG_CC 
     
    3939 
    4040cat >common_options.txt <<OPTIONS 
    41   -g 
    4241  -ansi 
    43   -pedantic 
    4442  -pedantic 
    4543  -Wextra  -Wall  -Waddress  -Warray-bounds  
     
    4947  -Wdisabled-optimization   
    5048  -Wempty-body  -Wenum-compare 
    51   -Wfloat-equal  -Wformat  -Wformat=2  
     49  -Wfloat-equal -Wformat=2  
    5250  -Wformat-nonliteral  
    5351  -Wformat-security  -Wformat-y2k  
     
    6664  -Wreturn-type  -Wsequence-point  -Wshadow  
    6765  -Wsign-compare  -Wsign-conversion  -Wstack-protector  
    68   -Wstrict-aliasing -Wstrict-aliasing=2 
    69   -Wstrict-overflow -Wstrict-overflow=2 
     66  -Wstrict-aliasing=2 
     67  -Wstrict-overflow=2 
    7068  -Wswitch  -Wswitch-default  -Wswitch-enum -Wsync-nand  
    7169  -Wtrigraphs  -Wtype-limits  -Wundef  -Wuninitialized  
     
    7775OPTIONS 
    7876# -Wsystem-headers  
    79 # -Waggregate-return  
     77# -Waggregate-return <---- TODO 
    8078 
    8179cat >c_options.txt <<OPTIONS 
     
    8886  -Wstrict-prototypes  
    8987  -Wdeclaration-after-statement -Wpointer-sign 
     88  -Wold-style-declaration  -Wold-style-definition  
    9089OPTIONS 
     90# -Wmissing-prototypes  <---- TODO 
    9191# -Wmissing-declarations <---- TODO 
    92 #-Wmissing-prototypes  
    93 #-Wtraditional  -Wtraditional-conversion  
    94 #-Wold-style-declaration  -Wold-style-definition  
     92# -Wtraditional-conversion 
     93# -Wtraditional   
    9594 
    9695cat >cxx_options.txt <<OPTIONS 
     
    111110  -Wundeclared-selector 
    112111OPTIONS 
     112 
    113113 
    114114for option in `cat common_options.txt`; do