1f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* 2f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project 3f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 4f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 5f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * you may not use this file except in compliance with the License. 6f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * You may obtain a copy of the License at 7f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 8f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 10f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * See the License for the specific language governing permissions and 14f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * limitations under the License. 15f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 16f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* 17f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * This represents a "raw" unswapped, unoptimized DEX file. We don't open 18f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * them directly, except to create the optimized version that we tuck in 19f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * the cache area. 20f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 21f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project#ifndef _DALVIK_RAWDEXFILE 22f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project#define _DALVIK_RAWDEXFILE 23f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 24f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* 25f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Structure representing a "raw" DEX file, in its unswapped unoptimized 26f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * state. 27f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 28f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Projecttypedef struct RawDexFile { 29f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project char* cacheFileName; 30f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project DvmDex* pDvmDex; 31f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project} RawDexFile; 32f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 33f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* 34f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Open a raw ".dex" file, optimize it, and load it. 35f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * 36f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * On success, returns 0 and sets "*ppDexFile" to a newly-allocated DexFile. 37f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * On failure, returns a meaningful error code [currently just -1]. 38f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 39f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Projectint dvmRawDexFileOpen(const char* fileName, const char* odexOutputName, 40f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project RawDexFile** ppDexFile, bool isBootstrap); 41f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 42f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* 43f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Free a RawDexFile structure, along with any associated structures. 44f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 45f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Projectvoid dvmRawDexFileFree(RawDexFile* pRawDexFile); 46f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 47f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* 48f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project * Pry the DexFile out of a RawDexFile. 49f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project */ 50f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source ProjectINLINE DvmDex* dvmGetRawDexFileDex(RawDexFile* pRawDexFile) { 51f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return pRawDexFile->pDvmDex; 52f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project} 53f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 54f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project/* get full path of optimized DEX file */ 55f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source ProjectINLINE const char* dvmGetRawDexFileCacheFileName(RawDexFile* pRawDexFile) { 56f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project return pRawDexFile->cacheFileName; 57f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project} 58f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project 59f6c387128427e121477c1b32ad35cdcaa5101ba3The Android Open Source Project#endif /*_DALVIK_RAWDEXFILE*/ 60