- Subject: [slang-users] patch for curl_easy_escape and curl_easy_unescape
- From: "Brian McQueen" <mcqueenorama@xxxxxxxxx>
- Date: Thu, 8 Mar 2007 08:52:57 -0800
Is this a useful format for the patch?
*** slcurl-0.1.2/src/curl-module.c Wed Feb 28 17:59:58 2007
--- slcurl/src/curl-module.c Wed Mar 7 21:55:22 2007
***************
*** 799,804 ****
--- 799,864 ----
return -1;
}
+ static void unescape_intrin (void)
+ {
+ SLang_MMT_Type *mmt;
+ Easy_Type *ez;
+ char *escaped_string = NULL;
+ char *unescaped_string = NULL;
+
+ if (-1 == SLang_pop_slstring (&escaped_string))
+ return;
+
+ if (NULL == (mmt = pop_easy_type (&ez, 0))) {
+ SLang_free_slstring(escaped_string);
+ return;
+ }
+
+ unescaped_string = curl_easy_unescape(ez->handle, escaped_string, 0, NULL);
+
+ if (unescaped_string == NULL) {
+ SLang_free_mmt(mmt);
+ SLang_free_slstring(escaped_string);
+ SLang_set_error(Curl_Error);
+ return;
+ }
+
+ (void) SLang_push_malloced_string (unescaped_string);
+
+ SLang_free_slstring(escaped_string);
+ SLang_free_mmt(mmt);
+
+ }
+
+ static void escape_intrin (void)
+ {
+ SLang_MMT_Type *mmt;
+ Easy_Type *ez;
+ char *unescaped_string = NULL;
+ char *escaped_string = NULL;
+
+ if (-1 == SLang_pop_slstring (&unescaped_string))
+ return;
+
+ if (NULL == (mmt = pop_easy_type (&ez, 0))) {
+ SLang_free_slstring(unescaped_string);
+ return;
+ }
+
+ escaped_string = curl_easy_escape(ez->handle, unescaped_string, 0);
+
+ if (escaped_string == NULL) {
+ SLang_free_mmt(mmt);
+ SLang_free_slstring(unescaped_string);
+ SLang_set_error(Curl_Error);
+ return;
+ }
+
+ (void) SLang_push_malloced_string (escaped_string);
+
+ SLang_free_slstring(unescaped_string);
+ SLang_free_mmt(mmt);
+ }
static void setopt_intrin (void)
{
***************
*** 1446,1451 ****
--- 1506,1513 ----
static SLang_Intrin_Fun_Type Module_Intrinsics [] =
{
MAKE_INTRINSIC_1("curl_new", new_curl_intrin, SLANG_VOID_TYPE,
SLANG_STRING_TYPE),
+ MAKE_INTRINSIC_0("curl_easy_escape", escape_intrin, SLANG_VOID_TYPE),
+ MAKE_INTRINSIC_0("curl_easy_unescape", unescape_intrin, SLANG_VOID_TYPE),
MAKE_INTRINSIC_0("curl_setopt", setopt_intrin, SLANG_VOID_TYPE),
MAKE_INTRINSIC_1("curl_global_init", global_init,
SLANG_VOID_TYPE, SLANG_LONG_TYPE),
MAKE_INTRINSIC_0("curl_global_cleanup", global_cleanup, SLANG_VOID_TYPE),
[2007 date index]
[2007 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]