[30087] trunk/base/src/pextlib1.0/curl.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 19 05:14:16 PDT 2007


Revision: 30087
          http://trac.macosforge.org/projects/macports/changeset/30087
Author:   afb at macports.org
Date:     2007-10-19 05:14:15 -0700 (Fri, 19 Oct 2007)

Log Message:
-----------
add optional --user-agent parameter to curl

Modified Paths:
--------------
    trunk/base/src/pextlib1.0/curl.c

Modified: trunk/base/src/pextlib1.0/curl.c
===================================================================
--- trunk/base/src/pextlib1.0/curl.c	2007-10-19 11:44:14 UTC (rev 30086)
+++ trunk/base/src/pextlib1.0/curl.c	2007-10-19 12:14:15 UTC (rev 30087)
@@ -150,6 +150,7 @@
 		const char* theUserPassString = NULL;
 		const char* effectiveURLVarName = NULL;
 		char* effectiveURL = NULL;
+		char* userAgent = "MacPorts libcurl/" LIBCURL_VERSION;
 		int optioncrsr;
 		int lastoption;
 		const char* theURL;
@@ -199,6 +200,18 @@
 					theResult = TCL_ERROR;
 					break;					
 				}
+			} else if (strcmp(theOption, "--user-agent") == 0) {
+				/* check we also have the parameter */
+				if (optioncrsr < lastoption) {
+					optioncrsr++;
+					userAgent = Tcl_GetString(objv[optioncrsr]);
+				} else {
+					Tcl_SetResult(interp,
+						"curl fetch: --user-agent option requires a parameter",
+						TCL_STATIC);
+					theResult = TCL_ERROR;
+					break;					
+				}
 			} else {
 				char theErrorString[512];
 				(void) snprintf(theErrorString, sizeof(theErrorString),
@@ -263,7 +276,7 @@
 		}
 
         /* -A option */
-        theCurlCode = curl_easy_setopt(theHandle, CURLOPT_USERAGENT, "MacPorts libcurl/" LIBCURL_VERSION);
+        theCurlCode = curl_easy_setopt(theHandle, CURLOPT_USERAGENT, userAgent);
         if (theCurlCode != CURLE_OK) {
             theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
             break;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20071019/1f40b3bf/attachment.html


More information about the macports-changes mailing list