1 /* libjclass - Library for reading java class files
2  * Copyright (C) 2003  Nicos Panayides
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  * $Id: class.h,v 1.25 2004/05/07 11:53:13 anarxia Exp $
19  */
20 
21 #ifndef __JCLASS_CLASS_H__
22 #define __JCLASS_CLASS_H__
23 
24 #ifdef _cplusplus
25   extern "C" {
26 #endif
27 
28 #include <jclass/field.h>
29 #include <jclass/class_loader.h>
30 
31 #define JAVA_CLASS_MAGIC 0xCAFEBABE
32 
33 /* Masks for access flags */
34 #define ACC_PUBLIC 0x0001
35 #define ACC_PRIVATE	0x0002
36 #define ACC_PROTECTED 0x0004
37 #define ACC_STATIC 0x0008
38 #define ACC_FINAL 0x0010
39 #define ACC_SYNCHRONIZED 0x0020
40 #define ACC_VOLATILE 0x0040
41 #define ACC_TRANSIENT 0x0080
42 #define ACC_NATIVE 0x0100
43 #define ACC_INTERFACE 0x0200
44 #define ACC_ABSTRACT 0x0400
45 #define ACC_STRICTFP 0x0800
46 
47 typedef struct {
48 	uint16_t minor_version;
49 	uint16_t major_version;
50 	ConstantPool *constant_pool;
51 	uint16_t access_flags;
52 	uint16_t interfaces_count;
53 	uint16_t *interfaces;
54 	uint16_t fields_count;
55 	Field *fields;
56 	uint16_t methods_count;
57 	Field *methods;
58 	uint16_t attributes_count;
59 	AttributeContainer *attributes;
60 } JavaClass;
61 
62 JavaClass* jclass_class_new(const char *filename, const ClassPath* classpath);
63 
64 JavaClass* jclass_class_new_from_buffer(const char *data);
65 JavaClass* jclass_class_new_from_file(FILE *classfile);
66 void jclass_class_free(JavaClass *javaclass);
67 
68 const char* jclass_class_get_vm_spec(JavaClass *javaclass);
69 char* jclass_class_get_class_name(JavaClass *javaclass);
70 char* jclass_class_get_super_class_name(JavaClass *javaclass);
71 char* jclass_class_get_package_name(JavaClass *javaclass);
72 char* jclass_class_get_sourcefile_name(JavaClass *javaclass);
73 char **jclass_class_get_interfaces(JavaClass *class_struct);
74 
75 #ifdef _cplusplus
76  }
77 #endif
78 
79 #endif
80