MCPcopy Index your code
hub / github.com/MapServer/MapServer / msBuildURLFromWMSParams

Function msBuildURLFromWMSParams

mapwmslayer.c:156–210  ·  view source on GitHub ↗

* msBuildWMSParamsUrl() * **********************************************************************/

Source from the content-addressed store, hash-verified

154 *
155 **********************************************************************/
156static char *msBuildURLFromWMSParams(wmsParamsObj *wmsparams)
157{
158 const char *key, *value;
159 size_t bufferSize = 0;
160 int nLen;
161 char *pszURL;
162
163 /* Compute size required for URL buffer
164 */
165 nLen = strlen(wmsparams->onlineresource) + 3;
166
167 key = msFirstKeyFromHashTable(wmsparams->params);
168 while (key != NULL)
169 {
170 value = msLookupHashTable(wmsparams->params, key);
171 nLen += strlen(key) + strlen(value) + 2;
172
173 key = msNextKeyFromHashTable(wmsparams->params, key);
174 }
175
176 bufferSize = nLen+1;
177 pszURL = (char*)msSmallMalloc(bufferSize);
178
179 /* Start with the onlineresource value and append trailing '?' or '&'
180 * if missing.
181 */
182 strcpy(pszURL, wmsparams->onlineresource);
183 if (strchr(pszURL, '?') == NULL)
184 strcat(pszURL, "?");
185 else
186 {
187 char *c;
188 c = pszURL+strlen(pszURL)-1;
189 if (*c != '?' && *c != '&')
190 strcpy(c+1, "&");
191 }
192
193 /* Now add all the parameters
194 */
195 nLen = strlen(pszURL);
196 key = msFirstKeyFromHashTable(wmsparams->params);
197 while (key != NULL)
198 {
199 value = msLookupHashTable(wmsparams->params, key);
200 snprintf(pszURL+nLen, bufferSize-nLen, "%s=%s&", key, value);
201 nLen += strlen(key) + strlen(value) + 2;
202 key = msNextKeyFromHashTable(wmsparams->params, key);
203 }
204
205 /* Get rid of trailing '&'*/
206 pszURL[nLen-1] = '\0';
207
208
209 return pszURL;
210}
211
212
213

Callers 2

msWMSGetFeatureInfoURLFunction · 0.85
msPrepareWMSLayerRequestFunction · 0.85

Calls 4

msFirstKeyFromHashTableFunction · 0.85
msLookupHashTableFunction · 0.85
msNextKeyFromHashTableFunction · 0.85
msSmallMallocFunction · 0.85

Tested by

no test coverage detected