⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resource.c

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 C
字号:
/* *  Copyright (c) 1999-2001 Sun Microsystems, Inc., 901 San Antonio Road, *  Palo Alto, CA 94303, U.S.A.  All Rights Reserved. * *  Sun Microsystems, Inc. has intellectual property rights relating *  to the technology embodied in this software.  In particular, and *  without limitation, these intellectual property rights may include *  one or more U.S. patents, foreign patents, or pending *  applications.  Sun, Sun Microsystems, the Sun logo, Java, KJava, *  and all Sun-based and Java-based marks are trademarks or *  registered trademarks of Sun Microsystems, Inc.  in the United *  States and other countries. * *  This software is distributed under licenses restricting its use, *  copying, distribution, and decompilation.  No part of this *  software may be reproduced in any form by any means without prior *  written authorization of Sun and its licensors, if any. * *  FEDERAL ACQUISITIONS:  Commercial Software -- Government Users *  Subject to Standard License Terms and Conditions *//*========================================================================= * KVM *========================================================================= * SYSTEM:    KVM * SUBSYSTEM: resource access (Generic Connection framework) * FILE:      resource.c * OVERVIEW:  This file implements the native functions for *            a Generic Connection protocol that is used for  *            accessing external resources. * AUTHOR:    Nik Shaylor *=======================================================================*//*========================================================================= * Include files *=======================================================================*/#include "global.h"/*========================================================================= * Forward declarations *=======================================================================*/void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_open(void);void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_close(void);void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_read(void);/*========================================================================= * Functions *=======================================================================*/ /*=========================================================================  * FUNCTION:      Object open(String) (STATIC)  * CLASS:         com.sun.cldc.io.j2me.resource.Protocol  * TYPE:          virtual native function  * OVERVIEW:      Open resource stream  * INTERFACE (operand stack manipulation):  *   parameters:  this  *   returns:     the integer value  *=======================================================================*/void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_open(void) {    STRING_INSTANCE string = popStackAsType(STRING_INSTANCE);    char           *name;    FILEPOINTER     fp;    START_TEMPORARY_ROOTS        DECLARE_TEMPORARY_ROOT(STRING_INSTANCE, _string, string);        long buflen = _string->length + 1;        DECLARE_TEMPORARY_ROOT(char *, buf,                               (char *)mallocHeapObject((buflen+CELL-1)>>log2CELL,                               GCT_NOPOINTERS));        name = getStringContentsSafely(_string, buf, buflen);        if (buf == NULL) {            throwException(&OutOfMemoryObject);        } else {            fp = openResourcefile(name);            if (fp == NULL) {                raiseException("java/io/IOException");            } else {                 pushStackAsType(FILEPOINTER, fp);            }        }    END_TEMPORARY_ROOTS} /*=========================================================================  * FUNCTION:      void close(Object) static   [Object is fp]  * CLASS:         com.sun.cldc.io.j2me.resource.Protocol  * TYPE:          virtual native function  * OVERVIEW:      Read an integer from the resource  * INTERFACE (operand stack manipulation):  *   parameters:  this  *   returns:     the integer value  *=======================================================================*/void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_close(void) {    START_TEMPORARY_ROOTS        DECLARE_TEMPORARY_ROOT(FILEPOINTER, fp, popStackAsType(FILEPOINTER));        if (fp == NULL) {            raiseException("java/io/IOException");        } else {            closeClassfile(&fp);        }    END_TEMPORARY_ROOTS    /* Java code will set the handle to NULL */} /*=========================================================================  * FUNCTION:      read()I (VIRTUAL)  * CLASS:         com.sun.cldc.io.j2me.resource.Protocol  * TYPE:          virtual native function  * OVERVIEW:      Read an integer from the resource  * INTERFACE (operand stack manipulation):  *   parameters:  this  *   returns:     the integer value  *=======================================================================*/void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_read(void) {    START_TEMPORARY_ROOTS        int result;        DECLARE_TEMPORARY_ROOT(FILEPOINTER, fp, popStackAsType(FILEPOINTER));        if (fp == NULL) {            raiseException("java/io/IOException");        } else {             result = loadByteNoEOFCheck(&fp);            pushStack(result);        }    END_TEMPORARY_ROOTS} /*=========================================================================  * FUNCTION:      readAll()I (VIRTUAL)  * CLASS:         com.sun.cldc.io.j2me..resource.Protocol  * TYPE:          virtual native function  * OVERVIEW:      Read an array of bytes from the stream  * INTERFACE (operand stack manipulation):  *   parameters:  this, byte array, offset, filepos, len  *   returns:     the number of bytes read  *=======================================================================*/void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_readBytes(void) {    int result;    int length = popStack();    int pos = popStack();    int offset = popStack();    BYTEARRAY bytes = popStackAsType(BYTEARRAY);    FILEPOINTER fp = popStackAsType(FILEPOINTER);    if (fp == NULL || bytes == NULL) {        raiseException("java/io/IOException");    } else {         result = loadBytesNoEOFCheck(&fp, (char *)&bytes->bdata[offset], pos, length);        pushStack(result);    }} /*=========================================================================  * FUNCTION:      available()I (VIRTUAL)  * CLASS:         com.sun.cldc.io.j2me.resource.Protocol  * TYPE:          virtual native function  * OVERVIEW:      return amount of data on this stream  * INTERFACE (operand stack manipulation):  *   parameters:  this  *   returns:     the number of bytes available  *=======================================================================*/void Java_com_sun_cldc_io_j2me_resource_PrivateInputStream_available(void) {    int result;    FILEPOINTER fp = popStackAsType(FILEPOINTER);    if (fp == NULL) {        raiseException("java/io/IOException");    } else {         result = getBytesAvailable(&fp);        pushStack(result);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -