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

void main(int argc, char **argv)
{
    char        *extname_p;
	int                  i;
	NJV_Nja	           nja;

	for(i = 1; i < argc; i++){
		if ( NULL != (extname_p = strrchr(argv[i], '.'))
			&& 0 < strlen(extname_p)) {
			if(!strcmp(extname_p, ".nja" ) || !strcmp(extname_p, ".NJA" ) ){
				if(FALSE == NJV_ReadNja(&nja, argv[i])) {
					fprintf(stderr, "ERROR ReadNja\n");
					goto L_END;	
				}
				ssn_PrintObject(nja.object_p);
				NJV_ReadNjaFree(&nja);
			}
			if(!strcmp(extname_p, ".nam" ) || !strcmp(extname_p, ".NAM" ) ){
				if(FALSE == NJV_ReadNam(&nja, argv[i], NJV_MODE_NAM)) {
					NJV_ReadNjaFree(&nja);
					fprintf(stderr, "ERROR ReadNam\n");
					goto L_END;	
				}
				ssn_PrintMotion(nja.action.motion);
				NJV_MotionFree(nja.action.motion, nja.motion_tree_n);
			}
		}
	}
L_END:;
}