From: Remi Collet <fedora(a)famillecollet.com>
---
src/libvirt-php.c | 299 ++++++++++++++++++------------------------------------
1 file changed, 99 insertions(+), 200 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 3f47075..80a947c 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -58,6 +58,7 @@ const char *features_binaries[] = { NULL };
#if PHP_MAJOR_VERSION >= 7
typedef size_t strsize_t;
+#define VIRT_COPY_OPT
#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \
if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \
RETURN_FALSE; \
@@ -68,6 +69,8 @@ typedef int strsize_t;
typedef long zend_long;
typedef unsigned long zend_ulong;
+#define VIRT_COPY_OPT ,1
+
#define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \
ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le);
@@ -2026,7 +2029,7 @@ if ((snapshot==NULL) || (snapshot->snapshot==NULL))
RETURN_FALSE;\
#define LONGLONG_ASSOC(out,key,in) \
if (LIBVIRT_G(longlong_to_string_ini)) { \
snprintf(tmpnumber,63,"%llu",in); \
- add_assoc_string_ex(out,key,strlen(key)+1,tmpnumber,1); \
+ add_assoc_string_ex(out,key,strlen(key)+1,tmpnumber VIRT_COPY_OPT); \
} \
else \
{ \
@@ -2090,11 +2093,7 @@ static int libvirt_virConnectCredType[] = {
PHP_FUNCTION(libvirt_get_last_error)
{
if (LIBVIRT_G (last_error) == NULL) RETURN_NULL();
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(LIBVIRT_G (last_error));
-#else
- RETURN_STRING(LIBVIRT_G (last_error),1);
-#endif
+ RETURN_STRING(LIBVIRT_G (last_error) VIRT_COPY_OPT);
}
/*
@@ -2254,7 +2253,7 @@ PHP_FUNCTION(libvirt_node_get_info)
if (retval==-1) RETURN_FALSE;
array_init(return_value);
- add_assoc_string_ex(return_value, "model", 6, info.model, 1);
+ add_assoc_string_ex(return_value, "model", 6, info.model VIRT_COPY_OPT);
add_assoc_long(return_value, "memory", (long)info.memory);
add_assoc_long(return_value, "cpus", (long)info.cpus);
add_assoc_long(return_value, "nodes", (long)info.nodes);
@@ -2349,9 +2348,9 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats)
add_assoc_long(return_value, "cpu", cpunr);
else
if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS)
- add_assoc_string_ex(return_value, "cpu", 4, "all", 1);
+ add_assoc_string_ex(return_value, "cpu", 4, "all"
VIRT_COPY_OPT);
else
- add_assoc_string_ex(return_value, "cpu", 4, "unknown",
1);
+ add_assoc_string_ex(return_value, "cpu", 4, "unknown"
VIRT_COPY_OPT);
free(params);
params = NULL;
@@ -2563,21 +2562,21 @@ PHP_FUNCTION(libvirt_connect_get_machine_types)
char tmp3[2048] = { 0 };
snprintf(key, sizeof(key), "%d", k);
- //add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k],
1);
+ //add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k]
VIRT_COPY_OPT);
snprintf(tmp3, sizeof(tmp3),
"//capabilities/guest/arch[@name=\"%s\"]/machine[text()=\"%s\"]/@maxCpus",
ret[i], ret3[k]);
numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL);
if (numTmp == NULL)
- add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k],
1);
+ add_assoc_string_ex(arr2, key, strlen(key) + 1, ret3[k]
VIRT_COPY_OPT);
else {
zval *arr4;
ALLOC_INIT_ZVAL(arr4);
array_init(arr4);
- add_assoc_string_ex(arr4, "name", 5, ret3[k],
1);
- add_assoc_string_ex(arr4, "maxCpus", 9, numTmp,
1);
+ add_assoc_string_ex(arr4, "name", 5, ret3[k]
VIRT_COPY_OPT);
+ add_assoc_string_ex(arr4, "maxCpus", 9, numTmp
VIRT_COPY_OPT);
add_assoc_zval_ex(arr2, key, strlen(key) + 1, arr4);
free(numTmp);
@@ -2605,14 +2604,14 @@ PHP_FUNCTION(libvirt_connect_get_machine_types)
numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL);
if (numTmp == NULL)
- add_assoc_string_ex(arr3, key, strlen(key) + 1, ret3[k],
1);
+ add_assoc_string_ex(arr3, key, strlen(key) + 1, ret3[k]
VIRT_COPY_OPT);
else {
zval *arr4;
ALLOC_INIT_ZVAL(arr4);
array_init(arr4);
- add_assoc_string_ex(arr4, "name", 5, ret3[k],
1);
- add_assoc_string_ex(arr4, "maxCpus", 9, numTmp,
1);
+ add_assoc_string_ex(arr4, "name", 5, ret3[k]
VIRT_COPY_OPT);
+ add_assoc_string_ex(arr4, "maxCpus", 9, numTmp
VIRT_COPY_OPT);
add_assoc_zval_ex(arr3, key, strlen(key) + 1, arr4);
free(numTmp);
@@ -2655,21 +2654,21 @@ PHP_FUNCTION(libvirt_connect_get_information)
tmp = virConnectGetURI(conn->conn);
DPRINTF("%s: Got connection URI of %s...\n", PHPFUNC, tmp);
array_init(return_value);
- add_assoc_string_ex(return_value, "uri", 4, tmp ? tmp :
"unknown", 1);
+ add_assoc_string_ex(return_value, "uri", 4, tmp ? tmp : "unknown"
VIRT_COPY_OPT);
free(tmp);
tmp = virConnectGetHostname(conn->conn);
- add_assoc_string_ex(return_value, "hostname", 9, tmp ? tmp :
"unknown", 1);
+ add_assoc_string_ex(return_value, "hostname", 9, tmp ? tmp :
"unknown" VIRT_COPY_OPT);
free(tmp);
if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type =
virConnectGetType(conn->conn)))
{
- add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type, 1);
+ add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type
VIRT_COPY_OPT);
add_assoc_long(return_value, "hypervisor_major",(long)((hvVer/1000000)
% 1000));
add_assoc_long(return_value, "hypervisor_minor",(long)((hvVer/1000) %
1000));
add_assoc_long(return_value, "hypervisor_release",(long)(hvVer
%1000));
snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type,
(long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000),
(long)(hvVer %1000));
- add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr, 1);
+ add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr
VIRT_COPY_OPT);
}
if (strcmp(type, "QEMU") == 0) {
@@ -2682,21 +2681,21 @@ PHP_FUNCTION(libvirt_connect_get_information)
add_assoc_long(return_value, "hypervisor_maxvcpus", maxvcpus);
iTmp = virConnectIsEncrypted(conn->conn);
if (iTmp == 1)
- add_assoc_string_ex(return_value, "encrypted", 10, "Yes",
1);
+ add_assoc_string_ex(return_value, "encrypted", 10, "Yes"
VIRT_COPY_OPT);
else
if (iTmp == 0)
- add_assoc_string_ex(return_value, "encrypted", 10, "No",
1);
+ add_assoc_string_ex(return_value, "encrypted", 10, "No"
VIRT_COPY_OPT);
else
- add_assoc_string_ex(return_value, "encrypted", 10,
"unknown", 1);
+ add_assoc_string_ex(return_value, "encrypted", 10,
"unknown" VIRT_COPY_OPT);
iTmp = virConnectIsSecure(conn->conn);
if (iTmp == 1)
- add_assoc_string_ex(return_value, "secure", 7, "Yes", 1);
+ add_assoc_string_ex(return_value, "secure", 7, "Yes"
VIRT_COPY_OPT);
else
if (iTmp == 0)
- add_assoc_string_ex(return_value, "secure", 7, "No", 1);
+ add_assoc_string_ex(return_value, "secure", 7, "No"
VIRT_COPY_OPT);
else
- add_assoc_string_ex(return_value, "secure", 7, "unknown",
1);
+ add_assoc_string_ex(return_value, "secure", 7, "unknown"
VIRT_COPY_OPT);
add_assoc_long(return_value, "num_inactive_domains",
virConnectNumOfDefinedDomains(conn->conn));
add_assoc_long(return_value, "num_inactive_interfaces",
virConnectNumOfDefinedInterfaces(conn->conn));
@@ -2735,11 +2734,7 @@ PHP_FUNCTION(libvirt_connect_get_uri)
DPRINTF("%s: virConnectGetURI returned %s\n", PHPFUNC, uri);
if (uri == NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(uri);
-#else
- RETVAL_STRING(uri, 1);
-#endif
+ RETVAL_STRING(uri VIRT_COPY_OPT);
free(uri);
}
@@ -2762,11 +2757,7 @@ PHP_FUNCTION(libvirt_connect_get_hostname)
DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname);
if (hostname==NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(hostname);
-#else
- RETVAL_STRING(hostname, 1);
-#endif
+ RETVAL_STRING(hostname VIRT_COPY_OPT);
free(hostname);
}
@@ -2919,14 +2910,14 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor)
DPRINTF("%s: virConnectGetType returned %s\n", PHPFUNC, type);
array_init(return_value);
- add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type, 1);
+ add_assoc_string_ex(return_value, "hypervisor", 11, (char *)type
VIRT_COPY_OPT);
add_assoc_long(return_value, "major",(long)((hvVer/1000000) % 1000));
add_assoc_long(return_value, "minor",(long)((hvVer/1000) % 1000));
add_assoc_long(return_value, "release",(long)(hvVer %1000));
snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type,
(long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer
%1000));
- add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr, 1);
+ add_assoc_string_ex(return_value, "hypervisor_string", 18, hvStr
VIRT_COPY_OPT);
}
/*
@@ -3021,7 +3012,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats)
add_assoc_bool(arr2, params.field, params.value.b);
break;
case VIR_TYPED_PARAM_STRING:
- add_assoc_string_ex(arr2, params.field, strlen(params.field)+1,
params.value.s, strlen(params.value.s)+1);
+ add_assoc_string_ex(arr2, params.field, strlen(params.field)+1,
params.value.s VIRT_COPY_OPT);
break;
}
}
@@ -3074,11 +3065,7 @@ PHP_FUNCTION(libvirt_connect_get_sysinfo)
sysinfo=virConnectGetSysinfo(conn->conn, 0);
if (sysinfo==NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(sysinfo);
-#else
- RETVAL_STRING(sysinfo, 1);
-#endif
+ RETVAL_STRING(sysinfo VIRT_COPY_OPT);
free(sysinfo);
}
@@ -3146,7 +3133,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal)
value = (char *)xmlNodeListGetString(doc,
nodeset->nodeTab[i]->xmlChildrenNode, 1);
snprintf(key, sizeof(key), "%d", i);
- add_assoc_string_ex(*val, key, strlen(key)+1, value, 1);
+ add_assoc_string_ex(*val, key, strlen(key)+1, value VIRT_COPY_OPT);
ret++;
}
}
@@ -4050,11 +4037,7 @@ PHP_FUNCTION(libvirt_domain_get_metadata)
}
}
else {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(ret);
-#else
- RETVAL_STRING(ret, 1);
-#endif
+ RETVAL_STRING(ret VIRT_COPY_OPT);
free(ret);
}
}
@@ -4207,11 +4190,7 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command)
ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags);
if (ret == NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(ret);
-#else
- RETURN_STRING(ret, 1);
-#endif
+ RETURN_STRING(ret VIRT_COPY_OPT);
}
/*
@@ -4511,11 +4490,7 @@ PHP_FUNCTION(libvirt_domain_get_name)
DPRINTF("%s: virDomainGetName(%p) returned %s\n", PHPFUNC,
domain->domain, name);
if (name==NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(name);
-#else
- RETURN_STRING(name, 1); //we can use the copy mechanism as we need not to free name
(we even can not!)
-#endif
+ RETURN_STRING(name VIRT_COPY_OPT); //we can use the copy mechanism as we need not to
free name (we even can not!)
}
/*
@@ -4540,7 +4515,7 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string)
if (retval!=0) RETURN_FALSE;
#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(uuid);
+ RETVAL_STRING(uuid VIRT_COPY_OPT);
efree(uuid);
#else
RETURN_STRING(uuid,0);
@@ -4641,12 +4616,12 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api)
if (WEXITSTATUS(exitStatus) != 0)
RETURN_FALSE;
- add_assoc_string_ex(return_value, "file", 5, fileNew, 1);
- add_assoc_string_ex(return_value, "mime", 5, "image/png",
1);
+ add_assoc_string_ex(return_value, "file", 5, fileNew VIRT_COPY_OPT);
+ add_assoc_string_ex(return_value, "mime", 5, "image/png"
VIRT_COPY_OPT);
}
else {
- add_assoc_string_ex(return_value, "file", 5, file, 1);
- add_assoc_string_ex(return_value, "mime", 5, mime, 1);
+ add_assoc_string_ex(return_value, "file", 5, file VIRT_COPY_OPT);
+ add_assoc_string_ex(return_value, "mime", 5, mime VIRT_COPY_OPT);
}
}
@@ -5104,17 +5079,9 @@ PHP_FUNCTION(libvirt_connect_get_capabilities)
tmp = get_string_from_xpath(caps, xpath, NULL, &retval);
if ((tmp == NULL) || (retval < 0)) {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(caps);
-#else
- RETVAL_STRING(caps, 1);
-#endif
+ RETVAL_STRING(caps VIRT_COPY_OPT);
} else {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(tmp);
-#else
- RETVAL_STRING(tmp, 1);
-#endif
+ RETVAL_STRING(tmp VIRT_COPY_OPT);
}
free(caps);
@@ -5149,11 +5116,7 @@ PHP_FUNCTION(libvirt_connect_get_emulator)
RETURN_FALSE;
}
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(tmp);
-#else
- RETVAL_STRING(tmp, 1);
-#endif
+ RETVAL_STRING(tmp VIRT_COPY_OPT);
free(tmp);
}
@@ -5218,7 +5181,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models)
tTokenizer t = tokenize(tmp, ",");
for (i = 0; i < t.numTokens; i++) {
snprintf(tmp2, sizeof(tmp2), "%d", i);
- add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[i],
1);
+ add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[i]
VIRT_COPY_OPT);
}
free_tokens(t);
}
@@ -5311,14 +5274,14 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models)
zval *arr;
ALLOC_INIT_ZVAL(arr);
array_init(arr);
- add_assoc_string_ex(arr, "name", 5, t.tokens[0], 1);
- add_assoc_string_ex(arr, "description", 12, desc, 1);
+ add_assoc_string_ex(arr, "name", 5, t.tokens[0]
VIRT_COPY_OPT);
+ add_assoc_string_ex(arr, "description", 12, desc
VIRT_COPY_OPT);
add_next_index_zval(return_value, arr);
}
else {
char tmp2[16] = { 0 };
snprintf(tmp2, sizeof(tmp2), "%d", n++);
- add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[0],
1);
+ add_assoc_string_ex(return_value, tmp2, strlen(tmp2) + 1, t.tokens[0]
VIRT_COPY_OPT);
}
free_tokens(t);
@@ -5585,11 +5548,7 @@ PHP_FUNCTION(libvirt_domain_new)
PHP_FUNCTION(libvirt_domain_new_get_vnc)
{
if (LIBVIRT_G(vnc_location))
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(LIBVIRT_G(vnc_location));
-#else
- RETURN_STRING(LIBVIRT_G(vnc_location),1);
-#endif
+ RETURN_STRING(LIBVIRT_G(vnc_location) VIRT_COPY_OPT);
RETURN_NULL();
}
@@ -5627,17 +5586,9 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc)
tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
if ((tmp == NULL) || (retval < 0)) {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(xml);
-#else
- RETVAL_STRING(xml, 1);
-#endif
+ RETVAL_STRING(xml VIRT_COPY_OPT);
} else {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(tmp);
-#else
- RETVAL_STRING(tmp, 1);
-#endif
+ RETVAL_STRING(tmp VIRT_COPY_OPT);
}
free(tmp);
@@ -6858,8 +6809,8 @@ PHP_FUNCTION(libvirt_domain_get_network_info)
}
array_init(return_value);
- add_assoc_string_ex(return_value, "mac", 4, mac, 1);
- add_assoc_string_ex(return_value, "network", 8, tmp, 1);
+ add_assoc_string_ex(return_value, "mac", 4, mac VIRT_COPY_OPT);
+ add_assoc_string_ex(return_value, "network", 8, tmp VIRT_COPY_OPT);
free(tmp);
free(xpath);
@@ -6870,9 +6821,9 @@ PHP_FUNCTION(libvirt_domain_get_network_info)
}
tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "nic_type", 9, tmp, 1);
+ add_assoc_string_ex(return_value, "nic_type", 9, tmp VIRT_COPY_OPT);
else
- add_assoc_string_ex(return_value, "nic_type", 9, "default",
1);
+ add_assoc_string_ex(return_value, "nic_type", 9, "default"
VIRT_COPY_OPT);
free(xml);
free(xpath);
@@ -6956,12 +6907,12 @@ PHP_FUNCTION(libvirt_domain_get_block_info)
array_init(return_value);
LONGLONG_INIT;
- add_assoc_string_ex(return_value, "device", 7, dev, 1);
+ add_assoc_string_ex(return_value, "device", 7, dev VIRT_COPY_OPT);
if (isFile)
- add_assoc_string_ex(return_value, "file", 5, tmp, 1);
+ add_assoc_string_ex(return_value, "file", 5, tmp VIRT_COPY_OPT);
else
- add_assoc_string_ex(return_value, "partition", 10, tmp, 1);
+ add_assoc_string_ex(return_value, "partition", 10, tmp VIRT_COPY_OPT);
free(xpath);
if (asprintf(&xpath,
"//domain/devices/disk/target[@dev='%s']/../driver/(a)type", dev) < 0)
{
@@ -6971,7 +6922,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info)
free(tmp);
tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
if (tmp != NULL)
- add_assoc_string_ex(return_value, "type", 5, tmp, 1);
+ add_assoc_string_ex(return_value, "type", 5, tmp VIRT_COPY_OPT);
LONGLONG_ASSOC(return_value, "capacity", info.capacity);
LONGLONG_ASSOC(return_value, "allocation", info.allocation);
@@ -7027,7 +6978,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath)
if (rc == 0)
RETURN_FALSE;
- add_assoc_string_ex(return_value, "xpath", 6, (char *)zpath, 1);
+ add_assoc_string_ex(return_value, "xpath", 6, (char *)zpath
VIRT_COPY_OPT);
if (rc < 0)
add_assoc_long(return_value, "error_code", (long)rc);
}
@@ -7387,11 +7338,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml)
xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags);
if (xml==NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(xml);
-#else
- RETVAL_STRING(xml, 1);
-#endif
+ RETVAL_STRING(xml VIRT_COPY_OPT);
free(xml);
}
@@ -7722,11 +7669,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_name)
DPRINTF("%s: virStorageVolGetName(%p) returned %s\n", PHPFUNC,
volume->volume, retval);
if (retval == NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(retval);
-#else
- RETURN_STRING (retval, 1);
-#endif
+ RETURN_STRING(retval VIRT_COPY_OPT);
}
/*
@@ -7748,11 +7691,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_path)
DPRINTF("%s: virStorageVolGetPath(%p) returned %s\n", PHPFUNC,
volume->volume, retval);
if (retval == NULL) RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(retval);
-#else
- RETURN_STRING (retval, 1);
-#endif
+ RETURN_STRING(retval VIRT_COPY_OPT);
}
/*
@@ -7816,17 +7755,9 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc)
tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
if ((tmp == NULL) || (retval < 0)) {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(xml);
-#else
- RETVAL_STRING(xml, 1);
-#endif
+ RETVAL_STRING(xml VIRT_COPY_OPT);
} else {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(tmp);
-#else
- RETVAL_STRING(tmp, 1);
-#endif
+ RETVAL_STRING(tmp VIRT_COPY_OPT);
}
free(xml);
@@ -8110,11 +8041,7 @@ PHP_FUNCTION(libvirt_storagepool_get_name)
if (name == NULL)
RETURN_FALSE;
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(name);
-#else
- RETURN_STRING(name, 1);
-#endif
+ RETURN_STRING(name VIRT_COPY_OPT);
}
/*
@@ -8191,17 +8118,9 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc)
tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
if ((tmp == NULL) || (retval < 0)) {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(xml);
-#else
- RETVAL_STRING(xml, 1);
-#endif
+ RETVAL_STRING(xml VIRT_COPY_OPT);
} else {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(tmp);
-#else
- RETVAL_STRING(tmp, 1);
-#endif
+ RETVAL_STRING(tmp VIRT_COPY_OPT);
}
free(xml);
@@ -9120,17 +9039,9 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc)
tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
if ((tmp == NULL) || (retval < 0)) {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(xml);
-#else
- RETVAL_STRING(xml, 1);
-#endif
+ RETVAL_STRING(xml VIRT_COPY_OPT);
} else {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(tmp);
-#else
- RETVAL_STRING(tmp, 1);
-#endif
+ RETVAL_STRING(tmp VIRT_COPY_OPT);
}
free(xml);
@@ -9175,18 +9086,18 @@ PHP_FUNCTION(libvirt_nodedev_get_information)
goto error;
}
- add_assoc_string_ex(return_value, "name", 5, tmp, 1);
+ add_assoc_string_ex(return_value, "name", 5, tmp VIRT_COPY_OPT);
/* Get parent name */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/parent", NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "parent", 7, tmp, 1);
+ add_assoc_string_ex(return_value, "parent", 7, tmp VIRT_COPY_OPT);
/* Get capability */
cap = get_string_from_xpath(xml, "//device/capability/@type", NULL,
&retval);
if ((cap != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "capability", 11, cap, 1);
+ add_assoc_string_ex(return_value, "capability", 11, cap
VIRT_COPY_OPT);
/* System capability is having hardware and firmware sub-blocks */
if (strcmp(cap, "system") == 0) {
@@ -9194,92 +9105,92 @@ PHP_FUNCTION(libvirt_nodedev_get_information)
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/hardware/vendor",
NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "hardware_vendor", 16, tmp, 1);
+ add_assoc_string_ex(return_value, "hardware_vendor", 16, tmp
VIRT_COPY_OPT);
/* Get hardware version */
free(tmp);
tmp = get_string_from_xpath(xml,
"//device/capability/hardware/version", NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "hardware_version", 17, tmp, 1);
+ add_assoc_string_ex(return_value, "hardware_version", 17, tmp
VIRT_COPY_OPT);
/* Get hardware serial */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/hardware/serial",
NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "hardware_serial", 16, tmp, 1);
+ add_assoc_string_ex(return_value, "hardware_serial", 16, tmp
VIRT_COPY_OPT);
/* Get hardware UUID */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/hardware/uuid",
NULL, &retval);
if (tmp != NULL)
- add_assoc_string_ex(return_value, "hardware_uuid", 15, tmp, 1);
+ add_assoc_string_ex(return_value, "hardware_uuid", 15, tmp
VIRT_COPY_OPT);
/* Get firmware vendor */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/firmware/vendor",
NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "firmware_vendor", 16, tmp, 1);
+ add_assoc_string_ex(return_value, "firmware_vendor", 16, tmp
VIRT_COPY_OPT);
/* Get firmware version */
free(tmp);
tmp = get_string_from_xpath(xml,
"//device/capability/firmware/version", NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "firmware_version", 17, tmp, 1);
+ add_assoc_string_ex(return_value, "firmware_version", 17, tmp
VIRT_COPY_OPT);
/* Get firmware release date */
free(tmp);
tmp = get_string_from_xpath(xml,
"//device/capability/firmware/release_date", NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "firmware_release_date", 22, tmp,
1);
+ add_assoc_string_ex(return_value, "firmware_release_date", 22, tmp
VIRT_COPY_OPT);
}
/* Get product_id */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/product/@id", NULL,
&retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "product_id", 11, tmp, 1);
+ add_assoc_string_ex(return_value, "product_id", 11, tmp
VIRT_COPY_OPT);
/* Get product_name */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/product", NULL,
&retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "product_name", 13, tmp, 1);
+ add_assoc_string_ex(return_value, "product_name", 13, tmp
VIRT_COPY_OPT);
/* Get vendor_id */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/vendor/@id", NULL,
&retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "vendor_id", 10, tmp, 1);
+ add_assoc_string_ex(return_value, "vendor_id", 10, tmp VIRT_COPY_OPT);
/* Get vendor_name */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/vendor", NULL,
&retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "vendor_name", 12, tmp, 1);
+ add_assoc_string_ex(return_value, "vendor_name", 12, tmp
VIRT_COPY_OPT);
/* Get driver name */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/driver/name", NULL,
&retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "driver_name", 12, tmp, 1);
+ add_assoc_string_ex(return_value, "driver_name", 12, tmp
VIRT_COPY_OPT);
/* Get driver name */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/interface", NULL,
&retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "interface_name", 15, tmp, 1);
+ add_assoc_string_ex(return_value, "interface_name", 15, tmp
VIRT_COPY_OPT);
/* Get driver name */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/address", NULL,
&retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "address", 8, tmp, 1);
+ add_assoc_string_ex(return_value, "address", 8, tmp VIRT_COPY_OPT);
/* Get driver name */
free(tmp);
tmp = get_string_from_xpath(xml, "//device/capability/capability/@type",
NULL, &retval);
if ((tmp != NULL) && (retval > 0))
- add_assoc_string_ex(return_value, "capabilities", 11, tmp, 1);
+ add_assoc_string_ex(return_value, "capabilities", 11, tmp
VIRT_COPY_OPT);
free(cap);
free(tmp);
@@ -9411,11 +9322,7 @@ PHP_FUNCTION(libvirt_network_get_bridge)
RETURN_FALSE;
}
-#if PHP_MAJOR_VERSION >= 7
- RETURN_STRING(name);
-#else
- RETURN_STRING(name, 1);
-#endif
+ RETURN_STRING(name VIRT_COPY_OPT);
}
/*
@@ -9488,42 +9395,42 @@ PHP_FUNCTION(libvirt_network_get_information)
RETURN_FALSE;
}
- add_assoc_string_ex(return_value, "name", 5, name, 1);
+ add_assoc_string_ex(return_value, "name", 5, name VIRT_COPY_OPT);
/* Get gateway IP address */
ipaddr = get_string_from_xpath(xml, "//network/ip/@address", NULL,
&retval);
if (ipaddr && retval > 0)
- add_assoc_string_ex(return_value, "ip", 3, ipaddr, 1);
+ add_assoc_string_ex(return_value, "ip", 3, ipaddr VIRT_COPY_OPT);
/* Get netmask */
netmask = get_string_from_xpath(xml, "//network/ip/@netmask", NULL,
&retval);
if (netmask && retval > 0) {
int subnet_bits = get_subnet_bits(netmask);
- add_assoc_string_ex(return_value, "netmask", 8, netmask, 1);
+ add_assoc_string_ex(return_value, "netmask", 8, netmask
VIRT_COPY_OPT);
add_assoc_long(return_value, "netmask_bits", (long) subnet_bits);
/* Format CIDR address representation */
ipaddr[strlen(ipaddr) - 1] = ipaddr[strlen(ipaddr) - 1] - 1;
snprintf(fixedtemp, sizeof(fixedtemp), "%s/%d", ipaddr, subnet_bits);
- add_assoc_string_ex(return_value, "ip_range", 9, fixedtemp, 1);
+ add_assoc_string_ex(return_value, "ip_range", 9, fixedtemp
VIRT_COPY_OPT);
}
/* Get forwarding settings */
mode = get_string_from_xpath(xml, "//network/forward/@mode", NULL,
&retval);
if (mode && retval > 0)
- add_assoc_string_ex(return_value, "forwarding", 11, mode, 1);
+ add_assoc_string_ex(return_value, "forwarding", 11, mode
VIRT_COPY_OPT);
/* Get forwarding settings */
dev = get_string_from_xpath(xml, "//network/forward/@dev", NULL,
&retval);
if (dev && retval > 0)
- add_assoc_string_ex(return_value, "forward_dev", 12, dev, 1);
+ add_assoc_string_ex(return_value, "forward_dev", 12, dev
VIRT_COPY_OPT);
/* Get DHCP values */
dhcp_start = get_string_from_xpath(xml, "//network/ip/dhcp/range/@start",
NULL, &retval);
dhcp_end = get_string_from_xpath(xml, "//network/ip/dhcp/range/@end", NULL,
&retval);
if (dhcp_start && dhcp_end && retval > 0) {
- add_assoc_string_ex(return_value, "dhcp_start", 11, dhcp_start, 1);
- add_assoc_string_ex(return_value, "dhcp_end", 9, dhcp_end, 1);
+ add_assoc_string_ex(return_value, "dhcp_start", 11, dhcp_start
VIRT_COPY_OPT);
+ add_assoc_string_ex(return_value, "dhcp_end", 9, dhcp_end
VIRT_COPY_OPT);
}
free(dhcp_end);
@@ -9615,17 +9522,9 @@ PHP_FUNCTION(libvirt_network_get_xml_desc)
tmp = get_string_from_xpath(xml, xpath, NULL, &retval);
if ((tmp == NULL) || (retval < 0)) {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(xml);
-#else
- RETVAL_STRING(xml, 1);
-#endif
+ RETVAL_STRING(xml VIRT_COPY_OPT);
} else {
-#if PHP_MAJOR_VERSION >= 7
- RETVAL_STRING(tmp);
-#else
- RETVAL_STRING(tmp, 1);
-#endif
+ RETVAL_STRING(tmp VIRT_COPY_OPT);
}
free(xml);
@@ -9665,7 +9564,7 @@ PHP_FUNCTION(libvirt_version)
add_assoc_long(return_value, "libvirt.minor",(long)((libVer/1000) %
1000));
add_assoc_long(return_value, "libvirt.major",(long)((libVer/1000000) %
1000));
- add_assoc_string_ex(return_value, "connector.version", 18,
PHP_LIBVIRT_WORLD_VERSION, 1);
+ add_assoc_string_ex(return_value, "connector.version", 18,
PHP_LIBVIRT_WORLD_VERSION VIRT_COPY_OPT);
add_assoc_long(return_value, "connector.major", VERSION_MAJOR);
add_assoc_long(return_value, "connector.minor", VERSION_MINOR);
add_assoc_long(return_value, "connector.release", VERSION_MICRO);
--
2.5.5