/*
 * Progress.c
 *
 * Copyright (c) 2007  Vreixo Formoso
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * See COPYING file for details.
 */

#include "org_pykix_libburnia_libburn_Progress.h"

#include <stdlib.h>
#include "libburn.h"

/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_new
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL 
Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1new
(
	JNIEnv *env, jclass cls
)
{
	//FIXME: sizeof(struct burn_progress) == 52, but if we alloc less
	//than 53 bytes code breaks, I don't known the reason!!!
	//return (jlong) calloc(1, sizeof(struct burn_progress) );
	return (jlong) calloc(1, 54 );
}

/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_free
 * Signature: (J)V
 */
JNIEXPORT void JNICALL 
Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1free
(
	JNIEnv *env, jclass cls, jlong p
)
{
	free( (void *) p );
}

/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_sessions
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL 
Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1sessions
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->sessions;
}

/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_session
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1session
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->session;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_tracks
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1tracks
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->tracks;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_track
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1track
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->track;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_indices
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1indices
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->indices;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_index
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1index
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->index;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_start_sector
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1start_1sector
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->start_sector;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_sectors
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1sectors
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->sectors;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_sector
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1sector
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->sector;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_buffer_capacity
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1buffer_1capacity
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->buffer_capacity;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_buffer_available
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1buffer_1available
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->buffer_available;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_buffered_bytes
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1buffered_1bytes
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->buffered_bytes;
}


/*
 * Class:     org_pykix_libburnia_libburn_Progress
 * Method:    burn_progress_buffer_min_fill
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL Java_org_pykix_libburnia_libburn_Progress_burn_1progress_1buffer_1min_1fill
(
	JNIEnv *env, jclass cls, jlong p
)
{
	return ((struct burn_progress*) p)->buffer_min_fill;
}

