MHEG5  18.9.0
MHEG5 Documentation
Classes | 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"

Go to the source code of this file.

Classes

struct  CiMessageContext_struct
 
struct  sOrmFuncs
 
struct  sOrmGetRequest
 
struct  sOrmPostRequest
 
struct  sOrmRequest
 

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 sOrmRequestP_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

Definition in file mh5fileorm.c.

Macro Definition Documentation

#define CHECK_ORM_MAGIC

Definition at line 124 of file mh5fileorm.c.

#define CI_ACK_TIMEOUT   9999 /* about 10 secs */

Definition at line 84 of file mh5fileorm.c.

#define CiAction   DummyFunc

Definition at line 333 of file mh5fileorm.c.

#define CiAlloc   AllocNothing

Definition at line 98 of file mh5fileorm.c.

#define CiClear   DummyFunc

Definition at line 334 of file mh5fileorm.c.

#define CLEAR_ORM_MAGIC (   r)    (r)->magic = ORM_REQUEST_BAD_MAGIC

Definition at line 130 of file mh5fileorm.c.

#define DEFAULT_ORIGIN   ORIGIN_DSM

Definition at line 113 of file mh5fileorm.c.

#define DsmAlloc   AllocRequest

Definition at line 90 of file mh5fileorm.c.

#define HttpAction   DummyFunc

Definition at line 379 of file mh5fileorm.c.

#define HttpAlloc   AllocNothing

Definition at line 105 of file mh5fileorm.c.

#define HttpClear   DummyFunc

Definition at line 380 of file mh5fileorm.c.

#define HybrAction   DummyFunc

Definition at line 377 of file mh5fileorm.c.

#define HybrAlloc   AllocNothing

Definition at line 106 of file mh5fileorm.c.

#define HybrClear   DummyFunc

Definition at line 378 of file mh5fileorm.c.

#define IS_HTTP_REQUEST (   r)    ((r)->origin == ORIGIN_HTTP || (r)->origin == ORIGIN_HTTPS)

Definition at line 119 of file mh5fileorm.c.

#define IS_HTTPS_REQUEST (   r)    ((r)->origin == ORIGIN_HTTPS)

Definition at line 120 of file mh5fileorm.c.

#define IS_HYBRID_REQUSET (   r)    ((r)->origin == ORIGIN_HYBRID)

Definition at line 121 of file mh5fileorm.c.

#define MAX_CI_REQUESTS   (1)

Definition at line 82 of file mh5fileorm.c.

#define MAX_PATHNAME_LENGTH   (1024)

Definition at line 79 of file mh5fileorm.c.

#define MAX_REDIRECTS   (5)

Definition at line 87 of file mh5fileorm.c.

#define MIN_HTTP_REPLY_BLOCK   (128)

Definition at line 86 of file mh5fileorm.c.

#define ORM_REQUEST_BAD_MAGIC   0xfeedface

Definition at line 128 of file mh5fileorm.c.

#define ORM_REQUEST_MAGIC   0xdeadbeef

Definition at line 127 of file mh5fileorm.c.

#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")

Definition at line 148 of file mh5fileorm.c.

#define PRINT_ERROR (   x)

Definition at line 144 of file mh5fileorm.c.

#define PRINTFILE (   t,
  n,
  d,
 
)

Definition at line 820 of file mh5fileorm.c.

#define SET_ORM_MAGIC (   r)    (r)->magic = ORM_REQUEST_MAGIC

Definition at line 129 of file mh5fileorm.c.

#define VERIFY_ORM_MAGIC (   r)    assert((r)->magic == ORM_REQUEST_MAGIC)

Definition at line 131 of file mh5fileorm.c.

Typedef Documentation

typedef struct sOrmRequest* P_OrmRequest

Definition at line 227 of file mh5fileorm.c.

typedef struct sOrmFuncs S_OrmFuncs
typedef struct sOrmRequest S_OrmRequest

Enumeration Type Documentation

enum E_OrmState
Enumerator
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 

Definition at line 177 of file mh5fileorm.c.

enum E_OrmType
Enumerator
ORM_TYPE_GET 
ORM_TYPE_FGR 
ORM_TYPE_POST 

Definition at line 195 of file mh5fileorm.c.

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.

Definition at line 979 of file mh5fileorm.c.

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

Definition at line 1179 of file mh5fileorm.c.

void MHEG5FileOrmInit ( void  )

Initialise the file ORM module.

Returns
always returns 1

Definition at line 576 of file mh5fileorm.c.

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

Definition at line 712 of file mh5fileorm.c.

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

Definition at line 1554 of file mh5fileorm.c.

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

Definition at line 830 of file mh5fileorm.c.

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.

Definition at line 595 of file mh5fileorm.c.

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

Definition at line 1290 of file mh5fileorm.c.