MCPcopy Create free account
hub / github.com/OpenPrinting/cups / http_copy_encode

Function http_copy_encode

cups/http-support.c:2238–2280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2236 */
2237
2238static char * /* O - End of current URI */
2239http_copy_encode(char *dst, /* O - Destination buffer */
2240 const char *src, /* I - Source pointer */
2241 char *dstend, /* I - End of destination buffer */
2242 const char *reserved, /* I - Extra reserved characters */
2243 const char *term, /* I - Terminating characters */
2244 int encode) /* I - %-encode reserved chars? */
2245{
2246 static const char hex[] = "0123456789ABCDEF";
2247
2248
2249 while (*src && dst < dstend)
2250 {
2251 if (term && *src == *term)
2252 return (dst);
2253
2254 if (encode && (*src == '%' || *src <= ' ' || *src & 128 ||
2255 (reserved && strchr(reserved, *src))))
2256 {
2257 /*
2258 * Hex encode reserved characters...
2259 */
2260
2261 if ((dst + 2) >= dstend)
2262 break;
2263
2264 *dst++ = '%';
2265 *dst++ = hex[(*src >> 4) & 15];
2266 *dst++ = hex[*src & 15];
2267
2268 src ++;
2269 }
2270 else
2271 *dst++ = *src++;
2272 }
2273
2274 *dst = '\0';
2275
2276 if (*src)
2277 return (NULL);
2278 else
2279 return (dst);
2280}
2281
2282
2283#ifdef HAVE_MDNSRESPONDER

Callers 2

httpAssembleURIFunction · 0.85
_httpEncodeURIFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected