diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 11:47:07 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 11:47:07 +0100 |
commit | 826020fe18bf2eee43f8afea392874bb88c0650a (patch) | |
tree | 7c6c40758611605be29b3528da647a78a071ea1b /java | |
parent | 3854bbdecd1c089959fb812a739b84a96c05fbbf (diff) | |
download | libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.tar.gz libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.tar.xz libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.zip |
Generated code for head/tail commands.
Diffstat (limited to 'java')
-rw-r--r-- | java/com/redhat/et/libguestfs/GuestFS.java | 108 | ||||
-rw-r--r-- | java/com_redhat_et_libguestfs_GuestFS.c | 144 |
2 files changed, 245 insertions, 7 deletions
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index 64b0802b..30913327 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -3112,14 +3112,14 @@ public HashMap<String,String> test0rhashtableerr () * <p> * @throws LibGuestFSException */ - public void sfdisk_N (String device, int n, int cyls, int heads, int sectors, String line) + public void sfdisk_N (String device, int partnum, int cyls, int heads, int sectors, String line) throws LibGuestFSException { if (g == 0) throw new LibGuestFSException ("sfdisk_N: handle is closed"); - _sfdisk_N (g, device, n, cyls, heads, sectors, line); + _sfdisk_N (g, device, partnum, cyls, heads, sectors, line); } - private native void _sfdisk_N (long g, String device, int n, int cyls, int heads, int sectors, String line) + private native void _sfdisk_N (long g, String device, int partnum, int cyls, int heads, int sectors, String line) throws LibGuestFSException; /** @@ -3623,4 +3623,106 @@ public HashMap<String,String> test0rhashtableerr () private native int _wc_c (long g, String path) throws LibGuestFSException; + /** + * return first 10 lines of a file + * <p> + * This command returns up to the first 10 lines of a file + * as a list of strings. + * <p> + * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + * <p> + * @throws LibGuestFSException + */ + public String[] head (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("head: handle is closed"); + return _head (g, path); + } + private native String[] _head (long g, String path) + throws LibGuestFSException; + + /** + * return first N lines of a file + * <p> + * If the parameter "nrlines" is a positive number, this + * returns the first "nrlines" lines of the file "path". + * <p> + * If the parameter "nrlines" is a negative number, this + * returns lines from the file "path", excluding the last + * "nrlines" lines. + * <p> + * If the parameter "nrlines" is zero, this returns an + * empty list. + * <p> + * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + * <p> + * @throws LibGuestFSException + */ + public String[] head_n (int nrlines, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("head_n: handle is closed"); + return _head_n (g, nrlines, path); + } + private native String[] _head_n (long g, int nrlines, String path) + throws LibGuestFSException; + + /** + * return last 10 lines of a file + * <p> + * This command returns up to the last 10 lines of a file + * as a list of strings. + * <p> + * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + * <p> + * @throws LibGuestFSException + */ + public String[] tail (String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("tail: handle is closed"); + return _tail (g, path); + } + private native String[] _tail (long g, String path) + throws LibGuestFSException; + + /** + * return last N lines of a file + * <p> + * If the parameter "nrlines" is a positive number, this + * returns the last "nrlines" lines of the file "path". + * <p> + * If the parameter "nrlines" is a negative number, this + * returns lines from the file "path", starting with the + * "-nrlines"th line. + * <p> + * If the parameter "nrlines" is zero, this returns an + * empty list. + * <p> + * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + * <p> + * @throws LibGuestFSException + */ + public String[] tail_n (int nrlines, String path) + throws LibGuestFSException + { + if (g == 0) + throw new LibGuestFSException ("tail_n: handle is closed"); + return _tail_n (g, nrlines, path); + } + private native String[] _tail_n (long g, int nrlines, String path) + throws LibGuestFSException; + } diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c index 3a162597..501e8d12 100644 --- a/java/com_redhat_et_libguestfs_GuestFS.c +++ b/java/com_redhat_et_libguestfs_GuestFS.c @@ -3728,24 +3728,24 @@ Java_com_redhat_et_libguestfs_GuestFS__1pvresize JNIEXPORT void JNICALL Java_com_redhat_et_libguestfs_GuestFS__1sfdisk_1N - (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jint jn, jint jcyls, jint jheads, jint jsectors, jstring jline) + (JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jint jpartnum, jint jcyls, jint jheads, jint jsectors, jstring jline) { guestfs_h *g = (guestfs_h *) (long) jg; int r; const char *device; - int n; + int partnum; int cyls; int heads; int sectors; const char *line; device = (*env)->GetStringUTFChars (env, jdevice, NULL); - n = jn; + partnum = jpartnum; cyls = jcyls; heads = jheads; sectors = jsectors; line = (*env)->GetStringUTFChars (env, jline, NULL); - r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line); + r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line); (*env)->ReleaseStringUTFChars (env, jdevice, device); (*env)->ReleaseStringUTFChars (env, jline, line); if (r == -1) { @@ -4199,3 +4199,139 @@ Java_com_redhat_et_libguestfs_GuestFS__1wc_1c return (jint) r; } +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1head + (JNIEnv *env, jobject obj, jlong jg, jstring jpath) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + int r_len; + jclass cl; + jstring jstr; + char **r; + const char *path; + int i; + + path = (*env)->GetStringUTFChars (env, jpath, NULL); + r = guestfs_head (g, path); + (*env)->ReleaseStringUTFChars (env, jpath, path); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + for (r_len = 0; r[r_len] != NULL; ++r_len) ; + cl = (*env)->FindClass (env, "java/lang/String"); + jstr = (*env)->NewStringUTF (env, ""); + jr = (*env)->NewObjectArray (env, r_len, cl, jstr); + for (i = 0; i < r_len; ++i) { + jstr = (*env)->NewStringUTF (env, r[i]); + (*env)->SetObjectArrayElement (env, jr, i, jstr); + free (r[i]); + } + free (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1head_1n + (JNIEnv *env, jobject obj, jlong jg, jint jnrlines, jstring jpath) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + int r_len; + jclass cl; + jstring jstr; + char **r; + int nrlines; + const char *path; + int i; + + nrlines = jnrlines; + path = (*env)->GetStringUTFChars (env, jpath, NULL); + r = guestfs_head_n (g, nrlines, path); + (*env)->ReleaseStringUTFChars (env, jpath, path); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + for (r_len = 0; r[r_len] != NULL; ++r_len) ; + cl = (*env)->FindClass (env, "java/lang/String"); + jstr = (*env)->NewStringUTF (env, ""); + jr = (*env)->NewObjectArray (env, r_len, cl, jstr); + for (i = 0; i < r_len; ++i) { + jstr = (*env)->NewStringUTF (env, r[i]); + (*env)->SetObjectArrayElement (env, jr, i, jstr); + free (r[i]); + } + free (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1tail + (JNIEnv *env, jobject obj, jlong jg, jstring jpath) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + int r_len; + jclass cl; + jstring jstr; + char **r; + const char *path; + int i; + + path = (*env)->GetStringUTFChars (env, jpath, NULL); + r = guestfs_tail (g, path); + (*env)->ReleaseStringUTFChars (env, jpath, path); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + for (r_len = 0; r[r_len] != NULL; ++r_len) ; + cl = (*env)->FindClass (env, "java/lang/String"); + jstr = (*env)->NewStringUTF (env, ""); + jr = (*env)->NewObjectArray (env, r_len, cl, jstr); + for (i = 0; i < r_len; ++i) { + jstr = (*env)->NewStringUTF (env, r[i]); + (*env)->SetObjectArrayElement (env, jr, i, jstr); + free (r[i]); + } + free (r); + return jr; +} + +JNIEXPORT jobjectArray JNICALL +Java_com_redhat_et_libguestfs_GuestFS__1tail_1n + (JNIEnv *env, jobject obj, jlong jg, jint jnrlines, jstring jpath) +{ + guestfs_h *g = (guestfs_h *) (long) jg; + jobjectArray jr; + int r_len; + jclass cl; + jstring jstr; + char **r; + int nrlines; + const char *path; + int i; + + nrlines = jnrlines; + path = (*env)->GetStringUTFChars (env, jpath, NULL); + r = guestfs_tail_n (g, nrlines, path); + (*env)->ReleaseStringUTFChars (env, jpath, path); + if (r == NULL) { + throw_exception (env, guestfs_last_error (g)); + return NULL; + } + for (r_len = 0; r[r_len] != NULL; ++r_len) ; + cl = (*env)->FindClass (env, "java/lang/String"); + jstr = (*env)->NewStringUTF (env, ""); + jr = (*env)->NewObjectArray (env, r_len, cl, jstr); + for (i = 0; i < r_len; ++i) { + jstr = (*env)->NewStringUTF (env, r[i]); + (*env)->SetObjectArrayElement (env, jr, i, jstr); + free (r[i]); + } + free (r); + return jr; +} + |