New Ticket     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #18736: patch-macports-curl-escape.diff

File patch-macports-curl-escape.diff, 2.0 KB (added by raimue@…, 3 years ago)
  • pextlib1.0/curl.c

     
    8181int SetResultFromCurlErrorCode(Tcl_Interp* interp, CURLcode inErrorCode); 
    8282int CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]); 
    8383int CurlIsNewerCmd(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]); 
     84int CurlEscapeCmd(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]); 
    8485 
    8586/* ========================================================================= ** 
    8687 * Entry points 
     
    809810} 
    810811 
    811812/** 
     813 * curl escape subcommand entry point. 
     814 * 
     815 * syntax: curl escape <string> 
     816 * 
     817 * @param interp                current interpreter 
     818 * @param objc                  number of parameters 
     819 * @param objv                  parameters 
     820 */ 
     821int 
     822CurlEscapeCmd(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) 
     823{ 
     824        int theResult = TCL_OK; 
     825        CURL* theHandle = NULL; 
     826        const char* theString = NULL; 
     827        char* escapedString = NULL; 
     828 
     829        if (objc != 3) { 
     830                Tcl_WrongNumArgs(interp, 1, objv, "escape string"); 
     831                return TCL_ERROR; 
     832        } 
     833 
     834        theString = Tcl_GetString(objv[2]); 
     835 
     836        /* Create the CURL handle */ 
     837        theHandle = curl_easy_init(); 
     838 
     839        /* Escape the string */ 
     840        escapedString = curl_easy_escape(theHandle, theString, 0); 
     841        Tcl_SetResult(interp, escapedString, TCL_VOLATILE); 
     842 
     843        curl_free(escapedString); 
     844        curl_easy_cleanup(theHandle); 
     845 
     846        return theResult; 
     847} 
     848 
     849/** 
    812850 * curl command entry point. 
    813851 * 
    814852 * @param clientData    custom data (ignored) 
     
    826864    typedef enum { 
    827865        kCurlFetch, 
    828866        kCurlIsNewer, 
    829         kCurlGetSize 
     867        kCurlGetSize, 
     868        kCurlEscape 
    830869    } EOption; 
    831870     
    832871        static tableEntryString options[] = { 
    833                 "fetch", "isnewer", "getsize", NULL 
     872                "fetch", "isnewer", "getsize", "escape", NULL 
    834873        }; 
    835874        int theResult = TCL_OK; 
    836875    EOption theOptionIndex; 
     
    861900                        case kCurlGetSize: 
    862901                                theResult = CurlGetSizeCmd(interp, objc, objv); 
    863902                                break; 
     903 
     904                        case kCurlEscape: 
     905                                theResult = CurlEscapeCmd(interp, objc, objv); 
     906                                break; 
     907 
    864908                } 
    865909        } 
    866910