1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef DMURIUTILITY_H 18 #define DMURIUTILITY_H 19 20 /*================================================================================================== 21 22 Header Name: dm_uri_utils.h 23 24 General Description: This file contains declaration declaration of helper functions for uri processing 25 26 ==================================================================================================*/ 27 28 #include <stdlib.h> 29 #include "xpl_Types.h" 30 #include "syncml_dm_data_types.h" 31 #include "dmvector.h" 32 33 #define SYNCML_DM_NULL ('\0') 34 #define SYNCML_DM_AMPERSAND ('&') 35 #define SYNCML_DM_STAR ('*') 36 #define SYNCML_DM_PLUS ('+') 37 #define SYNCML_DM_EQUAL_TO ('=') 38 #define SYNCML_DM_FORWARD_SLASH ('/') 39 #define SYNCML_DM_DOT ('.') 40 #define SYNCML_DM_PERCENTAGE ('%') 41 #define SYNCML_DM_QUESTION_MARK ('?') 42 #define SYNCML_DM_SPACE (' ') 43 #define SYNCML_DM_COMMA (',') 44 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 void DmParseURI(CPCHAR szPath, DMString& strURI, DMString& strKey ); 51 52 bool DmStringParserGetItem( DMString& strItem, DMString& strReminder, char cDelim ); 53 54 int DmStrToStringVector(const char * pStr, int nLen, DMStringVector& oVector, char cDelim ); 55 56 char* GetURISegment(char **ppbURI); 57 58 char* GetStringSegment(char **ppbURI, char cDelim); 59 60 /** 61 * Verifies if path is the DMAcc path 62 * \param szPath [in/out] - node path 63 * \return TRUE if path is the DMAcc path 64 */ 65 SYNCML_DM_RET_STATUS_T DmIsDMAccNodePath(CPCHAR szPath); 66 67 /** 68 * Verifies if path is enabled 69 * \param szPath [in/out] - node path 70 * \return TRUE if enabled 71 */ 72 BOOLEAN DmIsEnabledURI(CPCHAR szPath); 73 74 /** 75 * Verifies if szParentURI is direct or indirect parent (including node itself) of node szChildURI 76 * Both URIs can contain multi-node characters ('*') 77 * \param szParentURI [in] - parent path 78 * \param szChildURI [in] - child path 79 * \return TRUE if path is a parent 80 */ 81 BOOLEAN DmIsParentURI(CPCHAR szParentURI, CPCHAR szChildURI); 82 83 84 #ifdef __cplusplus 85 } 86 #endif 87 88 class CEnv 89 { 90 public: 91 CEnv(); 92 93 BOOLEAN Init(); 94 void Done(); 95 96 CPCHAR GetWFS() const { return m_szWFS;} 97 CPCHAR GetMainRFS() const { return m_szMainRFS; } 98 int GetRFSCount() const { return m_aFSes.size() > 1 ? m_aFSes.size() - 1 : 0;} 99 CPCHAR GetRFS( int index ) const { return (index +1) >= m_aFSes.size() ? NULL : m_aFSes[index +1].c_str(); } 100 CPCHAR GetWFSFullPath(CPCHAR name, DMString & path); 101 CPCHAR GetMainRFSFullPath(CPCHAR name, DMString & path); 102 CPCHAR GetRFSFullPath(int index, CPCHAR name, DMString & path); 103 104 private: 105 DMStringVector m_aFSes; // first element is WFS, second is MainRFS, all other - auxulary RFS 106 CPCHAR m_szWFS; 107 CPCHAR m_szMainRFS; 108 109 CPCHAR GetFullPath(CPCHAR fs_path, CPCHAR name, DMString & path); 110 }; 111 112 #endif 113