提交 6d19d742 编写于 作者: C Claudio Bley

libvirt.c: add 2 spaces of indentation to example code of virStreamSend

See libvirt-libvirt.html#virStreamSend for the effect.
上级 3a77ecac
...@@ -17016,37 +17016,37 @@ virStreamRef(virStreamPtr stream) ...@@ -17016,37 +17016,37 @@ virStreamRef(virStreamPtr stream)
* An example using this with a hypothetical file upload * An example using this with a hypothetical file upload
* API looks like * API looks like
* *
* virStreamPtr st = virStreamNew(conn, 0); * virStreamPtr st = virStreamNew(conn, 0);
* int fd = open("demo.iso", O_RDONLY) * int fd = open("demo.iso", O_RDONLY)
* *
* virConnectUploadFile(conn, "demo.iso", st); * virConnectUploadFile(conn, "demo.iso", st);
* *
* while (1) { * while (1) {
* char buf[1024]; * char buf[1024];
* int got = read(fd, buf, 1024); * int got = read(fd, buf, 1024);
* if (got < 0) { * if (got < 0) {
* virStreamAbort(st);
* break;
* }
* if (got == 0) {
* virStreamFinish(st);
* break;
* }
* int offset = 0;
* while (offset < got) {
* int sent = virStreamSend(st, buf+offset, got-offset)
* if (sent < 0) {
* virStreamAbort(st); * virStreamAbort(st);
* goto done; * break;
* } * }
* offset += sent; * if (got == 0) {
* } * virStreamFinish(st);
* } * break;
* if (virStreamFinish(st) < 0) * }
* ... report an error .... * int offset = 0;
* done: * while (offset < got) {
* virStreamFree(st); * int sent = virStreamSend(st, buf+offset, got-offset)
* close(fd); * if (sent < 0) {
* virStreamAbort(st);
* goto done;
* }
* offset += sent;
* }
* }
* if (virStreamFinish(st) < 0)
* ... report an error ....
* done:
* virStreamFree(st);
* close(fd);
* *
* Returns the number of bytes written, which may be less * Returns the number of bytes written, which may be less
* than requested. * than requested.
...@@ -17110,35 +17110,35 @@ error: ...@@ -17110,35 +17110,35 @@ error:
* An example using this with a hypothetical file download * An example using this with a hypothetical file download
* API looks like * API looks like
* *
* virStreamPtr st = virStreamNew(conn, 0); * virStreamPtr st = virStreamNew(conn, 0);
* int fd = open("demo.iso", O_WRONLY, 0600) * int fd = open("demo.iso", O_WRONLY, 0600)
* *
* virConnectDownloadFile(conn, "demo.iso", st); * virConnectDownloadFile(conn, "demo.iso", st);
* *
* while (1) { * while (1) {
* char buf[1024]; * char buf[1024];
* int got = virStreamRecv(st, buf, 1024); * int got = virStreamRecv(st, buf, 1024);
* if (got < 0) * if (got < 0)
* break; * break;
* if (got == 0) { * if (got == 0) {
* virStreamFinish(st); * virStreamFinish(st);
* break; * break;
* } * }
* int offset = 0; * int offset = 0;
* while (offset < got) { * while (offset < got) {
* int sent = write(fd, buf+offset, got-offset) * int sent = write(fd, buf+offset, got-offset)
* if (sent < 0) { * if (sent < 0) {
* virStreamAbort(st); * virStreamAbort(st);
* goto done; * goto done;
* } * }
* offset += sent; * offset += sent;
* } * }
* } * }
* if (virStreamFinish(st) < 0) * if (virStreamFinish(st) < 0)
* ... report an error .... * ... report an error ....
* done: * done:
* virStreamFree(st); * virStreamFree(st);
* close(fd); * close(fd);
* *
* *
* Returns the number of bytes read, which may be less * Returns the number of bytes read, which may be less
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册