Generated code to support previous 2 commits.

This commit is contained in:
Richard Jones
2009-05-08 14:28:03 +01:00
parent fa7c8bb79b
commit 0faa5dde7b
24 changed files with 1621 additions and 4 deletions

View File

@@ -3254,6 +3254,82 @@ py_guestfs_equal (PyObject *self, PyObject *args)
return py_r;
}
static PyObject *
py_guestfs_strings (PyObject *self, PyObject *args)
{
PyObject *py_g;
guestfs_h *g;
PyObject *py_r;
char **r;
const char *path;
if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_strings",
&py_g, &path))
return NULL;
g = get_handle (py_g);
r = guestfs_strings (g, path);
if (r == NULL) {
PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
return NULL;
}
py_r = put_string_list (r);
free_strings (r);
return py_r;
}
static PyObject *
py_guestfs_strings_e (PyObject *self, PyObject *args)
{
PyObject *py_g;
guestfs_h *g;
PyObject *py_r;
char **r;
const char *encoding;
const char *path;
if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_strings_e",
&py_g, &encoding, &path))
return NULL;
g = get_handle (py_g);
r = guestfs_strings_e (g, encoding, path);
if (r == NULL) {
PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
return NULL;
}
py_r = put_string_list (r);
free_strings (r);
return py_r;
}
static PyObject *
py_guestfs_hexdump (PyObject *self, PyObject *args)
{
PyObject *py_g;
guestfs_h *g;
PyObject *py_r;
char *r;
const char *path;
if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_hexdump",
&py_g, &path))
return NULL;
g = get_handle (py_g);
r = guestfs_hexdump (g, path);
if (r == NULL) {
PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
return NULL;
}
py_r = PyString_FromString (r);
free (r);
return py_r;
}
static PyMethodDef methods[] = {
{ (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
{ (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
@@ -3371,6 +3447,9 @@ static PyMethodDef methods[] = {
{ (char *) "dmesg", py_guestfs_dmesg, METH_VARARGS, NULL },
{ (char *) "ping_daemon", py_guestfs_ping_daemon, METH_VARARGS, NULL },
{ (char *) "equal", py_guestfs_equal, METH_VARARGS, NULL },
{ (char *) "strings", py_guestfs_strings, METH_VARARGS, NULL },
{ (char *) "strings_e", py_guestfs_strings_e, METH_VARARGS, NULL },
{ (char *) "hexdump", py_guestfs_hexdump, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};

View File

@@ -743,6 +743,11 @@ class GuestFS:
calculated using "strlen" (so in this case the content
cannot contain embedded ASCII NULs).
*NB.* Owing to a bug, writing content containing ASCII
NUL characters does *not* work, even if the length is
specified. We hope to resolve this bug in a future
version. In the meantime use "g.upload".
Because of the message protocol, there is a transfer
limit of somewhere between 2MB and 4MB. To transfer
large files you should use FTP.
@@ -1251,3 +1256,45 @@ class GuestFS:
"""
return libguestfsmod.equal (self._o, file1, file2)
def strings (self, path):
u"""This runs the strings(1) command on a file and returns
the list of printable strings found.
This function returns a list of strings.
Because of the message protocol, there is a transfer
limit of somewhere between 2MB and 4MB. To transfer
large files you should use FTP.
"""
return libguestfsmod.strings (self._o, path)
def strings_e (self, encoding, path):
u"""This is like the "g.strings" command, but allows you to
specify the encoding.
See the strings(1) manpage for the full list of
encodings.
Commonly useful encodings are "l" (lower case L) which
will show strings inside Windows/x86 files.
The returned strings are transcoded to UTF-8.
This function returns a list of strings.
Because of the message protocol, there is a transfer
limit of somewhere between 2MB and 4MB. To transfer
large files you should use FTP.
"""
return libguestfsmod.strings_e (self._o, encoding, path)
def hexdump (self, path):
u"""This runs "hexdump -C" on the given "path". The result
is the human-readable, canonical hex dump of the file.
Because of the message protocol, there is a transfer
limit of somewhere between 2MB and 4MB. To transfer
large files you should use FTP.
"""
return libguestfsmod.hexdump (self._o, path)