• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
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
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 #ifndef PVRTSP_CLIENT_ENGINE_UTILS_H
19 #define PVRTSP_CLIENT_ENGINE_UTILS_H
20 //#include "pvrtsp_client_engine_utils.h"
21 
22 #ifndef OSCL_BASE_H_INCLUDED
23 #include "oscl_base.h"
24 #endif
25 
26 #ifndef OSCL_STDSTRING_H_INCLUDED
27 #include "oscl_stdstring.h"
28 #endif
29 
30 #ifndef OSCL_UTF8CONV_H
31 #include "oscl_utf8conv.h"
32 #endif
33 
34 #ifndef OSCL_ERROR_CODES_H_INCLUDED
35 #include "oscl_error_codes.h"
36 #endif
37 
38 #ifndef OSCL_STRING_H_INCLUDED
39 #include "oscl_string.h"
40 #endif
41 
42 #define MAX_LONG_TEXT_LEN 1024
43 
44 typedef enum
45 {
46     CONCATENATE,
47     REPLACE_PATH,
48     REPLACE_HOST,
49     UNKNOWN
50 } URLType;
51 
52 const char FWD_SLASH = '/';
53 const char COLON = ':';
54 const char DOT = '.';
55 
56 
57 /*
58 *Function   : bool composeURL(char *baseURL, char *relativeURL, char *completeURL)
59 *Parameters : char *baseURL       - input parameter, needs to be NULL terminated
60 *             char *relativeURL   - input parameter, needs to be NULL terminated
61 *             char *completeURL   - output parameter, will be NULL terminated
62 *             int completeURLLen  - input/output parameter
63 *Date       : 06/03/2002
64 *Description: This function composes a URL using a base URL and relative URL. It is based
65 *             on RFC 2396 and supports a sub-set of the exhaustive list of relative URL
66 *             specified in the document. It does not support relative URLs that begin
67 *             with a "." or those that contain a ":" in them.
68 *             No memory is allocated inside the function. The caller of this function
69 *             must take care of all memory allocation/deallocation for the parameters
70 *             passed to this function.
71 *Output     : This function returns TRUE or FALSE based on a successful
72 *             composition or not. In case of successful composition, the complete URL
73 *             is returned in the third parameter.
74 */
75 bool composeURL(const char *baseURL, const char *relativeURL, \
76                 char *completeURL, unsigned int &completeURLLen);
77 
78 /*
79  * Function   : const char* findRelativeURL(const char *aURL)
80  * Parameters : const char *aURL - input parameter
81  * Date       : 10/05/2006
82  * Description: This function finds the relative URL within the aURL, including the forward slash. Returns NULL if NOT found.
83  * Output     : The relative URL or NULL.
84  */
85 const char* findRelativeURL(const char *aURL);
86 
87 /*
88 *Function   : URLType findRelativeURLType(char *relativeURL)
89 *Parameters : char *relativeURL   - input parameter, needs to be NULL terminated
90 *Date       : 06/03/2002
91 *Description: This function looks at the relative URL and determines what type of
92 *             operation needs to be performed to compose the complete URL.
93 *Output     : This function returns the URL type. The return values are of the
94 *             enumerated type URLType with values
95 *             CONCATENATE, REPLACE_PATH, REPLACE_HOST, UNKNOWN
96 */
97 URLType findRelativeURLType(const char *relativeURL);
98 
99 /*
100  * Function   : void dropTextAfterLastSlash(char *copyOfBaseURL)
101  * Parameters : char *copyOfBaseURL - input/output parameter
102  * Date       : 06/03/2002
103  * Description: This function drops text after the last "/" in the URL(if any).
104  * Output     : The modified URL is pointed to by the input parameter.
105  */
106 void dropTextAfterLastSlash(char *copyOfBaseURL);
107 
108 /*
109  * Function   : void dropTextAfterFirstSlash(char *copyOfBaseURL)
110  * Parameters : char *copyOfBaseURL - input/output parameter
111  * Date       : 06/03/2002
112  * Description: This function drops text after the first "/" in the URL(if any).
113  * Output     : The modified URL is pointed to by the input parameter.
114  */
115 void dropTextAfterFirstSlash(char *copyOfBaseURL);
116 
117 /*
118  * Function   : OSCL_String& generatePseudoUUID(void)
119  * Parameters : OSCL_String& aUUID - input/output parameter
120  * Date       : 03/27/2006
121  * Description: This function generate a pseudo UUID string.
122  * Output     : The pseudo UUID string like 6e31c837-b458-4c27-b290-73805cb08da1.
123  */
124 bool generatePseudoUUID(OSCL_String& aUUID);
125 
126 #endif  //PVRTSP_CLIENT_ENGINE_UTILS_H
127