M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __COMMON_TYPES_H__
#define __COMMON_TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define Trace(...)
#ifdef __cplusplus
}
#endif
#endif /* __COMMON_TYPES_H__ */
@@ -0,0 +1,242 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DRM1_JNI_H__
#define __DRM1_JNI_H__
#ifdef __cplusplus
extern "C" {
#endif
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class android_drm_mobile1_DrmRawContent */
#undef android_drm_mobile1_DrmRawContent_DRM_FORWARD_LOCK
#define android_drm_mobile1_DrmRawContent_DRM_FORWARD_LOCK 1L
#undef android_drm_mobile1_DrmRawContent_DRM_COMBINED_DELIVERY
#define android_drm_mobile1_DrmRawContent_DRM_COMBINED_DELIVERY 2L
#undef android_drm_mobile1_DrmRawContent_DRM_SEPARATE_DELIVERY
#define android_drm_mobile1_DrmRawContent_DRM_SEPARATE_DELIVERY 3L
#undef android_drm_mobile1_DrmRawContent_DRM_SEPARATE_DELIVERY_DM
#define android_drm_mobile1_DrmRawContent_DRM_SEPARATE_DELIVERY_DM 4L
#undef android_drm_mobile1_DrmRawContent_DRM_MIMETYPE_MESSAGE
#define android_drm_mobile1_DrmRawContent_DRM_MIMETYPE_MESSAGE 1L
#undef android_drm_mobile1_DrmRawContent_DRM_MIMETYPE_CONTENT
#define android_drm_mobile1_DrmRawContent_DRM_MIMETYPE_CONTENT 2L
#undef android_drm_mobile1_DrmRawContent_JNI_DRM_SUCCESS
#define android_drm_mobile1_DrmRawContent_JNI_DRM_SUCCESS 0L
#undef android_drm_mobile1_DrmRawContent_JNI_DRM_FAILURE
#define android_drm_mobile1_DrmRawContent_JNI_DRM_FAILURE -1L
#undef android_drm_mobile1_DrmRawContent_JNI_DRM_EOF
#define android_drm_mobile1_DrmRawContent_JNI_DRM_EOF -2L
#undef android_drm_mobile1_DrmRawContent_JNI_DRM_UNKNOWN_DATA_LEN
#define android_drm_mobile1_DrmRawContent_JNI_DRM_UNKNOWN_DATA_LEN -3L
/*
* Class: android_drm_mobile1_DrmRawContent
* Method: nativeConstructDrmContent
* Signature: (Ljava/io/InputStream;II)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRawContent_nativeConstructDrmContent
(JNIEnv *, jobject, jobject, jint, jint);
/*
* Class: android_drm_mobile1_DrmRawContent
* Method: nativeGetRightsAddress
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_android_drm_mobile1_DrmRawContent_nativeGetRightsAddress
(JNIEnv *, jobject);
/*
* Class: android_drm_mobile1_DrmRawContent
* Method: nativeGetDeliveryMethod
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRawContent_nativeGetDeliveryMethod
(JNIEnv *, jobject);
/*
* Class: android_drm_mobile1_DrmRawContent
* Method: nativeReadPieceOfContent
* Signature: ([BIII)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRawContent_nativeReadContent
(JNIEnv *, jobject, jbyteArray, jint, jint, jint);
/*
* Class: android_drm_mobile1_DrmRawContent
* Method: nativeGetContentType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_android_drm_mobile1_DrmRawContent_nativeGetContentType
(JNIEnv *, jobject);
/*
* Class: android_drm_mobile1_DrmRawContent
* Method: nativeGetContentLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRawContent_nativeGetContentLength
(JNIEnv *, jobject);
/*
* Class: android_drm_mobile1_DrmRawContent
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_android_drm_mobile1_DrmRawContent_finalize
(JNIEnv *, jobject);
/* Header for class android_drm_mobile1_DrmRights */
#undef android_drm_mobile1_DrmRights_DRM_PERMISSION_PLAY
#define android_drm_mobile1_DrmRights_DRM_PERMISSION_PLAY 1L
#undef android_drm_mobile1_DrmRights_DRM_PERMISSION_DISPLAY
#define android_drm_mobile1_DrmRights_DRM_PERMISSION_DISPLAY 2L
#undef android_drm_mobile1_DrmRights_DRM_PERMISSION_EXECUTE
#define android_drm_mobile1_DrmRights_DRM_PERMISSION_EXECUTE 3L
#undef android_drm_mobile1_DrmRights_DRM_PERMISSION_PRINT
#define android_drm_mobile1_DrmRights_DRM_PERMISSION_PRINT 4L
#undef android_drm_mobile1_DrmRights_DRM_CONSUME_RIGHTS_SUCCESS
#define android_drm_mobile1_DrmRights_DRM_CONSUME_RIGHTS_SUCCESS 0L
#undef android_drm_mobile1_DrmRights_DRM_CONSUME_RIGHTS_FAILURE
#define android_drm_mobile1_DrmRights_DRM_CONSUME_RIGHTS_FAILURE -1L
#undef android_drm_mobile1_DrmRights_JNI_DRM_SUCCESS
#define android_drm_mobile1_DrmRights_JNI_DRM_SUCCESS 0L
#undef android_drm_mobile1_DrmRights_JNI_DRM_FAILURE
#define android_drm_mobile1_DrmRights_JNI_DRM_FAILURE -1L
/*
* Class: android_drm_mobile1_DrmRights
* Method: nativeGetConstraintInfo
* Signature: (ILandroid/drm/mobile1/DrmConstraintInfo;)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRights_nativeGetConstraintInfo
(JNIEnv *, jobject, jint, jobject);
/*
* Class: android_drm_mobile1_DrmRights
* Method: nativeConsumeRights
* Signature: (I)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRights_nativeConsumeRights
(JNIEnv *, jobject, jint);
/* Header for class android_drm_mobile1_DrmRightsManager */
#undef android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_RIGHTS_XML
#define android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_RIGHTS_XML 3L
#undef android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_RIGHTS_WBXML
#define android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_RIGHTS_WBXML 4L
#undef android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_MESSAGE
#define android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_MESSAGE 1L
#undef android_drm_mobile1_DrmRightsManager_JNI_DRM_SUCCESS
#define android_drm_mobile1_DrmRightsManager_JNI_DRM_SUCCESS 0L
#undef android_drm_mobile1_DrmRightsManager_JNI_DRM_FAILURE
#define android_drm_mobile1_DrmRightsManager_JNI_DRM_FAILURE -1L
/* Inaccessible static: singleton */
/*
* Class: android_drm_mobile1_DrmRightsManager
* Method: nativeInstallDrmRights
* Signature: (Ljava/io/InputStream;IILandroid/drm/mobile1/DrmRights;)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRightsManager_nativeInstallDrmRights
(JNIEnv *, jobject, jobject, jint, jint, jobject);
/*
* Class: android_drm_mobile1_DrmRightsManager
* Method: nativeQueryRights
* Signature: (Landroid/drm/mobile1/DrmRawContent;Landroid/drm/mobile1/DrmRights;)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRightsManager_nativeQueryRights
(JNIEnv *, jobject, jobject, jobject);
/*
* Class: android_drm_mobile1_DrmRightsManager
* Method: nativeGetRightsNumber
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRightsManager_nativeGetNumOfRights
(JNIEnv *, jobject);
/*
* Class: android_drm_mobile1_DrmRightsManager
* Method: nativeGetRightsList
* Signature: ([Landroid/drm/mobile1/DrmRights;I)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRightsManager_nativeGetRightsList
(JNIEnv *, jobject, jobjectArray, jint);
/*
* Class: android_drm_mobile1_DrmRightsManager
* Method: nativeDeleteRights
* Signature: (Landroid/drm/mobile1/DrmRights;)I
*/
JNIEXPORT jint JNICALL Java_android_drm_mobile1_DrmRightsManager_nativeDeleteRights
(JNIEnv *, jobject, jobject);
/**
* DRM return value defines
*/
#define JNI_DRM_SUCCESS \
android_drm_mobile1_DrmRawContent_JNI_DRM_SUCCESS /**< Successful operation */
#define JNI_DRM_FAILURE \
android_drm_mobile1_DrmRawContent_JNI_DRM_FAILURE /**< General failure */
#define JNI_DRM_EOF \
android_drm_mobile1_DrmRawContent_JNI_DRM_EOF /**< Indicates the end of the DRM content is reached */
#define JNI_DRM_UNKNOWN_DATA_LEN \
android_drm_mobile1_DrmRawContent_JNI_DRM_UNKNOWN_DATA_LEN /**< Indicates the data length is unknown */
/**
* DRM MIME type defines
*/
#define JNI_DRM_MIMETYPE_MESSAGE \
android_drm_mobile1_DrmRawContent_DRM_MIMETYPE_MESSAGE /**< The "application/vnd.oma.drm.message" MIME type */
#define JNI_DRM_MIMETYPE_CONTENT \
android_drm_mobile1_DrmRawContent_DRM_MIMETYPE_CONTENT /**< The "application/vnd.oma.drm.content" MIME type */
#define JNI_DRM_MIMETYPE_RIGHTS_XML \
android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_RIGHTS_XML /**< The "application/vnd.oma.drm.rights+xml" MIME type */
#define JNI_DRM_MIMETYPE_RIGHTS_WBXML \
android_drm_mobile1_DrmRightsManager_DRM_MIMETYPE_RIGHTS_WBXML /**< The "application/vnd.oma.drm.rights+wbxml" MIME type */
/**
* DRM permission defines
*/
#define JNI_DRM_PERMISSION_PLAY \
android_drm_mobile1_DrmRights_DRM_PERMISSION_PLAY /**< The permission to play */
#define JNI_DRM_PERMISSION_DISPLAY \
android_drm_mobile1_DrmRights_DRM_PERMISSION_DISPLAY /**< The permission to display */
#define JNI_DRM_PERMISSION_EXECUTE \
android_drm_mobile1_DrmRights_DRM_PERMISSION_EXECUTE /**< The permission to execute */
#define JNI_DRM_PERMISSION_PRINT \
android_drm_mobile1_DrmRights_DRM_PERMISSION_PRINT /**< The permission to print */
/**
* DRM delivery type defines
*/
#define JNI_DRM_FORWARD_LOCK \
android_drm_mobile1_DrmRawContent_DRM_FORWARD_LOCK /**< forward lock */
#define JNI_DRM_COMBINED_DELIVERY \
android_drm_mobile1_DrmRawContent_DRM_COMBINED_DELIVERY /**< combined delivery */
#define JNI_DRM_SEPARATE_DELIVERY \
android_drm_mobile1_DrmRawContent_DRM_SEPARATE_DELIVERY /**< separate delivery */
#define JNI_DRM_SEPARATE_DELIVERY_DM \
android_drm_mobile1_DrmRawContent_DRM_SEPARATE_DELIVERY_DM /**< separate delivery DRM message */
#ifdef __cplusplus
}
#endif
#endif /* __DRM1_JNI_H__ */
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file drm_decoder.h
*
* provide service to decode base64 data.
*
* <!-- #interface list begin -->
* \section drm decoder interface
* - drm_decodeBase64()
* <!-- #interface list end -->
*/
#ifndef __DRM_DECODER_H__
#define __DRM_DECODER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/**
* Decode base64
* \param dest dest buffer to save decode base64 data
* \param destLen dest buffer length
* \param src source data to be decoded
* \param srcLen source buffer length, and when return, give out how many bytes has been decoded
* \return
* -when success, return a positive integer of dest buffer length,
* if input dest buffer is NULL or destLen is 0,
* return dest buffer length that user should allocate to save decoding data
* -when failed, return -1
*/
int32_t drm_decodeBase64(uint8_t * dest, int32_t destLen, uint8_t * src, int32_t * srcLen);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_DECODER_H__ */
@@ -0,0 +1,296 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* File Porting Layer.
*/
#ifndef __DRM_FILE_H__
#define __DRM_FILE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/** Type value of a regular file or file name. */
#define DRM_FILE_ISREG 1
/** Type value of a directory or directory name. */
#define DRM_FILE_ISDIR 2
/** Type value of a filter name */
#define DRM_FILE_ISFILTER 3
/** Return code that indicates successful completion of an operation. */
#define DRM_FILE_SUCCESS 0
/** Indicates that an operation failed. */
#define DRM_FILE_FAILURE -1
/** Indicates that the a DRM_file_read() call reached the end of the file. */
#define DRM_FILE_EOF -2
/** Open for read access. */
#define DRM_FILE_MODE_READ 1
/** Open for write access. */
#define DRM_FILE_MODE_WRITE 2
#ifndef MAX_FILENAME_LEN
/** Maximum number of characters that a filename may have. By default assumes
* that the entry results of DRM_file_listNextEntry() are returned in the async state
* buffer, after the #DRM_file_result_s, and calculates the maximum name
* from that.
*/
#define MAX_FILENAME_LEN 1024
#endif
/**
* Performs one-time initialization of the File System (FS).
* This function is called once during the lifetime of an application,
* and before any call to <code>DRM_file_*</code> functions by this application.
* When several applications are using the file interface, this function may be called
* several times, once per application.
*
* @return #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_startup(void);
/**
* Returns the length of a file (by name, opened or unopened).
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number characters encoded in name.
* asynchronous operation returns #DRM_FILE_WOULDBLOCK.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_FAILURE or the file length.
*/
int32_t DRM_file_getFileLength(const uint16_t* name,
int32_t nameChars);
/**
* Initializes a list iteration session.
*
* @param prefix Prefix that must be matched, UCS-2 encoded. *
* @param prefixChars Number characters encoded in prefix.
* @param session List session identifier.
* @param iteration List iteration identifier.
*
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_listOpen(const uint16_t* prefix,
int32_t prefixChars,
int32_t* session,
int32_t* iteration);
/**
* Used to fetch a list of file names that match a given name prefix.
*
* @param prefix See DRM_file_listOpen(). This does not change during the
* iteration session.
* @param prefixChars See DRM_file_listOpen(). This does not change during
* the iteration session.
* @param entry Buffer parameter to return the next file name that matches the
* #prefix parameter, if any, when the function returns a positive number of
* characters.
* @param entryBytes Size of entry in bytes.
* @param session See DRM_file_listOpen().
* @param iteration See DRM_file_listOpen().
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_FAILURE or the number of
* characters encoded in entry. Returns 0 when the end of the list is reached.
*/
int32_t DRM_file_listNextEntry(const uint16_t* prefix,
int32_t prefixChars,
uint16_t* entry,
int32_t entryBytes,
int32_t* session,
int32_t* iteration);
/**
* Ends a list iteration session. Notifies the implementation
* that the list session is over and that any session resources
* can be released.
*
* @param session See DRM_file_listOpen().
* @param iteration See DRM_file_listOpen().
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_listClose(int32_t session, int32_t iteration);
/**
* Renames a file, given its old name. The file or directory is renamed
* immediately on the actual file system upon invocation of this method.
* Any open handles on the file specified by oldName become invalid after
* this method has been called.
*
* @param oldName Current file name (unopened), UCS-2 encoded.
* @param oldNameChars Number of characters encoded on oldName.
* @param newName New name for the file (unopened), UCS-2 encoded.
* @param newNameChars Number of characters encoded on newName.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE. In particular,
* #DRM_FILE_FAILURE if a file or directory already exists with the new name.
*/
int32_t DRM_file_rename(const uint16_t* oldName,
int32_t oldNameChars,
const uint16_t* newName,
int32_t newNameChars);
/**
* Tests if a file exists given its name.
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_ISREG, #DRM_FILE_ISDIR, #DRM_FILE_FAILURE. If name
* exists, returns #DRM_FILE_ISREG if it is a regular file and #DRM_FILE_ISDIR if it is a directory.
* Returns #DRM_FILE_FAILURE in all other cases, including those where name exists but is neither
* a regular file nor a directory. Platforms that do not support directories MUST NOT return
* #DRM_FILE_ISDIR.
*/
int32_t DRM_file_exists(const uint16_t* name,
int32_t nameChars);
/**
* Opens a file with the given name and returns its file handle.
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @param mode Any combination of the #DRM_FILE_MODE_READ and
* #DRM_FILE_MODE_WRITE flags. If the file does not exist and mode contains the
* #DRM_FILE_MODE_WRITE flag, then the file is automatically created. If the
* file exists and the mode contains the #DRM_FILE_MODE_WRITE flag, the file is
* opened so it can be modified, but the data is not modified by the open call.
* In all cases the current position is set to the start of the file.
* The following table shows how to map the mode semantics above to UNIX
* fopen-style modes. For brevity in the table, R=#DRM_FILE_MODE_READ,
* W=#DRM_FILE_MODE_WRITE, E=File exists:
* <table>
* <tr><td>RW</td><td>E</td><td>Maps-to</td></tr>
* <tr><td>00</td><td>0</td><td>Return #DRM_FILE_FAILURE</td></tr>
* <tr><td>00</td><td>1</td><td>Return #DRM_FILE_FAILURE</td></tr>
* <tr><td>01</td><td>0</td><td>Use fopen mode "w"</td></tr>
* <tr><td>01</td><td>1</td><td>Use fopen mode "a" and fseek to the start</td></tr>
* <tr><td>10</td><td>0</td><td>Return #DRM_FILE_FAILURE</td></tr>
* <tr><td>10</td><td>1</td><td>Use fopen mode "r"</td></tr>
* <tr><td>11</td><td>0</td><td>Use fopen mode "w+"</td></tr>
* <tr><td>11</td><td>1</td><td>Use fopen mode "r+"</td></tr>
* </table>
* @param handle Pointer where the result handle value is placed when the function
* is called synchronously.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_open(const uint16_t* name,
int32_t nameChars,
int32_t mode,
int32_t* handle);
/**
* Deletes a file given its name, UCS-2 encoded. The file or directory is
* deleted immediately on the actual file system upon invocation of this
* method. Any open handles on the file specified by name become invalid
* after this method has been called.
*
* If the port needs to ensure that a specific application does not exceed a given storage
* space quota, then the bytes freed by the deletion must be added to the available space for
* that application.
*
* @param name Name of the file, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_delete(const uint16_t* name,
int32_t nameChars);
/**
* Read bytes from a file at the current position to a buffer. Afterwards the
* new file position is the byte after the last byte read.
* DRM_FILE_FAILURE is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete, DRM_file_rename, or DRM_file_close).
*
* @param handle File handle as returned by DRM_file_open().
* @param dst Buffer where the data is to be copied.
* @param length Number of bytes to be copied.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE, #DRM_FILE_EOF
* or the number of bytes that were read, i.e. in the range 0..length.
*/
int32_t DRM_file_read(int32_t handle,
uint8_t* dst,
int32_t length);
/**
* Write bytes from a buffer to the file at the current position. If the
* current position + number of bytes written > current size of the file,
* then the file is grown. Afterwards the new file position is the byte
* after the last byte written.
* DRM_FILE_FAILURE is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete, DRM_file_rename, or DRM_file_close).
*
* @param handle File handle as returned by DRM_file_open().
* @param src Buffer that contains the bytes to be written.
* @param length Number of bytes to be written.
* If the port needs to ensure that a specific application does not exceed a given storage
* space quota, the implementation must make sure the call does not violate that invariant.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_FAILURE or the number of bytes
* that were written. This number must be in the range 0..length.
* Returns #DRM_FILE_FAILURE when storage is full or exceeds quota.
*/
int32_t DRM_file_write(int32_t handle,
const uint8_t* src,
int32_t length);
/**
* Closes a file.
* DRM_FILE_SUCCESS is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete or DRM_file_rename).
*
* @param handle File handle as returned by DRM_file_open().
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_close(int32_t handle);
/**
* Sets the current position in an opened file.
* DRM_FILE_FAILURE is returned if the handle is invalid (e.g., as a
* consquence of DRM_file_delete, DRM_file_rename, or DRM_file_close).
*
* @param handle File handle as returned by DRM_file_open().
* @param value The new current position of the file. If value is greater
* than the length of the file then the file should be extended. The contents
* of the newly extended portion of the file is undefined.
* If the port needs to ensure that a specific application does not exceed a given storage
* space quota, the implementation must make sure the call does not violate that invariant.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
* Returns #DRM_FILE_FAILURE when storage is full or exceeds quota.
*/
int32_t DRM_file_setPosition(int32_t handle, int32_t value);
/**
* Creates a directory with the assigned name and full file permissions on
* the file system. The full path to the new directory must already exist.
* The directory is created immediately on the actual file system upon
* invocation of this method.
*
* @param name Name of the directory, UCS-2 encoded.
* @param nameChars Number of characters encoded in name.
* @return #DRM_FILE_WOULDBLOCK, #DRM_FILE_SUCCESS, #DRM_FILE_FAILURE.
*/
int32_t DRM_file_mkdir(const uint16_t* name,
int32_t nameChars);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_FILE_H__ */
@@ -0,0 +1,107 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DRM_I18N_H__
#define __DRM_I18N_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/**
* @name Charset value defines
* @ingroup i18n
*
* Charset value defines
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_81rn.asp
*/
typedef enum {
DRM_CHARSET_GBK = 936, /** Simplified Chinese GBK (CP936) */
DRM_CHARSET_GB2312 = 20936, /** Simplified Chinese GB2312 (CP936) */
DRM_CHARSET_BIG5 = 950, /** BIG5 (CP950) */
DRM_CHARSET_LATIN1 = 28591, /** ISO 8859-1, Latin 1 */
DRM_CHARSET_LATIN2 = 28592, /** ISO 8859-2, Latin 2 */
DRM_CHARSET_LATIN3 = 28593, /** ISO 8859-3, Latin 3 */
DRM_CHARSET_LATIN4 = 28594, /** ISO 8859-4, Latin 4 */
DRM_CHARSET_CYRILLIC = 28595, /** ISO 8859-5, Cyrillic */
DRM_CHARSET_ARABIC = 28596, /** ISO 8859-6, Arabic */
DRM_CHARSET_GREEK = 28597, /** ISO 8859-7, Greek */
DRM_CHARSET_HEBREW = 28598, /** ISO 8859-8, Hebrew */
DRM_CHARSET_LATIN5 = 28599, /** ISO 8859-9, Latin 5 */
DRM_CHARSET_LATIN6 = 865, /** ISO 8859-10, Latin 6 (not sure here) */
DRM_CHARSET_THAI = 874, /** ISO 8859-11, Thai */
DRM_CHARSET_LATIN7 = 1257, /** ISO 8859-13, Latin 7 (not sure here) */
DRM_CHARSET_LATIN8 = 38598, /** ISO 8859-14, Latin 8 (not sure here) */
DRM_CHARSET_LATIN9 = 28605, /** ISO 8859-15, Latin 9 */
DRM_CHARSET_LATIN10 = 28606, /** ISO 8859-16, Latin 10 */
DRM_CHARSET_UTF8 = 65001, /** UTF-8 */
DRM_CHARSET_UTF16LE = 1200, /** UTF-16 LE */
DRM_CHARSET_UTF16BE = 1201, /** UTF-16 BE */
DRM_CHARSET_HINDI = 57002, /** Hindi/Mac Devanagari */
DRM_CHARSET_UNSUPPORTED = -1
} DRM_Charset_t;
/**
* Convert multibyte string of specified charset to unicode string.
* Note NO terminating '\0' will be appended to the output unicode string.
*
* @param charset Charset of the multibyte string.
* @param mbs Multibyte string to be converted.
* @param mbsLen Number of the bytes (in mbs) to be converted.
* @param wcsBuf Buffer for the converted unicode characters.
* If wcsBuf is NULL, the function returns the number of unicode
* characters required for the buffer.
* @param bufSizeInWideChar The size (in wide char) of wcsBuf
* @param bytesConsumed The number of bytes in mbs that have been successfully
* converted. The value of *bytesConsumed is undefined
* if wcsBuf is NULL.
*
* @return Number of the successfully converted unicode characters if wcsBuf
* is not NULL. If wcsBuf is NULL, returns required unicode buffer
* size. -1 for unrecoverable errors.
*/
int32_t DRM_i18n_mbsToWcs(DRM_Charset_t charset,
const uint8_t *mbs, int32_t mbsLen,
uint16_t *wcsBuf, int32_t bufSizeInWideChar,
int32_t *bytesConsumed);
/**
* Convert unicode string to multibyte string with specified charset.
* Note NO terminating '\0' will be appended to the output multibyte string.
*
* @param charset Charset of the multibyte string to be converted to.
* @param wcs Unicode string to be converted.
* @param wcsLen Number of the unicode characters (in wcs) to be converted.
* @param mbsBuf Buffer for converted multibyte characters.
* If mbsBuf is NULL, the function returns the number of bytes
* required for the buffer.
* @param bufSizeInByte The size (in byte) of mbsBuf.
*
* @return Number of the successfully converted bytes.
*/
int32_t DRM_i18n_wcsToMbs(DRM_Charset_t charset,
const uint16_t *wcs, int32_t wcsLen,
uint8_t *mbsBuf, int32_t bufSizeInByte);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DRM_INNER_H__
#define __DRM_INNER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
#define INT_2_YMD_HMS(year, mon, day, date, hour, min, sec, time) do{\
year = date / 10000;\
mon = date % 10000 / 100;\
day = date %100;\
hour = time / 10000;\
min = time % 10000 / 100;\
sec = time % 100;\
}while(0)
/**
* Define the max malloc length for a DRM.
*/
#define DRM_MAX_MALLOC_LEN (50 * 1024) /* 50K */
#define DRM_ONE_AES_BLOCK_LEN 16
#define DRM_TWO_AES_BLOCK_LEN 32
typedef struct _T_DRM_DM_Binary_Node {
uint8_t boundary[256];
} T_DRM_DM_Binary_Node;
typedef struct _T_DRM_DM_Base64_Node {
uint8_t boundary[256];
uint8_t b64DecodeData[4];
int32_t b64DecodeDataLen;
} T_DRM_DM_Base64_Node;
typedef struct _T_DRM_Dcf_Node {
uint8_t rightsIssuer[256];
int32_t encContentLength;
uint8_t aesDecData[16];
int32_t aesDecDataLen;
int32_t aesDecDataOff;
uint8_t aesBackupBuf[16];
int32_t bAesBackupBuf;
} T_DRM_Dcf_Node;
typedef struct _T_DRM_Session_Node {
int32_t sessionId;
int32_t inputHandle;
int32_t mimeType;
int32_t (*getInputDataLengthFunc)(int32_t inputHandle);
int32_t (*readInputDataFunc)(int32_t inputHandle, uint8_t* buf, int32_t bufLen);
int32_t (*seekInputDataFunc)(int32_t inputHandle, int32_t offset);
int32_t deliveryMethod;
int32_t transferEncoding;
uint8_t contentType[64];
int32_t contentLength;
int32_t contentOffset;
uint8_t contentID[256];
uint8_t* rawContent;
int32_t rawContentLen;
int32_t bEndData;
uint8_t* readBuf;
int32_t readBufLen;
int32_t readBufOff;
void* infoStruct;
struct _T_DRM_Session_Node* next;
} T_DRM_Session_Node;
#ifdef __cplusplus
}
#endif
#endif /* __DRM_INNER_H__ */
@@ -0,0 +1,183 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __DRM_RIGHTS_MANAGER_H__
#define __DRM_RIGHTS_MANAGER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <openssl/aes.h>
#include <drm_common_types.h>
#include <parser_rel.h>
#ifdef DRM_DEVICE_ARCH_ARM
#define ANDROID_DRM_CORE_PATH "/data/drm/rights/"
#define DRM_UID_FILE_PATH "/data/drm/rights/uid.txt"
#else
#define ANDROID_DRM_CORE_PATH "/home/user/golf/esmertec/device/out/debug/host/linux-x86/product/sim/data/data/com.android.drm.mobile1/"
#define DRM_UID_FILE_PATH "/home/user/golf/esmertec/device/out/debug/host/linux-x86/product/sim/data/data/com.android.drm.mobile1/uid.txt"
#endif
#define EXTENSION_NAME_INFO ".info"
#define GET_ID 1
#define GET_UID 2
#define GET_ROAMOUNT 1
#define GET_ALL_RO 2
#define SAVE_ALL_RO 3
#define GET_A_RO 4
#define SAVE_A_RO 5
/**
* Get the id or uid from the "uid.txt" file.
*
* \param Uid The content id for a specially DRM object.
* \param id The id number managed by DRM engine for a specially DRM object.
* \param option The option to get id or uid, the value includes: GET_ID, GET_UID.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_readFromUidTxt(uint8_t* Uid, int32_t* id, int32_t option);
/**
* Save or read the rights information on the "id.info" file.
*
* \param id The id number managed by DRM engine for a specially DRM object.
* \param Ro The rights structure to save the rights information.
* \param RoAmount The number of rights for this DRM object.
* \param option The option include: GET_ROAMOUNT, GET_ALL_RO, SAVE_ALL_RO, GET_A_RO, SAVE_A_RO.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_writeOrReadInfo(int32_t id, T_DRM_Rights* Ro, int32_t* RoAmount, int32_t option);
/**
* Append a rights information to DRM engine storage.
*
* \param Ro The rights structure to save the rights information.
*
* return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_appendRightsInfo(T_DRM_Rights* rights);
/**
* Get the mex id number from the "uid.txt" file.
*
* \return
* -an integer to indicate the max id number.
* -(-1), if the operation failed.
*/
int32_t drm_getMaxIdFromUidTxt();
/**
* Remove the "id.info" file if all the rights for this DRM object has been deleted.
*
* \param id The id number managed by DRM engine for a specially DRM object.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_removeIdInfoFile(int32_t id);
/**
* Update the "uid.txt" file when delete the rights object.
*
* \param id The id number managed by DRM engine for a specially DRM object.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_updateUidTxtWhenDelete(int32_t id);
/**
* Get the CEK according the given content id.
*
* \param uid The content id for a specially DRM object.
* \param KeyValue The buffer to save the CEK.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_getKey(uint8_t* uid, uint8_t* KeyValue);
/**
* Discard the padding bytes in DCF decrypted data.
*
* \param decryptedBuf The aes decrypted data buffer to be scanned.
* \param decryptedBufLen The length of the buffer. And save the output result.
*
* \return
* -0
*/
void drm_discardPaddingByte(uint8_t *decryptedBuf, int32_t *decryptedBufLen);
/**
* Decrypt the media data according the CEK.
*
* \param Buffer The buffer to decrypted and also used to save the output data.
* \param BufferLen The length of the buffer data and also save the output data length.
* \param key The structure of the CEK.
*
* \return
* -0
*/
int32_t drm_aesDecBuffer(uint8_t * Buffer, int32_t * BufferLen, AES_KEY *key);
/**
* Update the DCF data length according the CEK.
*
* \param pDcfLastData The last several byte for the DCF.
* \param keyValue The CEK of the DRM content.
* \param moreBytes Output the more bytes for discarded.
*
* \return
* -TRUE, if the operation successfully.
* -FALSE, if the operation failed.
*/
int32_t drm_updateDcfDataLen(uint8_t* pDcfLastData, uint8_t* keyValue, int32_t* moreBytes);
/**
* Check and update the rights for a specially DRM content.
*
* \param id The id number managed by DRM engine for a specially DRM object.
* \param permission The permission to be check and updated.
*
* \return
* -DRM_SUCCESS, if there is a valid rights and update it successfully.
* -DRM_NO_RIGHTS, if there is no rights for this content.
* -DRM_RIGHTS_PENDING, if the rights is pending.
* -DRM_RIGHTS_EXPIRED, if the rights has expired.
* -DRM_RIGHTS_FAILURE, if there is some other error occur.
*/
int32_t drm_checkRoAndUpdate(int32_t id, int32_t permission);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_RIGHTS_MANAGER_H__ */
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* Time Porting Layer
*
* Basic support functions that are needed by time.
*
* <!-- #interface list begin -->
* \section drm_time Interface
* - DRM_time_getElapsedSecondsFrom1970()
* - DRM_time_sleep()
* - DRM_time_getSysTime()
* <!-- #interface list end -->
*/
#ifndef __DRM_TIME_H__
#define __DRM_TIME_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <drm_common_types.h>
/** the time format */
typedef struct __db_system_time_
{
uint16_t year;
uint16_t month;
uint16_t day;
uint16_t hour;
uint16_t min;
uint16_t sec;
} T_DB_TIME_SysTime;
/**
* Get the system time.it's up to UTC
* \return Return the time in elapsed seconds.
*/
uint32_t DRM_time_getElapsedSecondsFrom1970(void);
/**
* Suspend the execution of the current thread for a specified interval
* \param ms suspended time by millisecond
*/
void DRM_time_sleep(uint32_t ms);
/**
* function: get current system time
* \param time_ptr[OUT] the system time got
* \attention
* time_ptr must not be NULL
*/
void DRM_time_getSysTime(T_DB_TIME_SysTime *time_ptr);
#ifdef __cplusplus
}
#endif
#endif /* __DRM_TIME_H__ */
@@ -0,0 +1,376 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SVC_DRM_NEW_H__
#define __SVC_DRM_NEW_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
/**
* Define the mime type of DRM data.
*/
#define TYPE_DRM_MESSAGE 0x48 /**< The mime type is "application/vnd.oma.drm.message" */
#define TYPE_DRM_CONTENT 0x49 /**< The mime type is "application/vnd.oma.drm.content" */
#define TYPE_DRM_RIGHTS_XML 0x4a /**< The mime type is "application/vnd.oma.drm.rights+xml" */
#define TYPE_DRM_RIGHTS_WBXML 0x4b /**< The mime type is "application/vnd.oma.drm.rights+wbxml" */
#define TYPE_DRM_UNKNOWN 0xff /**< The mime type is unknown */
/**
* Define the delivery methods.
*/
#define FORWARD_LOCK 1 /**< Forward_lock */
#define COMBINED_DELIVERY 2 /**< Combined delivery */
#define SEPARATE_DELIVERY 3 /**< Separate delivery */
#define SEPARATE_DELIVERY_FL 4 /**< Separate delivery but DCF is forward-lock */
/**
* Define the permissions.
*/
#define DRM_PERMISSION_PLAY 0x01 /**< Play */
#define DRM_PERMISSION_DISPLAY 0x02 /**< Display */
#define DRM_PERMISSION_EXECUTE 0x04 /**< Execute */
#define DRM_PERMISSION_PRINT 0x08 /**< Print */
#define DRM_PERMISSION_FORWARD 0x10 /**< Forward */
/**
* Define the constraints.
*/
#define DRM_NO_CONSTRAINT 0x80 /**< Indicate have no constraint, it can use freely */
#define DRM_END_TIME_CONSTRAINT 0x08 /**< Indicate have end time constraint */
#define DRM_INTERVAL_CONSTRAINT 0x04 /**< Indicate have interval constraint */
#define DRM_COUNT_CONSTRAINT 0x02 /**< Indicate have count constraint */
#define DRM_START_TIME_CONSTRAINT 0x01 /**< Indicate have start time constraint */
#define DRM_NO_PERMISSION 0x00 /**< Indicate no rights */
/**
* Define the return values for those interface.
*/
#define DRM_SUCCESS 0
#define DRM_FAILURE -1
#define DRM_MEDIA_EOF -2
#define DRM_RIGHTS_DATA_INVALID -3
#define DRM_MEDIA_DATA_INVALID -4
#define DRM_SESSION_NOT_OPENED -5
#define DRM_NO_RIGHTS -6
#define DRM_NOT_SD_METHOD -7
#define DRM_RIGHTS_PENDING -8
#define DRM_RIGHTS_EXPIRED -9
#define DRM_UNKNOWN_DATA_LEN -10
/**
* The input DRM data structure, include DM, DCF, DR, DRC.
*/
typedef struct _T_DRM_Input_Data {
/**
* The handle of the input DRM data.
*/
int32_t inputHandle;
/**
* The mime type of the DRM data, if the mime type set to unknown, DRM engine
* will try to scan the input data to confirm the mime type, but we must say that
* the scan and check of mime type is not strictly precise.
*/
int32_t mimeType;
/**
* The function to get input data length, this function should be implement by out module,
* and DRM engine will call-back it.
*
* \param inputHandle The handle of the DRM data.
*
* \return
* -A positive integer indicate the length of input data.
* -0, if some error occurred.
*/
int32_t (*getInputDataLength)(int32_t inputHandle);
/**
* The function to read the input data, this function should be implement by out module,
* and DRM engine will call-back it.
*
* \param inputHandle The handle of the DRM data.
* \param buf The buffer mallocced by DRM engine to save the data.
* \param bufLen The length of the buffer.
*
* \return
* -A positive integer indicate the actually length of byte has been read.
* -0, if some error occurred.
* -(-1), if reach to the end of the data.
*/
int32_t (*readInputData)(int32_t inputHandle, uint8_t* buf, int32_t bufLen);
/**
* The function to seek the current file pointer, this function should be implement by out module,
* and DRM engine will call-back it.
*
* \param inputHandle The handle of the DRM data.
* \param offset The offset from the start position to be seek.
*
* \return
* -0, if seek operation success.
* -(-1), if seek operation fail.
*/
int32_t (*seekInputData)(int32_t inputHandle, int32_t offset);
} T_DRM_Input_Data;
/**
* The constraint structure.
*/
typedef struct _T_DRM_Constraint_Info {
uint8_t indicator; /**< Whether there is a right */
uint8_t unUsed[3];
int32_t count; /**< The constraint of count */
int32_t startDate; /**< The constraint of start date */
int32_t startTime; /**< The constraint of start time */
int32_t endDate; /**< The constraint of end date */
int32_t endTime; /**< The constraint of end time */
int32_t intervalDate; /**< The constraint of interval date */
int32_t intervalTime; /**< The constraint of interval time */
} T_DRM_Constraint_Info;
/**
* The rights permission and constraint information structure.
*/
typedef struct _T_DRM_Rights_Info {
uint8_t roId[256]; /**< The unique id for a specially rights object */
T_DRM_Constraint_Info playRights; /**< Constraint of play */
T_DRM_Constraint_Info displayRights; /**< Constraint of display */
T_DRM_Constraint_Info executeRights; /**< Constraint of execute */
T_DRM_Constraint_Info printRights; /**< Constraint of print */
} T_DRM_Rights_Info;
/**
* The list node of the Rights information structure.
*/
typedef struct _T_DRM_Rights_Info_Node {
T_DRM_Rights_Info roInfo;
struct _T_DRM_Rights_Info_Node *next;
} T_DRM_Rights_Info_Node;
/**
* Install a rights object to DRM engine, include the rights in Combined Delivery cases.
* Because all the rights object is managed by DRM engine, so every incoming rights object
* must be install to the engine first, or the DRM engine will not recognize it.
*
* \param data The rights object data or Combined Delivery case data.
* \param pRightsInfo The structure to save this rights information.
*
* \return
* -DRM_SUCCESS, when install successfully.
* -DRM_RIGHTS_DATA_INVALID, when the input rights data is invalid.
* -DRM_FAILURE, when some other error occur.
*/
int32_t SVC_drm_installRights(T_DRM_Input_Data data, T_DRM_Rights_Info* pRightsInfo);
/**
* Open a session for a special DRM object, it will parse the input DRM data, and then user
* can try to get information for this DRM object, or try to use it if the rights is valid.
*
* \param data The DRM object data, DM or DCF.
*
* \return
* -A handle for this opened DRM object session.
* -DRM_MEDIA_DATA_INVALID, when the input DRM object data is invalid.
* -DRM_FAILURE, when some other error occurred.
*/
int32_t SVC_drm_openSession(T_DRM_Input_Data data);
/**
* Get the delivery method of the DRM object.
*
* \param session The handle for this DRM object session.
*
* \return
* -The delivery method of this DRM object, include: FORWARD_LOCK, COMBINED_DELIVERY, SEPARATE_DELIVERY, SEPARATE_DELIVERY_FL.
* -DRM_FAILURE, when some other error occurred.
*/
int32_t SVC_drm_getDeliveryMethod(int32_t session);
/**
* Get DRM object media object content type.
*
* \param session The handle for this DRM object session.
* \param mediaType The buffer to save the media type string, 64 bytes is enough.
*
* \return
* -DRM_SUCCESS, when get the media object content type successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getContentType(int32_t session, uint8_t* mediaType);
/**
* Check whether a specific DRM object has the specific permission rights or not.
*
* \param session The handle for this DRM object session.
* \param permission Specify the permission to be checked.
*
* \return
* -DRM_SUCCESS, when it has the rights for the permission.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when it has no rights.
* -DRM_RIGHTS_PENDING, when it has the rights, but currently it is pending.
* -DRM_RIGHTS_EXPIRED, when the rights has expired.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_checkRights(int32_t session, int32_t permission);
/**
* Consume the rights when try to use the DRM object.
*
* \param session The handle for this DRM object session.
* \param permission Specify the permission to be checked.
*
* \return
* -DRM_SUCCESS, when consume rights successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when it has no rights.
* -DRM_RIGHTS_PENDING, when it has the rights, but currently it is pending.
* -DRM_RIGHTS_EXPIRED, when the rights has expired.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_consumeRights(int32_t session, int32_t permission);
/**
* Get DRM media object content data length.
*
* \param session The handle for this DRM object session.
*
* \return
* -A positive integer indicate the length of the media object content data.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when the rights object is not existed.
* -DRM_UNKNOWN_DATA_LEN, when DRM object media data length is unknown in case of DCF has no rights.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getContentLength(int32_t session);
/**
* Get DRM media object content data. Support get the data piece by piece if the content is too large.
*
* \param session The handle for this DRM object session.
* \param offset The offset to start to get content.
* \param mediaBuf The buffer to save media object data.
* \param mediaBufLen The length of the buffer.
*
* \return
* -A positive integer indicate the actually length of the data has been got.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when the rights object is not existed.
* -DRM_MEDIA_EOF, when reach to the end of the media data.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getContent(int32_t session, int32_t offset, uint8_t* mediaBuf, int32_t mediaBufLen);
/**
* Get the rights issuer address, this interface is specially for Separate Delivery method.
*
* \param session The handle for this DRM object session.
* \param rightsIssuer The buffer to save rights issuer, 256 bytes are enough.
*
* \return
* -DRM_SUCCESS, when get the rights issuer successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NOT_SD_METHOD, when it is not a Separate Delivery DRM object.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getRightsIssuer(int32_t session, uint8_t* rightsIssuer);
/**
* Get DRM object constraint informations.
*
* \param session The handle for this DRM object session.
* \param rights The structue to save the rights object information.
*
* \return
* -DRM_SUCCESS, when get the rights information successfully.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_NO_RIGHTS, when this DRM object has not rights.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_getRightsInfo(int32_t session, T_DRM_Rights_Info* rights);
/**
* Close the opened session, after closed, the handle become invalid.
*
* \param session The handle for this DRM object session.
*
* \return
* -DRM_SUCCESS, when close operation success.
* -DRM_SESSION_NOT_OPENED, when the session is not opened or has been closed.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_closeSession(int32_t session);
/**
* Check and update the given rights according the given permission.
*
* \param contentID The unique id of the rights object.
* \param permission The permission to be updated.
*
* \return
* -DRM_SUCCESS, when update operation success.
* -DRM_NO_RIGHTS, when it has no rights.
* -DRM_RIGHTS_PENDING, when it has the rights, but currently it is pending.
* -DRM_RIGHTS_EXPIRED, when the rights has expired.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_updateRights(uint8_t* contentID, int32_t permission);
/**
* Scan all the rights object in current DRM engine, and get all their information.
*
* \param ppRightsInfo The pointer to the list structure to save rights info.
*
* \return
* -DRM_SUCCESS, when get information successfully.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_viewAllRights(T_DRM_Rights_Info_Node **ppRightsInfo);
/**
* Free the allocated memory when call "SVC_drm_viewAllRights".
*
* \param pRightsHeader The header pointer of the list to be free.
*
* \return
* -DRM_SUCCESS, when free operation successfully.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_freeRightsInfoList(T_DRM_Rights_Info_Node *pRightsHeader);
/**
* Delete a specify rights.
*
* \param roId The unique id of the rights.
*
* \return
* -DRM_SUCCESS, when free operation successfully.
* -DRM_NO_RIGHTS, when there is not this rights object.
* -DRM_FAILURE, when some other error occured.
*/
int32_t SVC_drm_deleteRights(uint8_t* roId);
#ifdef __cplusplus
}
#endif
#endif /* __SVC_DRM_NEW_H__ */
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PARSER_DCF_H__
#define __PARSER_DCF_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
#define MAX_ENCRYPTION_METHOD_LEN 64
#define MAX_RIGHTS_ISSUER_LEN 256
#define MAX_CONTENT_NAME_LEN 64
#define MAX_CONTENT_DESCRIPTION_LEN 256
#define MAX_CONTENT_VENDOR_LEN 256
#define MAX_ICON_URI_LEN 256
#define MAX_CONTENT_TYPE_LEN 64
#define MAX_CONTENT_URI_LEN 256
#define HEADER_ENCRYPTION_METHOD "Encryption-Method: "
#define HEADER_RIGHTS_ISSUER "Rights-Issuer: "
#define HEADER_CONTENT_NAME "Content-Name: "
#define HEADER_CONTENT_DESCRIPTION "Content-Description: "
#define HEADER_CONTENT_VENDOR "Content-Vendor: "
#define HEADER_ICON_URI "Icon-Uri: "
#define HEADER_ENCRYPTION_METHOD_LEN 19
#define HEADER_RIGHTS_ISSUER_LEN 15
#define HEADER_CONTENT_NAME_LEN 14
#define HEADER_CONTENT_DESCRIPTION_LEN 21
#define HEADER_CONTENT_VENDOR_LEN 16
#define HEADER_ICON_URI_LEN 10
#define UINT_VAR_FLAG 0x80
#define UINT_VAR_DATA 0x7F
#define MAX_UINT_VAR_BYTE 5
#define DRM_UINT_VAR_ERR -1
typedef struct _T_DRM_DCF_Info {
uint8_t Version;
uint8_t ContentTypeLen; /**< Length of the ContentType field */
uint8_t ContentURILen; /**< Length of the ContentURI field */
uint8_t unUsed;
uint8_t ContentType[MAX_CONTENT_TYPE_LEN]; /**< The MIME media type of the plaintext data */
uint8_t ContentURI[MAX_CONTENT_URI_LEN]; /**< The unique identifier of this content object */
int32_t HeadersLen; /**< Length of the Headers field */
int32_t EncryptedDataLen; /**< Length of the encrypted data field */
int32_t DecryptedDataLen; /**< Length of the decrypted data field */
uint8_t Encryption_Method[MAX_ENCRYPTION_METHOD_LEN]; /**< Encryption method */
uint8_t Rights_Issuer[MAX_RIGHTS_ISSUER_LEN]; /**< Rights issuer */
uint8_t Content_Name[MAX_CONTENT_NAME_LEN]; /**< Content name */
uint8_t ContentDescription[MAX_CONTENT_DESCRIPTION_LEN]; /**< Content description */
uint8_t ContentVendor[MAX_CONTENT_VENDOR_LEN]; /**< Content vendor */
uint8_t Icon_URI[MAX_ICON_URI_LEN]; /**< Icon URI */
} T_DRM_DCF_Info;
/**
* Parse the DRM content format data
*
* \param buffer (in)Input the DCF format data
* \param bufferLen (in)The input buffer length
* \param pDcfInfo (out)A structure pointer which contain information of DCF headers
* \param ppEncryptedData (out)The location of encrypted data
*
* \return
* -TRUE, when success
* -FALSE, when failed
*/
int32_t drm_dcfParser(uint8_t *buffer, int32_t bufferLen, T_DRM_DCF_Info *pDcfInfo,
uint8_t **ppEncryptedData);
#ifdef __cplusplus
}
#endif
#endif /* __PARSER_DCF_H__ */
@@ -0,0 +1,101 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PARSER_DM_H__
#define __PARSER_DM_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
#define MAX_CONTENT_TYPE_LEN 64
#define MAX_CONTENT_ID 256
#define MAX_CONTENT_BOUNDARY_LEN 256
#define MAX_RIGHTS_ISSUER_LEN 256
#define DRM_MIME_TYPE_RIGHTS_XML "application/vnd.oma.drm.rights+xml"
#define DRM_MIME_TYPE_CONTENT "application/vnd.oma.drm.content"
#define HEADERS_TRANSFER_CODING "Content-Transfer-Encoding:"
#define HEADERS_CONTENT_TYPE "Content-Type:"
#define HEADERS_CONTENT_ID "Content-ID:"
#define TRANSFER_CODING_TYPE_7BIT "7bit"
#define TRANSFER_CODING_TYPE_8BIT "8bit"
#define TRANSFER_CODING_TYPE_BINARY "binary"
#define TRANSFER_CODING_TYPE_BASE64 "base64"
#define DRM_UID_TYPE_FORWORD_LOCK "forwardlock"
#define DRM_NEW_LINE_CRLF "\r\n"
#define HEADERS_TRANSFER_CODING_LEN 26
#define HEADERS_CONTENT_TYPE_LEN 13
#define HEADERS_CONTENT_ID_LEN 11
#define DRM_MESSAGE_CODING_7BIT 0 /* default */
#define DRM_MESSAGE_CODING_8BIT 1
#define DRM_MESSAGE_CODING_BINARY 2
#define DRM_MESSAGE_CODING_BASE64 3
#define DRM_B64_DEC_BLOCK 3
#define DRM_B64_ENC_BLOCK 4
typedef struct _T_DRM_DM_Info {
uint8_t contentType[MAX_CONTENT_TYPE_LEN]; /**< Content type */
uint8_t contentID[MAX_CONTENT_ID]; /**< Content ID */
uint8_t boundary[MAX_CONTENT_BOUNDARY_LEN]; /**< DRM message's boundary */
uint8_t deliveryType; /**< The Delivery type */
uint8_t transferEncoding; /**< Transfer encoding type */
int32_t contentOffset; /**< The offset of the media content from the original DRM data */
int32_t contentLen; /**< The length of the media content */
int32_t rightsOffset; /**< The offset of the rights object in case of combined delivery */
int32_t rightsLen; /**< The length of the rights object in case of combined delivery */
uint8_t rightsIssuer[MAX_RIGHTS_ISSUER_LEN];/**< The rights issuer address in case of separate delivery */
} T_DRM_DM_Info;
/**
* Search the string in a limited length.
*
* \param str The original string
* \param strSearch The sub-string to be searched
* \param len The length limited
*
* \return
* -NULL, when there is not the searched string in length
* -The pointer of this sub-string
*/
const uint8_t* drm_strnstr(const uint8_t* str, const uint8_t* strSearch, int32_t len);
/**
* Parse the DRM message format data.
*
* \param buffer (in)Input the DRM message format data
* \param bufferLen (in)The input buffer length
* \param pDmInfo (out)A structure pointer which contain information of DRM message headers
*
* \return
* -TRUE, when success
* -FALSE, when failed
*/
int32_t drm_parseDM(const uint8_t* buffer, int32_t bufferLen, T_DRM_DM_Info* pDmInfo);
#ifdef __cplusplus
}
#endif
#endif /* __PARSER_DM_H__ */
@@ -0,0 +1,123 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __PARSER_REL_H__
#define __PARSER_REL_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
#define WRITE_RO_FLAG(whoIsAble, boolValue, Indicator, RIGHTS) do{\
whoIsAble = boolValue;\
Indicator |= RIGHTS;\
}while(0)
#define CHECK_VALIDITY(ret) do{\
if(ret == NULL){\
if(XML_ERROR_NO_SUCH_NODE != xml_errno)\
return FALSE;\
}\
else\
{\
if(XML_ERROR_OK != xml_errno)\
return FALSE;\
}\
}while(0)
#define YMD_HMS_2_INT(year, mon, day, date, hour, min, sec, time) do{\
date = year * 10000 + mon * 100 + day;\
time = hour * 10000 + min * 100 + sec;\
}while(0)
#define DRM_UID_LEN 256
#define DRM_KEY_LEN 16
#define XML_DOM_PARSER
typedef struct _T_DRM_DATETIME {
int32_t date; /**< year * 10000 + mon *100 + day */
int32_t time; /**< hour * 10000 + min *100 + sec */
} T_DRM_DATETIME;
typedef struct _T_DRM_Rights_Constraint {
uint8_t Indicator; /**< Indicate which is constrainted, the first one indicate 0001, second one indicate 0010 */
uint8_t unUsed[3];
int32_t Count; /**< The times that can be used */
T_DRM_DATETIME StartTime; /**< The starting time */
T_DRM_DATETIME EndTime; /**< The ending time */
T_DRM_DATETIME Interval; /**< The interval time */
} T_DRM_Rights_Constraint;
typedef struct _T_DRM_Rights {
uint8_t Version[8]; /**< Version number */
uint8_t uid[256]; /**< record the rights object name */
uint8_t KeyValue[16]; /**< Decode base64 */
int32_t bIsPlayable; /**< Is playable */
int32_t bIsDisplayable; /**< Is displayable */
int32_t bIsExecuteable; /**< Is executeable */
int32_t bIsPrintable; /**< Is printable */
T_DRM_Rights_Constraint PlayConstraint; /**< Play constraint */
T_DRM_Rights_Constraint DisplayConstraint; /**< Display constraint */
T_DRM_Rights_Constraint ExecuteConstraint; /**< Execute constraint */
T_DRM_Rights_Constraint PrintConstraint; /**< Print constraint */
} T_DRM_Rights;
/**
* Input year and month, return how many days that month have
* \param year (in)Input the year
* \param month (in)Input the month
* \return
* -A positive integer, which is how many days that month have
* -When wrong input, return -1
*/
int32_t drm_monthDays(int32_t year, int32_t month);
/**
* Check whether the date and time is valid.
* \param year year of the date
* \param month month of the date
* \param day day of the date
* \param hour hour of the time
* \param min minute of the time
* \param sec second of the time
* \return
* -when it is a valid time, return 0
* -when it is a invalid time, return -1
*/
int32_t drm_checkDate(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, int32_t sec);
/**
* Parse the rights object include xml format and wbxml format data
*
* \param buffer (in)Input the DRM rights object data
* \param bufferLen (in)The buffer length
* \param format (in)Which format, xml or wbxml
* \param pRights (out)A structure pointer which save the rights information
*
* \return
* -TRUE, when success
* -FALSE, when failed
*/
int32_t drm_relParser(uint8_t* buffer, int32_t bufferLen, int32_t Format, T_DRM_Rights* pRights);
#ifdef __cplusplus
}
#endif
#endif /* __PARSER_REL_H__ */
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __WBXML_TINYPARSER_H__
#define __WBXML_TINYPARSER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
#define REL_TAG_RIGHTS 0x05
#define REL_TAG_CONTEXT 0x06
#define REL_TAG_VERSION 0x07
#define REL_TAG_UID 0x08
#define REL_TAG_AGREEMENT 0x09
#define REL_TAG_ASSET 0x0A
#define REL_TAG_KEYINFO 0x0B
#define REL_TAG_KEYVALUE 0x0C
#define REL_TAG_PERMISSION 0x0D
#define REL_TAG_PLAY 0x0E
#define REL_TAG_DISPLAY 0x0F
#define REL_TAG_EXECUTE 0x10
#define REL_TAG_PRINT 0x11
#define REL_TAG_CONSTRAINT 0x12
#define REL_TAG_COUNT 0x13
#define REL_TAG_DATETIME 0x14
#define REL_TAG_START 0x15
#define REL_TAG_END 0x16
#define REL_TAG_INTERVAL 0x17
#define REL_CHECK_WBXML_HEADER(x) ((x != NULL) && (x[0] == 0x03) && (x[1] == 0x0E) && (x[2] == 0x6A))
#ifdef __cplusplus
}
#endif
#endif /* __WBXML_TINYPARSER_H__ */
@@ -0,0 +1,171 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __XML_TINYPARSER_H__
#define __XML_TINYPARSER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <drm_common_types.h>
#define XML_DOM_PARSER
#define WBXML_DOM_PARSER
#define XML_DOM_CHECK_ENDTAG
#define XML_ENABLE_ERRNO
#define WBXML_OLD_VERSION /* for drm only */
#ifdef DEBUG_MODE
void XML_PrintMallocInfo();
#endif /* DEBUG_MODE */
#define XML_TRUE 1
#define XML_FALSE 0
#define XML_EOF 0
#define XML_TAG_START 0
#define XML_TAG_END 1
#define XML_TAG_SELF 2
#define XML_MAX_PROPERTY_LEN 256
#define XML_MAX_ATTR_NAME_LEN 256
#define XML_MAX_ATTR_VALUE_LEN 256
#define XML_MAX_VALUE_LEN 256
#define XML_ERROR_OK 0
#define XML_ERROR_BUFFER_NULL -1
#define XML_ERROR_ATTR_NAME -2
#define XML_ERROR_ATTR_MISSED_EQUAL -3
#define XML_ERROR_PROPERTY_NAME -4
#define XML_ERROR_ATTR_VALUE -5
#define XML_ERROR_ENDTAG -6
#define XML_ERROR_NO_SUCH_NODE -7
#define XML_ERROR_PROPERTY_END -8
#define XML_ERROR_VALUE -9
#define XML_ERROR_NO_START_TAG -14
#define XML_ERROR_NOVALUE -15
#define WBXML_ERROR_MISSED_CONTENT -10
#define WBXML_ERROR_MBUINT32 -11
#define WBXML_ERROR_MISSED_STARTTAG -12
#define WBXML_ERROR_MISSED_ENDTAG -13
#ifdef XML_ENABLE_ERRNO
extern int32_t xml_errno;
#define XML_ERROR(x) do { xml_errno = x; } while (0)
#else /* XML_ENABLE_ERRNO */
#define XML_ERROR
#endif /* XML_ENABLE_ERRNO */
#ifdef XML_DOM_PARSER
uint8_t *XML_DOM_getNode(uint8_t *buffer, const uint8_t *const node);
uint8_t *XML_DOM_getNodeValue(uint8_t *buffer, uint8_t *node,
uint8_t **value, int32_t *valueLen);
uint8_t *XML_DOM_getValue(uint8_t *buffer, uint8_t **pValue, int32_t *valueLen);
uint8_t *XML_DOM_getAttr(uint8_t *buffer, uint8_t **pName, int32_t *nameLen,
uint8_t **pValue, int32_t *valueLen);
uint8_t *XML_DOM_getNextNode(uint8_t *buffer, uint8_t **pNodeName,
int32_t *nodenameLen);
uint8_t *XML_DOM_getTag(uint8_t *buffer, int32_t *tagLen, int32_t *tagType);
#endif /* XML_DOM_PARSER */
#ifdef WBXML_DOM_PARSER
#define WBXML_WITH_ATTR 0x80
#define WBXML_WITH_CONTENT 0x40
#define WBXML_ATTR_END 0x01
#define WBXML_CONTENT_END 0x01
#define WBXML_SWITCH_PAGE 0x00
#define WBXML_STR_I 0x03
#define WBXML_END 0x00
#define WBXML_OPAUE 0xC3
#define WBXML_STR_T 0x83
#define WBXML_OPAQUE 0xC3
#define WBXML_GET_TAG(x) ((x) & 0x3F) /* get 6-digits */
#define WBXML_HAS_ATTR(x) ((x) & WBXML_WITH_ATTR)
#define WBXML_HAS_CONTENT(x) ((x) & WBXML_WITH_CONTENT)
typedef struct _WBXML {
uint8_t version;
uint8_t unUsed[3];
uint32_t publicid;
uint32_t charset;
int32_t strTableLen;
uint8_t *strTable;
uint8_t *Content;
uint8_t *End;
uint8_t *curPtr;
int32_t depth;
} WBXML;
typedef int32_t XML_BOOL;
#ifdef WBXML_OLD_VERSION
uint8_t *WBXML_DOM_getNode(uint8_t *buffer, int32_t bufferLen,
uint8_t *node);
uint8_t *WBXML_DOM_getNodeValue(uint8_t *buffer, int32_t bufferLen,
uint8_t *node,
uint8_t **value,
int32_t *valueLen);
#endif /* WBXML_OLD_VERSION */
XML_BOOL WBXML_DOM_Init(WBXML * pWbxml, uint8_t *buffer,
int32_t bufferLen);
XML_BOOL WBXML_DOM_Eof(WBXML * pWbxml);
uint8_t WBXML_DOM_GetTag(WBXML * pWbxml);
uint8_t WBXML_DOM_GetChar(WBXML * pWbxml);
uint8_t WBXML_DOM_GetUIntVar(WBXML * pWbxml);
void WBXML_DOM_Rewind(WBXML * pWbxml);
void WBXML_DOM_Seek(WBXML * pWbxml, int32_t offset);
int32_t WBXML_GetUintVar(const uint8_t *const buffer, int32_t *len);
#endif /* WBXML_DOM_PARSER */
#ifdef XML_TREE_STRUCTURE
typedef struct _XML_TREE_ATTR XML_TREE_ATTR;
struct _XML_TREE_ATTR {
uint8_t name[XML_MAX_ATTR_VALUE_LEN];
uint8_t value[XML_MAX_ATTR_VALUE_LEN];
XML_TREE_ATTR *next;
};
typedef struct _XML_TREE XML_TREE;
struct _XML_TREE {
uint8_t tag[XML_MAX_PROPERTY_LEN];
uint8_t value[XML_MAX_VALUE_LEN];
XML_TREE_ATTR *attr;
XML_TREE_ATTR *last_attr;
XML_TREE *brother;
XML_TREE *last_brother;
XML_TREE *child;
};
XML_TREE *XML_makeTree(uint8_t **buf);
void XML_freeTree(XML_TREE * pTree);
#endif /* XML_TREE_STRUCTURE */
#ifdef __cplusplus
}
#endif
#endif /* __XML_TINYPARSER_H__ */