Home | History | Annotate | Download | only in tf_daemon
      1 /**
      2  * Copyright(c) 2011 Trusted Logic.   All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *
      8  *  * Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  *  * Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in
     12  *    the documentation and/or other materials provided with the
     13  *    distribution.
     14  *  * Neither the name Trusted Logic nor the names of its
     15  *    contributors may be used to endorse or promote products derived
     16  *    from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 
     32 #ifndef __SMC_PROPERTIES_PARSER_H__
     33 #define __SMC_PROPERTIES_PARSER_H__
     34 
     35 
     36 
     37 #include "s_type.h"
     38 
     39 #ifdef __cplusplus
     40 extern "C" {
     41 #endif
     42 
     43 
     44 /* ---------------------------------------------------------------------------------
     45    Defines
     46    ---------------------------------------------------------------------------------*/
     47 
     48 #define SYSTEM_SECTION_NAME               "Global"
     49 #define CONFIG_SERVICE_ID_PROPERTY_NAME   "config.s.serviceID"
     50 #define CONFIG_PROPERTY_NAME              "config."
     51 
     52 
     53 
     54 /* ---------------------------------------------------------------------------------
     55    types definition
     56    ---------------------------------------------------------------------------------*/
     57 
     58 typedef struct NODE
     59 {
     60    struct NODE* pLeft;
     61    struct NODE* pRight;
     62    struct NODE* pNext;
     63    struct NODE* pPrevious;
     64    char* pName;
     65 } NODE;
     66 
     67 typedef struct
     68 {
     69    NODE* pRoot;
     70    NODE* pFirst;
     71 } LIST;
     72 
     73 typedef struct
     74 {
     75    NODE sNode;
     76    char* pValue;
     77    bool bChecked; /* Whether it has been checked that this property is allowed */
     78 } PROPERTY;
     79 
     80 typedef struct
     81 {
     82    NODE sNode;
     83    struct S_PROPERTY* pProperty;
     84 } S_PROPERTY_NODE;
     85 
     86 typedef struct SERVICE_SECTION
     87 {
     88    NODE sNode;
     89    bool inSCF;
     90    struct SERVICE_SECTION* pNextInSCF; /* next section defined in config file */
     91    S_UUID sUUID;
     92    uint32_t nFlags;
     93    char* pComment;
     94    void* pFileInfo;     /* used to retreive filename and MD5 hash (optional) */
     95    LIST sPublicPropertyList;
     96    LIST sPrivatePropertyList;
     97 } SERVICE_SECTION;
     98 
     99 typedef struct
    100 {
    101    char* pComment;
    102    LIST sSystemSectionPropertyList;
    103    SERVICE_SECTION* pFirstSectionInSCF; /* first section defined in config file */
    104    LIST sDriverSectionList;
    105    LIST sPreinstalledSectionList;
    106    LIST sSectionList;
    107 } CONF_FILE;
    108 
    109 
    110 
    111 /* ---------------------------------------------------------------------------------
    112    Prototypes
    113    ---------------------------------------------------------------------------------*/
    114 
    115 uint32_t SMCPropStringToInt           (char* pValue);
    116 char*    SMCPropGetSystemProperty     (CONF_FILE* pConfFile, char* pPropertyName);
    117 uint32_t SMCPropGetSystemPropertyAsInt(CONF_FILE* pConfFile, char* pPropertyName);
    118 S_RESULT SMCPropParseConfigFile       (char* pConfigFilename,CONF_FILE* pConfFile);
    119 
    120 
    121 #ifdef __cplusplus
    122 }
    123 #endif
    124 
    125 #endif /* __SMC_PROPERTIES_PARSER_H__ */
    126