提交 016b63bd 编写于 作者: J John Ferlan

docs: Fix code example formatting for virDomainInterfaceAddresses

Adjust the spacing so that the code examples are display in the code/text
box rather than just as paragraph text.
上级 585ad00b
...@@ -11523,34 +11523,35 @@ virDomainFSInfoFree(virDomainFSInfoPtr info) ...@@ -11523,34 +11523,35 @@ virDomainFSInfoFree(virDomainFSInfoPtr info)
* The caller *must* free @ifaces when no longer needed. Usual use case * The caller *must* free @ifaces when no longer needed. Usual use case
* looks like this: * looks like this:
* *
* virDomainInterfacePtr *ifaces = NULL; * virDomainInterfacePtr *ifaces = NULL;
* int ifaces_count = 0; * int ifaces_count = 0;
* size_t i, j; * size_t i, j;
* virDomainPtr dom = ... obtain a domain here ...; * virDomainPtr dom = ... obtain a domain here ...;
* *
* if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces, * if ((ifaces_count = virDomainInterfaceAddresses(dom, &ifaces,
* VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE)) < 0) * VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE)) < 0)
* goto cleanup; * goto cleanup;
* *
* ... do something with returned values, for example: * ... do something with returned values, for example:
* for (i = 0; i < ifaces_count; i++) { *
* printf("name: %s", ifaces[i]->name); * for (i = 0; i < ifaces_count; i++) {
* if (ifaces[i]->hwaddr) * printf("name: %s", ifaces[i]->name);
* printf(" hwaddr: %s", ifaces[i]->hwaddr); * if (ifaces[i]->hwaddr)
* * printf(" hwaddr: %s", ifaces[i]->hwaddr);
* for (j = 0; j < ifaces[i]->naddrs; j++) { *
* virDomainIPAddressPtr ip_addr = ifaces[i]->addrs + j; * for (j = 0; j < ifaces[i]->naddrs; j++) {
* printf("[addr: %s prefix: %d type: %d]", * virDomainIPAddressPtr ip_addr = ifaces[i]->addrs + j;
* ip_addr->addr, ip_addr->prefix, ip_addr->type); * printf("[addr: %s prefix: %d type: %d]",
* } * ip_addr->addr, ip_addr->prefix, ip_addr->type);
* printf("\n"); * }
* } * printf("\n");
* * }
* cleanup: *
* if (ifaces && ifaces_count > 0) * cleanup:
* for (i = 0; i < ifaces_count; i++) * if (ifaces && ifaces_count > 0)
* virDomainInterfaceFree(ifaces[i]); * for (i = 0; i < ifaces_count; i++)
* free(ifaces); * virDomainInterfaceFree(ifaces[i]);
* free(ifaces);
* *
* Returns the number of interfaces on success, -1 in case of error. * Returns the number of interfaces on success, -1 in case of error.
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册