Ticket #18736: patch-macports-curl-escape.diff
File patch-macports-curl-escape.diff, 2.0 KB (added by raimue (Rainer Müller), 16 years ago) |
---|
-
pextlib1.0/curl.c
81 81 int SetResultFromCurlErrorCode(Tcl_Interp* interp, CURLcode inErrorCode); 82 82 int CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]); 83 83 int CurlIsNewerCmd(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]); 84 int CurlEscapeCmd(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]); 84 85 85 86 /* ========================================================================= ** 86 87 * Entry points … … 809 810 } 810 811 811 812 /** 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 */ 821 int 822 CurlEscapeCmd(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 /** 812 850 * curl command entry point. 813 851 * 814 852 * @param clientData custom data (ignored) … … 826 864 typedef enum { 827 865 kCurlFetch, 828 866 kCurlIsNewer, 829 kCurlGetSize 867 kCurlGetSize, 868 kCurlEscape 830 869 } EOption; 831 870 832 871 static tableEntryString options[] = { 833 "fetch", "isnewer", "getsize", NULL872 "fetch", "isnewer", "getsize", "escape", NULL 834 873 }; 835 874 int theResult = TCL_OK; 836 875 EOption theOptionIndex; … … 861 900 case kCurlGetSize: 862 901 theResult = CurlGetSizeCmd(interp, objc, objv); 863 902 break; 903 904 case kCurlEscape: 905 theResult = CurlEscapeCmd(interp, objc, objv); 906 break; 907 864 908 } 865 909 } 866 910