MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
Macros | Typedefs | Enumerations | Functions
mh5fileorm.c File Reference

File based synchronous/asynchrounous ORM. More...

#include "mh5fileorm.h"
#include "mh5stream.h"
#include "mh5memory.h"
#include "mh5debug.h"
#include "mh5profile.h"
#include "mh5object.h"
#include "mh5queue.h"
#include "mh5gate.h"
#include "mh5misc.h"
#include "mh5control.h"
#include <string.h>
#include "glue_queue.h"
#include "glue_main.h"
#include "glue_timers.h"
#include "glue_dsmcc.h"

Macros

#define MAX_PATHNAME_LENGTH   (1024)
 
#define MAX_CI_REQUESTS   (1)
 
#define CI_ACK_TIMEOUT   9999 /* about 10 secs */
 
#define MIN_HTTP_REPLY_BLOCK   (128)
 
#define MAX_REDIRECTS   (5)
 
#define DsmAlloc   AllocRequest
 
#define CiAlloc   AllocNothing
 
#define HttpAlloc   AllocNothing
 
#define HybrAlloc   AllocNothing
 
#define DEFAULT_ORIGIN   ORIGIN_DSM
 
#define IS_HTTP_REQUEST(r)   ((r)->origin == ORIGIN_HTTP || (r)->origin == ORIGIN_HTTPS)
 
#define IS_HTTPS_REQUEST(r)   ((r)->origin == ORIGIN_HTTPS)
 
#define IS_HYBRID_REQUSET(r)   ((r)->origin == ORIGIN_HYBRID)
 
#define CHECK_ORM_MAGIC
 
#define ORM_REQUEST_MAGIC   0xdeadbeef
 
#define ORM_REQUEST_BAD_MAGIC   0xfeedface
 
#define SET_ORM_MAGIC(r)   (r)->magic = ORM_REQUEST_MAGIC
 
#define CLEAR_ORM_MAGIC(r)   (r)->magic = ORM_REQUEST_BAD_MAGIC
 
#define VERIFY_ORM_MAGIC(r)   assert((r)->magic == ORM_REQUEST_MAGIC)
 
#define PRINT_ERROR(x)
 
#define ORM_STATE_STRING(r)
 
#define CiAction   DummyFunc
 
#define CiClear   DummyFunc
 
#define HybrAction   DummyFunc
 
#define HybrClear   DummyFunc
 
#define HttpAction   DummyFunc
 
#define HttpClear   DummyFunc
 
#define PRINTFILE(t, n, d, s)
 

Typedefs

typedef struct
CiMessageContext_struct 
CiMessageContext
 
typedef struct sOrmRequest * P_OrmRequest
 
typedef struct sOrmFuncs S_OrmFuncs
 
typedef struct sOrmGetRequest S_OrmGetRequest
 
typedef struct sOrmPostRequest S_OrmPostRequest
 
typedef struct sOrmRequest S_OrmRequest
 

Enumerations

enum  E_OrmState {
  ORM_STATE_START, ORM_STATE_QUEUED, ORM_STATE_WAIT_ACCESS, ORM_STATE_CHECK_ACCESS,
  ORM_STATE_HAS_ACCESS, ORM_STATE_WAIT_CERT, ORM_STATE_HAS_CERT, ORM_STATE_REQUESTED,
  ORM_STATE_WAIT_VERIFY, ORM_STATE_CHECK_VERIFY, ORM_STATE_SUCCEEDED, ORM_STATE_FAILED,
  ORM_STATE_ABORTED
}
 
enum  E_OrmType { ORM_TYPE_GET, ORM_TYPE_FGR, ORM_TYPE_POST }
 

Functions

void MHEG5FileOrmInit (void)
 Initialise the file ORM module. More...
 
void MHEG5FileOrmReset (MHEG5FileOrmResetMode resetMode)
 Reset the ORM module. This function supports two modes: More...
 
