📄 repll.h
字号:
/*
* Copyright (C) Ericsson Mobile Communications AB, 2000.
* Licensed to AU-System AB.
* All rights reserved.
*
* This software is covered by the license agreement between
* the end user and AU-System AB, and may be used and copied
* only in accordance with the terms of the said agreement.
*
* Neither Ericsson Mobile Communications AB nor AU-System AB
* assumes any responsibility or liability for any errors or inaccuracies in
* this software, or any consequential, incidental or indirect damage arising
* out of the use of the Generic WAP Client software.
*/
#ifndef _RepLL_H
#define _RepLL_H
/*========================================================================
WAP Implementation Project
==========================================================================
File: RepLL.h
Description:
Author: Jens Pommer, AU-System Radio AB
Revision history:
Date Sign Comment
990803 JPR First version
990831 JPR Added functionality
990929 JPR Storage.h included, functions updated.
990930 JPR Init functions updated.
991001 JPR Function REP_Installing added
991004 JPR tMODIFYRESOURCES struct and functions added
991008 JPR Function REP_UpdateResource added
991026 JPR Updates in functions
000207 JPR Function REP_GetNextChToRemove added
000214 JPR Comments changed in REP_GetNextChToRemove
000215 JPR REP_GetAllChannels and REP_ScanRepository updated
000630 JPR Updated for WAP 1.2.1
001011 ASPN Lower-case filenames.
=========================================================================*/
#include "cmmnrsrc.h"
#include "rephdr.h"
#include "wae_cmmn.h"
#include "storage.h"
/*========================================================================
DEFINITIONS
=========================================================================*/
typedef struct tREPCHSTRUCT
{
WCHAR *pchEventId;
WCHAR *pchchannelid;
UINT32 iLLRepHId;
UINT32 iLLRepHIdToFirstRes;
UINT8 iStatus;
} REPCHSTRUCT, *pREPCHSTRUCT;
/* This struct is used to update the root block when resources or
channels are added to or removed from the repository. All content
in the list are either added to or removed from the root block list
of resources or channels. The elements in the list must always
reflect the changes needed on the root block to be consistent with
the repository. */
typedef struct tMODIFYROOT
{
UINT32 iContentId;
UINT8 iAction; /* X_ADD/X_REMOVE */
UINT32 iHashValue;
struct tMODIFYROOT* pNext;
} MODIFYROOT, *pMODIFYROOT;
typedef struct tREPCONTEXT
{
/* Used to init the repository. Used for channels in function
REP_GetAllChannels and for all content in REP_ScanRepository */
UINT16 iNumberOfElements;
UINT16 iCurrentElement;
UINT32* piElementList;
UINT8 iScanPhase;
/* Used during scan repository and at run-time */
UINT32* piResourceList;
UINT32* piHashList; /* One number for each resource */
UINT16 iNumberOfResources;
/* Storage object */
StorageObject Storage;
/* Pointer to content to be modified in the root block */
pMODIFYROOT pModRoot;
/* Reserved memory */
UINT32 iReserved;
} REPCONTEXT, *pREPCONTEXT;
/* The Root Block is always stored at ContentID 1 */
#define REP_ROOTBLK_ID 1
#define RESOURCE_ADD 1
#define RESOURCE_REMOVE 2
#define CHANNEL_ADD 3
#define CHANNEL_REMOVE 4
/*========================================================================
FUNCTION PROTOTYPES
=========================================================================*/
/*========================================================================
REP_GetResourceWithUrl
==========================================================================
The function retrieves a resource from the repository, specified with
the url. The url MUST be absolute. If the resource is found, a pointer
to a REPCONTENTTYPE struct is returned, otherwise NULL is returned.
It is the caller's responsibility to free the memory of the url and
the REPCONTENTTYPE struct. If the Install flag is set to TRUE, the
Installing Counter in the resource is increased with one.
The function also creates a tMODIFYRESOURCE-element.
The function does a WSP_PreParseHeaders on the header data. If this
operation fails, NULL is returned.
Input: void* (MUST be pREPCONTEXT), url, and BOOL
Output: pREPCONTENTSTRUCT or NULL if error
==========================================================================*/
pREPCONTENTSTRUCT REP_GetResourceWithUrl (void* pContext, BYTE *pbUrl,
BOOL fInstall);
/*========================================================================
REP_StoreResource
==========================================================================
The function stores a resource in the repository with the installation
counter set to one and the referring counter set to zero. If the
operation was successful, TRUE is returned and the input parameter
piContentID is set accordingly. Also, the pResource is updated with
the same value. FALSE is returned if the operation fails. It is the
caller's responsibility to delete the memory after the function has
returned.
The function creates a tMODIFYRESOURCE-element for each change needed
in the root block. The resource's ContentID is also added to the
context along with its hash value.
If the function returns TRUE, the size of the stored resource (in
BYTES) is stored in the piSize attribute. The amount is also decucted
from the reserved memory.
Input: void* (MUST be pREPCONTEXT), Data, and pointer to ContentID
Output: BOOL
==========================================================================*/
BOOL REP_StoreResource (void* pContext, pREPCONTENTSTRUCT pResource,
UINT32* piContentID, UINT32* piSize);
/*========================================================================
REP_UpdateResource
==========================================================================
The function replaces a resource in the repository, i.e., stores the
new data under the same ContentId. If the operation was successful,
TRUE is returned. Otherwise FALSE is returned. It is the caller's
responsibility to delete the memory after the function has returned.
Note! The function sets the installation counter and the referring
counter to the values of the old resource. The installation counter
is thereafter increased by one.
If the function returns TRUE, the difference between the old size and
the new size of the resource (in BYTES) is stored in the piSizeChanged
attribute (new size - old size).
Input: void* (MUST be pREPCONTEXT), Data, and ContentID
Output: BOOL
==========================================================================*/
BOOL REP_UpdateResource (void* pContext, pREPCONTENTSTRUCT pResource,
UINT32 iContentID, INT32* piSizeChange);
/*========================================================================
REP_GetContentWithID
==========================================================================
The function retrieves the data from the repository, specified with
the ContentID. If the content is found and it is of the specified
type a pointer to a REPCONTENTTYPE struct is returned, otherwise NULL
is returned. It is the caller's responsibility to free the memory of
the struct.
The function does a WSP_PreParseHeaders on the header data if the
content is a resource. If this operation fails, NULL is returned.
THE RESOURCE IS ALSO REMOVED FROM THE MEMORY IF THIS HAPPENS.
Input: void* (MUST be pREPCONTEXT), ContentID, Type
Output: pREPCONTENTSTRUCT or NULL if error
==========================================================================*/
pREPCONTENTSTRUCT REP_GetContentWithID (void* pContext, UINT32 iContentID,
UINT8 iType);
/*========================================================================
REP_RootBlockSafe
==========================================================================
This function must be called to inform the low level parts when
changes on the repository are being done. Before any changes can be
done (installation of channel or deletion of channel for example) the
function MUST be called with the parameter fSafe set to FALSE. When
ALL changes are made, the function SHOULD be called again with the
fSafe parameter set to TRUE. When this happens, the root block in the
repository is updated and set to status REPROOT_STATUS_OK if the
operation was successful. Otherwise the root block is removed.
Input: void* (MUST be pREPCONTEXT), BOOL
Output: -
==========================================================================*/
void REP_RootBlockSafe (void* pContext, BOOL fSafe);
/*========================================================================
REP_DecreaseInstallCounter
==========================================================================
The function decreases the install counter of the specified resource
with one and changes the status if necessary (e.g. if ref counter and
install counter both are 0, the resource is removed). If the operation
is successful, TRUE is returned, otherwise FALSE is returned.
Input: void* (MUST be pREPCONTEXT), ContentID
Output: BOOL
==========================================================================*/
BOOL REP_DecreaseInstallCounter (void* pContext, UINT32 iContentID);
/*========================================================================
REP_StoreChannel
==========================================================================
The function stores a channel in the repository. If the operation was
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -