Ticket #51516: patch-pextlib-curl_version_cmd.diff
File patch-pextlib-curl_version_cmd.diff, 2.9 KB (added by RJVB (René Bertin), 5 months ago) |
---|
-
src/pextlib1.0/curl.c
diff --git a/src/pextlib1.0/curl.c b/src/pextlib1.0/curl.c index 3292005e5..4b9902d08 100644
a b int CurlFetchCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); 91 91 int CurlIsNewerCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); 92 92 int CurlGetSizeCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); 93 93 int CurlPostCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); 94 int CurlVersionCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]); 94 95 95 96 typedef struct { 96 97 Tcl_Interp *interp; … … CurlPostCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) 1435 1436 return theResult; 1436 1437 } 1437 1438 1439 /** 1440 * curl version subcommand entry point. 1441 * 1442 * @param interp current interpreter 1443 * @param objc number of parameters 1444 * @param objv parameters 1445 */ 1446 int 1447 CurlVersionCmd(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) 1448 { 1449 int theResult = TCL_OK; 1450 Tcl_Obj *tcl_result = NULL; 1451 1452 do { 1453 curl_version_info_data *theVersionInfo = curl_version_info(CURLVERSION_NOW); 1454 tcl_result = Tcl_NewListObj(0, NULL); 1455 // info from the curl version we were built against: 1456 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewIntObj(CURLVERSION_NOW)); 1457 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(LIBCURL_VERSION, -1)); 1458 // runtime info from the libcurl we are actually using: 1459 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(theVersionInfo->version, -1)); 1460 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(theVersionInfo->host, -1)); 1461 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(theVersionInfo->ssl_version, -1)); 1462 Tcl_SetObjResult(interp, tcl_result); 1463 } while (0); 1464 1465 return theResult; 1466 } 1467 1438 1468 /** 1439 1469 * curl command entry point. 1440 1470 * … … CurlCmd( 1454 1484 kCurlFetch, 1455 1485 kCurlIsNewer, 1456 1486 kCurlGetSize, 1457 kCurlPost 1487 kCurlPost, 1488 kCurlVersion 1458 1489 } EOption; 1459 1490 1460 1491 static const char *options[] = { 1461 "fetch", "isnewer", "getsize", "post", NULL1492 "fetch", "isnewer", "getsize", "post", "version", NULL 1462 1493 }; 1463 1494 int theResult = TCL_OK; 1464 1495 EOption theOptionIndex; … … CurlCmd( 1467 1498 /* TODO: use dispatch_once when we drop Leopard support */ 1468 1499 pthread_once(&once, CurlInit); 1469 1500 1470 if (objc < 3) {1471 Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");1472 return TCL_ERROR;1473 }1474 1475 1501 theResult = Tcl_GetIndexFromObj( 1476 1502 interp, 1477 1503 objv[1], … … CurlCmd( 1479 1505 "option", 1480 1506 0, 1481 1507 (int*) &theOptionIndex); 1508 if (objc < 3 && theOptionIndex != kCurlVersion) { 1509 Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?"); 1510 return TCL_ERROR; 1511 } 1512 1482 1513 if (theResult == TCL_OK) { 1483 1514 switch (theOptionIndex) { 1484 1515 case kCurlFetch: … … CurlCmd( 1493 1524 case kCurlPost: 1494 1525 theResult = CurlPostCmd(interp, objc, objv); 1495 1526 break; 1527 case kCurlVersion: 1528 theResult = CurlVersionCmd(interp, objc, objv); 1529 break; 1496 1530 } 1497 1531 } 1498 1532