BOOLEAN MHEG5FileOrmIsReset (MHEG5FileOrmResetMode *resetMode)
 Tell whether the ORM module is currently being reset. If it is, the function also returns the current reset mode. This information is required in order to decide whether to generate an EngineEvent when a file load fails. If a file cannot be loaded (doesn't exist, timeout) then an event is required, but if a file load "fails" because the ORM module is being reset, then no event should be generated. resetMode is an optional parameter, and it can also be NULL. More...
 
BOOLEAN MHEG5FileOrmProcess (void)
 Check for any file requests that have arrived since this function was last called. For each arrived file the callback will be called. The function may have to be called more than once in case a file the arrived affects other files as well. More...
 
void MHEG5FileOrmClear (void *orm_ref)
 Remove outstanding file request for the given handle. More...
 
void * MHEG5FileOrmGet (MHEG5String name, U16BIT priority, void *userData, F_CB_Good cbGood, F_CB_Fail cbFail)
 Get a file. The file will be loaded and one of the callback functions called when request is resolved. When file system acceleration is available, this may retrieve the file from NVM cache. More...
 
void * MHEG5FileOrmRetrieve (E_FS_ORIGIN origin, S_STRING location, S_STRING name, U16BIT priority, void *userData, F_CB_Good cbGood, F_CB_Fail cbFail)
 Retrieve of a file. The file will be loaded and one of the callback functions called when request is resolved. This is intended to be used by the File System Acceleration code. More...
 
void MHEG5FileOrmPreloadHint (MHEG5String name)
 Provide a preload hint to DSM-CC that the specified file may be required in the future. DSM-CC could (but is not required to) acquire the file into cache. More...
 

Detailed Description

File based synchronous/asynchrounous ORM.

Date
01/02/2002
Author
R.Freeman

Macro Definition Documentation

#define ORM_STATE_STRING (   r)
Value:
((r)->state == ORM_STATE_START ? "ORM_STATE_START" : \
(r)->state == ORM_STATE_QUEUED ? "ORM_STATE_QUEUED" : \
(r)->state == ORM_STATE_WAIT_ACCESS ? "ORM_STATE_WAIT_ACCESS" : \
(r)->state == ORM_STATE_CHECK_ACCESS ? "ORM_STATE_WAIT_ACCESS" : \
(r)->state == ORM_STATE_HAS_ACCESS ? "ORM_STATE_HAS_ACCESS" : \
(r)->state == ORM_STATE_WAIT_CERT ? "ORM_STATE_WAIT_CERT" : \
(r)->state == ORM_STATE_HAS_CERT ? "ORM_STATE_HAS_CERT" : \
(r)->state == ORM_STATE_REQUESTED ? "ORM_STATE_REQUESTED" : \
(r)->state == ORM_STATE_WAIT_VERIFY ? "ORM_STATE_WAIT_VERIFY" : \
(r)->state == ORM_STATE_CHECK_VERIFY ? "ORM_STATE_CHECK_VERIFY" : \
(r)->state == ORM_STATE_SUCCEEDED ? "ORM_STATE_SUCCEEDED" : \
(r)->state == ORM_STATE_FAILED ? "ORM_STATE_FAILED" : \
(r)->state == ORM_STATE_ABORTED ? "ORM_STATE_ABORTED" : \
"UNKNOWN")

Function Documentation

void MHEG5FileOrmClear ( void *  orm_ref)

Remove outstanding file request for the given handle.

Aborts a request for file.

Parameters
orm_refHandle given back by MHEG5FileOrmGet
Returns
None.
void* MHEG5FileOrmGet ( MHEG5String  name,
U16BIT  priority,
void *  userData,
F_CB_Good  cbGood,
F_CB_Fail  cbFail 
)

Get a file. The file will be loaded and one of the callback functions called when request is resolved. When file system acceleration is available, this may retrieve the file from NVM cache.

Parameters
nameName of file to retrieve. This will be expanded using the rules specified by the UK1 profile.
priorityCache priority with which to fetch the object.
userDataUser data to be returned in callback functions.
cbGoodPointer to callback function that will be called when the file is retreived.
cbFailPointer to callback function that will be called when the file cannot be retrieved.
Returns
void* - the FileOrm request handle
void MHEG5FileOrmInit ( void  )

Initialise the file ORM module.

Returns
always returns 1
BOOLEAN MHEG5FileOrmIsReset ( MHEG5FileOrmResetMode *  resetMode)

Tell whether the ORM module is currently being reset. If it is, the function also returns the current reset mode. This information is required in order to decide whether to generate an EngineEvent when a file load fails. If a file cannot be loaded (doesn't exist, timeout) then an event is required, but if a file load "fails" because the ORM module is being reset, then no event should be generated. resetMode is an optional parameter, and it can also be NULL.

Parameters
resetModeReset mode (if return value is TRUE)
Returns
TRUE if the ORM module is being reset, FALSE otherwise
void MHEG5FileOrmPreloadHint ( MHEG5String  name)

Provide a preload hint to DSM-CC that the specified file may be required in the future. DSM-CC could (but is not required to) acquire the file into cache.

Parameters
nameName of file to preload
Returns
void
BOOLEAN MHEG5FileOrmProcess ( void  )

Check for any file requests that have arrived since this function was last called. For each arrived file the callback will be called. The function may have to be called more than once in case a file the arrived affects other files as well.

Returns
TRUE if the function should be called again, FALSE otherwise
void MHEG5FileOrmReset ( MHEG5FileOrmResetMode  resetMode)

Reset the ORM module. This function supports two modes:

  • In "objects" mode, only outstanding file requests that are related to MHEG-5 objects are cancelled.
  • In "all" mode, every outstanding file request is cleared. This includes file requests to certificates and access files.
    Parameters
    resetModeReset mode
    Returns
    None.
void* MHEG5FileOrmRetrieve ( E_FS_ORIGIN  origin,
S_STRING  location,
S_STRING  name,
U16BIT  priority,
void *  userData,
F_CB_Good  cbGood,
F_CB_Fail  cbFail 
)

Retrieve of a file. The file will be loaded and one of the callback functions called when request is resolved. This is intended to be used by the File System Acceleration code.

Parameters
originOrigin of file to retrieve.
locationPath location of file to retrieve.
nameName of file to retrieve.
priorityCache priority with which to fetch the object.
userDataUser data to be returned in callback functions.
cbGoodPointer to callback function that will be called when the file is retreived.
cbFailPointer to callback function that will be called when the file cannot be retrieved.
Returns
void* - the FileOrm request handle