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

a

Files:
1 modified

Legend:

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

    r37925 r37930  
    2121#define wcsdup(x) _wcsdup(x) 
    2222#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 
     31const GUID AUI_GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0 }}; 
     32const GUID AUI_IID_IDispatch = {0x00020400, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}}; 
     33 
     34#  if defined(UNICODE) || defined(_UNICODE) 
     35#    include <wchar.h> 
     36#    define _tcslen wcslen 
     37#    define _tcsdup wcsdup 
     38#    define _tcscpy wcscpy 
     39#    define _tcscat wcscat 
     40#    define _tfopen(x, y) (NULL) 
     41#    define _vstprintf vswprintf 
     42#  else 
     43#    define _tcslen strlen 
     44#    define _tcsdup AUI_strdup 
     45#    define _tcscpy strcpy 
     46#    define _tcscat strcat 
     47#    define _tfopen fopen 
     48#    define _vstprintf vsprintf 
     49#  endif 
     50 
     51#endif 
     52 
     53#if ! __STDC_WANT_SECURE_LIB__ 
     54#define _tfopen_s(x, y, z) {*x = _tfopen(y, z);} 
     55#define _tcscpy_s(x, y, z) _tcscpy(x, z) 
     56#define _tcscat_s(x, y, z) _tcscat(x, z) 
    2357#endif 
    2458 
     
    5488#if __STDC_WANT_SECURE_LIB__ 
    5589    result = _vstprintf_s(buffer, count, format, ap); 
     90#elif defined(UNICODE) || defined(_UNICODE) 
     91    result = vswprintf(buffer, count - 1, format, ap); 
    5692#else 
    5793    if (count == 0) { 
     
    6298    } 
    6399    memset(buffer, 0, count * sizeof(TCHAR)); 
    64 #if __CYGWIN__ 
    65     result = _vstprintf(buffer, format, ap); 
    66 #else 
    67     result = _vsntprintf(buffer, count - 1, format, ap); 
    68 #endif 
     100    result = vsnprintf(buffer, format, ap); 
    69101#endif 
    70102    va_end(ap);  
    71103    return result; 
    72104} 
    73  
    74  
    75 #ifdef __CYGWIN__ 
    76  
    77 #  define _T(x) TEXT(x) 
    78 #  define GUID_NULL AUI_GUID_NULL 
    79 #  define IID_IDispatch AUI_IID_IDispatch 
    80  
    81 const GUID AUI_GUID_NULL = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } }; 
    82 const GUID AUI_IID_IDispatch = { 0x00020400, 0, 0, { '\xc0', 0, 0, 0, 0, 0, 0, '\x46'} }; 
    83  
    84 #  if defined(UNICODE) || defined(_UNICODE) 
    85 #    include <wchar.h> 
    86 #    define _tcslen wcslen 
    87 #    define _tcsdup wcsdup 
    88 #    define _tcscpy wcscpy 
    89 #    define _tcscat wcscat 
    90 #    define _tfopen fopen 
    91 #    define _vstprintf vswprintf 
    92 #  else 
    93 #    define _tcslen strlen 
    94 #    define _tcsdup AUI_strdup 
    95 #    define _tcscpy strcpy 
    96 #    define _tcscat strcat 
    97 #    define _tfopen fopen 
    98 #    define _vstprintf vsprintf 
    99 #  endif 
    100  
    101 #endif 
    102  
    103 #if ! __STDC_WANT_SECURE_LIB__ 
    104 #define _tfopen_s(x, y, z) {*x = _tfopen(y, z);} 
    105 #define _tcscpy_s(x, y, z) _tcscpy(x, z) 
    106 #define _tcscat_s(x, y, z) _tcscat(x, z) 
    107 #endif 
    108  
    109105 
    110106typedef struct AUI_DownloadContext_ { 
     
    141137} AUI_Context; 
    142138 
    143 const static AU_Result AUI_SUCCESS = {1, 0, 0}; 
    144 const static AU_Result AUI_IO_PENDING = {0, 1, 0}; 
     139static const AU_Result AUI_SUCCESS = {1, 0, 0}; 
     140static const AU_Result AUI_IO_PENDING = {0, 1, 0}; 
    145141 
    146142static AU_Result E(AU_Error error) { 
     
    698694    IDispatch* descriptionNode = NULL; 
    699695 
    700     // -------------------------------------------------------------- 
    701     // CoInitialize 
    702     // -------------------------------------------------------------- 
    703696    { 
    704697        result = CoInitialize(NULL); 
     
    708701            break; 
    709702        case S_FALSE: 
    710             // CoInitialize: The COM library is already initialized on this thread 
     703            /* CoInitialize: The COM library is already initialized on this thread */ 
    711704            break; 
    712705        case RPC_E_CHANGED_MODE: 
    713             // 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. 
    714             break; 
    715         } 
    716     } 
    717  
    718     // -------------------------------------------------------------- 
    719     // var Microsoft_XMLDOM = new ActiveXObject("Microsoft.XMLDOM") 
    720     // -------------------------------------------------------------- 
     706            /* 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. */ 
     707            break; 
     708        } 
     709    } 
     710 
     711    /* var Microsoft_XMLDOM = new ActiveXObject("Microsoft.XMLDOM") */ 
    721712    { 
    722713        OLECHAR clsid_str[] = OLESTR("Microsoft.XMLDOM"); 
     
    728719        { 
    729720        case NOERROR: 
    730             //The CLSID was obtained successfully. 
     721            /* The CLSID was obtained successfully. */ 
    731722            break; 
    732723        case E_INVALIDARG: 
     
    734725            break; 
    735726        case CO_E_CLASSSTRING: 
    736             //The class string was improperly formatted. 
     727            /* The class string was improperly formatted. */ 
    737728            return; 
    738729            break; 
    739730        case REGDB_E_CLASSNOTREG: 
    740             //The CLSID corresponding to the class string was not found in the registry. 
     731            /* The CLSID corresponding to the class string was not found in the registry. */ 
    741732            return; 
    742733            break; 
    743734        case REGDB_E_READREGDB: 
    744             //The registry could not be opened for reading. 
     735            /* The registry could not be opened for reading. */ 
    745736            return; 
    746737            break; 
    747738        default: 
    748             // 
    749739            return; 
    750740            break; 
     
    762752            break; 
    763753        case REGDB_E_CLASSNOTREG: 
    764             //Debug(""); 
    765754            return; 
    766755            break; 
    767756        case CLASS_E_NOAGGREGATION: 
    768             //Debug("This class cannot be created as part of an aggregate"); 
     757            /* This class cannot be created as part of an aggregate */ 
    769758            return; 
    770759            break; 
    771760        case E_NOINTERFACE: 
    772             //Debug("The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface"); 
     761            /* The specified class does not implement the requested interface, or the controlling IUnknown does not expose the requested interface */ 
    773762            return; 
    774763            break; 
    775764        default: 
    776             //Debug("CoCreateInstance unknown error: " << result); 
     765            /* unknown error: */ 
    777766            return; 
    778767            break; 
     
    781770        if (Microsoft_XMLDOM == NULL) 
    782771        { 
    783             //Debug("pDispatch is NULL"); 
    784         } 
    785     } 
    786     // -------------------------------------------------------------- 
    787     // Microsoft_XMLDOM.async = false 
    788     // -------------------------------------------------------------- 
    789     { 
     772            return; 
     773        } 
     774    } 
     775 
     776     
     777    { /* Microsoft_XMLDOM.async = false */ 
    790778        args[0].vt = VT_BOOL; 
    791779        args[0].boolVal = VARIANT_FALSE; 
     
    793781    } 
    794782 
    795     // -------------------------------------------------------------- 
    796     // Microsoft_XMLDOM.load("file.xml") 
    797     // -------------------------------------------------------------- 
    798     { 
     783     
     784    { /* Microsoft_XMLDOM.load("file.xml") */ 
    799785        args[0].vt = VT_BSTR; 
    800         //args[0].bstrVal = SysAllocString(OLESTR("c:/Documents and Settings/saturday06/My Documents/My Dropbox/jsxml.xml")); 
     786        /* args[0].bstrVal = SysAllocString(OLESTR("c:/Documents and Settings/saturday06/My Documents/My Dropbox/jsxml.xml")); */ 
    801787                args[0].bstrVal = SysAllocString(OLESTR("D:/Documents/My Dropbox/jsxml.xml")); 
    802788        result = AUI_AutoWrap(DISPATCH_METHOD, &returnValue, Microsoft_XMLDOM, OLESTR("load"), 1, args); 
     
    810796    } 
    811797 
    812     // -------------------------------------------------------------- 
    813     // Microsoft_XMLDOM.setProperty("SelectionLanguage", "XPath"); 
    814     // -------------------------------------------------------------- 
    815     { 
     798    { /* Microsoft_XMLDOM.setProperty("SelectionLanguage", "XPath"); */ 
    816799        args[0].vt = VT_BSTR; 
    817800        args[0].bstrVal = SysAllocString(OLESTR("SelectionLanguage")); 
     
    829812        } 
    830813    } 
    831  
    832     // -------------------------------------------------------------- 
    833     // var documentElement = Microsoft_XMLDOM.documentElement 
    834     // -------------------------------------------------------------- 
    835     { 
     814     
     815    { /* var documentElement = Microsoft_XMLDOM.documentElement */ 
    836816        result = AUI_AutoWrap(DISPATCH_PROPERTYGET, &returnValue, Microsoft_XMLDOM, OLESTR("documentElement"), 0, NULL); 
    837817        if (FAILED(result)) { 
     
    845825    } 
    846826 
    847     // -------------------------------------------------------------- 
    848     // var releaseNode = documentElement.selectSingleNode("..."); 
    849     // -------------------------------------------------------------- 
    850     { 
     827    { /* var releaseNode = documentElement.selectSingleNode("..."); */ 
    851828#define DEBUG_CONDITION OLESTR("not(@debug) or @debug < 1") 
    852829        OLECHAR cond[] =  
     
    872849        VariantClear(&returnValue); 
    873850    } 
    874  
    875     // -------------------------------------------------------------- 
    876     // var urlNode = releaseNode.selectSingleNode("url"); 
    877     // -------------------------------------------------------------- 
    878     { 
     851     
     852    { /* var urlNode = releaseNode.selectSingleNode("url"); */ 
    879853        args[0].vt = VT_BSTR; 
    880854        args[0].bstrVal = SysAllocString(OLESTR("url")); 
     
    894868    } 
    895869 
    896     // -------------------------------------------------------------- 
    897     // urlNode.text; 
    898     // -------------------------------------------------------------- 
    899     { 
     870    { /* urlNode.text; */ 
    900871        result = AUI_AutoWrap(DISPATCH_PROPERTYGET, &returnValue, urlNode, OLESTR("text"), 0, NULL); 
    901872        if (FAILED(result)) {